UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_actorstartshoot.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#include "../../../../client.h"
29
33int 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
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}
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.
bool LE_IsLivingActor(const le_t *le)
Checks whether the given le is a living actor (but might be hidden).
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
const char * LE_GetAnim(const char *anim, int right, int left, int state)
Get the correct animation for the given actor state and weapons.
#define LE_IsStunned(le)
client_static_t cls
Definition cl_main.cpp:83
Primary header for client.
void Com_Error(int code, const char *fmt,...)
Definition common.cpp:459
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
#define ERR_DROP
Definition common.h:211
void CL_ActorStartShoot(const eventRegister_t *self, dbuffer *msg)
Starts shooting with actor.
int CL_ActorStartShootTime(const eventRegister_t *self, dbuffer *msg, eventTiming_t *eventTiming)
Decides if following events should be delayed.
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
#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
#define IS_SHOT_HEADGEAR(x)
Determine whether the selected shoot type is for the item in the headgear slot.
Definition q_shared.h:245
@ ET_ACTORHIDDEN
Definition q_shared.h:163
int32_t shoot_types_t
Available shoot types - also see the ST_ constants.
Definition q_shared.h:206
#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
void R_AnimChange(animState_t *as, const model_t *mod, const char *name)
Changes the animation for md2 models.
Struct that defines one particular event with all its callbacks and data.
Definition e_main.h:42
const char * formatString
The format string that is used to write and parse this event.
Definition e_main.h:54
CL_ParseEvent timers and vars.
Definition e_main.h:30
int shootTime
Definition e_main.h:32
int nextTime
Definition e_main.h:31
bool parsedDeath
Definition e_main.h:35
bool parsedShot
Definition e_main.h:36
a local entity
int state
animState_t as
model_t * model1
entity_type_t type
pos_t pos3_t[3]
Definition ufotypes.h:58