Resource icon

VScript Popfile Extensions V3

  • Hey you! Yes, you! Add images to your downloads, it's free! Use the orange "Manage Download Image" button in the top right.

VScript Popfile Extensions V3

VScript extensions for use inside population files

VScript-Popfile-Extensions​

VScript extensions for use inside population files Should make embedding VScripts into population files easier

Provides OnSpawn, OnDeath, OnTakeDamage, OnTakeDamagePost, OnDealDamage, OnDealDamagePost hooks to spawned bots with specified Tags

Provides OnSpawn, OnDeath, OnTakeDamage, OnTakeDamagePost hooks to spawned tanks with specified Name

Provides functions:
SetParentLocalOrigin, CreatePlayerWearable, SetupTriggerBounds, GetWaveIconSpawnCount, SetWaveIconSpawnCount, IncrementWaveIconSpawnCount, DecrementWaveIconSpawnCount, SetWaveIconActive, GetWaveIconActive

How to install: put scripts directory inside tf directory, merge if necessary

scripts/population/mvm_bigrock_vscript.pop is a demonstrative popfile that makes use of all available hooks

Example​

The example below makes bots with tag abc green, spawns a barrel prop on bot's head and gives them a frying pan (thanks to this script to download from here https://tf2maps.net/downloads/vscript-give_tf_weapon.14897/):

Code:
        // Add or replace existing InitWaveOutput with code below
        InitWaveOutput
        {
            Target gamerules // gamerules or tf_gamerules, depending on the map
            Action RunScriptCode
            Param "
                // The original InitWaveOutput trigger, change if necessary
                EntFire(`wave_init_relay`, `Trigger`)

                // Load popextensions script
                IncludeScript(`popextensions`)
                // Yaki's scripts for giving weapons, and making custom ones. Download: https://tf2maps.net/downloads/vscript-give_tf_weapon.14897/
                IncludeScript(`give_tf_weapon/_master`)

                // If you are hitting the 4096 character limit inside this script, it would be required to put hooks into separate file
                // IncludeScript(`mypophooks`)
                // Add event hooks for bots with specifed Tag.
                AddRobotTag(`abc`, {
                    // Called when the robot is spawned
                    OnSpawn = function(bot, tag) {
                        bot.KeyValueFromString(`rendercolor`, `0 255 0`)
                        bot.GiveWeapon(`Frying Pan`)
                        // Create a barrel prop on bot's head
                        CreatePlayerWearable(bot, `models/props_farm/wooden_barrel.mdl`, false, `head`)
                    },
                    // Called when the robot is killed
                    // Params as in player_death event in https://wiki.alliedmods.net/Team_Fortress_2_Events
                    // Params may be null if the bot was forcefully changed to spectator team
                    OnDeath = function(bot, params) {
                        // Restore colors back to normal as necessary
                        bot.KeyValueFromString(`rendercolor`, `255 255 255`)
                    },
                })
            "
        }

The following example makes all tanks that begin with name abc red and spawn with a prop and trigger_ignite on top. The tanks also use a custom icon

Code:
        // Add or replace existing InitWaveOutput with code below
        InitWaveOutput
        {
            Target gamerules // gamerules or tf_gamerules, depending on the map
            Action RunScriptCode
            Param "
                // The original InitWaveOutput trigger, change if necessary
                EntFire(`wave_init_relay`, `Trigger`)

                // Load popextensions script
                IncludeScript(`popextensions`)

                // ALERT! The function below will crash linux servers, remove if the mission is played on them
                // Add 3 custom tanks icon to the wavebar, uses crit outline and white background
                AddCustomTankIcon(`tank_sticky_hellmet`, 3, true, false, false, false)

                // Add event hooks for tanks with specified Name, also supports wildcard suffix
                AddTankName(`abc*`, {
                  
                    // Use custom tank icon
                    Icon = { name = `tank_sticky_hellmet`, isCrit = true, isBoss = false},

                    // Use custom tank model, can be either a string or a table of strings
                    // TankModel = `models/bots/boss_bot/boss_blimp.mdl`,
                    TankModel = {
                        Default = `models/bots/boss_bot/boss_blimp.mdl`,
                        Damage1 = `models/bots/boss_bot/boss_blimp_damage1.mdl`,
                        Damage2 = `models/bots/boss_bot/boss_blimp_damage2.mdl`,
                        Damage3 = `models/bots/boss_bot/boss_blimp_damage3.mdl`,
                        LeftTrack = `models/bots/boss_bot/tankred_track_l.mdl`,
                        RightTrack = `models/bots/boss_bot/tankred_track_r.mdl`,
                        Bomb = `models/bots/boss_bot/bombblue_mechanism.mdl`,
                    }
                    DisableTracks = true, // Disable track models
                    DisableBomb = true, // Disable bomb model

                    // Called when the tank is spawned
                    OnSpawn = function(tank, name) {
                        // Create a prop on top of the tank
                        local prop = SpawnEntityFromTable(`prop_dynamic`, {model = `models/props_badlands/barrel01.mdl`, origin = `0 0 200`})

                        // Create an ignite trigger
                        local trigger = SpawnEntityFromTable(`trigger_ignite`, {origin = `0 0 100`, spawnflags = `1`})
                        SetupTriggerBounds(trigger, Vector(-200,-200,-200), Vector(200,200,200))
                        SetParentLocalOrigin([prop, trigger], tank)

                        ClientPrint(null, 2, `OnSpawnTank`)
                        tank.KeyValueFromString(`rendercolor`, `255 0 0`)
                    }
                })
            "
        }
License
Free to use and modify. Credit is appreciated but not required.
Author
rafradek
Downloads
352
Views
1,718
First release
Last update
Category
VScript

More downloads from rafradek

Latest updates

  1. V3

    Added an ability to give tanks custom models
  2. More functions

    Added functions: SetParentLocalOrigin, CreatePlayerWearable, SetupTriggerBounds, GetWaveIconSpawnCount, SetWaveIconSpawnCount, IncrementWaveIconSpawnCount, DecrementWaveIconSpawnCount, SetWaveIconActive, GetWaveIconActive