UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_actorthrow.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"
27#include "e_event_actorthrow.h"
28
32int CL_ActorDoThrowTime (const eventRegister_t* self, dbuffer* msg, eventTiming_t* eventTiming)
33{
34 const int eventTime = eventTiming->nextTime;
35
36 /* the delay is encoded in the message already */
37 eventTiming->nextTime += NET_ReadShort(msg);
38 eventTiming->impactTime = eventTiming->shootTime = eventTiming->nextTime;
39 eventTiming->parsedDeath = false;
40
41 return eventTime;
42}
43
50void CL_ActorDoThrow (const eventRegister_t* self, dbuffer* msg)
51{
52 vec3_t muzzle, v0;
53 int flags;
54 int dtime;
55 int objIdx;
56 weaponFireDefIndex_t weapFdsIdx;
57 fireDefIndex_t fdIdx;
58
59 /* read data */
60 NET_ReadFormat(msg, self->formatString, &dtime, &objIdx, &weapFdsIdx, &fdIdx, &flags, &muzzle, &v0);
61
62 /* get the fire def */
63 const objDef_t* obj = INVSH_GetItemByIDX(objIdx);
64 const fireDef_t* fd = FIRESH_GetFiredef(obj, weapFdsIdx, fdIdx);
65
66 /* add effect le (local entity) */
68 LE_AddGrenade(fd, flags, muzzle, v0, dtime, nullptr);
69
70 /* start the sound */
71 if (fd->fireSound != nullptr && !(flags & SF_BOUNCED)) {
73 }
74}
void LE_AddGrenade(const fireDef_t *fd, int flags, const vec3_t muzzle, const vec3_t v0, int dt, le_t *leVictim)
Primary header for client.
#define SOUND_ATTN_IDLE
Definition common.h:187
int CL_ActorDoThrowTime(const eventRegister_t *self, dbuffer *msg, eventTiming_t *eventTiming)
Decides if following events should be delayed.
void CL_ActorDoThrow(const eventRegister_t *self, dbuffer *msg)
Throw item with actor.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const fireDef_t * FIRESH_GetFiredef(const objDef_t *obj, const weaponFireDefIndex_t weapFdsIdx, const fireDefIndex_t fdIdx)
Get the fire definitions for a given object.
int32_t weaponFireDefIndex_t
Definition inv_shared.h:77
int32_t fireDefIndex_t
Definition inv_shared.h:78
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
int NET_ReadShort(dbuffer *buf)
Definition netpack.cpp:242
#define SF_BOUNCED
Definition q_shared.h:251
bool S_LoadAndPlaySample(const char *s, const vec3_t origin, float attenuation, float volume)
does what the name implies in just one function to avoid exposing s_sample_t
Definition s_main.cpp:307
#define SND_VOLUME_DEFAULT
Definition s_main.h:42
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
int impactTime
Definition e_main.h:33
bool parsedDeath
Definition e_main.h:35
this is a fire definition for our weapons/ammo
Definition inv_shared.h:110
const char * fireSound
Definition inv_shared.h:117
Defines all attributes of objects used in the inventory.
Definition inv_shared.h:264
vec_t vec3_t[3]
Definition ufotypes.h:39