User:Windolon/PopExtensionsPlus Documentation

From Valve Developer Community
Jump to navigation Jump to search

Squirrel This is the documentation for PopExtensionsPlus, a VScript library for use in Team Fortress 2 Team Fortress 2.

Tip.pngTip:While it is generally discouraged to edit user pages, please feel free to contribute and edit away! This is because this is a documentation, not something personal. You can do so here and in all other subpages of the documentation.

Constants

See this page for a full list of constants available from the library.

Script function additions

Warning.pngWarning:PopExtensionsPlus modifies AddThinkToEnt so that the native function is unavailable for use. Trying to call AddThinkToEnt will result in a library-raised error. Use PopExtUtil.AddThinkToEnt instead. If you need to call AddThinkToEnt anyway, use _AddThinkToEnt. More about this below.

PopExtensions

These script functions come from the original repository that this library is forked from, and are accessed from the table PopExt. E.g. To call the AddRobotTag function, write PopExt.AddRobotTag.

Function Signature Description
_PopIncrementIcon void _PopIncrementIcon(table icon) A function that is used internally to handle adding custom icons. Generally does not need to be touched.
_PopIncrementTankIcon void _PopIncrementTankIcon(table icon) A function that is used internally to handle adding custom tank icons. Generally does not need to be touched.
AddCustomIcon void AddCustomIcon(string name, int count, bool isCrit = false, bool isBoss = false, bool isSupport = false, bool isSupportLimited = false) Add custom icon to the wavebar, should be called in InitWaveOutput.
AddCustomTankIcon void AddCustomTankIcon(string name, int count, bool isCrit = false, bool isBoss = false, bool isSupport = false, bool isSupportLimited = false) Add custom tank icon to the wavebar, should be called in InitWaveOutput.
Note.pngNote:In the original PopExtensions documentation, it is warned that functions which change wavebar icons will crash linux servers.
Todo: How true is this?
AddRobotTag void AddRobotTag(string tag, table hooks) Adds hooks to robots with specified popfile Tag. See main page for more details.
AddTankName void AddTankName(string name, table hooks) Adds hooks to tanks with specified popfile Name. Wildcard * suffix is supported.
SetWaveIconsFunction void SetWaveIconsFunction(function func) Use this function if you want to use IncrementWaveIconSpawnCount functions to add icons to the wavebar.

Wavebar function flags

These flags are used as inputs to the wavebar functions described below. They are accessible without the need to prefix. These are also inserted into root table so that they are available in popfile RunScriptCode params.

Name Value Description
MVM_CLASS_FLAG_NONE 0
MVM_CLASS_FLAG_NORMAL 1 Non support or mission icon.
MVM_CLASS_FLAG_SUPPORT 2 Support icon flag. Mission icon does not have this flag.
MVM_CLASS_FLAG_MISSION 4 Mission icon flag. Support icon does not have this flag.
MVM_CLASS_FLAG_MINIBOSS 8 Giant icon flag. Support and mission icons do not display red background when set.
MVM_CLASS_FLAG_ALWAYSCRIT 16 Crit icon flag. Support and mission icons do not display crit outline when set.
MVM_CLASS_FLAG_SUPPORT_LIMITED 32 Support limited flag. Game uses it together with support flag.

Wavebar functions

These functions, to reiterate, are accessed from the table PopExt.

Function Signature Description
DecrementWaveIconSpawnCount void/int DecrementWaveIconSpawnCount(string name, int flags, int count = 1, bool changeMaxEnemyCount = false) Increment wavebar spawn count of an icon with specified name and flags. Use it to decrement the spawn count when the enemy is killed. Should not be used for support type icons.
Warning.pngWarning:Documentation is taken from the original repository. The description seems to be contradictory?
GetWaveIconActive bool GetWaveIconActive(string name, int flags) Used for mission and support limited bots to display them on a wavebar during the wave, set by the game automatically when an enemy with this icon spawns.
GetWaveIconSpawnCount int GetWaveIconSpawnCount(string name, int flags) Get wavebar spawn count of an icon with specified name and flags.
IncrementWaveIconSpawnCount int IncrementWaveIconSpawnCount(string name, int flags, int count = 1, bool changeMaxEnemyCount = true) Increment wavebar spawn count of an icon with specified name and flags. Can be used to put custom icons on a wavebar. This function always returns 0.
SetWaveIconActive void SetWaveIconActive(string name, int flags, bool active) Used for mission and support limited bots to display them on a wavebar during the wave, set by the game automatically when an enemy with this icon spawns.
SetWaveIconSpawnCount void SetWaveIconSpawnCount(string name, int flags, int count, bool changeMaxEnemyCount = true) Set wavebar spawn count of an icon with specified name and flags. If count is set to 0, removes the icon from the wavebar. Can be used to put custom icons on a wavebar.

Utilities

Some useful utility variables and functions have been provided. They are all accessed from the table PopExtUtil.

Variables

Arrays and tables
Name Type Description
AllNavAreas table desc
BotArray array desc
Classes array desc
ClassesCaps array desc
DeflectableProjectiles table desc
HomingProjectiles table desc
HUMAN_ARM_PATHS array desc
HumanArray array desc
ItemBlacklist array desc
ItemWhitelist array desc
MaxAmmoTable table desc
PlayerArray array desc
ROBOT_ARM_PATHS array desc
ROMEVISION_MODELINDEXES array desc
ROMEVISION_MODELS table desc
Slots array desc
Other types
Name Type Description
ClientCommand handle desc
CurrentWaveNum integer desc
FinishedRelay handle desc
GameRoundWin handle desc
GameRules handle desc
IsWaveStarted boolean desc
MonsterResource handle desc
MvMLogicEnt handle desc
MvMStatsEnt handle desc
ObjectiveResource handle desc
PlayerManager handle desc
RespawnOverride handle desc
StartRelay handle desc
TriggerHurt handle desc
Worldspawn handle desc

Functions

Function Signature Description
_SetOwner _SetOwner() desc
AddAttributeToLoadout AddAttributeToLoadout() desc
AddThinkToEnt void AddThinkToEnt(handle ent, string func) desc
AnglesToVector AnglesToVector() desc
ApproachAngle ApproachAngle() desc
capwords capwords() desc
ChangePlayerTeamMvM ChangePlayerTeamMvM() desc
CheckBitwise CheckBitwise() desc
Clamp Clamp() desc
ClearLastKnownArea ClearLastKnownArea() desc
CopyTable CopyTable() desc
CountAliveBots CountAliveBots() desc
CountAlivePlayers CountAlivePlayers() desc
CreatePlayerWearable CreatePlayerWearable() desc
DisableCloak DisableCloak() desc
DoExplanation DoExplanation() desc
DoPrintTable DoPrintTable() desc
EndWaveReverse EndWaveReverse() desc
Explanation Explanation() desc
ForceChangeClass ForceChangeClass() desc
GetAllEnts GetAllEnts() desc
GetEntityColor GetEntityColor() desc
GetHammerID GetHammerID() desc
GetItemIndex GetItemIndex() desc
GetItemInSlot GetItemInSlot() desc
GetPlayerName GetPlayerName() desc
GetPlayerReadyCount GetPlayerReadyCount() desc
GetPlayerSteamID GetPlayerSteamID() desc
GetPlayerUserID GetPlayerUserID() desc
GetPopfileName GetPopfileName() desc
GetSpawnFlags GetSpawnFlags() desc
GetWeaponMaxAmmo GetWeaponMaxAmmo() desc
GiveWeapon GiveWeapon() desc
HasEffect HasEffect() desc
HasItemInLoadout HasItemInLoadout() desc
HexToRgb HexToRgb() desc
HideAnnotation HideAnnotation() desc
Ignite Ignite() desc
InButton InButton() desc
Info Info() desc
IntersectionPointBox IntersectionPointBox() desc
InUpgradeZone InUpgradeZone() desc
IsAlive IsAlive() desc
IsDucking IsDucking() desc
IsEntityClassnameInList IsEntityClassnameInList() desc
IsLinuxServer IsLinuxServer() desc
IsOnGround IsOnGround() desc
IsPointInRespawnRoom IsPointInRespawnRoom() desc
IsPointInTrigger IsPointInTrigger() desc
IsSpaceToSpawnHere IsSpaceToSpawnHere() desc
KillAllBots KillAllBots() desc
KillPlayer KillPlayer() desc
LockInPlace LockInPlace() desc
Max Max() desc
Min Min() desc
NormalizeAngle NormalizeAngle() desc
OnWeaponFire OnWeaponFire() desc
PlayerClassCount PlayerClassCount() desc
PlayerRespawn PlayerRespawn() desc
PlayerRobotModel PlayerRobotModel() desc
PlaySoundOnAllClients PlaySoundOnAllClients() desc
PlaySoundOnClient PlaySoundOnClient() desc
PrecacheParticle PrecacheParticle() desc
PressButton PressButton() desc
PrintTable PrintTable() desc
QAngleDistance QAngleDistance() desc
ReleaseButton ReleaseButton() desc
RemapVal RemapVal() desc
RemapValClamped RemapValClamped() desc
RemoveAmmo RemoveAmmo() desc
RemoveOutputAll RemoveOutputAll() desc
RemovePlayerWearables RemovePlayerWearables() desc
Round Round() desc
SetDestroyCallback SetDestroyCallback() desc
SetEffect SetEffect() desc
SetEntityColor SetEntityColor() desc
SetItemIndex SetItemIndex() desc
SetParentLocalOrigin SetParentLocalOrigin() desc
SetParentLocalOriginDo SetParentLocalOriginDo() desc
SetPlayerAttributes SetPlayerAttributes() desc
SetPlayerClassRespawnAndTeleport SetPlayerClassRespawnAndTeleport() desc
SetPlayerName SetPlayerName() desc
SetTargetname SetTargetname() desc
SetupTriggerBounds SetupTriggerBounds() desc
ShowAnnotation ShowAnnotation() desc
ShowChatMessage ShowChatMessage() desc
ShowHudHint ShowHudHint() desc
ShowMessage ShowMessage() desc
ShowModelToPlayer ShowModelToPlayer() desc
SilentDisguise SilentDisguise() desc
SpawnEffect SpawnEffect() desc
splitonce splitonce() desc
StopAndPlayMVMSound StopAndPlayMVMSound() desc
StringReplace StringReplace() desc
StripWeapon StripWeapon() desc
StunPlayer StunPlayer() desc
SwitchToFirstValidWeapon SwitchToFirstValidWeapon() desc
SwitchWeaponSlot SwitchWeaponSlot() desc
TeleportNearVictim TeleportNearVictim() desc
VectorAngles VectorAngles() desc
WeaponSwitchSlot WeaponSwitchSlot() desc

Custom attributes

The following table is similar to the item attributes table found on the TF2 wiki, which lists:

  • Name: Internal name of the attribute.
  • Description: The hud hint text that displays when the user inspects the weapon with the attribute. "%s1", "%s2" and so on are replaced with the value of the attribute.

Unless otherwise stated, all values are formatted additively for display, i.e. by their flat value.

Name Description Notes
add cond on hit applies cond %s1 to victim on hit Accepts both an integer value and a length-2 array of an integer and a float. The float controls how long the cond will last.
add cond when active when active: player receives cond %s1
alt-fire disabled Secondary fire disabled
always crit Weapon always crits
arrow ignite arrows are always ignited
build small sentries Sentries are 20⁒ smaller, have 33⁒ less health, take 25⁒ less metal to upgrade
can breathe under water Player can breathe underwater
can headshot Crits on headshot
cannot be headshot Immune to headshots
cannot headshot weapon cannot headshot
cannot upgrade Weapon cannot be upgraded
collect currency on kill bots drop money when killed
crit when health below Player is crit boosted when below %s1 health
custom kill icon Custom kill icon: %s1 The input should be a string of the name of the kill icon, for example "megaton". The full list can be found here.
custom projectile model Fires custom projectile model: %s1 The input should be a string of the directory to the model, for example "models/empty.mdl".
dmg bonus while half dead damage bonus while under 50% health
dmg penalty while half alive damage penalty while above 50% health
dont count damage towards crit rate Damage doesn't count towards crit rate
Obsolete explosive bullets Fires explosive rounds that deal %s1 damage Obsolete. Use explosive bullets ext instead.
explosive bullets ext Fires explosive rounds that deal %s1 damage in a radius of %s2 The input should be a table of keyvalues:
"explosive bullets ext":
{
	// the values here are defaults, modify at will
	damage   = 150
	radius   = 150
	team     = player.GetTeam() // player is the owner of the weapon with this attribute
	model    = ""
	particle = "mvm_loot_explosion"
	sound    = "weapons/pipe_bomb1.wav"
	killicon = "megaton"
}

Here, %s1 is the damage value, and %s2 is the radius value in hammer units.

fire full clip at once weapon fires full clip at once
Note.pngNote:Not implemented yet
fire input on hit fires custom entity input on hit: %s1 The input should be a string of EntFire inputs excluding the activator, separated by the ^ symbol. The target can also be !self. (The player who wields the weapon with this attribute.)

Example usage:

"fire input on hit": "BigNet^RunScriptCode^printl(\`Someone got hit 2 seconds ago!\`)^2"

The value and delay EntFire inputs default to "" and -1.

fire input on kill fires custom entity input on kill: %s1 The input should be a string of EntFire inputs excluding the activator, separated by the ^ symbol. The target can also be !self. (The player who wields the weapon with this attribute.)

Example usage:

"fire input on kill": "BigNet^RunScriptCode^printl(\`Someone got killed 2 seconds ago!\`)^2"

The value and delay EntFire inputs default to "" and -1.

fires milk bolt Secondary attack: fires a bolt that applies milk for %s1 seconds. Regenerates every %s2 seconds. The input should be a table of keyvalues:
"fires milk bolt":
{
	// the values here are defaults, modify at will
	duration = 10.0
	recharge = 20.0
}
immune to cond wielder is immune to cond %s1 Accepts a simple integer input, or an array of integers. Array length has no limit. The attribute will remove all from the array. The inspection text displays accordingly.
is invisible Weapon is invisible
is miniboss When weapon is active: player becomes giant
Note.pngNote:Not implemented yet
last shot crits Crit boost on last shot. Crit boost will stay active for %s1 seconds after holster
melee cleave attack On Swing: Weapon hits multiple targets The input value controls how big the cleave/splash radius is, in hammer units. Set it to 64 for fair results.
mod teleporter speed boost Teleporters grant a speed boost for %s1 seconds upon exiting
mult building scale building scale multiplied by %s1
mult crit dmg crit damage multiplied by %s1
mult dmg vs airborne damage multiplied by %s1 against airborne targets
mult dmg vs giants Damage vs giants multiplied by %s1
mult dmg vs same class Damage versus [player's own class] multiplied by %s1
mult dmg vs tanks Damage vs tanks multiplied by %s1
mult max health Player max health is multiplied by %s1
mult projectile scale projectile scale multiplied by %s1
mult swim speed Swimming speed multiplied by %s1
mult teleporter recharge rate Teleporter recharge rate multiplied by %s1
Note.pngNote:Not implemented yet
mvm sentry ammo Sentry ammo multiplied by %s1
Note.pngNote:Not implemented yet
no damage falloff Weapon has no damage fall-off or ramp-up
noclip projectile projectiles go through walls and enemies harmlessly
old sandman stun Uses pre-JI stun mechanics
passive reload weapon reloads when holstered
projectile gravity projectile gravity %s1 hu/s
projectile lifetime projectile disappears after %s1 seconds
radius sleeper On full charge headshot: create jarate explosion on victim
reloads full clip at once This weapon reloads its entire clip at once.
remove cond on hit Remove cond %s1 on hit
replace weapon fire sound Weapon fire sound replaced with %s1 Sound name can be raw filename or soundscript as this uses EmitSoundEx.
rocket penetration rocket penetrates up to %s1 enemy players
self add cond on hit applies cond %s1 to self on hit Accepts both an integer value and a length-2 array of an integer and a float. The float controls how long the cond will last.
self add cond on kill applies cond %s1 to self on kill Accepts both an integer value and a length-2 array of an integer and a float. The float controls how long the cond will last.
set damage type Damage type set to %s1 Combinable damage types. See Constants.FDmgType for a full list.
set damage type custom Custom damage type set to %s1 Only one custom damage type may be set. See Constants.ETFDmgCustom for a full list.
set turn to ice On Kill: Turn victim to ice.
special item description %s1 A purely cosmetic attribute used to give extra description.
stun on hit Stuns victim for %s1 seconds on hit The input should be a table of keyvalues:
"stun on hit":
{
	// the values here are defaults, modify at will
	duration   = 5
	type       = 2
	speedmult  = 0.2
	stungiants = true
}

The duration key is %s1.

teleport instead of die %s1⁒ chance of teleporting to spawn with 1 health instead of dying The value is formatted as a percentage, so setting to 0.75 means a 75% chance of escaping death.
uber on damage taken On take damage: %s1⁒ chance of gaining invicibility for 3 seconds The value is formatted as a percentage, so setting to 0.75 means a 75% chance of getting uber.
wet immunity Immune to jar effects when active

Mission attributes

Robot tags