e_event_actorstatechange.c
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "../../../../client.h"
00026 #include "../../../../ui/ui_main.h"
00027 #include "../../../cl_localentity.h"
00028 #include "../../../cl_actor.h"
00029 #include "e_event_actorstatechange.h"
00030
00031 void CL_ActorStateChange (const eventRegister_t *self, struct dbuffer *msg)
00032 {
00033 le_t *le;
00034 int entnum, state;
00035 character_t *chr;
00036
00037 NET_ReadFormat(msg, self->formatString, &entnum, &state);
00038
00039 le = LE_Get(entnum);
00040 if (!le)
00041 LE_NotFoundError(entnum);
00042
00043 if (!LE_IsActor(le)) {
00044 Com_Printf("StateChange message ignored... LE is no actor (number: %i, state: %i, type: %i)\n",
00045 entnum, state, le->type);
00046 return;
00047 }
00048
00049
00050 if (((state & STATE_CROUCHED) && !LE_IsCrouched(le)) ||
00051 (!(state & STATE_CROUCHED) && LE_IsCrouched(le))) {
00052 if (CL_ActorUsableTUs(le) < TU_CROUCH && CL_ActorReservedTUs(le, RES_CROUCH) >= TU_CROUCH) {
00053
00054
00055
00056 CL_ActorReserveTUs(le, RES_CROUCH, 0);
00057 }
00058 }
00059
00060
00061 if ((state & STATE_DEAD) && LE_IsLivingActor(le)) {
00062 le->state = state;
00063 FLOOR(le) = NULL;
00064 LE_SetThink(le, NULL);
00065 VectorCopy(player_dead_maxs, le->maxs);
00066 CL_ActorRemoveFromTeamList(le);
00067 return;
00068 } else {
00069 le->state = state;
00070 LE_SetThink(le, LET_StartIdle);
00071 }
00072
00073
00074 chr = CL_ActorGetChr(le);
00075 if (!chr)
00076 return;
00077
00078 chr->state = (le->state & STATE_REACTION);
00079
00080 if (!(le->state & STATE_REACTION)) {
00081 UI_ExecuteConfunc("disable_reaction");
00082 } else {
00083
00084 if (le->state & STATE_REACTION_MANY)
00085 UI_ExecuteConfunc("startreactionmany");
00086 else if (le->state & STATE_REACTION_ONCE)
00087 UI_ExecuteConfunc("startreactiononce");
00088 }
00089
00090
00091 CL_ActorConditionalMoveCalc(le);
00092 }