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 "e_event_actorwound.h"
29
30 /**
31 * @brief Parses the actor wound stats that come from the netchannel
32 * @sa CL_ParseEvent
33 * @sa G_SendStats
34 */
CL_ActorWound(const eventRegister_t * self,dbuffer * msg)35 void CL_ActorWound (const eventRegister_t* self, dbuffer* msg)
36 {
37 int entnum, bodyPart, wounds, treatment;
38 NET_ReadFormat(msg, self->formatString, &entnum, &bodyPart, &wounds, &treatment);
39
40 le_t* le = LE_Get(entnum);
41 if (!le)
42 LE_NotFoundError(entnum);
43
44 switch (le->type) {
45 case ET_ACTORHIDDEN:
46 case ET_ACTOR:
47 case ET_ACTOR2x2:
48 break;
49 default:
50 Com_Printf("CL_ActorWound: LE (%i) not an actor (type: %i)\n", entnum, le->type);
51 return;
52 }
53
54 if (le->wounds.woundLevel[bodyPart] < wounds && wounds > le->maxHP *
55 le->teamDef->bodyTemplate->woundThreshold(bodyPart) && !LE_IsDead(le)) {
56 const character_t* chr = CL_ActorGetChr(le);
57 char tmpbuf[128];
58 Com_sprintf(tmpbuf, lengthof(tmpbuf), _("%s has been wounded"), chr->name);
59 HUD_DisplayMessage(tmpbuf);
60 }
61 le->wounds.woundLevel[bodyPart] = wounds;
62 le->wounds.treatmentLevel[bodyPart] = treatment;
63 }
64