//vscript by stardustspy //do not use without my credit PLEASE!!!!!!!!! ::TEAM_RED <- 2 ::TEAM_BLU <- 3 ::TF_NAV_SPAWN_ROOM_RED <- 2 ::TF_NAV_SPAWN_ROOM_BLUE <- 4 ::TF_BOT_FAKE_CLIENT <- 1337 ::MAX_COUNT_WEAPON_EQUPPED <- 8 ::TEAM_SPECTATOR <- 1 ::SOLID_NONE <- 0 ::CONTENTS_SOLID <- 1 ::CONTENTS_WINDOW <- 2 ::CONTENTS_GRATE <- 8 ::CONTENTS_MOVEABLE <- 16384 ::CONTENTS_PLAYERCLIP <- 65536 ::MASK_NPCWORLDSTATIC <- 131083 ::MASK_PLAYERSOLID <- 33636363 ::MASK_NPCSOLID <- 33701899 ::MASK_SOLID <- 33570827 ::MASK_SHOT <- 1174421507 ::MASK_SHOT_HULL <- 100679691 ::IN_ATTACK2 <- 2048 ::PI <- 3.14159265359 ::PRIMARY_FIRE <- Constants.FButtons.IN_ATTACK ::SECONDARY_FIRE <- Constants.FButtons.IN_ATTACK2 ::gamerules <- Entities.FindByClassname(null, "tf_gamerules") ::player_manager <- Entities.FindByClassname(null, "tf_player_manager") ::WORLD_SPAWN <- Entities.FindByClassname(null, "worldspawn") ::MAX_COUNT_PLAYERS <- MaxClients().tointeger() ::MASK_VISIBLE_AND_NPCS <- 33579137 ::DMG_CRITICAL <- 1048576 ::TF_DMG_CUSTOM_HEADSHOT <- 1 ::TF_DMG_CUSTOM_BACKSTAB <- 2 ::TF_DMG_CRITICAL <- 1048576 ::SND_NOFLAGS <- 0 ::SND_CHANGE_VOL <- 1 ::SND_CHANGE_PITCH <- 2 ::SND_STOP <- 4 ::SND_SPAWNING <- 8 ::SND_DELAY <- 16 ::SND_STOP_LOOPING <- 32 ::SND_SPEAKER <- 64 ::SND_SHOULDPAUSE <- 128 ::SND_IGNORE_PHONEMES <- 256 ::SND_IGNORE_NAME <- 512 ::SND_DO_NOT_OVERWRITE_EXISTING_ON_CHANNEL <- 1024 ::IGNORE_ENEMIES <- 1024 const STRING_NETPROP_ITEMDEF = "m_AttributeManager.m_Item.m_iItemDefinitionIndex" const SLOT_COUNT = 7 const EFL_USER = 1048576 // EFL_IS_BEING_LIFTED_BY_BARNACLE const EFL_USER2 = 1073741824 //EFL_NO_PHYSCANNON_INTERACTION const SINGLE_TICK = 0.015 const DMG_NO_BULLET_FALLOFF = 2097152 PrecacheSound("ambient/energy/weld1.wav") PrecacheSound("ambient/energy/weld2.wav") PrecacheSound("player/recharged.wav") PrecacheSound("npc/assassin/ball_zap1.wav") PrecacheSound("weapons/drg_wrench_teleport.wav") PrecacheSound("misc/halloween/spell_lightning_ball_cast.wav") PrecacheSound("misc/halloween/spell_meteor_impact.wav") PrecacheSound("misc/halloween/spell_spawn_boss.wav") PrecacheSound("Weapon_Revolver.Single") //fold ::ROOT <- getroottable(); if (!("ConstantNamingConvention" in ROOT)) // make sure folding is only done once { foreach (a,b in Constants) foreach (k,v in b) ROOT[k] <- v != null ? v : 0; } function GetItemInSlot(player, slot) { local item for (local i = 0; i < SLOT_COUNT; i++) { local wep = NetProps.GetPropEntityArray(player, "m_hMyWeapons", i) if ( wep == null || wep.GetSlot() != slot) continue item = wep break } return item } ::BlastJumpMinigun <- { Cleanup = function() { for(local player; player = Entities.FindByClassname(player, "player");) { player.ValidateScriptScope() local scope = player.GetScriptScope(); local script_string = NetProps.GetPropString(player, "m_iszScriptThinkFunction") if (script_string == "InfectedEnemyThink") { NetProps.SetPropString(player, "m_iszScriptThinkFunction", ""); AddThinkToEnt(player, null); } } // keep this at the end delete ::BlastJumpMinigun } // mandatory events OnGameEvent_recalculate_holidays = function(_) { if (GetRoundState() == 3) { Cleanup() } } OnGameEvent_mvm_wave_complete = function(_) { Cleanup() } function PrintTable(table) { if (table == null) return; this.DoPrintTable(table, 0) } function DoPrintTable(table, indent) { local line = "" for (local i = 0; i < indent; i++) { line += " " } line += typeof table == "array" ? "[" : "{"; ClientPrint(null, 2, line) indent += 2 foreach(k, v in table) { line = "" for (local i = 0; i < indent; i++) { line += " " } line += k.tostring() line += " = " if (typeof v == "table" || typeof v == "array") { ClientPrint(null, 2, line) this.DoPrintTable(v, indent) } else { try { line += v.tostring() } catch (e) { line += typeof v } ClientPrint(null, 2, line) } } indent -= 2 line = "" for (local i = 0; i < indent; i++) { line += " " } line += typeof table == "array" ? "]" : "}"; ClientPrint(null, 2, line) } function CanBeHurt(entity) { local UberArray = [5, 8, 51, 52, 57] foreach(cond in UberArray) { if (entity.InCond(cond)) { return true } } return false } GetItemInSlot = function(player, slot) { local item for (local i = 0; i < SLOT_COUNT; i++) { local wep = NetProps.GetPropEntityArray(player, "m_hMyWeapons", i) if ( wep == null || wep.GetSlot() != slot) continue item = wep break } return item } StripWeapon = function(player, slot) { if (slot == -1) slot = player.GetActiveWeapon().GetSlot() for (local i = 0; i < SLOT_COUNT; i++) { local weapon = this.GetItemInSlot(player, i); if (weapon == null || weapon.GetSlot() != slot) continue; weapon.Kill(); break; } } GiveWeapon = function(player, className, itemID) { if (typeof itemID == "string" && className == "tf_wearable") { CTFBot.GenerateAndWearItem.call(player, itemID) return } local weapon = Entities.CreateByClassname(className) NetProps.SetPropInt(weapon, STRING_NETPROP_ITEMDEF, itemID) NetProps.SetPropBool(weapon, "m_AttributeManager.m_Item.m_bInitialized", true) NetProps.SetPropBool(weapon, "m_bValidatedAttachedEntity", true) weapon.SetTeam(player.GetTeam()) weapon.DispatchSpawn() // remove existing weapon in same slot for (local i = 0; i < SLOT_COUNT; i++) { local heldWeapon = NetProps.GetPropEntityArray(player, "m_hMyWeapons", i) if (heldWeapon == null || heldWeapon.GetSlot() != weapon.GetSlot()) continue heldWeapon.Destroy() NetProps.SetPropEntityArray(player, "m_hMyWeapons", null, i) break } player.Weapon_Equip(weapon) player.Weapon_Switch(weapon) // fixes bug where if a player is firing/reloading, the player has to switch weapons again to equip the weapon EntFireByHandle(gamerules, "RunScriptCode", "activator.Weapon_Switch(caller)", 0.1, player, weapon) return weapon } IsGrounded = function(player) { return player.GetFlags() & FL_ONGROUND } ToggleBlastCheck = function(player) { player.ValidateScriptScope() local attacker_scope = player.GetScriptScope() attacker_scope.bIsBlastJumping = true } CalculateCritFactor = function(attacker, victim) { if (victim.GetClassname() != "player") { victim = null } function IsMiniCritAttacker(entity) { local CritArray = [16, 19, 31] foreach(crit in CritArray) { if (entity.InCond(crit)) { return true } } return false } function IsMiniCritVictim(entity) { if (victim == null) return false local CritArray = [24, 30] foreach(crit in CritArray) { if (entity.InCond(crit)) { return true } } return false } function IsCritAttacker(entity) { local CritArray = [11, 34, 37, 39, 40, 44, 56] foreach(crit in CritArray) { if (entity.InCond(crit)) { return true } } return false } // Initialize the damage factor to 1.0 local factor = 1.0; // Check if the attacker is a crit attacker local isCritAttacker = IsCritAttacker(attacker); // Check if the attacker is a mini-crit attacker local isMiniCritAttacker = IsMiniCritAttacker(attacker); // Check if the victim is a mini-crit victim local isMiniCritVictim = IsMiniCritVictim(victim); // Determine the factor based on crit and mini-crit conditions if (isCritAttacker && isMiniCritVictim) { // If the attacker is a crit attacker and the victim is a mini-crit victim, crit overrides factor = 3.0; } else if (isCritAttacker) { // If the attacker is a crit attacker, crit factor factor = 3.0; } else if (isMiniCritAttacker) { // If the attacker is a mini-crit attacker, mini-crit factor factor = 1.35; } return factor; } DispatchParticleEffectEx = function(name, origin, angles, delay_start, delay_end, ent_attachment, debug) { PrecacheEntityFromTable({ classname = "info_particle_system", effect_name = name }) if (delay_start < delay_end && debug == true) { printl("WARNING: Start delay is slower then end delay! Particle may not spawn!") } local particle = SpawnEntityFromTable("info_particle_system", { effect_name = name, targetname = "temporary" origin = origin angles = angles }) if (ent_attachment != null) { NetProps.SetPropEntityArray(particle, "m_hControlPointEnts", ent_attachment, 0); } if (delay_start == -1) { particle.AcceptInput("Start", "", null, null) } else { EntFireByHandle(particle, "Start", "", delay_start, null, null); } EntFireByHandle(particle, "Stop", "", delay_end, null, null); EntFireByHandle(particle, "Kill", "", delay_end + SINGLE_TICK, null, null); } InfectEnemy = function(ent, duration, tick_rate, attacker, weapon) { ent.ValidateScriptScope() local scope = ent.GetScriptScope() ::InfectedEnemyThink <- function() { local cur_time = Time() local origin = self.GetOrigin() if (typeof(damage_timer) == "null") { damage_timer = 0; } if (IsGrounded(self)) { self.SetGravity(1) } function OnScriptHook_OnTakeDamage(params) { local victim = params.const_entity local weapon = params.weapon local attacker_ent = params.attacker local entity = params.inflictor local damage = params.damage local dmgtype = params.damage_type local dmg_special = params.damage_stats local weapon_id = NetProps.GetPropInt(weapon, STRING_NETPROP_ITEMDEF) attacker.ValidateScriptScope() local attacker_scope = attacker.GetScriptScope() local victim_scope = victim.GetScriptScope() local script_string = NetProps.GetPropString(attacker, "m_iszScriptThinkFunction") local script_string_victim = NetProps.GetPropString(victim, "m_iszScriptThinkFunction") local damage_mult = 1 local proj_ent_dmg = NetProps.GetPropFloat(entity, "m_flDamage") // accounts for dmg bonsu if (attacker_ent == attacker && weapon == custom_wep && proj_ent_dmg == damage) { if (!(victim.GetFlags() & FL_ONGROUND)) { //printl("added airborne mult") damage_mult = damage_mult + 1 } if (script_string_victim == "InfectedEnemyThink") { //printl("added poison mult") damage_mult = damage_mult + 1 } params.damage *= damage_mult } } __CollectGameEventCallbacks(this) if ((damage_timer + tick_rate) <= cur_time && cur_time <= time_end && NetProps.GetPropInt(self, "m_lifeState") == 0) { local has_air_control = self.GetCustomAttribute("increased air control", 1) local has_fall_damage = self.GetCustomAttribute("cancel falling damage", 0) if (has_air_control == 1) { self.AddCustomAttribute("increased air control", 0.1, 3) } if (has_fall_damage == 0) { self.AddCustomAttribute("cancel falling damage", 1, 3) } //printl("damage taken") self.TakeDamageEx(null, attacker, null, Vector(0, 0, 0), self.GetOrigin(), 8, 64) DispatchParticleEffectEx("doublejump_smoke_alt", origin + Vector(0, 0, 50), Vector(0, 0, 0), 0.01, 0.1, null, false) damage_timer = cur_time } else if (cur_time >= time_end) { NetProps.SetPropString(self, "m_iszScriptThinkFunction", ""); AddThinkToEnt(self, null); } return -1; } // Initialize the global attack tables list scope.attacker <- attacker scope.tick_rate <- tick_rate scope.damage_timer <- 0 scope.time_end <- Time() + duration scope.custom_wep <- weapon scope.DispatchParticleEffectEx <- DispatchParticleEffectEx scope.self <- ent // for some reason vscript is gay porn and i need to do this?????? scope.CalculateCritFactor <- CalculateCritFactor scope.IsGrounded <- IsGrounded AddThinkToEnt(ent, "InfectedEnemyThink") } MinigunSetup = function(ent) { local primary = GetItemInSlot(ent, 0) local secondary = GetItemInSlot(ent, 1) ent.ValidateScriptScope() local scope = ent.GetScriptScope() EntFireByHandle(gamerules, "runscriptcode", "activator.Regenerate(true)", 0.15, ent, ent) ::MinigunBlastJumperThink <- function() { local origin = self.GetOrigin() local custom_wep = GetItemInSlot(self, 0); local index_primary = custom_wep.entindex(); if (index_primary != ent_index) { // The player no longer has the weapon, stop thinking local scope = self.GetScriptScope(); NetProps.SetPropString(self, "m_iszScriptThinkFunction", ""); AddThinkToEnt(self, null); self.Regenerate(true); // need this if player is given weapons return -1; } if (bIsBlastJumping == true && !IsGrounded(self)) { function OnScriptHook_OnTakeDamage(params) { local victim = params.const_entity local weapon = params.weapon local attacker = params.attacker local entity = params.inflictor local damage = params.damage local dmgtype = params.damage_type local dmg_special = params.damage_stats local weapon_id = NetProps.GetPropInt(weapon, STRING_NETPROP_ITEMDEF) attacker.ValidateScriptScope() local attacker_scope = attacker.GetScriptScope() local victim_scope = victim.GetScriptScope() local script_string = NetProps.GetPropString(attacker, "m_iszScriptThinkFunction") if (attacker != self && victim == self && victim_scope.bIsBlastJumping == true) { params.damage *= 0.1 } } __CollectGameEventCallbacks(this) } if (bIsBlastJumping == true && IsGrounded(self)) { //printl("we are blast jumping!") for (local i = 0; i < 5; i++) { DispatchParticleEffectEx("halloween_boss_death_cloud", origin, Vector(90, 0, 0), 0.01, 0.1, null, false) } for(local enemy; enemy = Entities.FindByClassnameWithin(enemy, "player", origin, 325);) { if (enemy.GetClassname() in Damagable_Entities_List && enemy.GetTeam() != self.GetTeam()) { local crit_mult = CalculateCritFactor(self, enemy) local script_string = NetProps.GetPropString(enemy, "m_iszScriptThinkFunction") if (enemy.GetClassname() == "player" && enemy.GetTeam() != self.GetTeam() && enemy != self) { local invul_time = 6 bUseOverlay = true self.AddCustomAttribute("dmg taken increased", 0.1, invul_time) self.AddCondEx(65, invul_time, null) self.SetScriptOverlayMaterial("effects/invuln_overlay_red") local fall_velocity = 1000 enemy.TakeDamageEx(custom_wep, self, custom_wep, Vector(0, 0, 0), enemy.GetOrigin(), 45 * crit_mult, 64) enemy.SetGravity(0.2) if (enemy.GetTeam() == TEAM_BLU) { BlastJumpMinigun.InfectEnemy(enemy, 5, 0.5, self, custom_wep) } if (enemy.IsMiniBoss()) { local mult_airborne_reduction = enemy.GetCustomAttribute("airblast vulnerability multiplier", 1) fall_velocity = fall_velocity * mult_airborne_reduction } enemy.SetVelocity(Vector(0, 0, fall_velocity)) } else { enemy.TakeDamageEx(custom_wep, self, custom_wep, Vector(0, 0, 0), enemy.GetOrigin(), 45 * crit_mult, 64) } } } bIsBlastJumping = false } if (!self.InCond(65) && bUseOverlay == true) { self.SetScriptOverlayMaterial("") bUseOverlay = false } return -1; } // Initial setup scope.bUseOverlay <- false scope.bIsBlastJumping <- false scope.Damagable_Entities_List <- { "player" : 1, "obj_teleporter" : 1, "obj_sentrygun" : 1, "obj_dispenser" : 1, "tank_boss" : 1 } // Initialize the global attack tables list scope.PrintTable <- PrintTable scope.DoPrintTable <- DoPrintTable scope.GetItemInSlot <- GetItemInSlot scope.ent_index <- primary.entindex() scope.StripWeapon <- StripWeapon scope.IsGrounded <- IsGrounded scope.ToggleBlastCheck <- ToggleBlastCheck scope.CalculateCritFactor <- CalculateCritFactor scope.DispatchParticleEffectEx <- DispatchParticleEffectEx AddThinkToEnt(ent, "MinigunBlastJumperThink") } OnGameEvent_player_spawn = function(params) { local player = GetPlayerFromUserID(params.userid) player.ValidateScriptScope() local playerscope = player.GetScriptScope() local script_string = NetProps.GetPropString(player, "m_iszScriptThinkFunction") player.SetGravity(1) if (script_string == "InfectedEnemyThink") { NetProps.SetPropString(player, "m_iszScriptThinkFunction", ""); AddThinkToEnt(player, null); } //printl(primary) } OnGameEvent_player_disconnect = function(params) { local player = GetPlayerFromUserID(params.userid) player.ValidateScriptScope() local playerscope = player.GetScriptScope() NetProps.SetPropString(player, "m_iszScriptThinkFunction", "") AddThinkToEnt(player, null) } OnGameEvent_post_inventory_application = function(params) { local player = GetPlayerFromUserID(params.userid) player.ValidateScriptScope() local playerscope = player.GetScriptScope() local primary = GetItemInSlot(player, 0) local script_string = NetProps.GetPropString(player, "m_iszScriptThinkFunction") //printl(primary) player.SetGravity(1) if (script_string == "InfectedEnemyThink") { NetProps.SetPropString(player, "m_iszScriptThinkFunction", ""); AddThinkToEnt(player, null); } } OnScriptHook_OnTakeDamage = function(params) { local victim = params.const_entity local weapon = params.weapon local attacker = params.attacker local entity = params.inflictor local damage = params.damage local dmgtype = params.damage_type local dmg_special = params.damage_stats local weapon_id = NetProps.GetPropInt(weapon, STRING_NETPROP_ITEMDEF) attacker.ValidateScriptScope() local attacker_scope = attacker.GetScriptScope() local script_string = NetProps.GetPropString(attacker, "m_iszScriptThinkFunction") local Damagable_Entities_List = { "player" : 1, "obj_teleporter" : 1, "obj_sentrygun" : 1, "obj_dispenser" : 1, "tank_boss" : 1 } if (attacker == victim && script_string == "MinigunBlastJumperThink") { //printl("we hurt") EntFireByHandle(attacker, "runscriptcode", "ToggleBlastCheck(self)", 0.1, null, null) } } }; __CollectGameEventCallbacks(BlastJumpMinigun)