//////////////////////////ANA GUN //////////////////////////////////////////////NANOBOOST ADMINISTERED PrecacheSound("items/powerup_pickup_crits.wav") PrecacheSound("items/powerup_pickup_team_revenge.wav") local FixClasses = ["", "Scout", "Sniper", "Soldier", "Demo", "Medic", "Heavy", "Pyro", "Spy", "Engineer", "civilian"] //make element 0 a dummy string instead of doing array + 1 everywhere ::ClientPrintSafe <- function(player, text) { //replace ^ with \x07 at run-time local escape = "^" //just use the normal print function if there's no escape character if (!startswith(text, escape)) { ClientPrint(player, 3, text) return; } //split text at the escape character local splittext = split(text, escape) //remove 0-length strings for (local i = splittext.len() - 1; i >= 0; i--) if (splittext[i].len() < 1) splittext.remove(i); //format into new string local formatted = "" foreach (i, t in splittext) formatted += format("\x07%s", t) //print formatted string ClientPrint(player, 3, formatted) } ::GetPlayerName <- function(player) { return NetProps.GetPropString(player, "m_szNetname"); } ::NanoParticleThink <- function() { if (!(self.InCond(20))) return local temporigin = self.GetOrigin() boost_temp++ BoostTrackTime() if (boost_particle == null && self.InCond(20)) { boost_particle = SpawnEntityFromTable("info_particle_system", { targetname = "landing" origin = temporigin + Vector(0, 0, 90), angles = Vector(0, 0, 0), effect_name = "powerup_icon_resist_blue", flag_as_weather = 0, }) EntFireByHandle(boost_particle, "start", "", -1, null, null) } if (boost_particle != null && self.InCond(20)) { //boost_particle.SetOrigin(temporigin + Vector(0, 0, 110)) EntFireByHandle(boost_particle, "SetParent", "!activator", -1, self, null) } } ::NanoThink <- function() { local classname = self.GetPlayerClass() if (classname != 2) return local nano_buttons = NetProps.GetPropInt(self, "m_nButtons"); local nano_buttons_changed = nano_buttons_last ^ nano_buttons; local nano_buttons_pressed = nano_buttons_changed & nano_buttons; local nano_buttons_released = nano_buttons_changed & (~nano_buttons); local playerOrigin = self.GetOrigin() local getWep = PopExtUtil.GetItemInSlot(self, 0) local activeWep = self.GetActiveWeapon() local getwepIDSleep = NetProps.GetPropInt(getWep, "m_AttributeManager.m_Item.m_iItemDefinitionIndex") getWep.AddAttribute("sniper no headshots", 1, -1) if (nano_boost_value >= 40) { nano_boost_value = 40 } boostCharge = floor((nano_boost_value/100) * 40) if (nano_boost_value == 40) { ClientPrint(self, 4, "MOUSE3 WHILE LOOKING AT ALLY: GRANT HYPERBOOST!") self.PressSpecialFireButton(1) } else { ClientPrint(self, 4, "HYPERBOOST CHARGE: "+boostCharge+"%") } if (nano_buttons & Constants.FButtons.IN_ATTACK3 && getWep == activeWep && nano_boost_value == 40) { //printl("Player pressed left-click"); local getEyePosition = self.EyePosition()+self.EyeAngles().Forward()*1500 // eye position end local curGetEyePosition = self.EyePosition()+self.EyeAngles().Forward() // base eye position, looking forward function LookAt(target_pos, min_rate, max_rate) { local cur_eye_pos = self.EyePosition() local cur_eye_fwd = self.EyeAngles().Forward() local cur_eye_ang = self.EyeAngles() local dt = FrameTime() local dir = target_pos - cur_eye_pos dir.Norm() local dot = cur_eye_fwd.Dot(dir) local desired_angles = PopExtUtil.VectorAngles(dir) local rate_x = PopExtUtil.RemapValClamped(fabs(PopExtUtil.NormalizeAngle(cur_eye_ang.x) - PopExtUtil.NormalizeAngle(desired_angles.x)), 0.0, 180.0, min_rate, max_rate) local rate_y = PopExtUtil.RemapValClamped(fabs(PopExtUtil.NormalizeAngle(cur_eye_ang.y) - PopExtUtil.NormalizeAngle(desired_angles.y)), 0.0, 180.0, min_rate, max_rate) if (dot > 0.7) { local t = PopExtUtil.RemapValClamped(dot, 0.7, 1.0, 1.0, 0.05) local d = sin(1.57 * t) // pi/2 rate_x *= d rate_y *= d } cur_eye_ang.x = PopExtUtil.NormalizeAngle(PopExtUtil.ApproachAngle(desired_angles.x, cur_eye_ang.x, rate_x * dt)) cur_eye_ang.y = PopExtUtil.NormalizeAngle(PopExtUtil.ApproachAngle(desired_angles.y, cur_eye_ang.y, rate_y * dt)) self.SnapEyeAngles(cur_eye_ang) } for(local ally; ally = FindByClassname(ally, "player");) { if (ally == null) continue if ((ally.InCond(46))) continue local allyorigin = ally.GetOrigin() StopBoostTimer() if (breakBoolean == true) { cancelTimer = 10 breakBoolean = false ally = null break } if (ally.GetPlayerClass() == 2) continue if (ally.InCond(46)) continue //priority for giants; execute the code early if (ally.IsMiniBoss() == true) { if (ally.InCond(46)) continue if (ally.GetPlayerClass() != 2 && ally.GetTeam() == self.GetTeam() && !(ally.InCond(20))) { LookAt(allyorigin, 9999, 9999) break } if (nano_boost_value == 40) { aibot.UpdatePathAndMove(allyorigin) } } else if (ally.GetPlayerClass() != 2 && ally.GetTeam() == self.GetTeam() && !(ally.InCond(20))) { LookAt(allyorigin, 9999, 9999) break } if (nano_boost_value == 40) { aibot.UpdatePathAndMove(allyorigin) } } local eyetrace = { start = curGetEyePosition, end = getEyePosition ignore = self } TraceLineEx(eyetrace) if (eyetrace.hit && "enthit" in eyetrace && eyetrace.enthit.GetClassname() == "player") { //printl("hitty") if (eyetrace.enthit.GetPlayerClass() == 2) return // no sniper boosting local hitPlayer = eyetrace.enthit local allyOrigin = eyetrace.enthit.GetOrigin() if (eyetrace.enthit.GetTeam() == self.GetTeam()) { eyetrace.enthit.AddCustomAttribute("damage bonus", 1.5, 8) eyetrace.enthit.AddCustomAttribute("dmg taken increased", 0.5, 8) local entityHealth = eyetrace.enthit.GetMaxHealth() local class_string = FixClasses[hitPlayer.GetPlayerClass()] if (hitPlayer.IsMiniBoss()) { ClientPrintSafe(null, "^99CCFF"+GetPlayerName(self)+" ^ ^CCCC has BOOSTED a Giant "+class_string+"!") } else { ClientPrintSafe(null, "^99CCFF"+GetPlayerName(self)+" ^ ^CCCC has BOOSTED a "+class_string+"!") } eyetrace.enthit.SetHealth(entityHealth + 300) eyetrace.enthit.AddCondEx(46, 8, self) eyetrace.enthit.AddCondEx(20, 8, self) // amputator healing rings eyetrace.enthit.AddCondEx(32, 8, self) // whip isBoosted = true nano_boost_value = 0 //DispatchParticleEffect("powerup_supernova_explode_blue", allyOrigin, Vector(0, 0, 30)) local nova = SpawnEntityFromTable("info_particle_system", { targetname = "landing" origin = allyOrigin + Vector(0, 0, 30), angles = Vector(0, 0, 0), effect_name = "powerup_supernova_explode_blue", flag_as_weather = 0, }) //play particle + kill marked particle EntFireByHandle(nova, "start", "", -1, null, null) nova = null eyetrace.enthit.ValidateScriptScope() local tracescope = eyetrace.enthit.GetScriptScope() tracescope.boost_temp <- 0; tracescope.boost_particle <- null; tracescope.boostTimer <- 10 tracescope.serverTime <- 0 tracescope.BoostTrackTime <- function() { //caberCountTime acts as time if (boostTimer == null) return local time = floor(Time()) if (time != serverTime) { // Once every second serverTime = time if (boostTimer > 0) { boostTimer-- } if (boostTimer == 1) { tracescope.boost_particle.Kill() } //printl(boostTimer) } } PopExtUtil.AddThinkToEnt(eyetrace.enthit, "NanoParticleThink"); EmitSoundEx({ sound_name = "items/powerup_pickup_crits.wav", origin = allyOrigin, }); EmitSoundEx({ sound_name = "items/powerup_pickup_team_revenge.wav", origin = playerOrigin, }); } function GetBoostTime() { if (isBoosted == true) { boost_time = boost_time + 1 //printl(boost_time) if (boost_time >= 530) // 8 seconds { isBoosted = false hitPlayer.SetScriptOverlayMaterial("") } } } } } if (isBoosted == true) { GetBoostTime() } nano_buttons_last = nano_buttons; //applied to weapon, must return return -1 } //////////////////////////ON GAME EVENTS ::NanoEnable <- function() { ////printl(self) local playerScope = self.GetScriptScope() local wep = PopExtUtil.GetItemInSlot(self, 1) local wepScope = self.GetScriptScope() local wep = PopExtUtil.GetItemInSlot(self, 0) local getwepID = NetProps.GetPropInt(wep, "m_AttributeManager.m_Item.m_iItemDefinitionIndex") if (self != null && self.IsBotOfType(TF_BOT_TYPE)) { self.ValidateScriptScope() if (!("PlayerThinkTable" in self.GetScriptScope())) self.GetScriptScope().PlayerThinkTable <- {} if (self.HasBotTag("bot_nanoboost")) { self.ValidateScriptScope(); playerScope.nano_buttons_last <- 0; playerScope.nano_boost_value <- 0; // tracks how much the boost has until full playerScope.boost_time <- 0; // hack-time that tracks duration playerScope.boosted_player <- null; playerScope.isBoosted <- false; playerScope.boostCharge <- false; playerScope.cancelTimer <- 10 playerScope.serverTime <- 0 playerScope.breakBoolean <- false playerScope.StopBoostTimer <- function() { //caberCountTime acts as time if (cancelTimer == null) return local time = floor(Time()) if (time != serverTime) { // Once every second serverTime = time if (cancelTimer > 0) { cancelTimer-- } if (cancelTimer == 0) { breakBoolean = true } //printl(boostTimer) } } PopExtUtil.AddThinkToEnt(self, "NanoThink"); } } } function OnScriptHook_OnTakeDamage(params) { //printl("hrt") if (params.attacker == null || params.attacker.GetClassname() == "worldspawn") return; if (params.const_entity.GetClassname() != "player" || params.attacker.GetClassname() != "player") return; local victim = params.const_entity; local user = params.attacker; //local player = GetPlayerFromUserID(params.attacker) local scope = user.GetScriptScope() local damageNum = params.damage; //printl(damageNum) // local wepInflictor = params.inflictor; // local dmgType = params.damage_stats; if (user.GetClassname() == "player") { user.ValidateScriptScope(); if (!("PlayerThinkTable" in user.GetScriptScope())) user.GetScriptScope().PlayerThinkTable <- {} if ("NanoThink" in scope.PlayerThinkTable) { if (!(victim.InCond(14)) && !(victim.InCond(5)) && !(victim.InCond(51)) && !(victim.InCond(52))) { scope.nano_boost_value = scope.nano_boost_value + damageNum } } } } function OnGameEvent_player_spawn(params) { local player = GetPlayerFromUserID(params.userid); local playerScope = player.GetScriptScope() local wep = PopExtUtil.GetItemInSlot(player, 0) local getwepID = NetProps.GetPropInt(wep, "m_AttributeManager.m_Item.m_iItemDefinitionIndex") //!player.HasBotTag("bot_nanoboost") if (player != null && player.IsBotOfType(TF_BOT_TYPE)) { EntFireByHandle(player, "CallScriptFunction", "NanoEnable", 0.1, null, null); } //EntFireByHandle(player, "CallScriptFunction", "NanoEnable", 0.1, null, null); } __CollectGameEventCallbacks(this);