Various functions related to NPCs/Critters. More...
Various functions related to NPCs/Critters.
Include npc_common_h.fos for usage.
Defines | |
#define | _FreeHex (map.IsHexPassed(hx, hy) && @ (map.GetCritter(hx, hy)) == null) |
#define | _AddHex |
#define | _OldHex (hx == px && hy == py) |
#define | _ReturnHex outX = hx; outY = hy; return true |
Functions | |
bool | AttackCritter (Critter& attacker, Critter& target, uint minhp) |
bool | AttackCritter (Critter& attacker, Critter& target) |
bool | HasIntelligentBrain (Critter& cr) |
void | UnsetCritterIllegalFlag (Critter& critter) |
void | UnsetCritterIllegalFlag (Critter& critter, int location) |
void | UnsetCritterIllegalFlag (uint id, int location) |
void | SetCritterIllegalFlag (Critter& critter, int reason) |
void | SetCritterIllegalFlag (Critter& critter, int location, int reason) |
void | PutAwayItems (Critter& critter) |
int | GetCritterIllegalFlag (Critter& critter, int location) |
Get illegal flag status of critter in a specific location. | |
int | GetCritterIllegalFlag (Critter& critter) |
Clear illegal flags in critter's current location. | |
void | ClearIllegalFlags (Critter& critter) |
Clear illegal flags in all towns. | |
bool | IsFlaggedAsIllegal (Critter& critter) |
bool | IsFlaggedAsIllegal (Critter& critter, int location) |
void | Heal (Critter& cr) |
Heal a critter. | |
bool | HasSameScript (Critter& critter1, Critter& critter2) |
Check if two critters has the same script assigned. | |
bool | IsInLocation (Critter& critter, int locationPID) |
Check if a critter is in a specific location. | |
bool | MoveByDir (Critter& critter, uint8 dir, uint steps, bool run) |
uint | GetNearGuards (Map@ map, uint16 hexX, uint16 hexY, uint radius, array< Critter@>@ crits) |
Gets all general purpose guards in a radius around given hex. | |
uint | GetNearFactionGuards (Map@ map, uint16 hexX, uint16 hexY, uint radius, uint faction, array< Critter@>@ crits) |
Gets all faction guards in a radius around given hex. | |
Item@ | ArmBestWeapon (Critter& critter) |
Arm the best weapon available to the NPC. | |
Item@ | ArmFavoriteWeapon (Critter& critter) |
Tries to arm NPC with its favorite weapon. | |
void | FindFreeHexes (Map@ map, uint16 hexX, uint16 hexY, int& num, array< uint16 >& coordsX, array< uint16 >& coordsY) |
bool | FindNearestFreeHex (Map@ map, uint16 hexX, uint16 hexY, uint16& outX, uint16& outY) |
bool | Flee (Critter& cr) |
bool | Flee (Critter& cr, bool Run) |
Flee to worldmap via closest exitgrid. | |
void | MoveRandom (Critter& npc, uint maxDist) |
Issue random walk for a critter to a hex in stepDist distance, as long as the actual distance to home pos is less than maxDist. | |
void | MoveRandom (Critter& npc, uint maxDist, bool Run) |
void | MoveRandom (Critter& npc, uint maxDist, uint stepDist, bool Run) |
bool | CanUseWeapon (Critter& critter, uint proto) |
Checks if a critter can use a weapon (has an animation for it). | |
bool | CanUseWeapon (Critter& critter, Item@ weapon) |
Checks if a critter can use a weapon (has an animation for it). | |
bool | HasUnusableWeapon (Critter& critter, uint bag) |
Checks if a critter can't use a weapon from a specific bag. | |
bool | HasUnusableWeapon (Critter& critter) |
Checks if a critter can't use a weapon in his inventory. | |
bool | HasUnusableWeapon (uint crpid, uint bag) |
Checks if a critter PID can't use a weapon from a specific bag. | |
void | AddWaitPlan (Critter& critter, uint waittime) |
The critter will wait for the specified time without getting busy (it can speak to players). | |
void | TryReportOffense (Critter@ cr, Critter@ offender, int reputationdrop) |
string | GetStoredFirstName (Critter& critter) |
string | GetStoredName (Critter& critter) |
string | GenerateNewName (Critter& critter) |
uint | GetCrittersWithScript (Map& map, uint16 pid, uint findType, string& scriptName, string& funcDeclaration, array< Critter@>@ critters) |
Gather all critters from a map that share the given script, and comply to the search parameters. | |
uint | GetCrittersLoc (Location& loc, uint16 pid, uint findType, array< Critter@>@ critters) |
void | SetDeleteEvent (Critter& cr, uint time) |
void | DropDeleteEvent (Critter& cr) |
uint | cte_Delete (Critter& cr, int identifier, uint& rate) |
Dialog functions | |
| |
void | r_MoveRandom (Critter& player, Critter@ npc, int val) |
bool | d_HasNumPlayersInParty (Critter& leader, Critter@ npc, int num) |
Checks if a party has specified numbers of members. | |
bool | d_HasNotNumPlayersInParty (Critter& leader, Critter@ npc, int val) |
Checks if a party has NOT specified numbers of members. |
#define _FreeHex (map.IsHexPassed(hx, hy) && @ (map.GetCritter(hx, hy)) == null) |
#define _AddHex |
do { coordsX.insertLast(hx); coordsY.insertLast(hy); free++; if(free == num) \ return; } while(false)
#define _OldHex (hx == px && hy == py) |
#define _ReturnHex outX = hx; outY = hy; return true |
bool HasIntelligentBrain | ( | Critter& | cr | ) |
void UnsetCritterIllegalFlag | ( | Critter& | critter | ) |
void UnsetCritterIllegalFlag | ( | Critter& | critter, | |
int | location | |||
) |
void UnsetCritterIllegalFlag | ( | uint | id, | |
int | location | |||
) |
void SetCritterIllegalFlag | ( | Critter& | critter, | |
int | reason | |||
) |
void SetCritterIllegalFlag | ( | Critter& | critter, | |
int | location, | |||
int | reason | |||
) |
void PutAwayItems | ( | Critter& | critter | ) |
int GetCritterIllegalFlag | ( | Critter& | critter, | |
int | location | |||
) |
Get illegal flag status of critter in a specific location.
int GetCritterIllegalFlag | ( | Critter& | critter | ) |
Clear illegal flags in critter's current location.
void ClearIllegalFlags | ( | Critter& | critter | ) |
Clear illegal flags in all towns.
bool IsFlaggedAsIllegal | ( | Critter& | critter | ) |
bool IsFlaggedAsIllegal | ( | Critter& | critter, | |
int | location | |||
) |
void Heal | ( | Critter& | cr | ) |
Heal a critter.
cr | Critter handle. |
Check if two critters has the same script assigned.
bool IsInLocation | ( | Critter& | critter, | |
int | locationPID | |||
) |
Check if a critter is in a specific location.
bool MoveByDir | ( | Critter& | critter, | |
uint8 | dir, | |||
uint | steps, | |||
bool | run | |||
) |
Gets all general purpose guards in a radius around given hex.
uint GetNearFactionGuards | ( | Map@ | map, | |
uint16 | hexX, | |||
uint16 | hexY, | |||
uint | radius, | |||
uint | faction, | |||
array< Critter@>@ | crits | |||
) |
Gets all faction guards in a radius around given hex.
Arm the best weapon available to the NPC.
void FindFreeHexes | ( | Map@ | map, | |
uint16 | hexX, | |||
uint16 | hexY, | |||
int& | num, | |||
array< uint16 >& | coordsX, | |||
array< uint16 >& | coordsY | |||
) |
bool FindNearestFreeHex | ( | Map@ | map, | |
uint16 | hexX, | |||
uint16 | hexY, | |||
uint16& | outX, | |||
uint16& | outY | |||
) |
bool Flee | ( | Critter& | cr | ) |
bool Flee | ( | Critter& | cr, | |
bool | Run | |||
) |
Flee to worldmap via closest exitgrid.
void MoveRandom | ( | Critter& | npc, | |
uint | maxDist | |||
) |
Issue random walk for a critter to a hex in stepDist distance, as long as the actual distance to home pos is less than maxDist.
In this case, it issues walkplane closely to homepos.
maxDist | Max distance in hexes. | |
stepDist | Step distance, the actual distance of single move |
void MoveRandom | ( | Critter& | npc, | |
uint | maxDist, | |||
bool | Run | |||
) |
void MoveRandom | ( | Critter& | npc, | |
uint | maxDist, | |||
uint | stepDist, | |||
bool | Run | |||
) |
bool CanUseWeapon | ( | Critter& | critter, | |
uint | proto | |||
) |
Checks if a critter can use a weapon (has an animation for it).
critter | Critter handle. | |
proto | Proto Id of the weapon to check. |
Checks if a critter can use a weapon (has an animation for it).
critter | Critter handle. | |
weapon | Weapon to check. |
bool HasUnusableWeapon | ( | Critter& | critter, | |
uint | bag | |||
) |
Checks if a critter can't use a weapon from a specific bag.
critter | Critter handle. | |
bag | BagId to check. |
bool HasUnusableWeapon | ( | Critter& | critter | ) |
Checks if a critter can't use a weapon in his inventory.
critter | Critter handle. |
bool HasUnusableWeapon | ( | uint | crpid, | |
uint | bag | |||
) |
Checks if a critter PID can't use a weapon from a specific bag.
crpid | Critter PID. | |
bag | BagId to check. |
void AddWaitPlan | ( | Critter& | critter, | |
uint | waittime | |||
) |
The critter will wait for the specified time without getting busy (it can speak to players).
critter | Critter handle. | |
waittime | Time in ms. |
uint GetCrittersWithScript | ( | Map& | map, | |
uint16 | pid, | |||
uint | findType, | |||
string& | scriptName, | |||
string& | funcDeclaration, | |||
array< Critter@>@ | critters | |||
) |
Gather all critters from a map that share the given script, and comply to the search parameters.
map | Map to take the critters from. | |
pid | Critters pid, 0 to take all. | |
findType | Critters type and state, same as for generic find functions. | |
scriptName | Name of the script, if module is not given then current is used. | |
funcDeclaration | Declaration of the function in format retval s(args). | |
critters | Array of critters to be filled with critters, or a null handle. |
void SetDeleteEvent | ( | Critter& | cr, | |
uint | time | |||
) |
void DropDeleteEvent | ( | Critter& | cr | ) |
uint cte_Delete | ( | Critter& | cr, | |
int | identifier, | |||
uint& | rate | |||
) |
Checks if a party has specified numbers of members.
num | The amount of players to check for. |