Jump to content

User:MIDIMan/Ringslinger Revolution/Functions

From SRB2 Wiki

This is a comprehensive list of all functions that can be utilized in Ringslinger Revolution, excluding those that are part of the PSprites system.

Please note that all functions must be called under the RSR namespace. For example, to run the GamemodeActive() function, it must be written as RSR.GamemodeActive() for it to actually run.

Base

Function Return value(s) Description
GamemodeActive() boolean Returns true if the current gametype uses RSR logic, or if the current map’s level header has the Lua.RingslingerRev parameter; otherwise returns false.
AddGametype(INT16 gameType) nil Creates an entry in the RSR.RSR_GAMETYPES table for the given gametype. This makes the specified gametype use RSR’s gameplay and HUD logic.
AddEnum(string prefix, string name, [boolean startAtZero]) nil Creates an enum in the RSR namespace with the given prefix and name and sets it to a number. For example, Passing in WEAPON as the prefix, and MEGA as the name will create a variable with the name WEAPON_MEGA in the RSR namespace. This will also create a variable with the prefix WEAPON and the suffix MAX. This is automatically incremented by 1 every time the function is called with the same prefix. If startAtZero is set to true, the first enum will be set to 0 instead of 1.
Explode(mobj_t mo, [fixed_t bombDist, [fixed_t thrustDist, [INT32 bombDamage, [fixed_t fullDist, [INT32 thrustDamage, [boolean aimThrust]]]]]]) nil Deals splash damage from the center of an Object with a given radius.
  • bombDist determines the distance limit for the splash damage to hurt surrounding Objects. Default is 128 fracunits.
  • thrustDist determines the distance limit for the splash damage to push other surrounding Objects. Default is 120% of the bombDist or 6*bombDist/5.
  • bombDamage determines the maximum damage output of the splash damage. Default is 90.
  • fullDist determines the distance limit for the splash damage to deal the maximum damage output to surrounding Objects. Default is 37.5% of the bombDist or 3*bombDist/8.
  • thrustDamage determines the maximum thrust output to surrounding Objects. Default is 20.
  • aimThrust determines whether the thrust output given to the source of the explosion (usually a player) makes them go in the direction they’re facing.
GetArmageddonDamage(angle_t angle, angle_t destAngle, angle_t maxTurn) angle_t Returns the damage dealt from a detonated Armageddon Shield, based on the distance between the two Objects given. The target is the Object being damaged, and the inflictor is the Object dealing the damage.
AngleTowardsAngle(angle_t angle, angle_t destAngle, angle_t maxTurn) angle_t Returns a new angle in between angle and destAngle using maxTurn. maxTurn determines the maximum turning angle between angle and destAngle.
MoveMissile(mobj_t missile, angle_t angle, angle_t slope) nil Moves a missile in the direction of the given angle and slope (pitch). The missile’s speed depends on its Speed Object type property.
ColorTeamMissile(mobj_t missile, player_t player) nil In team gametypes, this changes missile’s translation to match the player’s team color (“RSRTeamRed” if the player is in the red team, or “RSRTeamBlue” if the player is in the blue team). In any other gametype, this will do nothing.
SpawnPlayerMissile(mobj_t source, int missileType, angle_t angle, angle_t slope, boolean reflected) mobj_t Similar to P_SPMAngle, except this function makes the spawned missile’s speed scale with the source’s momentum.
CheckFriendlyFire() boolean Returns true if the friendlyfire console variable is on or the current gametype has the GTR_FRIENDLYFIRE rule.
PlayersAreTeammates(player_t player, player_t player2) boolean Returns true if player and player2 are teammates. There are three factors that determine this:
  • The current gametype has the GTR_FRIENDLY rule.
  • The current gametype has the GTR_TEAMS rule and both players’ ctfteam variables are equal.
  • Both players have PF_TAGIT in their pflags.
PlayerHasEmerald(player_t player, int emerald) boolean Returns true if the player has the given emerald in their inventory (uses EMERALDn constants, where n is the number of the emerald).
WavesGamemodeActive() boolean Returns true if the current map uses the “Waves” gamemode.

Enemy

Function Return value(s) Description
EnemySetBlink(mobj_t mo, tic_t timer) nil Sets the enemy’s rsrEnemyBlink variable and adds it to the enemy thinker list, ENEMY_THINKERS.
AddEnemyType(int enemyType) nil Adds the given Object type to the list of enemies and adds ShouldDamage and TouchSpecial hooks to it.

This function is intended for adding custom enemy types, and as such should be called in an AddonLoaded hook.

HUD

Function Return value(s) Description
HUDBossHealth(drawer v, player_t player) nil Draws the boss's health bar to the player's HUD.
HUDEmeralds(drawer v, player_t player) nil Draws the player’s currently-held emeralds to their HUD.
HUDCTFFlagRadar(drawer v, player_t player) nil Draws the CTF flag radar to the player’s HUD.
HUDHypeMeter(drawer v, player_t player) nil Draws the player’s hype bar to their HUD.
KillfeedAdd(player_t victim, mobj_t inflictor, player_t attacker, int damagetype) nil Adds an entry to the killfeed. victim is the player who was killed, inflictor is the Object that killed the player, attacker is the source of the inflictor, and damagetype is the type of damage inflicted on the victim.
HUDKillfeed(drawer v, player_t player) nil Draws the killfeed to the player’s HUD.
HUDPowerups(drawer v, player_t player) nil Draws the player’s active powerups to their HUD.
HUDPSprites(drawer v, player_t player) nil Draws the player’s PSprites to their HUD.
HUDScreenFade(drawer v, player_t player) nil Draws the player’s screen fader to their HUD.
HUDTime(drawer v, player_t player) nil Draws the in-game time to the player’s HUD.
HUDWeaponBar(drawer v, player_t player) nil Draws the player’s weapon bar to their HUD.
HUDWavesEnemyRadar(drawer v, player_t player) nil Draws the player’s enemy radar to their HUD when in a “Waves” map.
HUDWaves(drawer v) nil Draws the wave start/completion/death messages to the HUD when in a “Waves” map.
HUDHealth(drawer v, player_t player) nil Draws the player's health to their HUD.

Items

Function Return value(s) Description
SpawnTeleportFog(mobj_t mo, fixed_t zOffset, int sound) nil Spawns a teleport fog EFX from mo. zOffset determines the vertical offset of the spawned teleport fog relative to mo (Default is 0), and is automatically adjusted to account for the Object’s scale and reverse gravity. sound determines what sound to play when the teleport fog is spawned (Default is sfx_rsrsp3).
BonusFade(player_t player) nil Makes the player's screen fade gold for 1/3rd of a second.
SetItemFuse(mobj_t mo) nil Sets the item’s fuse according to the respawnitemtime console variable if it is set to respawn.
EmeraldFlingSpark(mobj_t mo) nil Wrapper for RSR.ItemFlingSpark that flings a super spark EFX from mo (a collectible emerald).
ItemFlingSpark(mobj_t mo, fixed_t zOffset, fixed_t sparkScale, tic_t sparkTics) nil Flings a super spark EFX from mo. zOffset determines the vertical offset of the spawned teleport fog relative to mo (Default is 0), and is automatically adjusted to account for the Object’s scale and reverse gravity. sparkScale determines the spark’s scale, and sparkTics determines how long the spark lasts before disappearing in tics.
GiveHealth(player_t player, int health, [boolean isBonus]) boolean Gives health to the player, up to a limit of 100. If isBonus is true, the limit becomes 200 temporarily. Returns false if isBonus is false and the player’s health is 100 or more.
GiveArmor(player_t player, int armor, [boolean isBonus]) boolean Gives armor to the player, up to a limit of 100. If isBonus is true, the limit becomes 200 temporarily. Returns false if isBonus is false and the player’s armor is 100 or more.
GiveHype(player_t player, int hype) boolean Gives hype to the player, up to a limit of 3000. Returns false if the player’s hype is 3000 or more.
GivePowerup(player_t player, int powerup) nil Gives a powerup to the player (uses POWERUP_* constants).
AddPowerup(string name, table info) nil Adds a new powerup to RSR.
  • name determines the name of the powerup to add.
  • info should be a table containing the powerup’s icon, and duration.

Format of info: table{string icon, int tics}

Note: The name given to this function determines the name of the enum added. For example, passing in “damage” as a name will add POWERUP_DAMAGE as a valid enum.

Player

Function Return value(s) Description
PlayerSetChasecam(player_t player, boolean toggle) nil Sets the local player’s camera’s chase variable to toggle.
SpawnDamageSplatter(mobj_t target, int damage) nil Spawns a bunch of splatter particles from the target. Higher damage values spawn bigger and more particles.
PlayerAddAttacker(player_t player, player_t attacker, int damage) nil Adds an entry to the player’s attackerInfo list. If the attacker is already in the list, the damage value is added on to the existing one. This also sets knockedByAttacker to true.
PlayerLookForEnemies(player_t player) mobj_t Version of P_LookForEnemies that specifically looks for other players. See P_LookForEnemies for more information.
PlayerHomingAttack(player_t player, player_t player2) boolean player faces player2 and moves towards it; needs to be repeatedly used to work properly. player’s movement speed will be 2/3 of their actionspd value when using the Homing Thok, or 45 fracunits when using an Attraction Shield.
HasPowerup(player_t player, int powerup) boolean, int Returns true if the player has the given powerup (uses POWERUP_* constants); Otherwise returns false. Also returns the index in the player’s powerups array that the powerup was found (as a separate returned value).
SetScreenFade(player_t player, int color, int strength, tic_t tics) nil Makes the player’s screen fade using the given parameters:
  • color determines the color of the screen fade as a palette index.
  • strength determines the starting opacity of the screen fade, where 0 is invisible and FRACUNIT is opaque.
  • tics determines how long the screen fade lasts.
SuperFlingSpark(mobj_t mo) nil Wrapper for ItemFlingSpark that flings a super spark EFX from mo (a super player).

PSprites

For more information, see the PSprites page.

Function Return value(s) Description
CheckAmmo(player_t player, int ammoType, [int ammoAmount]) nil Returns true if the player has enough ammo for the given ammoType (uses AMMO_* constants). ammoAmount determines the amount of ammo to check for; Default is 1.
DrawWeapon(player_t player, [int weapon, [boolean force]]) nil Makes the player draw the given weapon if they can use weapons (uses WEAPON_* constants). If force is true, the player is forced to draw the weapon whether they can use it or not.
FireWeapon(player_t player) nil Makes the player fire their currently-held weapon.
FireWeaponAlt(player_t player) boolean Makes the player use the altfire of their weapon. If they don’t have enough ammo for it, this plays a sound effect instead. Returns true if the altfire succeeded.
CheckPendingWeapon(player_t player) boolean Used by A_WeaponReady to check if the player’s pendingWeapon is not but -1. If so, then make the player draw the weapon.

Weapon

Function Return value(s) Description
AddAmmo(string name, table info) nil Adds a new ammo type to RSR.
  • name determines the name of the ammo type to add.
  • info should be a table containing the pickup amount, max amount, and Object type for the ammo type.

Format of info: table{int amount, int maxamount, int motype}

Note: The name given to this function determines the name of the enum added. For example, passing in “sniper” as a name will add AMMO_SNIPER as a valid enum.

AddWeapon(string name, table info) nil Adds a new weapon to RSR.
  • name determines the name of the weapon to add.
  • info should be a table containing information on the weapon. See here for what information can be added to a weapon.

Note: The name given to this function determines the name of the enum added. For example, passing in “sniper” as a name will add WEAPON_SNIPER as a valid enum.

GetAmmoInfoFromWeapon(int weapon) table or nil Returns a table from AMMO_INFO for the given weapon (uses WEAPON_* constants). If there is no info for the weapon or the weapon doesn’t have an entry in WEAPON_INFO, this returns nil instead.
GiveAmmo(player_t player, int amount, int ammoType) nil Gives a specified amount of ammo to the player. ammoType determines what type of ammo is given to the player (uses AMMO_* constants).
TakeAmmo(player_t player, int amount, int ammoType, boolean ignoreInfinity) nil Takes a specified amount of ammo away from the player. ammoType determines what type of ammo is taken from the player (uses AMMO_* constants). If ignoreInfinity is true, ammo is forcefully taken away from the player even if they have the “infinity” powerup.
TakeAmmoFromReadyWeapon(player_t player, int amount, boolean ignoreInfinity) nil Calls RSR.TakeAmmo using the player’s currently held weapon’s ammo type.
CanUseWeapons(player_t player) boolean Returns true if the player can use their weapons. The player can not use their weapons under the following conditions:
  • The player is not tagged in a Tag gametype, and rsr_lasertag is off.
  • The player’s skin has noweapons set to true in SKIN_INFO.
GiveWeapon(player_t player, int weapon, [int newAmount]) nil Gives a specified weapon to the player (uses WEAPON_* constants). newAmount determines how much ammo for the weapon is given to the player; Default is the amount defined in AMMO_INFO for the weapon’s ammo type.
GetWeaponDelay(int weapon, boolean speed, boolean useAlt) int Returns the delay in tics for using a weapon after firing it.
  • weapon determines what weapon to get the delay for (uses WEAPON_* constants).
  • speed determines whether this should return the super sneakers delay value.
  • useAlt determines whether this should return the altfire delay value.
SetWeaponDelay(player_t player, int weapon, [boolean speed, [boolean useAlt]]) nil Sets the player’s weaponDelay and weaponDelayOrig variables using RSR.GetWeaponDelay.
  • weapon determines what weapon to set the delay for (uses WEAPON_* constants).
  • speed determines whether to use the super sneakers delay value.
  • useAlt determines whether to use the altfire delay value.
ProjectileSpawn(mobj_t mo) nil MobjSpawn hook code for projectiles. Automatically sets the variables shadowscale, rsrProjectile, and rsrGhostTimer. See Userdata structures for more information.
ProjectileMoveCollide(mobj_t tmthing, mobj_t thing) boolean or nil MobjMoveCollide hook code for projectiles. This differs slightly from the vanilla projectile behavior by having projectiles go through teammates/friendly players. Otherwise, it acts about the same.

Note: Some projectiles use their own version of this function (Bounce, Stickybomb, Charged Shot) since they behave differently.

ProjectileGhostTimer(mobj_t mo, boolean doSmoke) nil Runs the ghost spawn thinker for projectiles. Every time rsrGhostTimer reaches 0, a ghost Object is spawned from the projectile and the timer is reset to 4. If doSmoke is true, a smoke Object is spawned from the projectile instead of a ghost Object.
WeaponTouchSpecial(mobj_t special, mobj_t toucher, int weaponType) boolean or nil TouchSpecial hook code for weapon pickups.