e_event_actordie.c

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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     /* get les */
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     /* count spotted aliens */
00058     if (le->team != cls.team && le->team != TEAM_CIVILIAN && !LE_IsStunned(le))
00059         cl.numAliensSpotted--;
00060 
00061     /* set relevant vars */
00062     FLOOR(le) = NULL;
00063 
00064     le->state = state;
00065 
00066     /* play animation */
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     /* Print some info about the death or stun. */
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     /* update pathing as we maybe can walk onto the dead actor now */
00119     CL_ActorConditionalMoveCalc(selActor);
00120     LE_Unlock(le);
00121 }

Generated by  doxygen 1.6.2