Actor virtual functions

From ZDoom Wiki
Jump to navigation Jump to search
Called when sound variables are to be cached for faster access via those variables (e.g. AttackSound, ActiveSound, etc.). Useful for caching custom sound variables.
Called just after the actor is created and before PostBeginPlay and the first call to Tick.
Called after BeginPlay and before the first call to Tick. This is done before the very first state of an actor is ever reached, useful for performing one-time setups like giving local variables a value, without worrying about a monster being dormant at the start and going to Deactivate instead of Spawn.
Called every tic, 35 times a second. As the name implies, this is what makes an entity 'tick', or operate on its own.
Called when an actor is activated (specific meaning of activation and possible conditions are described here).
Called when an actor is deactivated (specific meaning of deactivation and possible conditions are described here).
Called by projectiles when they're about to hit and deal damage to another actor. Called before TakeSpecialDamage. Heretic's Phoenix Rod missile uses this to tell D'Sparil to teleport away and not take damage when hit by it.
Called from the damage taker when they're about to take damage but haven't yet. The return value is the new damage to be taken. This occurs after all forms of damage modifiers are applied.
  • void Die(Actor source, Actor inflictor, int dmgflags = 0, Name MeansOfDeath = 'none')
Called when an actor is killed (a damaging attack causes an actor's health to fall less than or equal to 0)
  • bool Slam(Actor victim)
Called when an actor that has SKULLFLY set collides with another. Normally called by Lost Souls and Maulotaurs. Returning true tells the caller to ignore the rest of the collision code with the victim it hit while returning false uses standard collision behavior.
  • victim - The actor the caller is colliding with.
  • void Touch(Actor toucher)
Called when an actor with the SPECIAL flag gets touched by another. Normally only used by Inventory and SpectralMonster.
Called when an actor is touching an item but has not yet picked it up. Returning true tells the engine to touch the item while returning false does the opposite.
  • item - The item the caller is touching.
Called from Inventory's CallTryPickup() before other checks to determine if this actor can receive the item.
Called at the end of Inventory's CallTryPickup(), once the item has been received by the actor. Allows to perform additional behavior when items are received without overriding and copying TryPickup() just to do it.
Called when two actors may be capable of colliding are about to collide with each other. This function is called from both actors involved in the collision. The return value determines if the collision is possible between the two actors.
Called when two actors capable of colliding with each other actually do so. This function is called from both actors involved in the collision.
Called any time the actor is about to cross a linedef, this is called after most checks on PIT_CheckLine have ran. Returning false will make the actor be blocked by the line.
NOTE This virtual needs the actor to have the CROSSLINECHECK flag to run.
  • crossing - The line that was checked to see if the actor can cross it.
  • next - The absolute Vector3 coordinates in which the actor will be moved to if the check succeeds.
Called when the actor is falling and when sinking inside of deep water based on the Transfer_Heights special or swimmable 3D floors. Can be used in conjunction with the waterdepth and waterlevel variables.
  • grav - The current gravity of the actor, returns the same value as GetGravity.
  • oldfloorz - The absolute floor Z coordinate of the sector that the actor is currently sinking within.
Called right before a dead actor is about to be resurrected. This function is called from both the dead actor and its resurrecter. If one of the actors returns false then the dead actor will not be resurrected. If both return true then standard resurrection behavior is used.
Called when an actor is to be blasted by a disc of repulsion. If false is returned, the actor will not be blasted. If true, standard blast behavior is used.
  • source - The actor calling the blast function
  • strength - The current strength level of the blast
Called when a missile hits an actor. This is called after all other collision checks. Returning one of the following values will determine what the missile does next:
Called when a bouncing projectile collides with an actor, line or plane, based on its flags.
  • bool Used(Actor user)
Called when an actor is used by a player with the use button. Returns false if the actor wasn't used, otherwise returning true.
Returns the class type that the actor's blood uses. This will account for classes that replace it i.e. custom blood types
  • type - The specific blood type to return.
  • 0 - Returns the class type for standard blood
  • 1 - Returns the class type for blood splatters
  • 2 - Returns the class type for axe blood
Returns the health value that an actor will gib at upon death.
Returns the height of the actor when it dies. This will take special deaths into account if the actor is already dead after calling it.
  • string GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
Returns the appropriate obituary for an actor's death depending on how it died.
  • int OnDrain(Actor victim, int damage, Name dmgtype)
Called when an actor is draining health from another actor. Returns the amount of health to be drained.
  • victim - The actor whose health is being drained.
  • damage - The amount of damage dealt in the attack.
  • dmgtype - The damage type applied to the attack.
Called when an actor discovers a secret. Returning false stops the default message from being displayed.
  • printmsg - Whether or not a message is to be displayed
  • playsound - Whether or not a sound is to be played
  • bool PreTeleport(Vector3 destpos, double destangle, int flags)
Called before an actor is teleported to a new location. Returning false stops the teleport.
  • destpos - The 3D position the actor is being teleported to
  • destangle - The angle the actor wishes to face after teleporting
  • flags - The teleportation flags to use in the action
  • void PostTeleport(Vector3 destpos, double destangle, int flags)
Called after an actor teleports to a new location. Can be used to apply special behavior after the fact.
  • destpos - The 3D position the actor teleported to
  • destangle - The angle the actor faced after teleporting
  • flags - The teleportation flags used in the action
Checks to see if the actor can switch its target to the new one upon being damaged. Returning false tells the caller not to switch targets
  • other - The new target the caller wants to switch to
Called when an actor is crushed by the environment (e.g. crushers, Hexen's polyobjects, etc.). Returns true if standard crushing behavior should be used.
  • items - Set to true if dropped items are to be crushed alongside the caller.
  • clearscope int GetMaxHealth(bool withupgrades = false) const
Returns the health an actor spawns with.
  • int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags = 0, double angle = 0)
Called by the actor whenever it takes damage. Returns the amount of damage the caller actually took from the attack.
Determines whether an actor should spawn into the map. If false is returned the actor will not be spawned at all.
(Need more info)
  • void SpawnLineAttackBlood(Actor attacker, Vector3 bleedpos, double SrcAngleFromTarget, int originaldamage, int actualdamage)
Spawns the blood after an actor takes damage from a hitscan attack.
  • attacker - The source of the hitscan attack.
  • bleedpos - The 3D position to spawn the blood.
  • SrcAngleFromTarget - The angle the hitscan attack traveled normalized to a range between -180 and 180 degrees
  • originaldamage - The unmodified damage to deal by the hitscan attack.
  • actualdamage - The actual amount of damage the caller took.
  • void ApplyKickback(Actor inflictor, Actor source, int damage, double angle, Name mod, int flags)
Calle by an actor when it's dealt damage and must be thrusted by the attack.
Adds an item to the caller's inventory.
  • item - The item to be added to the caller's inventory.
Removes an item from the caller's inventory
  • item - The item to be removed from the caller's inventory.
Uses an item in the caller's inventory. Returns true if the item was used successfully.
  • item - The item to be used.
Destroys all valid inventory items of the caller.
Called when an actor dies while morphed. Returns three values:
  • A pointer to the original actor before it was morphed.
  • The style of morph of the original actor.
  • The amount of health the original actor has.
Called right before an actor morphs on both the original actor and the newly created morph actor.
  • mo - A pointer to the other actor in the morph. If the original actor, this is the morph actor. If the morph actor, this is the original actor.
  • current - True if the caller is the newly created morph actor.
Called right after an actor morphs on both the original actor and the newly created morph actor.
  • mo - A pointer to the other actor in the morph. If the original actor, this is the morph actor. If the morph actor, this is the original actor.
  • current - True if the caller is the newly created morph actor.
Called right before an actor changes back on both the original actor and the morph actor.
  • mo - A pointer to the other actor in the morph. If the original actor, this is the morph actor. If the morph actor, this is the original actor.
  • current - True if the caller is the original actor.
Called right after an actor changes back on both the original actor and the morph actor.
  • mo - A pointer to the other actor in the morph. If the original actor, this is the morph actor. If the morph actor, this is the original actor.
  • current - True if the caller is the original actor.
  • bool Morph(Actor activator, class<PlayerPawn> playerclass, class<MorphedMonster> monsterclass, int duration = 0, int style = 0, class<Actor> morphflash = null, class<Actor>unmorphflash = null)
Called when a morph function is used. Returns true if the actor was successfully morphed.
  • activator - The actor responsible for the morph. Only used when players are morphing.
  • playerclass - The class type to use if a player is morphing.
  • monsterclass - The class type to use if a monster is morphing.
  • duration - The duration of the morph in tics.
  • style - The style of morphing to use.
  • morphflash - The class type to use when spawning a flash as the actor morphs.
  • unmorphflash- The class type to use when spawning a flash as the actor unmorphs.
  • bool UnMorph(Actor activator, int flags, bool force)
Called when a morphed actor is going to unmorph. Returns true if the actor successfully unmorphed.
  • activator - The actor responsible for the unmorph. Only used when players are unmorphing.
  • flags - The flags to check when a player is unmorphing. Only MRF_STANDARDUNDOING is used by default.
  • force - If true, don't collision check when unmorphing back into the original actor.
  • bool MorphMonster(Class<Actor> spawntype, int duration, int style, Class<Actor> enter_flash, Class<Actor> exit_flash)
Called when a monster is being morphed. Returns true if the monster morphed successfully.
  • spawntype - The class type to use for the newly created morph actor.
  • duration - The duration of the morph in tics.
  • style - The style of morphing to use.
  • enter_flash - The class type to use when spawning a flash as the monster morphs.
  • exit_flash - The class type to use when spawning a flash as the monster unmorphs.