g_events.c

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #include "g_local.h"
00026 
00035 void G_EventSpawnSound (const edict_t* ent, const vec3_t origin, const char *sound)
00036 {
00037     gi.PositionedSound(PM_ALL, origin, ent, sound);
00038 }
00039 
00046 void G_EventActorTurn (const edict_t* ent)
00047 {
00048     gi.AddEvent(G_VisToPM(ent->visflags), EV_ACTOR_TURN);
00049     gi.WriteShort(ent->number);
00050     gi.WriteByte(ent->dir);
00051 }
00052 
00057 void G_EventActorDie (const edict_t* ent)
00058 {
00059     gi.AddEvent(G_VisToPM(ent->visflags), EV_ACTOR_DIE);
00060     gi.WriteShort(ent->number);
00061     gi.WriteShort(ent->state);
00062 }
00063 
00068 void G_EventActorRevitalise (const edict_t* ent)
00069 {
00070     gi.AddEvent(G_VisToPM(ent->visflags), EV_ACTOR_REVITALISED);
00071     gi.WriteShort(ent->number);
00072     gi.WriteShort(ent->state);
00073 }
00074 
00079 void G_EventActorSendReservations (const edict_t *ent)
00080 {
00081     gi.AddEvent(G_PlayerToPM(G_PLAYER_FROM_ENT(ent)), EV_ACTOR_RESERVATIONCHANGE);
00082 
00083     gi.WriteShort(ent->number);
00084     gi.WriteShort(ent->chr.reservedTus.reaction);
00085     gi.WriteShort(ent->chr.reservedTus.shot);
00086     gi.WriteShort(ent->chr.reservedTus.crouch);
00087 
00088     gi.EndEvents();
00089 }
00090 
00099 void G_EventInventoryDelete (const edict_t* ent, int playerMask, const invDef_t* invDef, int x, int y)
00100 {
00101     gi.AddEvent(playerMask, EV_INV_DEL);
00102     gi.WriteShort(ent->number);
00103     gi.WriteByte(invDef->id);
00104     gi.WriteByte(x);
00105     gi.WriteByte(y);
00106 }
00107 
00115 void G_EventInventoryAdd (const edict_t* ent, int playerMask, int itemAmount)
00116 {
00117     gi.AddEvent(playerMask, EV_INV_ADD);
00118     gi.WriteShort(ent->number);
00119     gi.WriteShort(itemAmount * INV_INVENTORY_BYTES);
00120 }
00121 
00126 void G_EventPerish (const edict_t* ent)
00127 {
00128     gi.AddEvent(G_VisToPM(ent->visflags), EV_ENT_PERISH);
00129     gi.WriteShort(ent->number);
00130 }
00131 
00136 void G_EventDestroyEdict (const edict_t* ent)
00137 {
00138     gi.AddEvent(PM_ALL, EV_ENT_DESTROY);
00139     gi.WriteShort(ent->number);
00140 }
00141 
00149 void G_EventInventoryAmmo (const edict_t* ent, const objDef_t* ammo, int amount, shoot_types_t shootType)
00150 {
00151     gi.AddEvent(G_VisToPM(ent->visflags), EV_INV_AMMO);
00152     gi.WriteShort(ent->number);
00153     gi.WriteByte(amount);
00154     gi.WriteByte(ammo->idx);
00155     if (IS_SHOT_RIGHT(shootType))
00156         gi.WriteByte(gi.csi->idRight);
00157     else
00158         gi.WriteByte(gi.csi->idLeft);
00159     /* x and y value */
00160     gi.WriteByte(0);
00161     gi.WriteByte(0);
00162 }
00163 
00171 void G_EventStartShoot (const edict_t* ent, int visMask, shoot_types_t shootType, const pos3_t at)
00172 {
00173     gi.AddEvent(G_VisToPM(visMask), EV_ACTOR_START_SHOOT);
00174     gi.WriteShort(ent->number);
00175     gi.WriteByte(shootType);
00176     gi.WriteGPos(ent->pos);
00177     gi.WriteGPos(at);
00178 }
00179 
00186 void G_EventShootHidden (int visMask, const fireDef_t* fd, qboolean firstShoot)
00187 {
00188     gi.AddEvent(~G_VisToPM(visMask), EV_ACTOR_SHOOT_HIDDEN);
00189     gi.WriteByte(firstShoot);
00190     gi.WriteShort(fd->obj->idx);
00191     gi.WriteByte(fd->weapFdsIdx);
00192     gi.WriteByte(fd->fdIdx);
00193 }
00194 
00207 void G_EventShoot (const edict_t* ent, int visMask, const fireDef_t* fd, qboolean firstShoot, shoot_types_t shootType, int flags, const trace_t* trace, const vec3_t from, const vec3_t impact)
00208 {
00209     const edict_t *targetEdict = trace->ent;
00210 
00211     gi.AddEvent(G_VisToPM(visMask), EV_ACTOR_SHOOT);
00212     gi.WriteShort(ent->number);
00213     if (targetEdict && G_IsBreakable(targetEdict))
00214         gi.WriteShort(targetEdict->number);
00215     else
00216         gi.WriteShort(SKIP_LOCAL_ENTITY);
00217     gi.WriteByte(firstShoot ? 1 : 0);
00218     gi.WriteShort(fd->obj->idx);
00219     gi.WriteByte(fd->weapFdsIdx);
00220     gi.WriteByte(fd->fdIdx);
00221     gi.WriteByte(shootType);
00222     gi.WriteByte(flags);
00223     gi.WriteByte(trace->contentFlags);
00224     gi.WritePos(from);
00225     gi.WritePos(impact);
00226     gi.WriteDir(trace->plane.normal);
00227 }
00228 
00229 void G_EventReactionFireChange (const edict_t* ent)
00230 {
00231     const objDef_t *od = ent->chr.RFmode.weapon;
00232 
00233     gi.AddEvent(G_PlayerToPM(G_PLAYER_FROM_ENT(ent)), EV_ACTOR_REACTIONFIRECHANGE);
00234 
00235     gi.WriteShort(ent->number);
00236     gi.WriteByte(ent->chr.RFmode.fmIdx);
00237     gi.WriteByte(ent->chr.RFmode.hand);
00238     gi.WriteShort(od ? od->idx : NONE);
00239 
00240     gi.EndEvents();
00241 }
00242 
00251 void G_EventParticleSpawn (int playerMask, const char *name, int levelFlags, const vec3_t s, const vec3_t v, const vec3_t a)
00252 {
00253     gi.AddEvent(playerMask, EV_PARTICLE_SPAWN);
00254     gi.WriteByte(levelFlags);
00255     gi.WritePos(s);
00256     gi.WritePos(v);
00257     gi.WritePos(a);
00258     gi.WriteString(name);
00259 }
00260 
00261 void G_EventActorFall (const edict_t* ent)
00262 {
00263     gi.AddEvent(G_VisToPM(ent->visflags), EV_ACTOR_MOVE);
00264     gi.WriteShort(ent->number);
00265     gi.WriteByte(1);
00266     gi.WriteByte(ent->pos[0]);
00267     gi.WriteByte(ent->pos[1]);
00268     gi.WriteByte(ent->pos[2]);
00269     gi.WriteByte(makeDV(DIRECTION_FALL, ent->pos[2]));
00270     gi.WriteShort(GRAVITY);
00271     gi.WriteShort(0);
00272 }
00273 
00279 void G_EventSetClientAction (const edict_t *ent)
00280 {
00281     assert(ent->clientAction);
00282 
00283     /* tell the hud to show the door buttons */
00284     gi.AddEvent(G_TeamToPM(ent->team), EV_DOOR_ACTION);
00285     gi.WriteShort(ent->number);
00286     gi.WriteShort(ent->clientAction->number);
00287     gi.EndEvents();
00288 }
00289 
00295 void G_EventResetClientAction (const edict_t* ent)
00296 {
00297     gi.AddEvent(G_PlayerToPM(G_PLAYER_FROM_ENT(ent)), EV_RESET_CLIENT_ACTION);
00298     gi.WriteShort(ent->number);
00299 }
00300 
00301 void G_EventActorStats (const edict_t* ent)
00302 {
00303     gi.AddEvent(G_TeamToPM(ent->team), EV_ACTOR_STATS);
00304     gi.WriteShort(ent->number);
00305     gi.WriteByte(ent->TU);
00306     gi.WriteShort(ent->HP);
00307     gi.WriteByte(ent->STUN);
00308     gi.WriteByte(ent->morale);
00309 }
00310 
00315 void G_EventEndRound (void)
00316 {
00317     gi.AddEvent(PM_ALL, EV_ENDROUND);
00318     gi.WriteByte(level.activeTeam);
00319 }
00320 
00321 void G_EventInventoryReload (const edict_t* ent, int playerMask, const item_t* item, const invDef_t* invDef, const invList_t* ic)
00322 {
00323     gi.AddEvent(playerMask, EV_INV_RELOAD);
00324     gi.WriteShort(ent->number);
00325     gi.WriteByte(item->t->ammo);
00326     gi.WriteByte(item->m->idx);
00327     gi.WriteByte(invDef->id);
00328     gi.WriteByte(ic->x);
00329     gi.WriteByte(ic->y);
00330 }
00331 
00340 void G_EventThrow (int visMask, const fireDef_t *fd, float dt, byte flags, const vec3_t position, const vec3_t velocity)
00341 {
00342     gi.AddEvent(G_VisToPM(visMask), EV_ACTOR_THROW);
00343     gi.WriteShort(dt * 1000);
00344     gi.WriteShort(fd->obj->idx);
00345     gi.WriteByte(fd->weapFdsIdx);
00346     gi.WriteByte(fd->fdIdx);
00347     gi.WriteByte(flags);
00348     gi.WritePos(position);
00349     gi.WritePos(velocity);
00350 }
00351 
00356 void G_EventSendEdict (const edict_t *ent)
00357 {
00358     gi.AddEvent(PM_ALL, EV_ADD_EDICT);
00359     gi.WriteByte(ent->type);
00360     gi.WriteShort(ent->number);
00361     gi.WritePos(ent->absmin);
00362     gi.WritePos(ent->absmax);
00363 }

Generated by  doxygen 1.6.2