ClientPrint(null, 4, "Loading termination vscript file") //grey_mann_escape_relay ::greyTrainEnt <- Entities.FindByName(null, "grey_mann_escape_train"); EntFireByHandle(greyTrainEnt, "TeamNum", "3", 0, null, null); EntFireByHandle(greyTrainEnt, "EnableCollision", "", 0, null, null); ::trainBotEnt <- null // Add event hooks for bots with specifed Tag. PopExt.AddRobotTag("escapeTrainBot", { // Called when the robot is spawned OnSpawn = function(bot, tag) { ClientPrint(null, 3, "OnSpawn escapeTrainBot") trainBotEnt = bot }, // Called when the robot takes damage // Non const prefixed params when altered will affect the damage taken // Params as in https://developer.valvesoftware.com/wiki/List_of_TF2_Script_Functions#:~:text=Description-,const_entity,-handle OnTakeDamage = function(bot, params) { ClientPrint(null, 3, "OnTakeDamage escapeTrainBot") PrintTable(params) }, // Called when the robot takes damage, after the damage is dealt // Params as in https://wiki.alliedmods.net/Team_Fortress_2_Events#player_hurt:~:text=type-,player_hurt,-Note%3A%20When OnTakeDamagePost = function(bot, params) { ClientPrint(null, 3, "OnTakeDamagePost escapeTrainBot") //PrintTable(params) }, OnDeath = function(bot, params) { NetProps.SetPropString(bot, "m_iName", "") NetProps.SetPropString(bot, "m_iszScriptThinkFunction", ""); }, }) ::damageTrainBot <- function(dmgFloat, dmgType, hAttacker) { //Constants.FDmgType if(trainBotEnt != null && trainBotEnt.IsValid()) { trainBotEnt.TakeDamage(dmgFloat, dmgType, hAttacker) ClientPrint(null, 2, "damageTrainBot called") //trainBotEnt.SetHealth(trainBotEnt.GetHealth() - dmgFloat) } else { ClientPrint(null, 2, "trainBotEnt invalid") } } // { // crit_type = 0 // damage_type = 538968064 // early_out = null // damage_bonus = 0 // damage_position = (vector : (719.442627, -2868.910156, 400.476318) // damage_force = (vector : (18608.722656, 11197.399414, 10182.964844) // damage = 60 // const_entity = ([314] prop_dynamic: grey_mann_escape_train) // inflictor = ([5] player) // force_friendly_fire = false // ammo_type = -1 // player_penetration_count = 0 // reported_position = (vector : (0.000000, 0.000000, 0.000000) // damaged_other_players = 0 // damage_bonus_provider = null // attacker = ([5] player) // damage_custom = 0 // const_base_damage = 60 // damage_stats = 0 // max_damage = 6 // damage_for_force_calc = 0 // weapon = ([1102] tf_weapon_soda_popper) // } //ent name function OnScriptHook_OnTakeDamage(params) { local ent = params.const_entity; local inf = params.inflictor; ClientPrint(null, 3, "take damage hook, ent name " + ent.GetName()) if ( ent.GetClassname() == "prop_dynamic" && ent.GetName() == "grey_mann_escape_train") { printl("hit " + ent.GetClassname()) ClientPrint(null, 3, "take damage hook, ent name " + ent.GetName()) //ent.GetScriptScope().attackedBy <- params.inflictor //printl("OnScriptHook_OnTakeDamage:") PrintTable(params) damageTrainBot(params.damage*100, 2, inf) //damageTrainBot() } } // { // damageamount = 100 // health = 187 // weaponid = 76 // attacker_player = 48 // crit = 0 // entindex = 618 // } //this is after damage amount has been calculated but not yet applied //function OnGameEvent_npc_hurt(params) //{ // local ent = EntIndexToHScript(params.entindex); // local inf = EntIndexToHScript(params.attacker_player); // //damageTrainBot(params.damageamount*100, Constants.FDmgType.DMG_BULLET, inf) // if (ent.GetClassname() == "prop_dynamic" ) //|| ent.GetName() // { // //ent.GetScriptScope().attackedBy <- params.inflictor // //printl("OnScriptHook_OnTakeDamage:") // PrintTable(params) // ClientPrint(null, 4, ent.GetName()) // //damageTrainBot() // } //} __CollectGameEventCallbacks(this); // Setting a error handler allows us to view vscript error messages, even if we are not testing locally i.e. on potato testing server ::DebugSteamIds <- {} DebugSteamIds["[U:1:1086491858]"] <- 1 //Table DebugSteamIds["[U:1:66915592]"] <- 1 //Claudz seterrorhandler(function(e) { for (local player; player = Entities.FindByClassname(player, "player");) { if (DebugSteamIds.rawin(NetProps.GetPropString(player, "m_szNetworkIDString"))) { local Chat = @(m) (printl(m), ClientPrint(player, 2, m)) ClientPrint(player, 3, format("\x07FF0000AN ERROR HAS OCCURRED [%s].\nCheck console for details", e)) Chat(format("\n====== TIMESTAMP: %g ======\nAN ERROR HAS OCCURRED [%s]", Time(), e)) Chat("CALLSTACK") local s, l = 2 while (s = getstackinfos(l++)) Chat(format("*FUNCTION [%s()] %s line [%d]", s.func, s.src, s.line)) Chat("LOCALS") if (s = getstackinfos(2)) { foreach (n, v in s.locals) { local t = type(v) t == "null" ? Chat(format("[%s] NULL" , n)) : t == "integer" ? Chat(format("[%s] %d" , n, v)) : t == "float" ? Chat(format("[%s] %.14g" , n, v)) : t == "string" ? Chat(format("[%s] \"%s\"", n, v)) : Chat(format("[%s] %s %s" , n, t, v.tostring())) } } return } } })