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();
303 const int attackerTeam = (attacker !=
nullptr ? attacker->
getTeam() :
MAX_TEAMS);
306 alive[victimTeam] += deltaAlive;
307 if (alive[victimTeam] > spawned)
308 gi.Error(
"alive counter out of sync");
310 if (deltaStuns != 0) {
312 stuns[victimTeam] += deltaStuns;
313 if (stuns[victimTeam] > spawned)
314 gi.Error(
"stuns counter out of sync");
317 if (deltaKills != 0) {
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) {
339 }
else if (
i == attacker->
team) {
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();
589 _(
"Can't perform action - weapon already fully loaded with the same ammunition!"));
641 item.setAmmoDef(
nullptr);
642 item.setDef(toItemBackup.
ammoDef());
643 item.rotated = fromItemBackup.rotated;
644 item.setAmount(toItemBackup.
getAmount());
645 toContType = fromContType;
646 if (toContType->isFloorDef()) {
652 fromItemBackup = item;
653 fromItemBackup.setX(item2->
getX());
654 fromItemBackup.setY(item2->
getY());
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);
Edict * G_SpawnFloor(const pos3_t pos)
Spawns a new entity at the floor.
void G_ClientPrintf(const Player &player, int printLevel, const char *fmt,...)
inventory_action_t
Possible inventory actions for moving items between containers.
Edict * G_EdictsGetNextInUse(Edict *lastEnt)
Iterate through the entities that are in use.
int G_TouchTriggers(Edict *ent, const entity_type_t type)
Check the world against triggers for the current entity.
#define VectorCopy(src, dest)
const objDef_t * getWeapon() const
void G_EventActorStateChange(playermask_t playerMask, const Edict &ent)
void G_PrintStats(const char *format,...)
Prints stats to game console and stats log file.
this is a fire definition for our weapons/ammo
void G_EventInventoryReload(const Edict &ent, playermask_t playerMask, const Item *item, const invDef_t *invDef, const Item *ic)
void G_ReactionFireOnDead(const Actor *target)
Removes the given target from the reaction fire lists.
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...
void G_EventActorTurn(const Edict &ent)
Send the turn event for the given entity.
int G_ActorDoTurn(Edict *ent, byte dir)
Turns an actor around.
int G_ActorUsableTUs(const Edict *ent)
Calculates the amount of usable TUs. This is without the reserved TUs.
const teamDef_t * teamDef
unsigned num_stuns[MAX_TEAMS+1][MAX_TEAMS]
Misc utility functions for game module.
#define FL_CLIENTACTION
Edict flag to indicate, that the edict can be used in the context of a client action.
void G_ClientStateChange(const Player &player, Actor *actor, int reqState, bool checkaction)
Changes the state of a player/soldier.
unsigned int playermask_t
inventory_action_t moveInInventory(Inventory *const inv, const invDef_t *from, Item *item, const invDef_t *to, int tx, int ty, int *TU, Item **icp)
Conditions for moving items between containers.
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
bool isRightDef() const
Checks whether the inventory definition is the right Hand.
const objDef_t * def(void) const
void G_ActorReserveTUs(Edict *ent, int resReaction, int resShot, int resCrouch)
Reserves TUs for different actor actions.
bool isLeftDef() const
Checks whether a given inventory definition is of special type.
void Com_Printf(const char *const fmt,...)
#define G_IsCrouched(ent)
Defines all attributes of objects used in the inventory.
const byte dvleft[CORE_DIRECTIONS]
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_ActorSetMaxs(Actor *actor)
Sets correct bounding box for actor (state dependent).
bool G_IsLivingActor(const Edict *ent)
Checks whether the given edict is a living actor.
Player & getPlayer() const
#define FL_GROUPSLAVE
not the first on the team
unsigned num_kills[MAX_TEAMS+1][MAX_TEAMS]
Item * getContainer(const containerIndex_t idx) const
void G_ActorGiveTimeUnits(Actor *actor)
Set time units for the given edict. Based on speed skills.
Item * getRightHandItem() const
Item * findInContainer(const containerIndex_t contId, const Item *const item) const
Searches a specific item in the inventory&container.
void G_EventResetClientAction(const Edict &ent)
Reset the client actions for the given entity.
item instance data, with linked list capability
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 G_InventoryToFloor(Edict *ent)
Move items to adjacent locations if the containers on the current floor edict are full...
#define FLYING_DIRECTIONS
#define PATHFINDING_DIRECTIONS
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.
void setFloor(const Edict *other)
int getWeight() const
Get the weight of the items in the given inventory (excluding those in temp containers).
static void G_ActorRevitalise(Actor *actor)
Edict * G_FindRadius(Edict *from, const vec3_t org, float rad, entity_type_t type)
Returns entities that have origins within a spherical area.
void G_ActorUseDoor(Actor *actor, Edict *door)
Make the actor use (as in open/close) a door edict.
int G_ActorGetModifiedTimeForFiredef(const Edict *const ent, const fireDef_t *const fd, const bool reaction)
int G_ActorGetContentFlags(const vec3_t origin)
Get the content flags from where the actor is currently standing.
static bool G_ActorDie(Actor *actor, const Edict *attacker)
byte num_alive[MAX_TEAMS]
bool CHRSH_IsTeamDefRobot(const teamDef_t *const td)
Check if a team definition is a robot.
void G_ActorSetClientAction(Edict *actor, Edict *ent)
Handles the client actions (interaction with the world)
void G_EventActorRevitalise(const Edict &ent)
Announce the actor revitalize event for the clients that are seeing the actor.
playermask_t G_VisToPM(teammask_t teamMask)
Converts vis mask to player mask.
const invDef_t * def() const
#define INVDEF(containerID)
Item * getNextItem(const Item *prev) const
void G_WriteItem(const Item &item, const containerIndex_t contId, int x, int y)
Write an item to the network buffer.
void G_ActorModifyCounters(const Edict *attacker, const Edict *victim, int deltaAlive, int deltaKills, int deltaStuns)
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.
bool G_ActorReload(Actor *actor, const invDef_t *invDef)
Reload weapon with actor.
#define G_IsBlockingMovementActor(ent)
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. ...
#define VectorCompare(a, b)
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.
bool isLoadableInWeapon(const objDef_s *weapon) const
Checks if an item can be used to reload a weapon.
bool isFloorDef() const
Checks whether the inventory definition is the floor.
Item * getHandItem(actorHands_t hand) const
static bool G_ActorStun(Actor *actor, const Edict *attacker)
void G_ReactionFireTargetsDestroy(const Edict *shooter)
free function to destroy the table of reaction fire targets for the given edict.
#define GET_ENCUMBRANCE_PENALTY(weight, max)
void G_ActorUseTU(Edict *ent, int tus)
bool G_ActionCheckForCurrentTeam(const Player &player, Actor *ent, int TU)
Checks whether the requested action is possible for the current active team.
void G_EventActorSendReservations(const Edict &ent)
Will inform the player about the real TU reservation.
#define G_SetState(ent, s)
const byte dvright[CORE_DIRECTIONS]
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.
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
void G_EventSetClientAction(const Edict &ent)
Informs the client that an interaction with the world is possible.
Brings new objects into the world.
void G_ActorSetTU(Edict *ent, int tus)
void G_ActorCheckRevitalise(Actor *actor)
void G_EventPerish(const Edict &ent)
Send an event to all clients that are seeing the given edict, that it just has disappeared.
functions to handle the storage and lifecycle of all edicts in the game module.
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.
unsigned num_spawned[MAX_TEAMS]
void G_EventInventoryAdd(const Edict &ent, playermask_t playerMask, int itemAmount)
Tell the client to add the item from the container.
bool isHeldTwoHanded() const
const objDef_t * ammoDef(void) const
inventory definition for our menus
void G_EventActorDie(const Edict &ent, bool attacker)
Announce the actor die event for the clients that are seeing the actor.
void G_ActorGetEyeVector(const Edict *actor, vec3_t eye)
Fills a vector with the eye position of a given actor.
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...
Edict * G_GetFloorItems(Edict *ent)
Prepares a list of items on the floor at given entity position.
const float directionAngles[CORE_DIRECTIONS]
actorHands_t getHand() const
void G_SendStats(Edict &ent)
Send stats to network buffer.
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 setMaxs(const vec3_t maxi)
int getReservedTUs() const
Calculates the amount of all currently reserved TUs.
int G_ActorCalculateMaxTU(const Edict *ent)
float G_ActorGetInjuryPenalty(const Edict *const ent, const modifier_types_t type)
Returns the penalty to the given stat caused by the actor wounds.
int skills[SKILL_NUM_TYPES]
void G_FreeEdict(Edict *ent)
Marks the edict as free.
Interface for g_client.cpp.
playermask_t G_TeamToPM(int team)
Generates the player bit mask for a given team.
#define G_IsPanicked(ent)
int G_ActorGetTUForReactionFire(const Edict *ent)
Calculates the amount of TUs that are needed for the current selected reaction fire mode...
chrReservations_t reservedTus