36#define MAX_TU (ROUTING_NOT_REACHABLE - 1)
69 Edict* closeActor =
nullptr;
122 assert(weapon->
def());
138 if (ent->
getTus() >= resReaction + resShot + resCrouch) {
179 if (angleDiv > 180.0)
181 if (angleDiv < -180.0)
193 num = (angleDiv + angleStep / 2) / angleStep;
197 num = (-angleDiv + angleStep / 2) / angleStep;
206 for (
int i = 0;
i < num;
i++) {
228 switch (actor->
type) {
236 gi.Error(
"G_ActorSetMaxs: Unknown actor type: %i (ent %i)", actor->
type, actor->
getIdNum());
253 return std::min(currentMaxTU,
MAX_TU);
269 if (tus > 0 && tus < ent->getTus()) {
275 ent->
setTus(std::max(tus, 0));
292 actor->
link = attacker;
301 const int victimTeam = victim->
getTeam();
302 const unsigned spawned =
level.num_spawned[victimTeam];
303 const int attackerTeam = (attacker !=
nullptr ? attacker->
getTeam() :
MAX_TEAMS);
304 byte* alive =
level.num_alive;
306 alive[victimTeam] += deltaAlive;
307 if (alive[victimTeam] > spawned)
308 gi.Error(
"alive counter out of sync");
310 if (deltaStuns != 0) {
311 unsigned* stuns =
level.num_stuns[attackerTeam];
312 stuns[victimTeam] += deltaStuns;
313 if (stuns[victimTeam] > spawned)
314 gi.Error(
"stuns counter out of sync");
317 if (deltaKills != 0) {
318 unsigned* kills =
level.num_kills[attackerTeam];
319 kills[victimTeam] += deltaKills;
320 if (kills[victimTeam] > spawned)
321 gi.Error(
"kills counter out of sync");
329 if (
i == victimTeam) {
336 if (j == victimTeam) {
337 Com_Printf(
"^2num_kills (team %i killed %i): %i\n",
i, j,
level.num_kills[
i][j]);
338 Com_Printf(
"^2num_stuns (team %i stunned %i): %i\n",
i, j,
level.num_stuns[
i][j]);
339 }
else if (
i == attacker->
team) {
340 Com_Printf(
"^3num_kills (team %i killed %i): %i\n",
i, j,
level.num_kills[
i][j]);
341 Com_Printf(
"^3num_stuns (team %i stunned %i): %i\n",
i, j,
level.num_stuns[
i][j]);
390 Edict* otherActor =
nullptr;
446 gi.DPrintf(
"G_ActorDieOrStun: State wasn't changed\n");
491 return gi.PointContents(pointTrace);
509 assert(fItem->
def());
512 Item fromItemBackup = *fItem;
521 toItemBackup = *fItem;
542 bool newFloor =
false;
547 }
else if (fromContType->
isFloorDef() && !floor) {
549 gi.DPrintf(
"G_ClientInvMove: No source-floor found.\n");
566 int originalTU = actor->
getTus();
572 ia =
game.invi.moveInInventory(&actor->
chr.
inv, fromContType, fItem, toContType, tx, ty, checkaction ? &actor->
TU :
nullptr, &item2);
589 _(
"Can't perform action - weapon already fully loaded with the same ammunition!"));
645 toContType = fromContType;
650 item2 = actor->chr.inv.findInContainer(toContType->
id, &item);
652 fromItemBackup = item;
656 tx = fromItemBackup.
getX();
657 ty = fromItemBackup.
getY();
735 const invDef_t* bestContainer =
nullptr;
736 Item* ammoItem =
nullptr;
740 if (cont->
def()->
out >= tu)
746 Item* item =
nullptr;
751 tu = bestContainer->
out;
759 return G_ActorInvMove(actor, bestContainer, ammoItem, invDef, 0, 0,
true);
bool CHRSH_IsTeamDefRobot(const teamDef_t *const td)
Check if a team definition is a robot.
#define INVDEF(containerID)
void setMaxs(const vec3_t maxi)
Item * getNextItem(const Item *prev) const
const invDef_t * def() const
void setFloor(const Edict *other)
Item * getRightHandItem() const
Player & getPlayer() const
int getReservedTUs() const
Calculates the amount of all currently reserved TUs.
Item * getHandItem(actorHands_t hand) const
Item * getContainer(const containerIndex_t idx) const
actorHands_t getHand() const
const objDef_t * getWeapon() const
bool canHoldItemWeight(containerIndex_t from, containerIndex_t to, const Item &item, int maxWeight) const
Check that adding an item to the inventory won't exceed the max permitted weight.
void findSpace(const invDef_t *container, const Item *item, int *const px, int *const py, const Item *ignoredItem) const
Finds space for item in inv at container.
int getWeight() const
Get the weight of the items in the given inventory (excluding those in temp containers).
Item * getItemAtPos(const invDef_t *container, const int x, const int y) const
Searches if there is an item at location (x,y) in a container.
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
item instance data, with linked list capability
const objDef_t * ammoDef(void) const
void setAmount(int value)
void setAmmoDef(const objDef_t *od)
void setDef(const objDef_t *objDef)
const objDef_t * def(void) const
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
void getFirstShapePosition(int *const x, int *const y) const
Calculates the first "true" bit in the shape and returns its position in the item.
void setAmmoLeft(int value)
bool isHeldTwoHanded() const
void Com_Printf(const char *const fmt,...)
void G_ActorReserveTUs(Edict *ent, int resReaction, int resShot, int resCrouch)
Reserves TUs for different actor actions.
static bool G_ActorStun(Actor *actor, const Edict *attacker)
bool G_ActorDieOrStun(Actor *actor, Edict *attacker)
Reports and handles death or stun of an actor. If the HP of an actor is zero the actor will die,...
bool G_ActorReload(Actor *actor, const invDef_t *invDef)
Reload weapon with actor.
void G_ActorGiveTimeUnits(Actor *actor)
Set time units for the given edict. Based on speed skills.
int G_ActorUsableTUs(const Edict *ent)
Calculates the amount of usable TUs. This is without the reserved TUs.
void G_ActorModifyCounters(const Edict *attacker, const Edict *victim, int deltaAlive, int deltaKills, int deltaStuns)
void G_ActorCheckRevitalise(Actor *actor)
void G_ActorSetClientAction(Edict *actor, Edict *ent)
Handles the client actions (interaction with the world).
void G_ActorUseDoor(Actor *actor, Edict *door)
Make the actor use (as in open/close) a door edict.
int G_ActorCalculateMaxTU(const Edict *ent)
void G_ActorSetTU(Edict *ent, int tus)
int G_ActorGetTUForReactionFire(const Edict *ent)
Calculates the amount of TUs that are needed for the current selected reaction fire mode.
int G_ActorGetModifiedTimeForFiredef(const Edict *const ent, const fireDef_t *const fd, const bool reaction)
static bool G_ActorDie(Actor *actor, const Edict *attacker)
static void G_ActorRevitalise(Actor *actor)
void G_ActorUseTU(Edict *ent, int tus)
int G_ActorDoTurn(Edict *ent, byte dir)
Turns an actor around.
bool G_IsLivingActor(const Edict *ent)
Checks whether the given edict is a living actor.
void G_ActorSetMaxs(Actor *actor)
Sets correct bounding box for actor (state dependent).
bool G_ActorInvMove(Actor *actor, const invDef_t *fromContType, Item *fItem, const invDef_t *toContType, int tx, int ty, bool checkaction)
Moves an item inside an inventory. Floors are handled special.
int G_ActorGetContentFlags(const vec3_t origin)
Get the content flags from where the actor is currently standing.
void G_ActorGetEyeVector(const Edict *actor, vec3_t eye)
Fills a vector with the eye position of a given actor.
#define G_IsCrouched(ent)
#define G_SetState(ent, s)
#define G_IsPanicked(ent)
playermask_t G_TeamToPM(int team)
Generates the player bit mask for a given team.
bool G_ActionCheckForCurrentTeam(const Player &player, Actor *ent, int TU)
Checks whether the requested action is possible for the current active team.
bool G_ClientUseEdict(const Player &player, Actor *actor, Edict *edict)
This function 'uses' the edict. E.g. it opens the door when the player wants it to open.
void G_ClientStateChange(const Player &player, Actor *actor, int reqState, bool checkaction)
Changes the state of a player/soldier.
void G_ClientPrintf(const Player &player, int printLevel, const char *fmt,...)
playermask_t G_VisToPM(teammask_t teamMask)
Converts vis mask to player mask.
Interface for g_client.cpp.
Edict * G_EdictsGetNextInUse(Edict *lastEnt)
Iterate through the entities that are in use.
functions to handle the storage and lifecycle of all edicts in the game module.
void G_EventInventoryDelete(const Edict &ent, playermask_t playerMask, const containerIndex_t containerId, int x, int y)
Tell the client to remove the item from the container.
void G_EventActorTurn(const Edict &ent)
Send the turn event for the given entity.
void G_EventSetClientAction(const Edict &ent)
Informs the client that an interaction with the world is possible.
void G_EventActorDie(const Edict &ent, bool attacker)
Announce the actor die event for the clients that are seeing the actor.
void G_EventInventoryAdd(const Edict &ent, playermask_t playerMask, int itemAmount)
Tell the client to add the item from the container.
void G_EventActorSendReservations(const Edict &ent)
Will inform the player about the real TU reservation.
void G_EventPerish(const Edict &ent)
Send an event to all clients that are seeing the given edict, that it just has disappeared.
void G_EventActorRevitalise(const Edict &ent)
Announce the actor revitalize event for the clients that are seeing the actor.
void G_EventInventoryReload(const Edict &ent, playermask_t playerMask, const Item *item, const invDef_t *invDef, const Item *ic)
void G_EventResetClientAction(const Edict &ent)
Reset the client actions for the given entity.
void G_EventActorStateChange(playermask_t playerMask, const Edict &ent)
unsigned int playermask_t
float G_ActorGetInjuryPenalty(const Edict *const ent, const modifier_types_t type)
Returns the penalty to the given stat caused by the actor wounds.
void G_InventoryToFloor(Edict *ent)
Move items to adjacent locations if the containers on the current floor edict are full.
Edict * G_GetFloorItems(Edict *ent)
Prepares a list of items on the floor at given entity position.
void G_WriteItem(const Item &item, const containerIndex_t contId, int x, int y)
Write an item to the network buffer.
#define FL_GROUPSLAVE
not the first on the team
void G_SendStats(Edict &ent)
Send stats to network buffer.
#define FL_CLIENTACTION
Edict flag to indicate, that the edict can be used in the context of a client action.
#define G_IsBlockingMovementActor(ent)
void G_ReactionFireSettingsUpdate(Actor *actor, fireDefIndex_t fmIdx, actorHands_t hand, const objDef_t *od)
Updates the reaction fire settings in case something was moved into a hand or from a hand that would ...
void G_ReactionFireTargetsDestroy(const Edict *shooter)
free function to destroy the table of reaction fire targets for the given edict.
void G_ReactionFireOnDead(const Actor *target)
Removes the given target from the reaction fire lists.
Edict * G_SpawnFloor(const pos3_t pos)
Spawns a new entity at the floor.
Brings new objects into the world.
void G_PrintStats(const char *format,...)
Prints stats to game console and stats log file.
void G_FreeEdict(Edict *ent)
Marks the edict as free.
int G_TouchTriggers(Edict *ent, const entity_type_t type)
Check the world against triggers for the current entity.
Edict * G_FindRadius(Edict *from, const vec3_t org, float rad, entity_type_t type)
Returns entities that have origins within a spherical area.
Misc utility functions for game module.
int G_CheckVisTeamAll(const int team, const vischeckflags_t visFlags, const Edict *ent)
Do G_CheckVisTeam for all entities ent is the one that is looking at the others.
void G_CheckVis(Edict *check, const vischeckflags_t visFlags)
Check if the edict appears/perishes for the other teams. If they appear for other teams,...
inventory_action_t
Possible inventory actions for moving items between containers.
const byte dvleft[CORE_DIRECTIONS]
const float directionAngles[CORE_DIRECTIONS]
const byte dvright[CORE_DIRECTIONS]
#define FLYING_DIRECTIONS
#define PATHFINDING_DIRECTIONS
#define GET_ENCUMBRANCE_PENALTY(weight, max)
chrReservations_t reservedTus
const teamDef_t * teamDef
int skills[SKILL_NUM_TYPES]
this is a fire definition for our weapons/ammo
inventory definition for our menus
bool isFloorDef() const
Checks whether the inventory definition is the floor.
bool isLeftDef() const
Checks whether a given inventory definition is of special type.
bool isRightDef() const
Checks whether the inventory definition is the right Hand.
Defines all attributes of objects used in the inventory.
bool isLoadableInWeapon(const objDef_s *weapon) const
Checks if an item can be used to reload a weapon.
#define VectorCopy(src, dest)
#define VectorCompare(a, b)