EntFire("prereq_bomb_right","Disable") EntFire("prereq_bomb_left","Disable") Convars.SetValue("tf_bot_flag_escort_max_count", 0) //Recreate escort behaviour so bots only escort their respective bomb Entities.FindByName(null,"bomb_left").ValidateScriptScope() local scope = Entities.FindByName(null,"bomb_left").GetScriptScope() scope.Dropped <- function() //Left bomb dropped { printl("Left Bomb dropped") Entities.FindByName(null,"bomb_model_red").SetAbsOrigin(self.GetOrigin()) self.SetAbsOrigin(self.GetOrigin()-Vector(0,0,5000)) NetProps.SetPropInt(self,"m_bGlowEnabled",0) EntFire("bomb_model_red_glow","Enable") EntFire("prereq_bomb_left","Enable") } scope.PickedUp <- function() //Left bomb picked up { printl("Left Bomb picked up") EntFire("prereq_bomb_left","Disable") NetProps.SetPropInt(self,"m_bGlowEnabled",1) EntFire("bomb_model_red_glow","Disable") for (local i = 1; i <= MaxClients().tointeger(); i++) { local bot = PlayerInstanceFromIndex(i) if (bot != null) { if (bot.IsBotOfType(1337) && bot.HasBotTag("left") && !bot.HasItem()) { bot.AddCustomAttribute("cannot pick up intelligence",1,-1) } } } } scope.Returned <- function() //Left bomb reset { printl("Left Bomb returned") Entities.FindByName(null,"bomb_model_red").SetAbsOrigin(Vector(0,0,0)) NetProps.SetPropInt(self,"m_bGlowEnabled",0) EntFire("bomb_model_red_glow","Disable") EntFire("prereq_bomb_left","Disable") } scope.Think <- function() { return -1 } AddThinkToEnt(Entities.FindByName(null,"bomb_left"),"Think") Entities.FindByName(null,"bomb_right").ValidateScriptScope() local scope = Entities.FindByName(null,"bomb_right").GetScriptScope() scope.Dropped <- function() //Right bomb dropped { printl("Right Bomb dropped") Entities.FindByName(null,"bomb_model_blue").SetAbsOrigin(self.GetOrigin()) self.SetAbsOrigin(self.GetOrigin()-Vector(0,0,5000)) NetProps.SetPropInt(self,"m_bGlowEnabled",0) EntFire("bomb_model_blue_glow","Enable") EntFire("prereq_bomb_right","Enable") } scope.PickedUp <- function() //Right bomb picked up { printl("Right Bomb picked up") EntFire("prereq_bomb_right","Disable") NetProps.SetPropInt(self,"m_bGlowEnabled",1) EntFire("bomb_model_blue_glow","Disable") for (local i = 1; i <= MaxClients().tointeger(); i++) { local bot = PlayerInstanceFromIndex(i) if (bot != null) { if (bot.IsBotOfType(1337) && bot.HasBotTag("right") && !bot.HasItem()) { bot.AddCustomAttribute("cannot pick up intelligence",1,-1) } } } } scope.Returned <- function() //Right bomb reset { printl("Right Bomb returned") Entities.FindByName(null,"bomb_model_blue").SetAbsOrigin(Vector(0,0,0)) NetProps.SetPropInt(self,"m_bGlowEnabled",0) EntFire("bomb_model_blue_glow","Disable") EntFire("prereq_bomb_right","Disable") } //Bot spawn logic ::PostBotSpawn <- function() { //Potato servers don't allow bots with "cannot pick up intelligence" to spawn with bomb, add the attribute after they spawn EntFireByHandle(self,"RunScriptCode","self.AddCustomAttribute(`cannot pick up intelligence`,1,-1)",1,null,null) //Bot think function self.ValidateScriptScope() local scope = self.GetScriptScope() scope.PickUpCooldown <- 10 scope.MedicSquad <- false scope.BotThink <- function() { if(NetProps.GetPropInt(self, "m_lifeState") != 0) { //Remove think on death AddThinkToEnt(self, null) NetProps.SetPropString(self, "m_iszScriptThinkFunction", "") } else { if (PickUpCooldown > 0) { PickUpCooldown = PickUpCooldown - 1 } //Right side bots if(self.HasBotTag("right")) { //Bomb is back on field, allow picking up bomb if(Entities.FindByNameWithin(null,"bomb_right",self.GetOrigin(),72)) { self.RemoveCustomAttribute("cannot pick up intelligence") self.AddCustomAttribute("cannot pick up intelligence",0,-1) } //Fake bomb is on field, move real bomb onto field if(Entities.FindByNameWithin(null,"bomb_model_blue",self.GetOrigin(),72) && !self.HasBotTag("squad")) { Entities.FindByName(null,"bomb_right").SetAbsOrigin(Entities.FindByName(null,"bomb_model_blue").GetOrigin()) NetProps.SetPropInt(Entities.FindByName(null,"bomb_right"),"m_bGlowEnabled",1) Entities.FindByName(null,"bomb_model_blue").SetAbsOrigin(Vector(0,0,0)) EntFire("bomb_model_blue_glow","Disable") } //Fake bomb is on same nav square, push towards it if(NavMesh.GetNavArea(Entities.FindByName(null,"bomb_model_blue").GetOrigin(),1024) == NavMesh.GetNavArea(self.GetOrigin(),32) && self.IsAllowedToTaunt() && Entities.FindByName(null,"bomb_right").GetOwner() == null && !self.HasBotTag("squad")) { local g = 600 local d = Entities.FindByName(null,"bomb_model_blue").GetOrigin() - self.GetOrigin() local t = d.Length() / (500 * self.GetCustomAttribute("move speed bonus",1)) local vz = d.z / t + 0.5 * g * t local v = Vector(d.x / t, d.y / t, vz/50) self.SetAbsVelocity(v) //printl("blue test") } if (self.HasItem()) { if(NetProps.GetPropEntity(self,"m_hItem").GetName() == "bomb_left") //right bots not meant to have left bomb { EntFire("bomb_left","ForceDrop") PickUpCooldown = 5 self.AddCustomAttribute("cannot pick up intelligence",1,-1) printl("Left bomb unintentionally picked up, drop it.") } } } //Left side bots if(self.HasBotTag("left")) { //Bomb is back on field, allow picking up bomb if(Entities.FindByNameWithin(null,"bomb_left",self.GetOrigin(),72)) { self.RemoveCustomAttribute("cannot pick up intelligence") self.AddCustomAttribute("cannot pick up intelligence",0,-1) } //Fake bomb is on field, move real bomb onto field if(Entities.FindByNameWithin(null,"bomb_model_red",self.GetOrigin(),72) && !self.HasBotTag("squad")) { Entities.FindByName(null,"bomb_left").SetAbsOrigin(Entities.FindByName(null,"bomb_model_red").GetOrigin()) NetProps.SetPropInt(Entities.FindByName(null,"bomb_left"),"m_bGlowEnabled",1) Entities.FindByName(null,"bomb_model_red").SetAbsOrigin(Vector(0,0,0)) EntFire("bomb_model_red_glow","Disable") } //Fake bomb is on same nav square, push towards it if(NavMesh.GetNavArea(Entities.FindByName(null,"bomb_model_red").GetOrigin(),1024) == NavMesh.GetNavArea(self.GetOrigin(),32) && self.IsAllowedToTaunt() && Entities.FindByName(null,"bomb_left").GetOwner() == null && !self.HasBotTag("squad")) { local g = 600 local d = Entities.FindByName(null,"bomb_model_red").GetOrigin() - self.GetOrigin() local t = d.Length() / (500 * self.GetCustomAttribute("move speed bonus",1)) local vz = d.z / t + 0.5 * g * t local v = Vector(d.x / t, d.y / t, vz/50) self.SetAbsVelocity(v) //printl("red test") } if (self.HasItem()) { if(NetProps.GetPropEntity(self,"m_hItem").GetName() == "bomb_right") { if(PickUpCooldown > 0) { //if left bot picks up right bomb inside spawn, give it left bomb if its not already being held if(Entities.FindByName(null,"bomb_left").GetOwner() == null) { printl("Left bot spawned with right bomb, give them left bomb instead") EntFire("bomb_right","ForceResetSilent") EntFire("bomb_model_blue_glow","Disable") Entities.FindByName(null,"bomb_left").SetAbsOrigin(self.GetOrigin()) self.RemoveCustomAttribute("cannot pick up intelligence") self.AddCustomAttribute("cannot pick up intelligence",0,-1) } } else { //left bots not meant to have right bomb EntFire("bomb_right","ForceDrop") PickUpCooldown = 5 self.AddCustomAttribute("cannot pick up intelligence",1,-1) printl("Right bomb unintentionally picked up, drop it.") } } } } //Squad checking //Squad members need to be exempt from picking up bombs //GetSquadFormationError will only return 0 if bots are a squad leader or a medic healing the leader //The squad needs to start moving for it to start fluctuating if(self.IsInASquad() && self.GetSquadFormationError() > 0) { self.AddBotTag("squad") } //If a medic is in a squad healing someone, there are most likely a squad member if(self.IsInASquad() && self.GetHealTarget() != null) { MedicSquad = true } if (MedicSquad == true) { self.AddBotTag("squad") } //No longer in a squad if(self.IsInASquad() == false) { self.RemoveBotTag("squad") MedicSquad = false } } return -1 } AddThinkToEnt(self, "BotThink") } function OnGameEvent_player_spawn(params) { if(params.team == 3) //Is the player blue { local player = GetPlayerFromUserID(params.userid) EntFireByHandle(player, "CallScriptFunction", "PostBotSpawn", 0, null, null); } } __CollectGameEventCallbacks(this)