Skip to content

VSH 2 Internal API Reference

Kevin Yonan edited this page Aug 1, 2021 · 9 revisions

General Boss and Player API

methodmap BaseFighter - applies to both bosses and non-bosses

Properties

int userid
  • returns userid of the player
int index
  • returns entity index of the player
int iQueue
  • get/set the Queue points of a player (this uses the array as backup while saving to cookies)
int iPresetType
  • get/set the preferred boss type of the player (this uses the array as backup while saving to cookies)
int iKills
  • get/set the amount of kills a player got
int iHits
  • get/set the amount of times a player got hit
int iLives
  • get/set the amount of lives a player gets
int iState
  • get/set the state of a player (this data can mean any kind of state for anything)
int iDamage
  • get/set the damage a player did to a boss
int iAirDamage
  • get/set the damage a player did with the AirStrike weapon
int iSongPick
  • get/set the preferred song/background theme for the player
int iOwnerBoss
  • gets the entity index of the boss who owns this player (Set this property using the boss' userid)
int iUberTarget
  • get/set the target of a medic's uber, (use userid when setting this property)
int iShieldDmg
  • get/set the amount of damage done when not having a shield, this property is primarily to track demoman shield regeneration.
int iClimbs
  • get/set the amount of climbs a player did.
TFClassType iTFClass
  • gets the player's TF2 class.
bool bIsMinion
  • get/set if a player is a minion to a boss (use in conjunction with iOwnerBoss so you can identify what boss made this player into a minion).
bool bInJump
  • get/set if a player is jumping
bool bNoMusic
  • get/set if a player can hear the boss music/background theme
float flGlowtime
  • get/set the time when a player is glowing or not (use in conjunction with bGlow)
float flLastHit
  • get/set the last time a player was hit
float flLastShot
  • get/set the last time a player fired/swung their weapon
float flMusicTime
  • get/set the amount of time a song is (this is for setting how long background music is) to the player.

Methods

BaseFighter(const int ind, bool uid=false)
  • constructor for BaseFighter, gives you the option to make an instance using a player's entity index or, if uid is set to true, a player's userid.
void ConvertToMinion(const float time)
  • converts a player to a minion, automatically sets bIsMinion to true
int SpawnWeapon(char[] name, const int index, const int level, const int qual, char[] att)
  • spawns a weapon to a player
int getAmmotable(const int wepslot)
  • gets the ammo table for a player's weapon in a weapon slot
 void setAmmotable(const int wepslot, const int val)
  • sets the ammo table for a player's weapon in a weapon slot
 int getCliptable(const int wepslot)
  • gets the clip table for a player's weapon in a weapon slot
 void setCliptable(const int wepslot, const int val)
  • sets the clip table for a player's weapon in a weapon slot
 int GetWeaponSlotIndex(const int slot)
  • gets the item index of a weapon by weapon slot
 void SetWepInvis(const int alpha)
  • sets the alpha of a weapon so it can be transparent (255 for no transparent, 0 for completely invisible)
 void SetOverlay(const char[] strOverlay)
  • puts an overlay on a player's screen
 void TeleToSpawn(int team = 0)
  • teleports a player to spawn, depending what team spawn.
 void IncreaseHeadCount(bool addhealth=true, int head_count=1)
  • if using demoman swords, increases the head count and applies the buff
 void SpawnSmallHealthPack(int ownerteam=0)
  • spawns a health pack at a player's origin
 void ForceTeamChange(const int team)
  • forces a player to change to a different team
 void ClimbWall(const int weapon, const float upwardvel, const float health, const bool attackdelay)
  • makes a player climb a wall as long the wall is 90 degrees (more or less).
 void HelpPanelClass()
  • sends a help panel to a player telling them about the class and their changes based on what class the player is.
 int GetHealTarget()
  • gets the player index of the current healing target.
 bool IsNearDispenser()
  • checks if the player is being healed/supplied by a dispenser.
bool IsInRange(const int target, const float dist, bool pTrace=false)
  • checks if the player is in range of a specific entity, pTrace being false means ignoring objects between the entities.
void RemoveBack(int[] indices, const int len)
  • Removes a set/array of cosmetic-based items from the player (like mantreads for instance).
int FindBack(int[] indices, const int len)
  • finds an item within a set/array of cosmetic-based items from the player (like mantreads for instance).
int ShootRocket(bool bCrit=false, float vPosition[3], float vAngles[3], const float flSpeed, const float dmg, const char[] model, bool arc=false)
  • shoots a rocket-like, arc-able projectile from the player.
void Heal(const int health, bool on_hud=false, bool overridehp=false, int overheal_limit=0)
  • heals the player with option to show the health gained on the hud.
void PlayMusic(const float vol, const char[] override="");
  • starts playing music to the player, vol for volume.
void void StopMusic();
  • stop music that is playing to the player.

methodmap BaseBoss - derives from BaseFigher, this is the methodmap all bosses (must) inherit from

Properties

int iHealth
  • get/set the current health of the boss
int iMaxHealth
  • get/set the maximum health of the boss (primarily used for damage and various calculations)
int iBossType
  • get/set the Boss type, it's extremely important to set the player's boss type when making them into a boss.
int iStabbed
  • get/set the amount of times the individual boss has been backstabbed
int iMarketted
  • get/set the amount of times the individual boss has been market gardened
int iDifficulty
  • get/set the difficulty setting of a boss (primarily unused)
bool bIsBoss
  • get if a player is a boss.
bool bUsedUltimate
  • get/set if a boss used a rare ability, primarily used for abilities like rage that are only useable once but of course, you can always reset it.
bool bSuperCharge
  • get/set if a boss can do a super-duper jump, can be repurposed for other abilities just like bUsedUltimate.
float flSpeed
  • get/set the speed of the boss, this is primarily used for health-based movement speed.
float flCharge
  • get/set the right click or crouching ability charge. Depends how you coded your boss so it can charge via right click or crouching.
float flRAGE
  • get/set the rage ability, automatically clamps between 0.0 and 100.0
float flKillSpree
  • this is for getting when a boss has killed a certain amount of people under flKillingSpree's time. Look in bosses/hale.sp to understand what this means.
float flWeighDown
  • get/set the charge for doing the weighdown ability.

You can actually use flWeighDown or any others to control a completely different ability. Or even better, make your own if necessary.

Methods

 BaseBoss(const int ind, bool uid = false)
  • constructor to make a player as an instance of BaseBoss, works the same as the constructor for BaseFighter see BaseFighter(const int ind, bool uid=false) on how to use.
 void ConvertToBoss()
  • this method sets the bIsBoss property depending what bSetOnSpawn is set to, sets flRAGE to 0.0 and calls _MakePlayerBoss. It's preferred to use MakeBossAndSwitch over this method.
 void GiveRage(const int damage)
  • generic health based calculated method to give rage to the boss, the formula works as damage/sqrt(currentHealth)*1.76. If necessary, you can make your own for your custom bosses
 void MakeBossAndSwitch(const int type, bool callEvent)
  • This function sets bSetOnSpawn to true, sets the boss type based on what type is, calls ConvertToBoss(), and forces the player to be team switched to BLU. Use this method over ConvertToBoss(). New in 1.3.0 Beta - callEvent let's you control if you want MakeBossAndSwitch to call the OnBossSelected event.
 void DoGenericStun(const float rageDist)
  • generic rage stun that's commonly used by many VSH/FF2 bosses but as a function. rageDist specifies the max distance radius, anyone (players, buildings) within the radius will be stunned.
 void RemoveAllItems()
  • removes ALL (cosmetics and weapons, etc) items from the boss' person. Removes weapons and their associated cosmetics, Demoman shield cosmetic, wearable cosmetics, and MvM powerup canteens.
bool GetName(char buffer[MAX_BOSS_NAME_SIZE])
  • Gets the set name of the boss, MAX_BOSS_NAME_SIZE is 64 bytes large.
bool SetName(char name[MAX_BOSS_NAME_SIZE])
  • Sets the name of the boss, MAX_BOSS_NAME_SIZE is 64 bytes large.
void SuperJump(const float power, const float reset)
  • performs the generic super jump ability.
void WeighDown(const float reset)
  • performs the generic weighdown ability.
void PlayVoiceClip(const char[] vclip, const int flags)
  • player a boss specific voice clip, using different voice flags for effects.

Available Voice flags:

VSH2_VOICE_ALL
VSH2_VOICE_ABILITY
VSH2_VOICE_RAGE
VSH2_VOICE_SPREE
VSH2_VOICE_STABBED
VSH2_VOICE_WIN
VSH2_VOICE_LOSE
VSH2_VOICE_INTRO
VSH2_VOICE_LASTGUY

Gamemode Manager API (modules/gamemode.sp)

methodmap VSHGameMode - controls the VSH mod and functionality

Properties

int iRoundState
  • get/set the current Round State of the gamemode. Here's the enum for it.
enum /** VSH2 Round States */ {
	StateDisabled = -1,
	StateStarting = 0,
	StateRunning = 1,
	StateEnding = 2,
};
int iSpecial
  • get/set the predetermined boss type to be used when a player becomes a boss (this is overrode if the player set their boss OR if the admin used the set special commands to forcefully change it. If iSpecial is -1, then it'll pick a random boss between 0 and MAXBOSS define)
int iPrevSpecial
  • get/set the previous iSpecial from the round before.
VSHHealthBar iHealthBar
  • gets/set the healthbar (please don't touch this unless you know what you're doing)
int iHealthBar.iState
  • get/set the state of the healthbar which usually just changes its color...
int iHealthBar.iPercent
  • get/set the percentage byte of the health bar from 0 to 255, setting the health bar automatically clamps the value between 0 and 255 so you can set it with unsafe numbers if you care.
int iTotalMaxHealth
  • get/set the Total Max health for all current bosses.
int iTimeLeft
  • get/set the time left for the last player showdown timer.
int iRoundCount
  • get/set the amount of rounds that have been played
int iHealthChecks
  • get/set the amount of times players have used the Check Health command.
int iCaptures
  • get/set the amount of times the Arena control point has been captured.
bool bSteam
  • if steam tools is included and enabled, get/set if the plugin should use Steam (this is mainly for setting the game server's description to something else)
bool bTF2Attribs
  • if TF2Attributes is included and compiled with VSH2, this gets/sets if the plugin will use TF2Attributes natives.
bool bPointReady
  • get/set if the control point is ready.
bool bMedieval
  • get/set if Medieval Mode VSH2 is enabled.
bool bDoors
  • get/set if the map doors must be forced open.
bool bTeleToSpawn
  • get/set if bosses should be teleported back to spawn when hitting a trigger_hurt.
float flHealthTime
  • get/set the last time a health check was performed.
float flMusicTime
  • get/set the amount of time a song is (this is for setting how long background music is)
float flRoundStartTime
  • gets the time when the round started. Unchanged until next round starts.
BaseBoss hNextBoss
  • get/set the handle of a BaseBoss instance to be the next chosen boss player (ALWAYS CHECK IF THIS IS 0). THIS IS NOT A HANDLE TYPE.

Methods

BaseBoss GetRandomBoss(const bool balive)
  • gets a random boss and allows you to get a living or dead boss
BaseBoss GetBossByType(const bool balive, const int type)
  • this is the same as GetRandomBoss but it allows you to also get a random boss by type.
void CheckArena(const bool type)
  • presets the Arena control point enable time.
int GetQueue(BaseBoss[] players)
  • populates a player array and sorts it by queue points.
BaseBoss FindNextBoss()
  • gets the player that will become the next boss via queue points.
int CountMinions(const bool balive, BaseBoss ownerboss=0)
  • counts all players that have bIsMinion set to true and allows you to count living or dead.
int CountBosses(const bool balive)
  • same as CountMinions but for bosses, you check if you want to count only living bosses.
int GetTotalBossHealth()
  • returns the total current boss health of each individual boss.
void SearchForItemPacks()
  • scans the map for ammo and health packs to replace and if there's none, it'll spawn health and ammo packs in the player spawn.
void UpdateBossHealth()
  • self explanatory, gets the total boss health and does a percentage calculation between 0 and 255 and sets the healthbar based on that.
void GetBossType()
  • sets the next boss type for the new round. This is only called in RoundStart event.
bool IsVSHMap()
  • checks if the map is a valid VSH map.
void CheckDoors()
  • checks the saxton hale config whether the map must force its doors to be open.
void CheckTeleToSpawn()
  • checks if the map requires that bosses be teleported to spawn if they hit a trigger_hurt.
static int GetBosses(BaseBoss[] bossarray, const bool balive)
  • gets bosses by filling in a buffer and returns the amount of bosses filled into the buffer, can also filter by living bosses.
static int GetFighters(BaseBoss[] redarray, const bool balive)
  • gets the RED players by filling in a buffer and returns the amount of RED players filled into the buffer, can also filter by living players.
static int GetMinions(BaseBoss[] marray, const bool balive, BaseBoss ownerboss=0)
  • gets the minions by filling in a buffer and returns the amount of minions filled into the buffer, can also filter by living minions.