e_event_actordie.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 "../../../cl_actor.h"
00027 #include "../../../cl_hud.h"
00028 #include "../../../../renderer/r_mesh_anim.h"
00029 #include "e_event_actordie.h"
00030
00037 void CL_ActorDie (const eventRegister_t *self, struct dbuffer *msg)
00038 {
00039 le_t *le;
00040 int entnum, state;
00041
00042 NET_ReadFormat(msg, self->formatString, &entnum, &state);
00043
00044
00045 le = LE_Get(entnum);
00046
00047 if (!le)
00048 LE_NotFoundError(entnum);
00049
00050 if (!LE_IsLivingActor(le))
00051 Com_Error(ERR_DROP, "CL_ActorDie: Can't kill, LE is not an actor (type: %i)", le->type);
00052
00053 if (!LE_IsStunned(le) && LE_IsDead(le))
00054 Com_Error(ERR_DROP, "CL_ActorDie: Can't kill, actor already dead");
00055
00056 LE_Lock(le);
00057
00058 if (le->team != cls.team && le->team != TEAM_CIVILIAN && !LE_IsStunned(le))
00059 cl.numAliensSpotted--;
00060
00061
00062 FLOOR(le) = NULL;
00063
00064 le->state = state;
00065
00066
00067 LE_SetThink(le, NULL);
00068 if (!le->invis)
00069 R_AnimChange(&le->as, le->model1, va("death%i", LE_GetAnimationIndexForDeath(le)));
00070 R_AnimAppend(&le->as, le->model1, va("dead%i", LE_GetAnimationIndexForDeath(le)));
00071
00072
00073 if (le->team == cls.team) {
00074 const character_t *chr = CL_ActorGetChr(le);
00075 if (chr) {
00076 char tmpbuf[128];
00077 if (LE_IsStunned(le)) {
00078 Com_sprintf(tmpbuf, lengthof(tmpbuf), _("%s was stunned\n"), chr->name);
00079 } else {
00080 Com_sprintf(tmpbuf, lengthof(tmpbuf), _("%s was killed\n"), chr->name);
00081 }
00082 HUD_DisplayMessage(tmpbuf);
00083 }
00084 } else {
00085 switch (le->team) {
00086 case (TEAM_CIVILIAN):
00087 if (LE_IsStunned(le))
00088 HUD_DisplayMessage(_("A civilian was stunned.\n"));
00089 else
00090 HUD_DisplayMessage(_("A civilian was killed.\n"));
00091 break;
00092 case (TEAM_ALIEN):
00093 if (LE_IsStunned(le))
00094 HUD_DisplayMessage(_("An alien was stunned.\n"));
00095 else
00096 HUD_DisplayMessage(_("An alien was killed.\n"));
00097 break;
00098 case (TEAM_PHALANX):
00099 if (LE_IsStunned(le))
00100 HUD_DisplayMessage(_("A soldier was stunned.\n"));
00101 else
00102 HUD_DisplayMessage(_("A soldier was killed.\n"));
00103 break;
00104 default:
00105 if (LE_IsStunned(le))
00106 HUD_DisplayMessage(va(_("A member of team %i was stunned.\n"), le->team));
00107 else
00108 HUD_DisplayMessage(va(_("A member of team %i was killed.\n"), le->team));
00109 break;
00110 }
00111 }
00112
00113 CL_ActorPlaySound(le, SND_DEATH);
00114
00115 VectorCopy(player_dead_maxs, le->maxs);
00116 CL_ActorRemoveFromTeamList(le);
00117
00118
00119 CL_ActorConditionalMoveCalc(selActor);
00120 LE_Unlock(le);
00121 }