UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
e_event_actorrevitalised.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 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"
30 
37 {
38  int entnum, state;
39  NET_ReadFormat(msg, self->formatString, &entnum, &state);
40 
41  /* get les */
42  le_t* le = LE_Get(entnum);
43  if (!le)
44  LE_NotFoundError(entnum);
45 
46  if (!LE_IsStunned(le) && !LE_IsLivingActor(le))
47  Com_Error(ERR_DROP, "CL_ActorRevitalised: Can't revitalise, LE is not a dead or stunned actor");
48 
49  LE_Lock(le);
50 
51  /* link any floor container into the actor temp floor container */
52  le_t* floor = LE_Find(ET_ITEM, le->pos);
53  if (floor)
54  le->setFloor(floor);
55 
56  le->state = state;
57 
58  /* play animation */
60 
61  /* Print some info. */
62  if (le->team == cls.team) {
63  const character_t* chr = CL_ActorGetChr(le);
64  if (chr) {
65  char tmpbuf[128];
66  Com_sprintf(tmpbuf, lengthof(tmpbuf), _("%s was revitalised\n"), chr->name);
67  HUD_DisplayMessage(tmpbuf);
68  }
69  } else {
70  switch (le->team) {
71  case (TEAM_CIVILIAN):
72  HUD_DisplayMessage(_("A civilian was revitalised."));
73  break;
74  case (TEAM_ALIEN):
75  HUD_DisplayMessage(_("An alien was revitalised."));
76  break;
77  case (TEAM_PHALANX):
78  HUD_DisplayMessage(_("A soldier was revitalised."));
79  break;
80  default:
81  HUD_DisplayMessage(va(_("A member of team %i was revitalised."), le->team));
82  break;
83  }
84  }
85 
87 
88  if (le->ptl) {
89  CL_ParticleFree(le->ptl);
90  le->ptl = nullptr;
91  }
92 
93  /* add team members to the actor list */
95 
96  /* update pathing as we maybe not can walk onto this actor anymore */
98  LE_Unlock(le);
99 }
#define LE_IsStunned(le)
void CL_ActorRevitalised(const eventRegister_t *self, dbuffer *msg)
Revitalizes a stunned actor (all that is needed is the local entity state set).
#define TEAM_PHALANX
Definition: q_shared.h:62
#define TEAM_ALIEN
Definition: q_shared.h:63
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
Definition: shared.cpp:410
pos3_t pos
#define _(String)
Definition: cl_shared.h:43
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition: shared.cpp:494
void LE_Unlock(le_t *le)
Unlocks a previously locked le_t struct.
void NET_ReadFormat(dbuffer *buf, const char *format,...)
The user-friendly version of NET_ReadFormat that reads variable arguments from a buffer according to ...
Definition: netpack.cpp:533
character_t * CL_ActorGetChr(const le_t *le)
Returns the character information for an actor in the teamlist.
Definition: cl_actor.cpp:155
#define TEAM_CIVILIAN
Definition: q_shared.h:61
void CL_ActorAddToTeamList(le_t *le)
Adds the actor to the team list.
Definition: cl_actor.cpp:362
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
client_static_t cls
Definition: cl_main.cpp:83
void CL_ActorConditionalMoveCalc(le_t *le)
Recalculate forbidden list, available moves and actor's move length for the current selected actor...
Definition: cl_actor.cpp:682
#define ERR_DROP
Definition: common.h:211
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
ptl_t * ptl
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
a local entity
le_t * selActor
Definition: cl_actor.cpp:49
void CL_ParticleFree(ptl_t *p)
Free a particle and all it's children.
AABB aabb
void LE_Lock(le_t *le)
Markes a le_t struct as locked. Should be called at the beginning of an event handler on this le_t...
le_t * LE_Find(entity_type_t type, const pos3_t pos)
Searches a local entity on a given grid field.
char name[MAX_VAR]
Definition: chr_shared.h:371
#define lengthof(x)
Definition: shared.h:105
int team
bool LE_IsLivingActor(const le_t *le)
Checks whether the given le is a living actor (but might be hidden)
void setMaxs(const vec3_t maxi)
Definition: aabb.h:71
void setFloor(le_s *other)
void LE_SetThink(le_t *le, localEntityThinkFunc_t think)
void LET_StartIdle(le_t *le)
Change the animation of an actor to the idle animation (which can be panic, dead or stand) ...
int state
static const vec3_t player_maxs
void HUD_DisplayMessage(const char *text)
Displays a message on the hud.
Definition: cl_hud.cpp:138
#define LE_NotFoundError(entnum)
Describes a character with all its attributes.
Definition: chr_shared.h:369