UFO: Alien Invasion
Doxygen documentation generating
e_event_actorstartshoot.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2023 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_localentity.h"
27 #include "../../../../renderer/r_mesh_anim.h"
29 
33 int CL_ActorStartShootTime (const eventRegister_t* self, dbuffer* msg, eventTiming_t* eventTiming)
34 {
35  const int eventTime = eventTiming->nextTime;
36 
37  eventTiming->parsedShot = true;
38  eventTiming->parsedDeath = false;
39  eventTiming->nextTime += 300;
40  eventTiming->shootTime = eventTiming->nextTime;
41 
42  return eventTime;
43 }
44 
55 void CL_ActorStartShoot (const eventRegister_t* self, dbuffer* msg)
56 {
57  pos3_t from, target;
58  int entnum;
59  shoot_types_t shootType;
60 
61  NET_ReadFormat(msg, self->formatString, &entnum, &shootType, &from, &target);
62 
63  /* shooting actor */
64  le_t* le = LE_Get(entnum);
65 
66  /* center view (if wanted) */
67  if (!cls.isOurRound())
68  CL_CheckCameraRoute(from, target);
69 
70  /* actor dependent stuff following */
71  if (!le)
72  /* it's OK, the actor is not visible */
73  return;
74 
75  if (!LE_IsLivingActor(le) || LE_IsStunned(le)) {
76  Com_Printf("CL_ActorStartShoot: LE (%i) not a living actor (type: %i)\n", entnum, le->type);
77  return;
78  }
79 
80  /* ET_ACTORHIDDEN actors don't have a model yet */
81  if (le->type == ET_ACTORHIDDEN)
82  return;
83 
84  /* Animate - we have to check if it is right or left weapon usage. */
85  if (IS_SHOT_RIGHT(shootType)) {
86  R_AnimChange(&le->as, le->model1, LE_GetAnim("move", le->right, le->left, le->state));
87  } else if (IS_SHOT_LEFT(shootType)) {
88  R_AnimChange(&le->as, le->model1, LE_GetAnim("move", le->left, le->right, le->state));
89  } else if (!IS_SHOT_HEADGEAR(shootType)) {
90  /* no animation for headgear (yet) */
91  Com_Error(ERR_DROP, "CL_ActorStartShoot: Invalid shootType given (entnum: %i, shootType: %i).\n", shootType, entnum);
92  }
93 }
#define LE_IsStunned(le)
int state
const char * LE_GetAnim(const char *anim, int right, int left, int state)
Get the correct animation for the given actor state and weapons.
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
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
void CL_CheckCameraRoute(const pos3_t from, const pos3_t target)
Only moves the camera to the given target location if its not yet close enough.
Definition: cl_camera.cpp:285
void R_AnimChange(animState_t *as, const model_t *mod, const char *name)
Changes the animation for md2 models.
int right
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
#define IS_SHOT_RIGHT(x)
Determine whether the selected shoot type is for the item in the right hand, either shooting or react...
Definition: q_shared.h:243
model_t * model1
bool isOurRound() const
Definition: client.h:106
int nextTime
Definition: e_main.h:31
client_static_t cls
Definition: cl_main.cpp:83
#define ERR_DROP
Definition: common.h:211
a local entity
int CL_ActorStartShootTime(const eventRegister_t *self, dbuffer *msg, eventTiming_t *eventTiming)
Decides if following events should be delayed.
int32_t shoot_types_t
Available shoot types - also see the ST_ constants.
Definition: q_shared.h:206
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
#define IS_SHOT_HEADGEAR(x)
Determine whether the selected shoot type is for the item in the headgear slot.
Definition: q_shared.h:245
bool parsedShot
Definition: e_main.h:36
#define IS_SHOT_LEFT(x)
Determine whether the selected shoot type is for the item in the left hand, either shooting or reacti...
Definition: q_shared.h:241
int left
pos_t pos3_t[3]
Definition: ufotypes.h:58
void CL_ActorStartShoot(const eventRegister_t *self, dbuffer *msg)
Starts shooting with actor.
entity_type_t type
animState_t as
CL_ParseEvent timers and vars.
Definition: e_main.h:30
bool LE_IsLivingActor(const le_t *le)
Checks whether the given le is a living actor (but might be hidden)
bool parsedDeath
Definition: e_main.h:35
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
int shootTime
Definition: e_main.h:32