ZScript virtual functions

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.

Overview

Virtual functions in ZScript are functions designed for inheritance purposes, which allow for child classes to override them with their own version. This grants the ability to also call the super function which will execute everything in the predecessor class's function.

Class ActA : Actor
{
    int a;
    virtual void MyVirtualFunction()
    {
        // Do some stuff here.
        a++;
    }
}

This class will perform a++ and b++, with b++ going first.

Class ActB : ActA
{
    int b;
    override void MyVirtualFunction()
    {
        b++;
        Super.MyVirtualFunction();
    }
}

Note: Through chaining actors via inheritance, it's possible to execute every version down to the base actor, if they're set up to call the super function. The following example demonstrates the variables 'c', then 'b', and finally 'a' being incremented in that order.

Class ActC : ActB
{
    int c;
    override void MyVirtualFunction()
    {
        c++;
        Super.MyVirtualFunction();
    }
}

Abstract functions

Abstract functions are virtual functions that do not have a body (i.e. code). They can only be defined in abstract classes. The purpose of abstract functions is to create interface-like classes with different implementations. If you have a base class that is never used directly, only through implementations, then it should be marked abstract. Virtual functions that are always overridden in derived classes should also be converted to abstract functions.

Example:

class Base abstract
{
    abstract int MyFunc();
}

class Derived1 : Base
{
    override int MyFunc()
    {
         return 1;
    }
}

class Derived2 : Base
{
    override int MyFunc()
    {
        return 2;
    }
}

Note that if you don't override an abstract function in a derived class, GZDoom will consider it a script error, unless the derived class is also marked abstract. It is also considered a script error to call an abstract function via the Super qualifier. Additionally, you cannot subclass DECORATE-based actors from ZScript classes with abstract functions.

Internal Functions

Some of ZDoom's classes have several functions available for overriding if desired.

Some of these govern fairly basic actor functionality and may produce unintended side effects or behaviours if overridden. Please test thoroughly whenever you override these (or call them in some unusual place, e.g., CanCollideWith() in some custom missile impact code), and if you don't know exactly what a virtual does you might want to call super.<nameofvirtualfunction>() in your override until you've had time to check the GZDoom source code to figure out what (if anything) it does by default.

Object

  • virtualscope void OnDestroy()
Called when an object is about to be removed from the game. This could be used for actor maintenance, such as removal of children actors which would otherwise stop functioning without the master, or special effects that may be associated with that actor in particular.

LineTracer

Called when the ray trace hits a potential blocker, be it an actor, wall, or plane. Returns the status telling the ray trace what to do next.

Thinker

  • 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.
WARNING: Due to the way Doom handles calling a state's function (a state change immediately calls the function attached to the new state), there is no guarantee that PostBeginPlay runs before any state, especially in weapons/inventory items. Timing-critical operations should not rely on this assumption, and would be better deferred for a few tics into the weapon/inventory's existence.
  • 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.
WARNING: On PlayerPawn actors, weird quirks can occur if voodoo dolls are present and Tick is overridden without proper handling. The following code below checks if the PlayerPawn is a voodoo doll and should be placed at the beginning of Tick so that any code after it will only be applied to real players.
if (!player || !player.mo || player.mo != self)
{
	Super.Tick();
	return;
}

Actor

  • 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 Activate(Actor activator)
Only works on monsters by default. Default behavior makes the monster stop being dormant and sets its state to Active if it has it.
  • activator - The actor responsible for activating this actor.
  • void Deactivate(Actor activator)
Only works on monsters by default. Default behavior makes the monster dormant and sets its state to Inactive if it has it.
  • 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. Called after DoSpecialDamage.
NOTE: If the actor taking damage isn't damageable (e.g. they're dormant) this function will not be called.
  • inflictor - The actor dealing the damage.
  • source - The actor that's responsible for the inflictor.
  • damage - The amount of damage to take.
  • damagetype - The name of the damage type to apply.
  • 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)
  • source - The actor responsible for the inflictor.
  • inflictor - The actor that dealt the damage of the killing blow.
  • dmgflags - The damage flags that were used in the killing blow.
  • MeansOfDeath - The damage type of the damage that killed the actor.
  • 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 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.
NOTE: If the actor is attempting to resurrect itself this function will only be called once and the passive flag will always be false.
  • other - The target of the caller. For the dead actor this is the resurrecter. For the resurrecter this is the dead actor.
  • passive - Used to determine which actor is currently calling the function. If false, the resurrecter is the current caller.
  • 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.
NOTE: This will not be called if the actor has the USESPECIAL flag.
  • user - The actor that pressed the used key
  • 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.
  • victim - The actor that was killed.
  • inflictor - The actor that dealt the killing blow.
  • mod - The damage type of the killing blow.
  • playerattack - If true, a hitscan weapon fired by a player landed the killing blow.
  • 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. 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.
  • withupgrades - Take Strife's health upgrades into account. Does nothing by default.
  • 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.
  • inflictor - The actor dealing the damage. This is the missile for projectiles and the puff for hitscan attacks. For monster melee attacks this is the same as the source.
  • source - The actor responsible for the inflictor.
  • damage - The amount of damage to deal.
  • mod - The damage type applied to the attack.
  • flags - The damage flags to use in the attack:
  • DMG_NO_ARMOR - Don't call AbsorbDamage on any of the victim's inventory items.
  • DMG_NO_PAIN - Tell the victim not to enter their Pain state.
  • DMG_INFLICTOR_IS_PUFF - Used by ApplyKickback to determine whether the origin should be the source (if the flag is set) or the inflictor. Automatically set by hitscan attacks.
  • DMG_THRUSTLESS - Don't call ApplyKickback on the victim.
  • DMG_FORCED - Ignores all damage negation flags/properties the victim has such as NODAMAGE and doesn't call special damage functions e.g. TakeSpecialDamage. Players with the NODAMAGE flag, god2, or buddha2 cheats are immune due to potential abuse.
  • DMG_NO_FACTOR - Don't apply the victim's damage factors.
  • DMG_PLAYERATTACK - The attack came from a hitscan weapon fired by a player.
  • DMG_FOILINVUL - Ignore the INVULNERABLE flag if the victim has it set.
  • DMG_FOILBUDDHA - Ignore the BUDDHA flag if the victim has it set.
  • DMG_NO_PROTECT - Don't call ModifyDamage on any of the victim's inventory items.
  • DMG_NO_ENHANCE - Don't call ModifyDamage on any of the source's inventory items.
  • DMG_USEANGLE - Use the angle parameter when applying kickback instead of having ApplyKickback calculate the angle from the origin of the attack.
  • DMG_EXPLOSION - Marks the attack as splash damage from an explosion. Does not do anything by default.
  • angle - The absolute angle for thrusting enemies from the damage if DMG_USEANGLE is set.
  • bool ShouldSpawn()
Determines whether an actor should spawn into the map. If false is returned the actor will not be spawned at all.
  • 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.

MorphedMonster

  • bool UndoMonsterMorph(bool force = false)
Called when a monster is going to unmorph. Returns true if the monster successfully unmorphed.
  • force - If true, don't collision check when unmorphing back into the original actor.

FastProjectile

  • void Effect()
Responsible for spawning the FastProjectile's trail while it's traveling.

SorcBall

  • void DoFireSpell()
Called when a SorcBall decides to cast its spell. Can be used to add custom pre and post spell behavior.
  • void SorcUpdateBallAngle()
Called when the SorcBall is orbiting around its parent and is not casting a spell.
  • void CastSorcererSpell()
Called when a SorcBall decides to cast its spell. This contains behavior for the spell itself that's being casted.

PathFollower

  • bool Interpolate()
Handles the behavior for moving from one interpolation point to the next. Returning false tells the PathFollower to not look for its next node after reaching its current destination.

SectorAction

  • bool TriggerAction(Actor triggerer, int activationType)
Called when the SectorAction is triggered by an actor. Returns true if the action was successfully triggered.
  • triggerer - The actor directly responsible for triggering the action.
  • activationType - The type of action(s) the triggerer wants to trigger. Will not activate if it doesn't align with the SectorAction's own activation types.
  • bool CanTrigger(Actor triggerer)
Called when testing if the actor that activated the SectorAction is capable of doing so. Returns true if the actor can activate it.
  • triggerer - The actor directly responsible for triggering the action.

Inventory

  • Inventory CreateCopy(Actor other)
Called when picking up an item. Used to determine whether the item should be directly picked up (it doesn't respawn) or a copy of it (it does respawn). Returns the actor that will be picked up.
  • other - The actor picking up the item.
  • bool HandlePickup(Inventory item)
Called when an item that already exists in the owner's inventory is picked up. Used to handle duplicate pick ups of an item instead of attaching a new instance of an item every time it's picked up. AttachToOwner should be used for handling first time pick up behavior. Returning true tells the game that the pick up was handled already and the item doesn't need to be attached.
  • item - The item the owner is trying to pick up.
  • protected bool TryPickup(in out Actor toucher)
Called when trying to pick up an item. Returning true tells the game the item was successfully picked up.
  • toucher - The actor trying to pick up the item.
  • bool CanPickup(Actor toucher)
Called when trying to see if the actor is capable of picking up the item based on class type. Returning true tells the game that actor can pick up the item.
  • toucher - The actor trying to pick up the item.
  • bool ShouldStay()
Called when checking to see if the item should disappear after being picked up. Returning true tells it to stay.
  • bool TryPickupRestricted(in out Actor toucher)
Called if CanPickup is false but the item does not have the RESTRICTABSOLUTELY flag set. Allows for custom restricted pick up behavior. Returning true tells the game the actor can pick it up.
  • toucher - The actor trying to pick up the item.
  • void AttachToOwner(Actor other)
Called when an item is picked up by an actor for the first time. HandlePickup should be used to handle behavior when the item already exists in the actor's inventory.
  • other - The actor to attach to.
  • void DetachFromOwner()
Called when an item is removed from its owner's inventory. This only happens on drop or if the item is completely destroyed.
  • Inventory CreateTossable(int amt = -1)
Called when an item is attempting to be dropped from the owner's inventory. Returns the item that should be tossed.
  • amt - The amount of the item that should be dropped. This doesn't create duplicates but instead returns one item with its amount set to amt. Negative values will drop 1 by default.
  • String PickupMessage()
Returns the pick up message for the item.
  • void DepleteOrDestroy()
Called when an item's amount has reached 0 after use. Determines whether the item should stay in the owner's inventory or be destroyed entirely.
(Need more info)
  • void Travelled()
Called when an item with an owner has entered a different map. This works with both regular maps and hubs.
  • void DoEffect()
Called every tic similar to Tick, but only if the item has an owner. Allows for special effects that only work when attached to an actor (e.g. power ups).
NOTE: This function will not be called if the owner has the NOINTERACTION flag set.
  • void Hide()
Called when an item that respawns is set to hide after being picked up. This is not called if ShouldStay returns true.
  • bool ShouldRespawn()
Called when determining if the item should stay after being picked up so it can respawn later. Returns true if the item should stay, otherwise the item will be directly picked up and never respawn.
  • void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor = null, Actor source = null, int flags = 0)
Allows modification of damage the owner is taking or dealing if the damage flags allow it. Called before AbsorbDamage.
  • damage - The amount of damage being dealt in the attack.
  • damageType - The damage type applied to the attack.
  • newdamage - The same as damage. Modifying this number directly modifies the amount of damage being dealt in the attack.
  • passive - Whether the owner is dealing or taking damage. If false, the owner is dealing damage.
  • inflictor - The actor dealing damage.
  • source - The actor responsible for the inflictor.
  • flags - The damage flags used in the attack. See DamageMobj.
  • bool Use(bool pickup)
Called when an item is attempting to be used. Returns true if the item was successfully used.
  • pickup - If true, this item is being used as the owner is picking it up.
  • double GetSpeedFactor()
Returns the speed modifier the item applies to the owner.
  • bool GetNoTeleportFreeze()
Returns whether or not the owner should be frozen briefly after teleporting. Returning true tells the owner not to freeze.
  • ui void AlterWeaponSprite(VisStyle vis, in out int changed)
Allows direct modification of an owning player's weapon sprites.
  • vis - The current visual information about the player's weapon sprite. Modifying this directly affects the sprite.
  • RenderStyle - The current rendering style of the weapon sprite.
  • alpha - The current alpha of the sprite.
  • invert - Whether the sprite is currently inverted or not.
  • changed - Whether or not the style was changed in any AlterWeaponSprite calls this frame (must be set manually). Does nothing by default.
  • void OwnerDied()
Called when the item's owner dies.
  • color GetBlend()
Returns the color of the screen blend the item applies. Mainly used with power ups.
  • void UseAll(Actor user)
Called when the item's owner uses the "use all inventory items" key.
  • user - The actor trying to use the item.
  • void DoPickupSpecial(Actor toucher)
Called when an item is picked up by an actor. Activates the item's special if it has one.
  • toucher - The actor picking the item up.
  • void PlayPickupSound(Actor toucher)
Called when an actor picks up an item and the item doesn't have the QUIET flag set. Plays the item's pick up sound.
  • toucher - The actor picking the item up. This is considered the origin of the sound.
  • void AbsorbDamage(int damage, Name damageType, out int newdamage, Actor inflictor = null, Actor source = null, int flags = 0)
Allows modification of the damage an item's owner is taking if the damage flags allow it. Called after ModifyDamage.
  • damage - The damage being dealt in the attack.
  • damageType - The damage type applied to the attack.
  • newdamage - The same as damage. Modifying this number directly modifies the amount of damage being dealt in the attack.
  • inflictor - The actor dealing damage.
  • source - The actor responsible for the inflictor.
  • flags - The damage flags used in the attack. See DamageMobj.
  • bool SpecialDropAction(Actor dropper)
Called when dropping an item. Allows for special actions to trigger when doing so. Returning true prevents the standard drop behavior from executing.
  • dropper - The actor dropping the item.
Called after an item has been dropped. Allows for custom post-drop behavior.
  • dropper - The actor that dropped the item.
  • void ModifyDropAmount(int dropamount)
Called when an item is being dropped. Modifies the amount the item has after doing so.
  • dropamount - The new amount to give the item. If this is 0 or less than the amount is not changed.
  • void SetGiveAmount(Actor receiver, int amount, bool givecheat)
Called when an item is being given. Modifies the amount of the item.
  • receiver - The actor the item is being given to.
  • amount - The amount to set the item's amount to.
  • givecheat - If true, the item was given via cheating.

Weapon

  • Inherits from StateProvider which inherits from Inventory
  • int, int CheckAddToSlots()
Called when the game is first started. Checks which slot to assign a weapon to. Returns the slot number of the weapon and its slot priority multiplied by 65536.
  • State GetReadyState()
Returns the weapon's Ready state. Called by multiple functions when setting a weapon to its Ready state (e.g. A_Raise).
  • State GetUpState()
Returns the weapon's Select state. Called when a pending weapon becomes the player's current weapon.
  • State GetDownState()
Returns the weapon's Deselect state. Called when a pending weapon has been queued up and the current weapon needs to be lowered.
  • State GetAtkState(bool hold)
Returns the weapon's Fire state. Called by PlayerPawn's fire function.
  • hold - If true, returns the Hold state instead if one is found, otherwise returning Fire.
  • State GetAltAtkState(bool hold)
Returns the weapon's Altfire state. Called by PlayerPawn's alt fire function
  • hold - If true, returns the AltHold state instead if one is found, otherwise returning Altfire.
  • void PlayUpSound(Actor origin)
Plays the weapon's UpSound. Called when a pending weapon becomes the player's current weapon.
  • origin - The actor to play the sound from.
  • void EndPowerup()
Called when a Tome of Power expires and the weapon is currently powered up.
  • bool CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo = false, int ammocount = -1)
Called when the game checks to see if a weapon has enough ammo either for firing or for switching to. Returns true if the weapon has enough ammo.
  • fireMode - Determines which ammo properties to use. Valid values are PrimaryFire, AltFire, and EitherFire.
  • autoSwitch - If true, automatically switches the player's weapon to a new one if out of ammo.
  • requireAmmo - If true, optional ammo weapon flags are ignored.
  • ammocount - If a weapon is DeHackEd and this value is not negative, use it instead of the weapon's AmmoUse(1) property.
  • bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1)
Called when the weapon consumes ammo. Returns true if there was enough ammo to fire.
  • altFire - Determines which ammo properties to use.
  • checkEnough - If true, check to make sure there's enough ammo to fire before depleting ammo.
  • ammouse - If a weapon is DeHackEd and this value is not negative, use it instead of the weapon's AmmoUse(1) property when altFire is false.

Powerup

  • void InitEffect()
Called when a power up becomes active for the first time.
  • void EndEffect()
Called when the power up ends.
  • clearscope TextureID GetPowerupIcon() const
Returns the icon drawn on the screen for the power up (e.g. with Heretic's Tome of Power).
  • clearscope bool isBlinking() const
Returns true if the power up is about to run out and is currently in the middle of a blink. Returns false otherwise.

Ammo

  • Class<Ammo> GetParentAmmo()
Returns the class type of the base ammo used for this class of ammo e.g. with ClipBox the class type returned would be Clip.

RandomSpawner

  • void PostSpawn(Actor spawned)
Called after the random actor has been spawned and initialized. Allows for further post modifications of the actor from the RandomSpawner itself instead of on the actor.
  • spawned - The actor that the RandomSpawner created
  • Name ChooseSpawn()
The function for deciding which actor to spawn. Returns the name of the actor class that should be spawned. Returning 'None' will spawn nothing.

PlayerPawn

WARNING: Caution must be used when overriding player virtual functions. Client-prediction can cause desyncs when playing in networked games, especially with functions related to PlayerThink. Only override these functions if you absolutely know what you're doing.
  • void PlayIdle()
Sets the player to their SpawnState. Called when the player stops moving.
  • void PlayRunning()
Sets the player to their SeeState. Called when the player starts moving.
  • void PlayAttacking()
Sets the player's state to their MissileState. Called when the player performs an attack.
  • void PlayAttacking2()
Sets the player's state to their MeleeState. Often called when the player's weapon fires and a muzzle flash is produced.
  • void MorphPlayerThink()
Called every tic while the player is morphed. Allows for special behavior when morphed.
  • void OnRespawn()
Called when the player respawns.
  • void FireWeapon(State stat)
Called when the player fires their weapon's primary attack.
  • stat - The state to set the player's current weapon to.
  • void FireWeaponAlt(State stat)
Called when the player fires their weapon's alternate attack.
  • stat - The state to set the player's current weapon to.
  • void CheckWeaponChange()
Called every tic when checking to see if the player has a pending weapon. If so, the current weapon starts to lower.
  • void TickPSprites()
Called every tic. Handles the logic for the player's weapon sprites (including CustomInventory sprites).
  • void CalcHeight()
Called every tic. Calculates the view height offset of the player (e.g. the view bob when running).
  • void DeathThink()
Called every tic while the player is dead. Allows for special behavior while dead.
  • void CheckFOV()
Called every tic when checking if the player's FOV matches their desired FOV. This is what handles the zooming in and out effect when using A_ZoomFactor.
  • void CheckCheats()
Called every tic when checking to see what cheats the player currently has active. By default handles flying and noclipping.
  • bool CheckFrozen()
Called every tic to check if the player is frozen via the FROZEN flags. Returns true if the player is partially or totally frozen.
  • bool CanCrouch()
Checks if the player is capable of crouching. Returns true if the player can.
  • void CrouchMove(int direction)
Handles the view height movement when crouching and uncrouching.
  • direction - Whether the movement is down (negative, crouching) or up (positive, uncrouching).
  • void CheckCrouch(bool totallyfrozen)
Called every tic to check if the player is crouching or not.
  • totallyfrozen - True if the player is partially/totally frozen via the FROZEN flags.
  • double, double TweakSpeeds(double forward, double side)
Modifies the speed values by the player's speed modification properties and items. Returns the modified forward and sideways movement speeds.
  • forward - The original forward speed.
  • side - The original sideways speed.
  • void MovePlayer()
Moves the player based off their current button inputs.
  • void CheckPitch()
Called every tic to modify the player's pitch based off their current input.
  • void CheckJump()
Handles making the player jump.
  • void CheckMoveUpDown()
Handles the up and down flight movement when using something like Heretic's Wings of Wrath.
  • void HandleMovement()
Called every tic to handle all of the movement functions of the player.
  • void CheckUndoMorph()
Called every tic to check if the player should unmorph.
  • void CheckPoison()
Called every tic to apply poison damage and modify the poison screen effect Hexen has.
  • void CheckDegeneration()
Called every tic to check if the player's health should degenerate if over their max health when the CVar is set.
  • void CheckAirSupply()
Called every tic to check the player's air supply if underwater.
  • void PlayerThink()
Called every tic before anything else in the game. Largely handles all player checks, special player tic functions, and player movement.
  • void GiveDefaultInventory()
Called when giving the player their default starting items.
  • void GiveDeathmatchInventory()
Called when giving the player their death match starting items.
  • int GetTeleportFreezeTime()
Gets the amount of time the player should be frozen after teleporting. This mainly checks for items that invalidate the player's TeleportFreezeTime property. Returns the duration to freeze in tics.
  • Weapon PickWeapon(int slot, bool checkammo)
Called when picking a weapon in a slot. Looks for the last weapon in the slot first. Returns the weapon that should be selected.
  • slot - The slot number to look in.
  • checkammo - If false, don't check if the weapon has enough ammo to fire.
  • Weapon PickNextWeapon()
Gets the next weapon when going through the slots in order. Returns the weapon that should be selected.
  • Weapon PickPrevWeapon()
Gets the previous weapon when going through the slots in order. Returns the weapon that should be selected.
  • Vector2 BobWeapon(double ticfrac)
Called every frame. Returns the weapon sprite's xy bobbing offset for that frame.
  • ticfrac - The percentage of the way to the next tic that the current frame is at. Ranges from 0 to 1. Used for interpolating the offset between tics.
  • clearscope color GetPainFlash() const
Returns the pain flash color the player has when taking damage.
  • bool ResetAirSupply(bool playgasp = true)
Resets the player's air supply. Returns whether or not the player was drowning.
  • playgasp - If true and the player was drowning, play the gasp sound.
(Need more info)
  • void Travelled()
Called when a player has traveled to a different map. Works on both regular maps and hubs.
  • void CheatGive(String name, int amount)
Called when the player uses the console give cheat.
  • name - The name of the inventory type to give.
  • amount - The amount to give of the inventory type.
  • void CheatTake(String name, int amount)
Called when the player uses the console take cheat.
  • name - The name of the inventory type to take.
  • amount - The amount to take of the inventory type.
  • void CheatSetInv(String strng, int amount, bool beyond)
Called when the player uses the console setinv cheat.
  • strng - The name of the inventory type to set.
  • amount - The amount to set the inventory type to.
  • beyond - If true, allow the inventory type to go beyond its max amount.
  • String CheatMorph(class<PlayerPawn> morphClass, bool quickundo)
Called when the player uses the console morphme cheat. Returns the text to display after morphing.
  • morphClass - The class type to morph into.
  • quickundo - If false, allow the player to morph into a different class while still morphed.
  • void CheatTakeWeaps()
Handles taking away the player's non-wimpy weapons.
  • protected Inventory GetFlechetteItem()
Called when using a flechette. Returns the flechette item to use in the action.
  • void ActivateMorphWeapon()
Called on the morph actor when the player morphs. Responsible for giving the player their appropriate morph weapon after doing so.
  • bool MorphPlayer(playerinfo activator, Class<PlayerPawn> spawntype, int duration, int style, Class<Actor> enter_flash = null, Class<Actor> exit_flash = null)
Morphs the player into the new morph actor. Returns true if the player successfully morphed.
  • activator - The info of the player that's responsible for the morph.
  • spawntype - The class type to use for the new morph actor.
  • duration - The duration of the morph in tics.
  • style - The style to use for the morph.
  • enter_flash - The class type to use when spawning a flash as the player morphs.
  • exit_flash - The class type to use when spawning a flash as the player unmorphs.
  • bool UndoPlayerMorph(playerinfo activator, int unmorphflag = 0, bool force = false)
Unmorphs the player back into their original form. Returns true if the player unmorphed successfully.
  • activator - The info of the player that's responsible for the unmorph.
  • unmorphflag - The flags to check when unmorphing. Only MRF_STANDARDUNDOING is used by default.
  • force - If true, don't collision check when unmorphing back into the original player.

StaticEventHandler

  • void OnRegister()
  • void OnUnregister()
  • void WorldLoaded(WorldEvent e)
  • void WorldUnloaded(WorldEvent e)
  • void WorldThingSpawned(WorldEvent e)
  • void WorldThingDied(WorldEvent e)
  • void WorldThingRevived(WorldEvent e)
  • void WorldThingDamaged(WorldEvent e)
  • void WorldThingDestroyed(WorldEvent e)
  • void WorldLinePreActivated(WorldEvent e)
  • void WorldLineActivated(WorldEvent e)
  • void WorldSectorDamaged(WorldEvent e)
  • void WorldLineDamaged(WorldEvent e)
  • void WorldLightning(WorldEvent e)
  • void WorldTick()
  • ui void RenderOverlay(RenderEvent e)
  • ui void RenderUnderlay(RenderEvent e)
  • void PlayerEntered(PlayerEvent e)
  • void PlayerRespawned(PlayerEvent e)
  • void PlayerDied(PlayerEvent e)
  • void PlayerDisconnected(PlayerEvent e)
  • ui bool UiProcess(UiEvent e)
  • ui bool InputProcess(InputEvent e)
  • ui void UiTick()
  • ui void PostUiTick()
  • ui void ConsoleProcess(ConsoleEvent e)
  • void NetworkProcess(ConsoleEvent e)
  • void CheckReplacement(ReplaceEvent e)
  • void CheckReplacee(ReplacedEvent e)
  • void NewGame()

InterBackground

  • bool LoadBackground(bool isenterpic)
Called when loading the background image for the intermission screen. Returns whether or not to automatically start the next map. Returning false will start a count down until the next map automatically starts.
  • isenterpic - If true, load the image for entering the next map instead of the stats screen.
  • void updateAnimatedBack()
Called every tic during the intermission screen. Handles animating the background image.
  • void drawBackground(int CurState, bool drawsplat, bool snl_pointeron)
Called every frame during the intermission screen. Draws the background for the screen.
  • CurState - The current state of the intermission screen's logic.
  • StatCount - Showing the stats for the previous level.
  • ShowNextLoc - Currently showing the next location.
  • NoState - No current state.
  • LeavingIntermission - Closing the intermission screen.
  • drawsplat - If true, draw the splat effects on locations the player has already been to (see: Doom 1's intermission screens).
  • snl_pointeron - If true, draw the arrow pointing to the location the player is entering (see: Doom 1's intermission screens).

StatusScreen

  • int drawLF()
Called when drawing the title text for finishing a level at the top of the intermission screen. Returns the y offset from the top of the screen.
  • void drawEL()
Called when drawing the title text for entering a level at the top of the intermission screen.
  • void End()
Called when the intermission screen is closing.
  • protected void initNoState()
Handles the behavior for initializing the intermission screen with no state. Called shortly before the intermission screen is about to close.
  • protected void updateNoState()
Called every tic that the intermission's CurState is set to NoState. Handles automated closing of intermission screen when entering the next map.
  • protected void initShowNextLoc()
Called when going from the stats screen to showing the next location.
  • protected void updateShowNextLoc()
Called every tic that the intermission's CurState is set to ShowNextLoc. Handles the blinking arrow and counting down towards setting NoState.
  • protected void drawShowNextLoc(void)
Called every frame that the intermission's CurState is set to ShowNextLoc and LeavingIntermission. Handles drawing the entering level background and entering level title text.
  • protected void drawNoState()
Called every frame that the intermission's CurState is set to NoState. Calls drawShowNextLoc with the arrow set to not blink when drawn.
  • void StartMusic()
Handles starting the intermission music on the first tic of the intermission screen.
  • void Ticker(void)
Called every tic. Handles the update functions for the intermission screen based on the CurState.
  • void Drawer(void)
Called every frame. Handles the draw functions for the intermission screen based on the CurState.
  • void Start(wbstartstruct wbstartstruct)
Called when the intermission screen is first created.
  • wbstartstruct - Contains information and player stats about the previous level and information about the next level.
  • protected void initStats()
Called when the intermission screen is started. Handles initializing the stats.
  • protected void updateStats()
Called every tic that the intermission's CurState is set to StatCount.
  • protected void drawStats()
Called every frame that the intermission's CurState is set to StatCount.

HUDMessageBase

  • bool Tick()
Called every tic the HUD message is active by the status bar. Returns true if the message should disappear.
  • void ScreenSizeChanged()
Called by the status bar whenever the screen size changes. Handles resizing the text to fit appropriately.
  • void Draw(int bottom, int visibility)
Called every frame the HUD message is active by the status bar. Handles drawing the text of the message.
  • bottom - The y offset that corresponds to the bottom of the screen. Takes whether or not the status bar is visible into account.
  • visibility - The visibility flags to use when drawing the message. If any of the HUD message's visibility flags match one, the message won't draw.

BaseStatusBar

  • void Init()
Called when the status bar is first created. Can be used to set up additional functionality.
  • void Tick()
Called every tic. Can be used to track functionality that should be handled on a consistently timed basis.
  • void Draw(int state, double TicFrac)
Called every frame. Handles drawing functionality of the HUD.
  • state - The current state of the HUD.
  • HUD_StatusBar - The status bar is currently visible.
  • HUD_Fullscreen - The HUD is currently in full screen mode.
  • HUD_None - The HUD is currently disabled.
  • HUD_AltHud - GZDoom's alternate HUD is being used.
  • TicFrac - The percentage of the way to the next tic that the current frame is at. Ranges from 0 to 1. Can be used to interpolate between tics.
  • void ScreenSizeChanged()
Called whenever the screen size changes. Sets up the HUD to properly scale with the new resolution.
  • clearscope void ReceivedWeapon(Weapon weapn)
Called when a weapon is picked up for the first time. Signals the mug shot to grin.
  • weapn - The weapon that was picked up.
  • clearscope void SetMugShotState(String state_name, bool wait_till_done=false, bool reset=false)
Sets the current state of the mug shot.
  • state_name - The name of the mug shot image to use.
  • wait_till_done - If true, wait for the current mug shot state to finish before switching to the new one.
  • reset - If true, reset the current state of the mug shot if both it and the new state are the same.
  • clearscope void FlashItem(class<Inventory> itemtype)
Responsible for the flash that appears in the player's visible inventory when using an item (see: Heretic and Hexen).
  • itemtype - The class type of the item that was used.
  • void AttachToPlayer(PlayerInfo player)
Attaches the HUD to the specified player.
  • player - The player info of the player that the HUD should attach to.
  • void FlashCrosshair()
Responsible for the crosshair size change that can be set when picking up items.
  • void NewGame()
Called whenever a new game is started. Does not include loading a saved game.
  • void ShowPop(int popnum)
Draws a popup box like the character portraits when talking to someone in Strife.
  • popnum - The index of the popup to show.
  • bool MustDrawLog(int state)
Checks to see if a log instead of a popup should be drawn. Returning true tells the game to draw the log.
  • state - The current state of the HUD.
  • bool ProcessNotify(EPrintLevel printlevel, String outline)
Called when the console receives a notification. If true is returned then the console will not print the notification.
  • printlevel - The type of message being received.
  • outline - The text to be printed.
  • void FlushNotify()
Called when the console notifications are cleared.
  • bool ProcessMidPrint(Font fnt, String msg, bool bold)
Called when the console wants to print a HUD message. If true is returned then the console will not automatically create the HUD message.
  • fnt - The font type to print the message with.
  • msg - The message to be printed.
  • bold - If true, uses the font's bold text.
(Need more info)
  • bool DrawChat(String txt)
Called when a chat message is to be printed. If true is returned then the game will not execute the default logic for chat printing.
  • txt - The current message to be printed.
  • int GetProtrusion(double scaleratio) const
Called when calculating the height of the status bar when drawing the level name in the auto map. Useful for graphics that extend higher than the status bar itself. Returns the additional height to add to the top of the status bar relative to the resolution of the HUD.
  • scaleratio - The current width ratio of the last line of text to draw of the level name to the width of the HUD.
  • void DrawMyPos()
Called every frame the idmypos cheat is on. Handles drawing the player's current position on the screen.
  • void DrawAutomapHUD(double ticFrac)
Called every frame the automap is active. Handles drawing text based information that's printed while the auto map is open.
  • ticfrac - The percentage of the way to the next tic that the current frame is at. Ranges from 0 to 1.
  • void DrawPowerups()
Called every frame. Handles drawing power up icons if they have one.

DoomStatusBar

  • Inherits from BaseStatusBar
  • protected void DrawBarKeys()
Called every frame. Responsible for drawing the keys in Doom's status bar.
  • protected void DrawBarAmmo()
Called every frame. Responsible for drawing the collection of ammo totals in Doom's status bar.
  • protected void DrawBarWeapons()
Called every frame. Responsible for drawing the weapon slot numbers in Doom's status bar.
  • protected void DrawFullscreenKeys()
Called every frame. Responsible for drawing the keys on the HUD in Doom when in fullscreen mode.

AltHud

  • void Init()
Called when the status bar is first created. Can be used to add custom functionality on creation.
  • void DrawTimeString(Font fnt, int color, int timer, int x, int y, double trans = 0.75)
Called every frame. Responsible for drawing the formatted timer of how long the player has been playing.
  • fnt - The font to use for the text.
  • color - The color to use for the text.
  • timer - The timer being used to create the formatted string (tracked in tics).
  • x - The x offset of the text. The text here is right aligned.
  • y - The y offset of the text.
  • trans - The alpha to use for the text.
  • void DrawStatLine(int x, in out int y, String prefix, String text)
Handles drawing a stat e.g. kills.
  • x - The x offset of the text.
  • y - The y offset of the text. This value is directly modifiable so it can be automatically shifted up when called in DrawStatus.
  • prefix - The prefix for the text, often used to indicate which stat is being printed.
  • text - The text to be printed, often the stat value itself.
  • void DrawStatus(PlayerInfo CPlayer, int x, int y)
Called every frame. Draws any stats that are enabled.
  • CPlayer - The player info of the player to get stats from if applicable (mainly in multiplayer).
  • x - The x offset to draw the stats at.
  • y - The y offset to start drawing the stats at.
  • void DrawHealth(PlayerInfo CPlayer, int x, int y)
Called every frame. Draws the player's health.
  • CPlayer - The player info of the player whose health is being drawn.
  • x - The x offset to draw the health at.
  • y - The y offset to draw the health at.
  • void DrawArmor(BasicArmor barmor, HexenArmor harmor, int x, int y)
Called every frame. Draws the armor value based on the armors passed to it.
  • barmor - The BasicArmor pointer to use when calculating the amount of armor.
  • harmor - The HexenArmor pointer to use when calculating the AC of the armor.
  • x - The x offset to draw the armor value at.
  • y - The y offset to draw the armor value at.
  • bool DrawOneKey(int xo, int x, int y, in out int c, Key inv)
Draws a single key on the HUD. Returns true if the key had a valid icon to draw.
  • xo - The base x offset the keys are drawn at. Does nothing by default.
  • x - The current x offset to draw the key at.
  • y - The y offset to draw the key at.
  • c - The number of keys that have been drawn on the current line. Can be directly modified for more customizability. Does nothing by default.
  • inv - The key to check the icon for so it can be drawn.
  • int DrawKeys(PlayerInfo CPlayer, int x, int y)
Called every frame. Handles drawing all the keys on the HUD. Returns the y offset of the next line on top of the drawn keys.
  • CPlayer - The player info of the player to search for keys.
  • x - The x offset to start drawing the keys at. Keys drawn shift leftward on the line until reaching 10 and then wrap back.
  • y - The y offset to start drawing the keys at. Keys drawn shift upward every time the line wraps.
  • int DrawAmmo(PlayerInfo CPlayer, int x, int y)
Called every frame. Draws all the information related to the player's ammo on the HUD. Returns the y offset of the next line on top of the drawn ammo values.
  • CPlayer - The player info of the player to get the ammo from.
  • x - The x offset to draw the ammo at.
  • y - The y offset to start drawing the ammo at. Shifts upward.
  • void DrawOneWeapon(PlayerInfo CPlayer, int x, in out int y, Weapon weapon)
Draws the image of a weapon on the HUD.
  • CPlayer - The player info of the player who owns the weapon.
  • x - The x offset to draw the image at.
  • y - The y offset to draw the image at. This value is directly modifiable so it can be automatically shifted up when called in DrawWeapons.
  • weapons - The weapon to check for an image to draw.
  • void DrawWeapons(PlayerInfo CPlayer, int x, int y)
Called every frame. Draws images of all of the player's current weapons.
  • CPlayer - The player info of the player to look for weapons.
  • x - The x offset to start drawing the weapon images at.
  • y - The y offset to start drawing the weapon images at.
  • void DrawInventory(PlayerInfo CPlayer, int x,int y)
Called every frame. Draws the player's visible inventory items on the HUD.
  • CPlayer - The player info of the player whose inventory should be searched.
  • x - The x offset to start drawing the items at. Shifts rightward.
  • y - The y offset to draw the items at.
  • void DrawFrags(PlayerInfo CPlayer, int x, int y)
Called every frame during death match games. Draws the number of frags the player currently has.
  • CPlayer - The player info of the player to get the frag count from.
  • x - The x offset to draw the frag count at.
  • y - The y offset to draw the frag count at.
  • void DrawCoordinates(PlayerInfo CPlayer, bool withmapname)
Called every frame the automap is open or when the idmypos cheat is true. Draws the player's current coordinates.
  • CPlayer - The player info the player to get the position of.
  • withmapname - If true, draws the name of the level along with it.
  • bool DrawTime(int y)
Called every frame. Draws the current formatted time based on the option selected by the player. Returns true if the time was drawn.
  • y - The y offset to draw the time at.
  • bool DrawLatency(int y)
Called every frame. Draws the latency from the client to the host of the game. Returns true if the latency was drawn.
  • y - The y offset to draw the latency at.
  • void DrawPowerups(PlayerInfo CPlayer, int y)
Called every frame. Draws the player's power up icons if they have any.
  • CPlayer - The player info of the player to check for power ups.
  • y - The y offset to start drawing the icons at. Shifts downward if the icons would go off screen (shifts leftward as more are drawn).
  • void DrawInGame(PlayerInfo CPlayer)
Called every frame. The main drawing function for the HUD.
  • CPlayer - The player info of the player to get information from.
  • void DrawAutomap(PlayerInfo CPlayer)
Called every frame the automap is active. Responsible for drawing text information related to the automap.
  • CPlayer - The player info of the player to get information from.
  • void Draw(PlayerInfo CPlayer, int w, int h)
Called every frame. Determines whether to draw the regular HUD or automap HUD.
  • CPlayer - The player info of the player to get information from.
  • w - The width to use for the HUD.
  • h - The height to use for the HUD.

Menu

  • bool MenuEvent(int mkey, bool fromcontroller)
Called whenever a hardcoded menu button is pressed. Returns true if the event should have no further handling but does nothing by default.
  • mkey - The code for the menu key that was used.
  • fromcontroller - If true, the event was triggered by a controller.
  • bool OnUIEvent(UIEvent ev)
Called whenever a GUI mouse or keyboard action occurs. Returns true if the event should have no further handling.
  • ev - Contains information about the event that occurred.
  • bool OnInputEvent(InputEvent ev)
Called when any non-GUI related input is used. Returns true if the event should have no further handling.
  • ev - Contains information about the event that occurred.
  • void Drawer()
Called every frame. Handles drawing any generic menu visuals.
  • bool TranslateKeyboardEvents()
If a GUI keyboard action occurs, handle the behavior for converting that action to a menu action. Returning false will stop the default conversion behavior.
  • void SetFocus(MenuItemBase fc)
Sets the menu item to take focus of. Focus is when an item becomes the currently selected option the player is using. Does nothing by default.
  • fc - The menu item that wants to take focus.
  • bool CheckFocus(MenuItemBase fc)
Checks if the menu item is the current focus of the menu. Returns true if the menu item is the current focus. Does nothing by default.
  • fc - The menu item to check if it's focused.
  • void ReleaseFocus()
Handles unsetting the current focus of the menu. Does nothing by default.
  • void ResetColor()
Used to reset the color value of a color picker. Does nothing by default.
  • bool MouseEvent(int type, int mx, int my)
Called from the default OnUIEvent behavior. Handles specific mouse-related actions such as left clicking and movement. Returns true if the mouse should be captured after left clicking.
  • type - The type of mouse event that occurred.
  • mx - The current x position of the mouse on the screen.
  • my - The current y position of the mouse on the screen.
  • void Ticker()
Called every tic. Can be used to handle behavior that should happen on time consistent basis.
  • void OnReturn()
Called when the menu is closing. Can be used to handle any special clean up behavior.

GenericMenu

  • Inherits from Menu
  • void Init(Menu parent)
Called when the menu is first created. Allows for custom functionality when initializing.
  • parent - The menu this one belongs to. If parent is not null it can be considered a sub menu.

OptionMenu

  • Inherits from Menu
  • void Init(Menu parent, OptionMenuDescriptor desc)
Called when the menu is first created. Allows for custom functionality when initializing.
  • parent - The menu this one belongs to. If parent is not null it can be considered a sub menu.
  • desc - The option menu items in this menu and related information of their display.
  • int GetIndent()
Calculates the indent for where to draw the option menu's items at. Returns the x offset to draw at.

ListMenu

  • Inherits from Menu
  • void Init(Menu parent = NULL, ListMenuDescriptor desc = NULL)
Called when the menu is first created. Allows for custom functionality when initializing.
  • parent - The menu this one belongs to. If parent is not null it can be considered a sub menu.
  • desc - The list menu items in this menu and related information of their display.

ConversationMenu

  • Inherits from Menu
  • int Init(StrifeDialogueNode CurNode, PlayerInfo player, int activereply)
Called when the menu is first created. Allows for custom functionality when initializing. Returns the y offset for the top of the reply list.
  • CurNode - The dialogue node the menu starts at.
  • player - The player info of the player the speaker is talking to.
  • activereply - The reply to be automatically selected.
  • int FormatReplies(int activereply)
Handles the text formatting of the replies on menu initialization. Returns the y offset for the top of the reply list.
  • activereply - The reply to be automatically selected.
  • void FormatSpeakerMessage()
Handles the text formatting of the speaker's dialogue on menu initialization.
  • bool DrawBackdrop()
Handles drawing the backdrop for the conversation. Returning true dims the background of the text.
  • void DrawSpeakerText(bool dimbg)
Handles drawing the dialogue of the speaker alongside other information such as their name.
  • dimbg - If true, dims the background behind the text.
  • void DrawReplies()
Handles drawing the replies in list form.
  • void DrawGold()
Handles drawing the player's current gold if the menu has it enabled.

MessageBoxMenu

  • Inherits from Menu
  • void Init(Menu parent, String message, int messagemode, bool playsound = false, Name cmd = 'None', voidptr native_handler = null)
Called when the menu is first created. Allows for custom functionality when initializing.
  • parent - The menu this one belongs to. If parent is not null it can be considered a sub menu.
  • message - The text of the prompt.
  • messagemode - The mode for displaying the responses. Non-zero values will leave out the generic yes and no responses.
  • playsound - If true, plays the prompt sound.
  • cmd - The name of the menu class to go to if this is a sub menu with no handler.
  • native_handler - The handler to call when handling the result. If there is none the parent menu is used instead.
  • void HandleResult(bool res)
Handles the player's response to the prompt.
  • res - True if the player hit yes.

MenuItemBase

  • bool CheckCoordinate(int x, int y)
Checks against the passed xy coordinate. Returns true if the check passed. Does nothing by default.
  • x - The x coordinate to check against.
  • y - The y coordinate to check against.
  • void Ticker()
Called every tic by the menu this menu item belongs to. Can be used to handle functionality that should be done with consistent time intervals.
  • void Drawer(bool selected)
Called every frame. Handles drawing the menu item's generic visuals.
  • selected - If true, this menu item is currently the focus of the menu.
  • bool Selectable()
Checks if the menu item can be selected. Returns true if it can. Does nothing by default.
  • bool Activate()
Activates the menu item. Returns true if it activated successfully. Does nothing by default.
  • Name, int GetAction()
Returns the name of the menu class the item goes to and the parameters when setting that menu.
  • bool SetString(int i, String s)
Changes a text value of the menu item. Returns true if the value successfully changed. Does nothing by default.
  • i - Which text value to change.
  • s - The new value to change it to.
  • bool, String GetString(int i)
Gets a text value of the menu item. Returns true if it retrieved the value successfully and the value it retrieved. Does nothing by default.
  • i - Which text value to get.
  • bool SetValue(int i, int value)
Sets a number value of the menu item. Returns true if the value successfully changed. Does nothing by default.
  • i - Which number value to change.
  • value - The new value to change it to.
  • bool, int GetValue(int i)
Gets a number value of the menu item. Returns true if it retrieved the value successfully and the value it retrieved. Does nothing by default.
  • i - Which number value to get.
  • void Enable(bool on)
Handles enabling and disabling of the menu item.
  • on - If true, enable the menu. Otherwise disable it.
  • bool MenuEvent(int mkey, bool fromcontroller)
Called when the menu this menu item belongs to gets a menu event and it's the selected menu item. Returns true if the event should have no further handling but does nothing by default.
  • mkey - The code for the menu key that was used.
  • fromcontroller - If true, the event was triggered by a controller.
  • bool MouseEvent(int type, int x, int y)
Called when the menu this menu item belongs to gets a mouse event and it's the selected menu item. Returns true if the mouse should be captured after left clicking but does nothing by default.
  • type - The type of mouse event that occurred.
  • mx - The current x position of the mouse on the screen.
  • my - The current y position of the mouse on the screen.
  • bool CheckHotkey(int c)
Checks if the pressed key is the hot key for the menu item to be selected. Returns true if the hotkey matches. Does nothing by default.
  • c - The character code for the key pressed.
  • int GetWidth()
Calculates the width of the menu item. Returns the width.
  • int GetIndent()
Calculates the indent of the menu item to draw its values from. Returns the x offset.
  • int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
Called every frame by the menu this menu item belongs to. Handles drawing with extra information about the menu as a whole. Returns the indent the menu item used.
  • desc - Contains the menu items the parent menu has and information related to displaying them.
  • y - The current y offset of the menu item.
  • indent - The indent of the menu itself.
  • selected - If true, this menu item is currently the focus of the menu.
  • void OnMenuCreated()
Called when the menu this menu item belongs to initializes. Can be used to set up custom functionality when the menu is created.

OptionMenuItemOptionBase

  • Inherits from OptionMenuItem which inherits from MenuItemBase
  • int GetSelection()
Gets which entry the option menu item's CVar belongs to in the map data structure containing all the CVars and their values. Returns the entry number of the CVar.
  • void SetSelection(int Selection)
Sets the option menu item's CVar value with the option menu item's current value.
  • Selection - Which entry corresponds to the CVar in the map data structure containing all the CVars and their values.
  • bool isGrayed()
Checks if the option is currently grayed out. Returns true if it is.

OptionMenuSliderBaser

  • Inherits from OptionMenuItem which inherits from MenuItemBase
  • double GetSliderValue()
Returns the slider's value.
  • void SetSliderValue(double val)
Sets the slider's value to the new number.
  • val - The number to set the slider to.

OptionMenuItemSliderReverbEditOption

  • Inherits fom OptionMenuSliderBase
  • String Represent()
Returns the formatted text to draw when displaying the reverb editing's text field value.

OptionMenuFieldBase

  • Inherits from OptionMenuItem which inherits from MenuItemBase
  • String Represent()
Returns the formatted text to draw when displaying the text field's value.

ListMenuItem

  • Inherits from MenuItemBase
  • void DrawSelector(double xofs, double yofs, TextureID tex)
Handles drawing the selector arrow when the list item is currently selected.
  • xofs - The x offset to use from the list item's current x position.
  • yofs - The y offset to use from the list item's current y position.
  • tex- The id of the texture to draw.

Examples

The following demonstrates how SpecialMissileHit works on MageStaffFX2.

override int SpecialMissileHit (Actor victim)
{
	if (victim != target && !victim.player && !victim.bBoss)
	{
		victim.DamageMobj (self, target, 10, 'Fire');
		return 1;	// Keep going
	}
	return -1;
}

The following demonstrates how SpecialBlastHandling is performed with the Disc of Repulsion.

override bool SpecialBlastHandling (Actor source, double strength)
{
    // Reflect to originator
    tracer = target;	
    target = source;
    return true;
}

The following demonstrates how CanCollideWith can be used:

//--------------------------------------------------------------------------
// Disable collisions on some actors.
//--------------------------------------------------------------------------

override bool CanCollideWith(Actor other, bool passive)
{
    // Non-passive means the one moving into the other is performing the checks.
    if (!passive)
    {
        if (!other)		
            return false;
	
        // Pass through dead things. There is a difference between this and CORPSE.
        if (other.bKILLED)
            return false;
		
        // Solid obstacles must block.
        if (other.bSOLID && !other.bNONSHOOTABLE && !other.bSHOOTABLE)
            return true;
		
        if (other.bSHOOTABLE && (other.bFLOAT || other.bNOGRAVITY))
            return false;

        // Walk over 'em if they're small enough.
        if (other.Height <= 75 && other.Radius <= 60)
            return false;

        // Pass through different species of select types.
        if (other.GetSpecies() == 'CommonInfected')
            return false;
    }
    // We don't really care about others making the check.
    return true;
}

See also