Actor virtual functions: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
mNo edit summary |
SpecialMissileHit link |
||
| Line 66: | Line 66: | ||
:*''strength'' - The current strength level of the blast |
:*''strength'' - The current strength level of the blast |
||
*int '''SpecialMissileHit'''(Actor victim) |
*int '''[[SpecialMissileHit]]'''(Actor victim) |
||
: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 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: |
||
:*1: The missile ignores the actor |
:*1: The missile ignores the actor |
||
Revision as of 14:38, 11 November 2023
- void MarkPrecacheSounds()
- 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.
- void BeginPlay()
- Called just after the actor is created and before PostBeginPlay and the first call to Tick.
- void PostBeginPlay()
- 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.
- void Tick()
- Called every tic, 35 times a second. As the name implies, this is what makes an entity 'tick', or operate on its own.
- Called every time the thinker is loaded from a save game (serialized).
- void Activate(Actor activator)
- By default is called on dormant monsters when they're activated. Any actor can call it with BUMPSPECIAL or USESPECIAL if their Activation property is set to THINGSPEC_Activate or THINGSPEC_Switch.
- activator - The actor responsible for activating this actor.
- void Deactivate(Actor activator)
- By default is called on non-dormant monsters when they're made dormant, and changes their state to Inactive if they have one. Any actor can call it with BUMPSPECIAL or USESPECIAL if their Activation property is set to THINGSPEC_Deactivate or THINGSPEC_Switch.
- activator - The actor responsible for deactivating this actor.
- int DoSpecialDamage(Actor target, int damage, name damagetype)
- Called from the damage dealer (e.g. a missile) when an actor is about to take damage but hasn't yet. The return value is the new damage to be dealt. This occurs after skill and CVar damage modifiers are applied but before any actor specific ones are. 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.
- NOTE: If the actor taking damage isn't damageable (e.g. they're dormant) this function will not be called.
- target - The actor taking damage.
- damage - The damage intended to be dealt to the target.
- damagetype - The name of the damage type to apply.
- int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype)
- 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.
- toucher - The actor touching the caller.
- bool CanTouchItem(Inventory item)
- 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.
- bool CanCollideWith(Actor other, bool passive)
- Called when two actors capable of colliding with each other do so. This function is called from both actors involved in the collision. If one of the actors returns false then the engine will act as though the two actors didn't collide. If both return true then standard collision behavior is used.
- NOTE: This will only be called if regular actor blocking is not bypassed entirely with the use of flags like THRUACTORS or an object lacking SOLID while not having BLOCKEDBYSOLIDACTORS, etc.
- WARNING: This function assumes that the two colliding actors are the same before and after the calls. Do not destroy, damage, or perform any complex alterations of either actor within these calls as doing so may cause memory issues.
- other - The actor the caller is colliding with.
- passive - Used to determine which actor is currently calling the function. If false, the actor that caused the collision is the current caller.
- 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.
- void FallAndSink(double grav, double oldfloorz)
- 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.
- bool CanResurrect(Actor other, bool passive)
- 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.
- bool SpecialBlastHandling(Actor source, double strength)
- 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
- int SpecialMissileHit(Actor victim)
- 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:
- 1: The missile ignores the actor
- 0: The missile hits but does no special behavior (e.g. won't deal damage, explode, etc.)
- -1: Uses standard missile hit behavior
- victim - The actor that was hit by the missile.
- 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.
- class<Actor> GetBloodType(int type)
- 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
- int GetGibHealth()
- Returns the health value that an actor will gib at upon death.
- double GetDeathHeight()
- 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.
- bool OnGiveSecret(bool printmsg, bool playsound)
- 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
- bool OkayToSwitchTarget(Actor other)
- 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
- bool Grind(bool items)
- 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.
- bool ShouldSpawn()
- Determines whether an actor should spawn into the map. If false is returned the actor will not be spawned at all.
- void PlayerLandedMakeGruntSound(Actor onmobj)
- (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)
- Responsible for applying thrust after an actor takes damage.
- inflictor - The actor that dealt the damage
- source - The actor responsible for the inflictor.
- damage - The amount of damage taken in the attack.
- angle - The angle to apply kickback. Only used if DMG_USEANGLE is set in the flags.
- mod - The damage type applied to the attack.
- flags - The damage flags used in the attack. DMG_INFLICTOR_IS_PUFF and DMG_USEANGLE are the only two relevant flags by default (see DamageMobj for more details).
- void AddInventory(Inventory item)
- Adds an item to the caller's inventory.
- item - The item to be added to the caller's inventory.
- void RemoveInventory(Inventory item)
- Removes an item from the caller's inventory
- item - The item to be removed from the caller's inventory.
- bool UseInventory(Inventory item)
- Uses an item in the caller's inventory. Returns true if the item was used successfully.
- item - The item to be used.
- void ClearInventory()
- Destroys all valid inventory items of the caller.
- Actor, int, int MorphedDeath()
- 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.
- void PreMorph(Actor mo, bool current)
- 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.
- void PostMorph(Actor mo, bool current)
- 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.
- void PreUnmorph(Actor mo, bool current)
- 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.
- void PostUnmorph(Actor mo, bool current)
- 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.