Difference between revisions of "Script/Creature"

From SF3
Jump to: navigation, search
(Class Methods)
(Class Methods)
Line 306: Line 306:
 
|-
 
|-
 
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]]  
 
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]]  
| style='color: black; width: 90%; line-height: 1.0;' | '''FollowCreature''' ([[../LevelReference|LevelReference@]] ''_Level'', const [[../Creature|Creature]]&in ''_Target'', const [[../BasicDataTypes|uint]] ''_uMaxDistance'', const [[../BasicDataTypes|uint]] ''_uMinDistance'', const [[../BasicDataTypes|bool]] ''_bQueued'')
+
| style='color: black; width: 90%; line-height: 1.0;' | '''FollowCreature''' ([[../LevelReference|LevelReference@]] ''_Level'', const [[../Creature|Creature]]&in ''_Target'', const [[../BasicDataTypes|uint]] ''_uMaxDistance'', const [[../BasicDataTypes|uint]] ''_uMinDistance'', const [[../BasicDataTypes|bool]] ''_bQueued'', const [[../BasicDataTypes|bool]] ''_bWalk'' = false)
 
|-
 
|-
 
|
 
|

Revision as of 14:47, 13 March 2017

class Creature

Represents a reference to a creature in the game world. An instance of this class acts like a weak pointer to an existing creature in the game world and provides an interface to interact with it. Before interacting with the creature, you should call Exists() in order to check if the creature actually (still) exists. IMPORTANT: This class must NOT be stored as a class member. If you want to store the creature for later reference, store the id obtained by GetId instead. You can then later retrieve the creature from the LevelReference class by calling GetCreatureById.

Inherits from: Entity

Class Methods

string GetDescriptionName () const
get creature description name
ECreatureType GetCreatureType () const
get creature type
int GetCurrentHP () const
get current creature health
int GetMaxHP () const
get maximum creature health
void Heal (const uint _uHP)
heal the creature for _uHP health points
void EnableHealthRegen (const bool _bEnableHealthRegen)
enable health regen
void EnableFocusRegen (const bool _bEnableFocusRegen)
enable focus regen
void AddAttributePoints (const uint8 _uNumPoints)
give the creature attribute points that the player can spend however they wish (only works for heroes)
void AddAbilityPoints (const uint8 _uNumPoints)
give the creature ability points that the player can spend however they wish (only works for heroes)
void ModifyBaseAttribute (const ECreatureAttribute _Attribute, const int8 _iAmount)
modify the creature's base attribute value by the given number of points
void AddSpell (const LevelReference@ _Level, const string&in _sSpellName)
unlock the given spell for this creature
void RemoveSpell (const LevelReference@ _Level, const string&in _sSpellName)
remove the given spell from this creature
void AddPerk (const LevelReference@ _Level, const string&in _sPerkName)
add the given perk to this creature
void RemovePerk (const LevelReference@ _Level, const string&in _sPerkName)
add the given perk to this creature
bool CanVisitPOIs () const
can the creature visit POIs?
bool IsPOIVisitingBehaviorEnabled () const
is the creature's POI visiting behavior currently enabled?
void EnablePOIVisitingBehavior (const bool _bEnable)
enable or disable POI visiting behavior (only works for creatures where CanVisitPOIs is true)
void SetPOICategories (const LevelReference@ _Level, const string[]&in _CategoryNames)
set the POI categories to be visited by this creature
bool IsTrader () const
is trading possible for this character?
bool IsTradeEnabled () const
is trading allowed for this character?
void EnableTrade (const bool _bEnable)
set whether this character is allowed to trade (only works if the character is already a trader)
bool IsPlayerControllable () const
can the creature be given commands by the player?
void SetPlayerControllable (const bool _bControllable)
set whether the creature can be controlled by the player
bool IsImmovable () const
can the creature be pushed around by others while idle?
void SetImmovable (const bool _bImmovable)
set whether the creature can be pushed around by others while idle (only valid until the creature gets another command).
bool IsImmortal () const
can the creature die (this does not mean invincibility, the creature can simply never fall below 1 HP)
void SetImmortal (const bool _bImmortal)
set whether the creature is immortal (immortality will prevent the creature from falling below 1 HP but will still alow it to take damage)
bool ShouldPreserveBody () const
whether the body of this creature will be prevented from vanishing after its death
void SetPreserveBody (const bool _bPreserve)
set whether the body of this creature should be preserved (i.e. never vanish) after its death
bool AreAttacksAllowed () const
can the creature perform attacks?
void AllowAttacks (const bool _bAllow)
set whether the creature can perform attacks
void PreventLootDrops (const bool _bPrevent)
prevent or allow the creature to drop loot upon death
bool GetEquipment (const EItemSlot _Slot, string&out _sOutItemName) const
get the item currently equipped in the given slot of the creature. returns false if there was no item in the given slot.
bool Equip (LevelReference@ _Level, const EItemSlot _Slot, const string&in _sItemName, const ECreatureEquipMode _Mode)
equip the given item in the given slot. returns true if successful.
bool Unequip (LevelReference@ _Level, const EItemSlot _Slot, const ECreatureUnequipMode _Mode)
unequip the item currently in the given slot. returns false if there was no item in the given slot.
void ChangeEquipmentSet (const string&in _sSetName)
change the equipment of the creature to the given set built in the data editor. use set index -1 to unequip everything.
void ChangeEquipmentSet (const int _iSetIndex)
change the equipment of the creature to the given set built in the data editor. use empty set name to unequip everything.
bool Damage (const EDamageType _DamageType, const uint _uAmount)
damage the creature for _uAmount HP of the given damage type, returns true if killed
void Kill ()
immediately kill the creature
void KillAndPreserve (LevelReference@ _Level)
immediately kill the creature and preserve its body (prevent it from vanishing after the usual timer)
void Revive ()
revive the creature if it's dead and refill its health
bool HasCondition (const uint _uDescriptionId)
check if creature has condition with given _uDescriptionId
bool ApplyCondition (const uint _uDescriptionId, const int _iDuration)
try to apply condition with given _uDescriptionId to creature for the defined _uDuration in seconds (-1 for infinite) - returns true if applied
bool RemoveCondition (const uint _uDescriptionId)
try to remove condition with given _uDescriptionId from creature - returns true if removed
void Stop (LevelReference@ _Level)
stop the creature dead in its tracks immediately. cancels any pending orders.
void FollowPath (LevelReference@ _Level, const string&in _sPathName, const bool _bForward, const bool _bQueued, const bool _bWalk = false)
make the creature walk along the given path (creature will go to the closest point on the given path and follow it from there)
void FollowPathFromBeginning (LevelReference@ _Level, const string&in _sPathName, const bool _bForward, const bool _bQueued, const bool _bWalk = false)
make the creature walk along the given path (creature will go to the beginning of the path and follow it from there)
void FollowPathWait (LevelReference@ _Level, const string&in _sPathName, const bool _bForward, const bool _bFromBeginning, const uint8 _WaitForHeroesFaction, const EFollowPathWaitMode _WaitMode, const bool _bQueued = false, const bool _bWalk = false)
make the creature walk along the given path, but wait for heroes of the given party to be nearby before continuing to the next waypoint
void Patrol (LevelReference@ _Level, const string&in _sPathName, const bool _bPingPong, const bool _bForward, const bool _bSmooth, const bool _bQueued = false, const bool _bWalk = false)
make the creature continuously patrol along the given path. if _bPingPong is true, the group will alternate between walking the path forward and backward. otherwise, it will start over from the beginning after reaching the end.
void FollowCreature (LevelReference@ _Level, const Creature&in _Target, const uint _uMaxDistance, const uint _uMinDistance, const bool _bQueued, const bool _bWalk = false)
make the creature follow another creature
void GoTo (LevelReference@ _Level, const Entity&in _Target, const uint _uMinDistance, const uint _uMaxDistance, const bool _bQueued)
make the creature walk to the given target
void Teleport (LevelReference@ _Level, const Entity&in _Target)
teleport the creature next to the given target
void StartTimedAction (LevelReference@ _Level, const ECreatureAnimation _Animation, const uint _uDurationMS, const Entity&in _TargetEntity = Entity ( ), const uint _uTargetDistance = 10, const bool _bCancelOnDamage = true, const bool _bCanCancel = true, const bool _bQueued = false)
start a timed action with the creature. Note: _uDurationMS is the duration of the action in milliseconds!
bool Interact (LevelReference@ _Level, const Entity&in _Target, const bool _bQueued, const uint8 _uFaction = kMaxFactions, const uint8 _uControlIndex = 0)
make the creature interact with the given target
bool Talk (LevelReference@ _Level, const Entity&in _Target, const string&in _sContainerName, const string&in _sTopicName, const bool _bQueued, const uint8 _uFaction = kMaxFactions, const uint8 _uControlIndex = 0)
make the creature talk to the given target
bool Shoutout (LevelReference@ _Level, const string&in _sContainerName, const string&in _sTopicName, const bool _bQueued, const uint8 _uFaction = kMaxFactions, const uint8 _uControlIndex = 0)
make the creature talk to itself.
bool IsInDialogue () const
is the creature currently engaged in a dialogue?
void CancelDialogue ()
cancel whatever dialogue the creature is currently participating in
void PlayAnimation (LevelReference@ _Level, const ECreatureAnimation _Animation, const int8 _iVariant, const uint _uDurationMS, const bool _bLoop, const bool _bQueued, const Entity&in _EntityToFace = Entity ( ))
play the given animation for _uDurationMS milli(!)seconds. If _iVariant is < 0, a random animation variant will be played.
void DropItem (LevelReference@ _Level, const string&in _sItemName, const uint _uAmount)
drop the given item at the creature's feet
Creature& operator= (const Creature&in)
bool operator== (const Creature&in)
bool operator== (const Entity&in)
bool Exists () const
does the entity actually exist? (always check this before doing anything with the entity!)
uint GetId () const
get persistent entity id, use this to save the entity for later reference.
uint8 GetFaction () const
get owner faction
void SetFaction (const uint8 _Faction)
set owner faction
EEntityType GetEntityType () const
get entity type
bool IsEnabled () const
whether the entity is currently enabled (i.e. is visible in the game world)
void Enable (const bool _bEnabled)
enabled or disable the entity
bool IsInteractive () const
can the entity be interacted with?
void SetInteractive (const bool _bInteractive)
set whether the entity can be interacted with
bool IsSelectable () const
can the entity (theoretically) be selected by the player?
void SetSelectable (const bool _bSelectable)
set whether the entity can be selected by the player

(note that depending on the type of entity, there may be additional checks preventing the entity from being selected)

bool IsBusy () const
is the entity currently marked as busy?
void SetBusy (const bool _bBusy)
mark the entity as busy
void SetInspectionText (const uint _uTextId)
make the entity inspectable and set the text to be displayed upon inspection
bool CanBeAttacked () const
can the entity be attacked?
void SetAttackable (const bool _bAttackable)
set whether the entity can be attacked
Entity opImplConv () const

class Creature

Represents a reference to a creature in the game world. An instance of this class acts like a weak pointer to an existing creature in the game world and provides an interface to interact with it. Before interacting with the creature, you should call Exists() in order to check if the creature actually (still) exists. IMPORTANT: This class must NOT be stored as a class member. If you want to store the creature for later reference, store the id obtained by GetId instead. You can then later retrieve the creature from the LevelReference class by calling GetCreatureById.

Inherits from: Entity

Class Methods

string GetDescriptionName () const
get creature description name
ECreatureType GetCreatureType () const
get creature type
int GetCurrentHP () const
get current creature health
int GetMaxHP () const
get maximum creature health
void Heal (const uint _uHP)
heal the creature for _uHP health points
void EnableHealthRegen (const bool _bEnableHealthRegen)
enable health regen
void EnableFocusRegen (const bool _bEnableFocusRegen)
enable focus regen
void AddAttributePoints (const uint8 _uNumPoints)
give the creature attribute points that the player can spend however they wish (only works for heroes)
void AddAbilityPoints (const uint8 _uNumPoints)
give the creature ability points that the player can spend however they wish (only works for heroes)
void ModifyBaseAttribute (const ECreatureAttribute _Attribute, const int8 _iAmount)
modify the creature's base attribute value by the given number of points
void AddSpell (const LevelReference@ _Level, const string&in _sSpellName)
unlock the given spell for this creature
void RemoveSpell (const LevelReference@ _Level, const string&in _sSpellName)
remove the given spell from this creature
void AddPerk (const LevelReference@ _Level, const string&in _sPerkName)
add the given perk to this creature
void RemovePerk (const LevelReference@ _Level, const string&in _sPerkName)
add the given perk to this creature
bool CanVisitPOIs () const
can the creature visit POIs?
bool IsPOIVisitingBehaviorEnabled () const
is the creature's POI visiting behavior currently enabled?
void EnablePOIVisitingBehavior (const bool _bEnable)
enable or disable POI visiting behavior (only works for creatures where CanVisitPOIs is true)
void SetPOICategories (const LevelReference@ _Level, const string[]&in _CategoryNames)
set the POI categories to be visited by this creature
bool IsTrader () const
is trading possible for this character?
bool IsTradeEnabled () const
is trading allowed for this character?
void EnableTrade (const bool _bEnable)
set whether this character is allowed to trade (only works if the character is already a trader)
bool IsPlayerControllable () const
can the creature be given commands by the player?
void SetPlayerControllable (const bool _bControllable)
set whether the creature can be controlled by the player
bool IsImmovable () const
can the creature be pushed around by others while idle?
void SetImmovable (const bool _bImmovable)
set whether the creature can be pushed around by others while idle (only valid until the creature gets another command).
bool IsImmortal () const
can the creature die (this does not mean invincibility, the creature can simply never fall below 1 HP)
void SetImmortal (const bool _bImmortal)
set whether the creature is immortal (immortality will prevent the creature from falling below 1 HP but will still alow it to take damage)
bool ShouldPreserveBody () const
whether the body of this creature will be prevented from vanishing after its death
void SetPreserveBody (const bool _bPreserve)
set whether the body of this creature should be preserved (i.e. never vanish) after its death
bool AreAttacksAllowed () const
can the creature perform attacks?
void AllowAttacks (const bool _bAllow)
set whether the creature can perform attacks
void PreventLootDrops (const bool _bPrevent)
prevent or allow the creature to drop loot upon death
bool GetEquipment (const EItemSlot _Slot, string&out _sOutItemName) const
get the item currently equipped in the given slot of the creature. returns false if there was no item in the given slot.
bool Equip (LevelReference@ _Level, const EItemSlot _Slot, const string&in _sItemName, const ECreatureEquipMode _Mode)
equip the given item in the given slot. returns true if successful.
bool Unequip (LevelReference@ _Level, const EItemSlot _Slot, const ECreatureUnequipMode _Mode)
unequip the item currently in the given slot. returns false if there was no item in the given slot.
void ChangeEquipmentSet (const string&in _sSetName)
change the equipment of the creature to the given set built in the data editor. use set index -1 to unequip everything.
void ChangeEquipmentSet (const int _iSetIndex)
change the equipment of the creature to the given set built in the data editor. use empty set name to unequip everything.
bool Damage (const EDamageType _DamageType, const uint _uAmount)
damage the creature for _uAmount HP of the given damage type, returns true if killed
void Kill ()
immediately kill the creature
void KillAndPreserve (LevelReference@ _Level)
immediately kill the creature and preserve its body (prevent it from vanishing after the usual timer)
void Revive ()
revive the creature if it's dead and refill its health
bool HasCondition (const uint _uDescriptionId)
check if creature has condition with given _uDescriptionId
bool ApplyCondition (const uint _uDescriptionId, const int _iDuration)
try to apply condition with given _uDescriptionId to creature for the defined _uDuration in seconds (-1 for infinite) - returns true if applied
bool RemoveCondition (const uint _uDescriptionId)
try to remove condition with given _uDescriptionId from creature - returns true if removed
void Stop (LevelReference@ _Level)
stop the creature dead in its tracks immediately. cancels any pending orders.
void FollowPath (LevelReference@ _Level, const string&in _sPathName, const bool _bForward, const bool _bQueued, const bool _bWalk = false)
make the creature walk along the given path (creature will go to the closest point on the given path and follow it from there)
void FollowPathFromBeginning (LevelReference@ _Level, const string&in _sPathName, const bool _bForward, const bool _bQueued, const bool _bWalk = false)
make the creature walk along the given path (creature will go to the beginning of the path and follow it from there)
void FollowPathWait (LevelReference@ _Level, const string&in _sPathName, const bool _bForward, const bool _bFromBeginning, const uint8 _WaitForHeroesFaction, const EFollowPathWaitMode _WaitMode, const bool _bQueued = false, const bool _bWalk = false)
make the creature walk along the given path, but wait for heroes of the given party to be nearby before continuing to the next waypoint
void Patrol (LevelReference@ _Level, const string&in _sPathName, const bool _bPingPong, const bool _bForward, const bool _bSmooth, const bool _bQueued = false, const bool _bWalk = false)
make the creature continuously patrol along the given path. if _bPingPong is true, the group will alternate between walking the path forward and backward. otherwise, it will start over from the beginning after reaching the end.
void FollowCreature (LevelReference@ _Level, const Creature&in _Target, const uint _uMaxDistance, const uint _uMinDistance, const bool _bQueued)
make the creature follow another creature
void GoTo (LevelReference@ _Level, const Entity&in _Target, const uint _uMinDistance, const uint _uMaxDistance, const bool _bQueued)
make the creature walk to the given target
void Teleport (LevelReference@ _Level, const Entity&in _Target)
teleport the creature next to the given target
void StartTimedAction (LevelReference@ _Level, const ECreatureAnimation _Animation, const uint _uDurationMS, const Entity&in _TargetEntity = Entity ( ), const uint _uTargetDistance = 10, const bool _bCancelOnDamage = true, const bool _bCanCancel = true, const bool _bQueued = false)
start a timed action with the creature. Note: _uDurationMS is the duration of the action in milliseconds!
bool Interact (LevelReference@ _Level, const Entity&in _Target, const bool _bQueued, const uint8 _uFaction = kMaxFactions, const uint8 _uControlIndex = 0)
make the creature interact with the given target
bool Talk (LevelReference@ _Level, const Entity&in _Target, const string&in _sContainerName, const string&in _sTopicName, const bool _bQueued, const uint8 _uFaction = kMaxFactions, const uint8 _uControlIndex = 0)
make the creature talk to the given target
bool Shoutout (LevelReference@ _Level, const string&in _sContainerName, const string&in _sTopicName, const bool _bQueued, const uint8 _uFaction = kMaxFactions, const uint8 _uControlIndex = 0)
make the creature talk to itself.
bool IsInDialogue () const
is the creature currently engaged in a dialogue?
void CancelDialogue ()
cancel whatever dialogue the creature is currently participating in
void PlayAnimation (LevelReference@ _Level, const ECreatureAnimation _Animation, const int8 _iVariant, const uint _uDurationMS, const bool _bLoop, const bool _bQueued, const Entity&in _EntityToFace = Entity ( ))
play the given animation for _uDurationMS milli(!)seconds. If _iVariant is < 0, a random animation variant will be played.
void DropItem (LevelReference@ _Level, const string&in _sItemName, const uint _uAmount)
drop the given item at the creature's feet
Creature& operator= (const Creature&in)
bool operator== (const Creature&in)
bool operator== (const Entity&in)
bool Exists () const
does the entity actually exist? (always check this before doing anything with the entity!)
uint GetId () const
get persistent entity id, use this to save the entity for later reference.
uint8 GetFaction () const
get owner faction
void SetFaction (const uint8 _Faction)
set owner faction
EEntityType GetEntityType () const
get entity type
bool IsEnabled () const
whether the entity is currently enabled (i.e. is visible in the game world)
void Enable (const bool _bEnabled)
enabled or disable the entity
bool IsInteractive () const
can the entity be interacted with?
void SetInteractive (const bool _bInteractive)
set whether the entity can be interacted with
bool IsSelectable () const
can the entity (theoretically) be selected by the player?
void SetSelectable (const bool _bSelectable)
set whether the entity can be selected by the player

(note that depending on the type of entity, there may be additional checks preventing the entity from being selected)

bool IsBusy () const
is the entity currently marked as busy?
void SetBusy (const bool _bBusy)
mark the entity as busy
void SetInspectionText (const uint _uTextId)
make the entity inspectable and set the text to be displayed upon inspection
bool CanBeAttacked () const
can the entity be attacked?
void SetAttackable (const bool _bAttackable)
set whether the entity can be attacked
Entity opImplConv () const