UFO: Alien Invasion
e_event_actorthrow.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2022 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 "e_event_actorthrow.h"
28 
32 int 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 
50 void 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)
void CL_ActorDoThrow(const eventRegister_t *self, dbuffer *msg)
Throw item with actor.
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
int shootTime
Definition: e_main.h:32
CL_ParseEvent timers and vars.
Definition: e_main.h:30
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
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:314
bool parsedDeath
Definition: e_main.h:35
const char * fireSound
Definition: inv_shared.h:117
this is a fire definition for our weapons/ammo
Definition: inv_shared.h:110
#define SOUND_ATTN_IDLE
Definition: common.h:187
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
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.
Definition: inv_shared.cpp:385
int nextTime
Definition: e_main.h:31
int32_t fireDefIndex_t
Definition: inv_shared.h:78
int NET_ReadShort(dbuffer *buf)
Definition: netpack.cpp:242
int32_t weaponFireDefIndex_t
Definition: inv_shared.h:77
int CL_ActorDoThrowTime(const eventRegister_t *self, dbuffer *msg, eventTiming_t *eventTiming)
Decides if following events should be delayed.
vec_t vec3_t[3]
Definition: ufotypes.h:39
int impactTime
Definition: e_main.h:33
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
Definition: inv_shared.cpp:266
#define SF_BOUNCED
Definition: q_shared.h:251
#define SND_VOLUME_DEFAULT
Definition: s_main.h:42