示例#1
0
/**
 * @brief Actor has been wounded/treated
 * @param[in] ent The actor whose wound status has changed
 * @note This event is sent to the player this actor belongs to
 */
void G_EventActorWound (const edict_t *ent, const int bodyPart)
{
	const int mask = G_PlayerToPM(G_PLAYER_FROM_ENT(ent));
	G_EventAdd(mask, EV_ACTOR_WOUND, ent->number);
	gi.WriteByte(bodyPart);
	gi.WriteByte(ent->chr.wounds.woundLevel[bodyPart]);
	gi.WriteByte(ent->chr.wounds.treatmentLevel[bodyPart]);
	G_EventEnd();
}
示例#2
0
void G_EventActorStats (const edict_t* ent, int playerMask)
{
	G_EventAdd(playerMask, EV_ACTOR_STATS, ent->number);
	gi.WriteByte(ent->TU);
	gi.WriteShort(ent->HP);
	gi.WriteByte(ent->STUN);
	gi.WriteByte(ent->morale);
	G_EventEnd();
}
示例#3
0
/**
 * @brief Start the shooting event for hidden actors
 * @param visMask the vis mask to determine the clients from this event is send to
 * @param fd The firedefinition to use for the shoot
 * @param firstShoot Is this the first shoot
 */
void G_EventShootHidden (vismask_t visMask, const fireDef_t* fd, bool firstShoot)
{
	G_EventAdd(~G_VisToPM(visMask), EV_ACTOR_SHOOT_HIDDEN, -1);
	gi.WriteByte(firstShoot);
	gi.WriteShort(fd->obj->idx);
	gi.WriteByte(fd->weapFdsIdx);
	gi.WriteByte(fd->fdIdx);
	G_EventEnd();
}
示例#4
0
/**
 * @brief Send info about an actor's wounds to the client.
 * @param[in] ent The actor whose wound status we are sending.
 * @param[in] bodyPart The body part index we are sending wound info about.
 * @note This event is sent to the player this actor belongs to
 */
void G_EventActorWound (const Edict& ent, const int bodyPart)
{
	const int mask = G_PlayerToPM(ent.getPlayer());
	G_EventAdd(mask, EV_ACTOR_WOUND, ent.number);
	gi.WriteByte(bodyPart);
	const woundInfo_t& wounds = ent.chr.wounds;
	gi.WriteByte(wounds.woundLevel[bodyPart]);
	gi.WriteByte(wounds.treatmentLevel[bodyPart]);
	G_EventEnd();
}
示例#5
0
/**
 * @brief Spawn a new particle for the client
 * @param[in] playerMask A bit mask. One bit for each affected player
 * @param[in] name The id of the particle (see ptl_*.ufo script files in base/ufos)
 * @param[in] levelFlags Show at which levels
 * @param[in] s starting/location vector
 * @param[in] v velocity vector
 * @param[in] a acceleration vector
 */
void G_EventParticleSpawn (playermask_t playerMask, const char* name, int levelFlags, const vec3_t s, const vec3_t v, const vec3_t a)
{
	G_EventAdd(playerMask, EV_PARTICLE_SPAWN, -1);
	gi.WriteByte(levelFlags);
	gi.WritePos(s);
	gi.WritePos(v);
	gi.WritePos(a);
	gi.WriteString(name);
	G_EventEnd();
}
示例#6
0
void G_EventInventoryReload (const Edict& ent, playermask_t playerMask, const Item* item, const invDef_t* invDef, const Item* ic)
{
	G_EventAdd(playerMask, EV_INV_RELOAD, ent.number);
	gi.WriteByte(item->def()->ammo);
	gi.WriteByte(item->ammoDef()->idx);
	gi.WriteByte(invDef->id);
	gi.WriteByte(ic->getX());
	gi.WriteByte(ic->getY());
	G_EventEnd();
}
示例#7
0
/**
 * @brief Informs the client that an interaction with the world is possible
 * @note It's assumed that the clientAction is already set
 * @param[in] ent The edict that can execute the action (an actor)
 */
void G_EventSetClientAction (const Edict& ent)
{
	assert(ent.clientAction);
	assert(ent.clientAction->flags & FL_CLIENTACTION);

	/* tell the hud to show the door buttons */
	G_EventAdd(G_TeamToPM(ent.team), EV_CLIENT_ACTION, ent.number);
	gi.WriteShort(ent.clientAction->number);
	G_EventEnd();
}
示例#8
0
/**
 * @brief Will inform the player about the real TU reservation
 * @param ent The actors edict.
 */
void G_EventActorSendReservations (const Edict& ent)
{
	G_EventAdd(G_PlayerToPM(ent.getPlayer()), EV_ACTOR_RESERVATIONCHANGE, ent.number);
	const chrReservations_t& reservedTUs = ent.chr.reservedTus;
	gi.WriteShort(reservedTUs.reaction);
	gi.WriteShort(reservedTUs.shot);
	gi.WriteShort(reservedTUs.crouch);

	G_EventEnd();
}
示例#9
0
void G_EventInventoryReload (const edict_t* ent, int playerMask, const item_t* item, const invDef_t* invDef, const invList_t* ic)
{
	G_EventAdd(playerMask, EV_INV_RELOAD, ent->number);
	gi.WriteByte(item->item->ammo);
	gi.WriteByte(item->ammo->idx);
	gi.WriteByte(invDef->id);
	gi.WriteByte(ic->x);
	gi.WriteByte(ic->y);
	G_EventEnd();
}
示例#10
0
void G_EventReactionFireChange (const edict_t* ent)
{
	const objDef_t *od = ent->chr.RFmode.weapon;

	G_EventAdd(G_PlayerToPM(G_PLAYER_FROM_ENT(ent)), EV_ACTOR_REACTIONFIRECHANGE, ent->number);
	gi.WriteByte(ent->chr.RFmode.fmIdx);
	gi.WriteByte(ent->chr.RFmode.getHand());
	gi.WriteShort(od ? od->idx : NONE);

	G_EventEnd();
}
示例#11
0
/**
 * @brief Send an appear event to the client.
 * @param playerMask The players to send the event to
 * @param ent The camera that should appear to the players included in the given mask.
 */
void G_EventCameraAppear (unsigned int playerMask, const edict_t *ent)
{
	G_EventAdd(playerMask, EV_CAMERA_APPEAR, ent->number);
	gi.WritePos(ent->origin);
	gi.WriteByte(ent->team);
	gi.WriteByte(ent->dir);
	gi.WriteByte(ent->camera.cameraType);
	/* strip the higher bits - only send levelflags */
	gi.WriteByte(ent->spawnflags & 0xFF);
	gi.WriteByte(ent->camera.rotate);
	G_EventEnd();
}
示例#12
0
void G_EventActorFall (const Edict& ent)
{
	G_EventAdd(G_VisToPM(ent.visflags), EV_ACTOR_MOVE, ent.number);
	gi.WriteByte(1);
	gi.WriteByte(ent.pos[0]);
	gi.WriteByte(ent.pos[1]);
	gi.WriteByte(ent.pos[2]);
	gi.WriteByte(makeDV(DIRECTION_FALL, ent.pos[2]));
	gi.WriteShort(GRAVITY);
	gi.WriteShort(0);
	G_EventEnd();
}
示例#13
0
/**
 * @brief Send an appear event to the client.
 * @param playerMask The players to send the event to
 * @param ent The camera that should appear to the players included in the given mask.
 */
void G_EventCameraAppear (playermask_t playerMask, const Edict& ent)
{
	G_EventAdd(playerMask, EV_CAMERA_APPEAR, ent.number);
	gi.WritePos(ent.origin);
	gi.WriteByte(ent.team);
	gi.WriteByte(ent.dir);
	gi.WriteByte(ent.camera.cameraType);
	/* strip the higher bits - only send levelflags */
	gi.WriteByte(ent.spawnflags & 0xFF);
	gi.WriteByte(ent.camera.rotate);
	G_EventEnd();
}
示例#14
0
void G_EventReactionFireChange (const Edict& ent)
{
	const FiremodeSettings& fireMode = ent.chr.RFmode;
	const objDef_t* od = fireMode.getWeapon();

	G_EventAdd(G_PlayerToPM(ent.getPlayer()), EV_ACTOR_REACTIONFIRECHANGE, ent.number);
	gi.WriteByte(fireMode.getFmIdx());
	gi.WriteByte(fireMode.getHand());
	gi.WriteShort(od ? od->idx : NONE);

	G_EventEnd();
}
示例#15
0
/**
 * @param[in] teamMask the vis mask to determine the clients from this event is send to
 * @param[in] fd The firedefinition to use
 * @param[in] dt Delta time
 * @param[in] flags bitmask of the following values: @c SF_BODY, @c SF_IMPACT, @c SF_BOUNCING and @c SF_BOUNCED
 * @param[in] position The current position
 * @param[in] velocity The velocity of the throw
 */
void G_EventThrow (teammask_t teamMask, const fireDef_t* fd, float dt, byte flags, const vec3_t position, const vec3_t velocity)
{
	G_EventAdd(G_VisToPM(teamMask), EV_ACTOR_THROW, -1);
	gi.WriteShort(dt * 1000);
	gi.WriteShort(fd->obj->idx);
	gi.WriteByte(fd->weapFdsIdx);
	gi.WriteByte(fd->fdIdx);
	gi.WriteByte(flags);
	gi.WritePos(position);
	gi.WritePos(velocity);
	G_EventEnd();
}
示例#16
0
/**
 * @sa CL_ActorAdd
 */
void G_EventActorAdd (unsigned int playerMask, const edict_t *ent)
{
	G_EventAdd(playerMask, EV_ACTOR_ADD, ent->number);
	gi.WriteByte(ent->team);
	gi.WriteByte(ent->chr.teamDef ? ent->chr.teamDef->idx : NONE);
	gi.WriteByte(ent->chr.gender);
	gi.WriteByte(ent->pnum);
	gi.WriteGPos(ent->pos);
	gi.WriteShort(ent->state & STATE_PUBLIC);
	gi.WriteByte(ent->fieldSize);
	G_EventEnd();
}
示例#17
0
/**
 * @sa CL_ActorAdd
 */
void G_EventActorAdd (playermask_t playerMask, const Edict& ent)
{
	G_EventAdd(playerMask, EV_ACTOR_ADD, ent.number);
	gi.WriteByte(ent.team);
	gi.WriteByte(ent.chr.teamDef ? ent.chr.teamDef->idx : NONE);
	gi.WriteByte(ent.chr.gender);
	gi.WriteByte(ent.pnum);
	gi.WriteGPos(ent.pos);
	gi.WriteShort(ent.state & STATE_PUBLIC);
	gi.WriteByte(ent.fieldSize);
	G_EventEnd();
}
示例#18
0
/**
 * @brief Change the amount of available ammo for the given entity
 * @param ent The entity to change the amount of ammo for
 * @param ammo The ammo to change
 * @param amount The new amount of the left ammo
 * @param shootType The shooting type to determine which container to use
 */
void G_EventInventoryAmmo (const Edict& ent, const objDef_t* ammo, int amount, shoot_types_t shootType)
{
	G_EventAdd(G_VisToPM(ent.visflags), EV_INV_AMMO, ent.number);
	gi.WriteByte(amount);
	gi.WriteByte(ammo->idx);
	if (IS_SHOT_RIGHT(shootType))
		gi.WriteByte(CID_RIGHT);
	else
		gi.WriteByte(CID_LEFT);
	/* x and y value */
	gi.WriteByte(0);
	gi.WriteByte(0);
	G_EventEnd();
}
示例#19
0
void G_EventAddBrushModel (unsigned int playerMask, const edict_t *ent)
{
	G_EventAdd(playerMask, EV_ADD_BRUSH_MODEL, ent->number);
	gi.WriteByte(ent->type);
	gi.WriteShort(ent->modelindex);
	/* strip the higher bits - only send levelflags */
	gi.WriteByte(ent->spawnflags & 0xFF);
	gi.WritePos(ent->origin);
	gi.WritePos(ent->angles);
	gi.WriteShort(ent->speed);
	gi.WriteByte(ent->angle);
	gi.WriteByte(ent->dir);
	G_EventEnd();
}
示例#20
0
/**
 * @brief Change the amount of available ammo for the given entity
 * @param ent The entity to change the amount of ammo for
 * @param ammo The ammo to change
 * @param amount The new amount of the left ammo
 * @param shootType The shooting type to determine which container to use
 */
void G_EventInventoryAmmo (const edict_t* ent, const objDef_t* ammo, int amount, shoot_types_t shootType)
{
	G_EventAdd(G_VisToPM(ent->visflags), EV_INV_AMMO, ent->number);
	gi.WriteByte(amount);
	gi.WriteByte(ammo->idx);
	if (IS_SHOT_RIGHT(shootType))
		gi.WriteByte(gi.csi->idRight);
	else
		gi.WriteByte(gi.csi->idLeft);
	/* x and y value */
	gi.WriteByte(0);
	gi.WriteByte(0);
	G_EventEnd();
}
示例#21
0
void G_EventAddBrushModel (playermask_t playerMask, const Edict& ent)
{
	G_EventAdd(playerMask, EV_ADD_BRUSH_MODEL, ent.number);
	gi.WriteByte(ent.type);
	gi.WriteShort(ent.modelindex);
	/* strip the higher bits - only send levelflags */
	gi.WriteByte(ent.spawnflags & 0xFF);
	gi.WritePos(ent.origin);
	gi.WritePos(ent.angles);
	gi.WriteShort(ent.speed);
	gi.WriteByte(ent.angle);
	gi.WriteByte(ent.dir);
	G_EventEnd();
}
示例#22
0
void G_EventActorAppear (playermask_t playerMask, const Edict& check, const Edict* ent)
{
	const int mask = G_TeamToPM(check.team) & playerMask;

	/* parsed in CL_ActorAppear */
	G_EventAdd(playerMask, EV_ACTOR_APPEAR, check.number);
	gi.WriteShort(ent && ent->number > 0 ? ent->number : SKIP_LOCAL_ENTITY);
	gi.WriteByte(check.team);
	gi.WriteByte(check.chr.teamDef ? check.chr.teamDef->idx : NONE);
	gi.WriteByte(check.chr.gender);
	gi.WriteShort(check.chr.ucn);
	gi.WriteByte(check.pnum);
	gi.WriteGPos(check.pos);
	gi.WriteByte(check.dir);
	if (check.getRightHandItem()) {
		gi.WriteShort(check.getRightHandItem()->def()->idx);
	} else {
		gi.WriteShort(NONE);
	}

	if (check.getLeftHandItem()) {
		gi.WriteShort(check.getLeftHandItem()->def()->idx);
	} else {
		gi.WriteShort(NONE);
	}

	if (check.body == 0 || check.head == 0) {
		gi.Error("invalid body and/or head model indices");
	}
	gi.WriteShort(check.body);
	gi.WriteShort(check.head);
	gi.WriteByte(check.chr.bodySkin);
	gi.WriteByte(check.chr.headSkin);
	/* strip the server private states */
	gi.WriteShort(check.state & STATE_PUBLIC);
	gi.WriteByte(check.fieldSize);
	/* get the max values for TU and morale */
	gi.WriteByte(G_ActorCalculateMaxTU(&check));
	gi.WriteByte(std::min(MAX_SKILL, GET_MORALE(check.chr.score.skills[ABILITY_MIND])));
	gi.WriteShort(check.chr.maxHP);
	G_EventEnd();

	if (mask) {
		G_EventActorStateChange(mask, check);
		G_SendInventory(mask, check);
	}
}
示例#23
0
/**
 * @brief Spawns a sound (that will be spatialized on the client side)
 * @param ent The edict that is causing the sound
 * @param origin The origin of the sound
 * @param sound The sound file, path relative to sounds/. If there is a + at the end the client will
 * choose a random sound. See the event function for more information.
 * of the path, a random sound will be taken.
 */
void G_EventSpawnSound (unsigned int playerMask, bool instant, const edict_t* ent, const vec3_t origin, const char *sound)
{
	G_EventAdd(playerMask, EV_SOUND | (instant ? EVENT_INSTANTLY : 0), ent->number);

	/* use the entity origin unless it is a bmodel or explicitly specified */
	if (!origin) {
		if (ent->solid == SOLID_BSP) {
			vec3_t origin_v;
			VectorCenterFromMinsMaxs(ent->mins, ent->maxs, origin_v);
			VectorAdd(ent->origin, origin_v, origin_v);
			gi.WritePos(origin);
		} else {
			gi.WritePos(vec3_origin);
		}
	} else {
		gi.WritePos(origin);
	}
	gi.WriteString(sound);
	G_EventEnd();
}
示例#24
0
/**
 * @brief Do the shooting
 * @param ent The entity that is doing the shooting
 * @param visMask the vis mask to determine the clients from this event is send to
 * @param fd The firedefinition to use for the shoot
 * @param firstShoot Is this the first shoot
 * @param shootType The type of the shoot
 * @param flags Define some flags in a bitmask: @c SF_BODY, @c SF_IMPACT, @c SF_BOUNCING and @c SF_BOUNCING
 * @param trace The trace what was used to determine whether this shot has hit something
 * @param from The position the entity shoots from
 * @param impact The impact world vector for the shot
 */
void G_EventShoot (const edict_t* ent, vismask_t visMask, const fireDef_t* fd, bool firstShoot, shoot_types_t shootType, int flags, const trace_t* trace, const vec3_t from, const vec3_t impact)
{
	const edict_t *targetEdict = trace->ent;

	G_EventAdd(G_VisToPM(visMask), EV_ACTOR_SHOOT, ent->number);
	if (targetEdict && G_IsBreakable(targetEdict))
		gi.WriteShort(targetEdict->number);
	else
		gi.WriteShort(SKIP_LOCAL_ENTITY);
	gi.WriteByte(firstShoot ? 1 : 0);
	gi.WriteShort(fd->obj->idx);
	gi.WriteByte(fd->weapFdsIdx);
	gi.WriteByte(fd->fdIdx);
	gi.WriteByte(shootType);
	gi.WriteByte(flags);
	gi.WriteByte(trace->contentFlags);
	gi.WritePos(from);
	gi.WritePos(impact);
	gi.WriteDir(trace->plane.normal);
	G_EventEnd();
}
示例#25
0
/**
 * @brief Do the shooting
 * @param ent The entity that is doing the shooting
 * @param teamMask the vis mask to determine the clients from this event is send to
 * @param fd The firedefinition to use for the shoot
 * @param firstShoot Is this the first shoot
 * @param shootType The type of the shoot
 * @param flags Define some flags in a bitmask: @c SF_BODY, @c SF_IMPACT, @c SF_BOUNCING and @c SF_BOUNCING
 * @param trace The trace what was used to determine whether this shot has hit something
 * @param from The position the entity shoots from
 * @param impact The impact world vector for the shot
 */
void G_EventShoot (const Edict& ent, teammask_t teamMask, const fireDef_t* fd, bool firstShoot, shoot_types_t shootType, int flags, const trace_t* trace, const vec3_t from, const vec3_t impact)
{
	const Edict* targetEdict = G_EdictsGetByNum(trace->entNum);	/* the ent possibly hit by the trace */

	G_EventAdd(G_VisToPM(teamMask), EV_ACTOR_SHOOT, ent.number);
	if (targetEdict && G_IsBreakable(targetEdict))
		gi.WriteShort(targetEdict->number);
	else
		gi.WriteShort(SKIP_LOCAL_ENTITY);
	gi.WriteByte(firstShoot ? 1 : 0);
	gi.WriteShort(fd->obj->idx);
	gi.WriteByte(fd->weapFdsIdx);
	gi.WriteByte(fd->fdIdx);
	gi.WriteByte(shootType);
	gi.WriteByte(flags);
	gi.WriteByte(trace->contentFlags);
	gi.WritePos(from);
	gi.WritePos(impact);
	gi.WriteDir(trace->plane.normal);
	G_EventEnd();
}
示例#26
0
/**
 * @brief Spawns a sound (that will be spatialized on the client side)
 * @param playerMask A bit mask. One bit for each affected player
 * @param ent The edict that is causing the sound
 * @param origin The origin of the sound
 * @param sound The sound file, path relative to sounds/. If there is a + at the end the client will
 * choose a random sound. See the event function for more information.
 * of the path, a random sound will be taken.
 */
void G_EventSpawnSound (playermask_t playerMask, const Edict& ent, const vec3_t origin, const char* sound)
{
	G_EventAdd(playerMask, EV_SOUND, ent.number);

	/* use the entity origin unless it is a bmodel or explicitly specified */
	if (!origin) {
		if (ent.solid == SOLID_BSP) {
			vec3_t origin_v;
			ent.entBox.getCenter(origin_v);
			VectorAdd(ent.origin, origin_v, origin_v);
			gi.WritePos(origin);
		} else {
			gi.WritePos(vec3_origin);
		}
	} else {
		gi.WritePos(origin);
	}
	gi.WriteByte(0xFF);
	gi.WriteString(sound);
	G_EventEnd();
}
示例#27
0
/**
 * @brief Writes a step of the move event to the net
 * @param[in] ent Edict to move
 * @param[in] stepAmount Pointer to the amount of steps in this move-event
 * @param[in] dvec The direction vector for the step to be added
 * @param[in] contentFlags The material we are walking over
 */
static void G_WriteStep (edict_t* ent, byte** stepAmount, const int dvec, const int contentFlags)
{
	/* write move header if not yet done */
	if (gi.GetEvent() != EV_ACTOR_MOVE) {
		G_EventAdd(G_VisToPM(ent->visflags), EV_ACTOR_MOVE, ent->number);
	}

	/* the moveinfo stuff is used inside the G_PhysicsStep think function */
	if (ent->moveinfo.steps >= MAX_ROUTE) {
		ent->moveinfo.steps = 0;
		ent->moveinfo.currentStep = 0;
	}
	ent->moveinfo.contentFlags[ent->moveinfo.steps] = contentFlags;
	ent->moveinfo.visflags[ent->moveinfo.steps] = ent->visflags;
	ent->moveinfo.steps++;

	/* write move header and always one step after another - because the next step
	 * might already be the last one due to some stop event */
	gi.WriteShort(dvec);
	gi.WriteShort(ent->speed);
	gi.WriteShort(contentFlags);
}
示例#28
0
/**
 * @brief Send the turn event for the given entity
 * @param ent The entity to send the turn event for
 * @note Every player that can see this ent will reveive the turn event data
 * @note Make sure that the direction to turn into is already set
 */
void G_EventActorTurn (const Edict& ent)
{
	G_EventAdd(G_VisToPM(ent.visflags), EV_ACTOR_TURN, ent.number);
	gi.WriteByte(ent.dir);
	G_EventEnd();
}
示例#29
0
void G_EventDoorClose (const Edict& door)
{
	G_EventAdd(PM_ALL, EV_DOOR_CLOSE, door.number);
	G_EventEnd();
}
示例#30
0
void G_EventDoorOpen (const Edict& door)
{
	G_EventAdd(PM_ALL, EV_DOOR_OPEN, door.number);
	G_EventEnd();
}