1 /**
2 * @file
3 */
4
5 /*
6 Copyright (C) 2002-2013 UFO: Alien Invasion.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 See the GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 */
24
25 #include "../../../../client.h"
26 #include "../../../cl_actor.h"
27 #include "../../../cl_hud.h"
28 #include "../../../cl_particle.h"
29 #include "e_event_actorrevitalised.h"
30
31 /**
32 * @brief Kills an actor (all that is needed is the local entity state set to STATE_DEAD).
33 * @note Also changes the animation to a random death sequence and appends the dead animation
34 * @param[in] msg The netchannel message
35 * @param[in] self Pointer to the event structure that is currently executed
36 */
CL_ActorRevitalised(const eventRegister_t * self,dbuffer * msg)37 void CL_ActorRevitalised (const eventRegister_t* self, dbuffer* msg)
38 {
39 int entnum, state;
40 NET_ReadFormat(msg, self->formatString, &entnum, &state);
41
42 /* get les */
43 le_t* le = LE_Get(entnum);
44 if (!le)
45 LE_NotFoundError(entnum);
46
47 if (!LE_IsStunned(le) && !LE_IsLivingActor(le))
48 Com_Error(ERR_DROP, "CL_ActorRevitalised: Can't revitalise, LE is not a dead or stunned actor");
49
50 LE_Lock(le);
51
52 /* link any floor container into the actor temp floor container */
53 le_t* floor = LE_Find(ET_ITEM, le->pos);
54 if (floor)
55 le->setFloor(floor);
56
57 le->state = state;
58
59 /* play animation */
60 LE_SetThink(le, LET_StartIdle);
61
62 /* Print some info about the death or stun. */
63 if (le->team == cls.team) {
64 const character_t* chr = CL_ActorGetChr(le);
65 if (chr) {
66 char tmpbuf[128];
67 Com_sprintf(tmpbuf, lengthof(tmpbuf), _("%s was revitalised\n"), chr->name);
68 HUD_DisplayMessage(tmpbuf);
69 }
70 } else {
71 switch (le->team) {
72 case (TEAM_CIVILIAN):
73 HUD_DisplayMessage(_("A civilian was revitalised."));
74 break;
75 case (TEAM_ALIEN):
76 HUD_DisplayMessage(_("An alien was revitalised."));
77 break;
78 case (TEAM_PHALANX):
79 HUD_DisplayMessage(_("A soldier was revitalised."));
80 break;
81 default:
82 HUD_DisplayMessage(va(_("A member of team %i was revitalised."), le->team));
83 break;
84 }
85 }
86
87 le->aabb.setMaxs(player_maxs);
88
89 if (le->ptl) {
90 CL_ParticleFree(le->ptl);
91 le->ptl = nullptr;
92 }
93
94 /* add team members to the actor list */
95 CL_ActorAddToTeamList(le);
96
97 /* update pathing as we maybe not can walk onto this actor anymore */
98 CL_ActorConditionalMoveCalc(selActor);
99 LE_Unlock(le);
100 }
101