--By Zilloy --Big thanks to Wacev for helping with it classIndices_Internal = { [1] = "Scout", [3] = "Soldier", [7] = "Pyro", [4] = "Demoman", [6] = "Heavy", [9] = "Engineer", [5] = "Medic", [2] = "Sniper", [8] = "Spy", } ENEMY_MODEL_TABLE = { [0] = { -- COMMONS [TF_CLASS_DEMOMAN] = "models/bots/demo/bot_demo.mdl", [TF_CLASS_CIVILIAN] = "models/bots/engineer/bot_engineer.mdl", [TF_CLASS_ENGINEER] = "models/bots/engineer/bot_engineer.mdl", [TF_CLASS_HEAVYWEAPONS] = "models/bots/heavy/bot_heavy.mdl", [TF_CLASS_MEDIC] = "models/bots/medic/bot_medic.mdl", [TF_CLASS_PYRO] = "models/bots/pyro/bot_pyro.mdl", [TF_CLASS_SCOUT] = "models/bots/scout/bot_scout.mdl", [TF_CLASS_SNIPER] = "models/bots/sniper/bot_sniper.mdl", [TF_CLASS_SOLDIER] = "models/bots/soldier/bot_soldier.mdl", [TF_CLASS_SPY] = "models/bots/spy/bot_spy.mdl", }, [1] = { -- GIANTS [TF_CLASS_DEMOMAN] = "models/bots/demo_boss/bot_demo_boss.mdl", [TF_CLASS_CIVILIAN] = "models/bots/engineer/bot_engineer.mdl", [TF_CLASS_ENGINEER] = "models/bots/engineer/bot_engineer.mdl", [TF_CLASS_HEAVYWEAPONS] = "models/bots/heavy_boss/bot_heavy_boss.mdl", [TF_CLASS_MEDIC] = "models/bots/medic/bot_medic.mdl", [TF_CLASS_PYRO] = "models/bots/pyro_boss/bot_pyro_boss.mdl", [TF_CLASS_SCOUT] = "models/bots/scout_boss/bot_scout_boss.mdl", [TF_CLASS_SNIPER] = "models/bots/sniper/bot_sniper.mdl", [TF_CLASS_SOLDIER] = "models/bots/soldier_boss/bot_soldier_boss.mdl", [TF_CLASS_SPY] = "models/bots/spy/bot_spy.mdl", } } baseClassHealth = { [1] = 125, [3] = 200, [7] = 175, [4] = 175, [6] = 300, [9] = 125, [5] = 150, [2] = 125, [8] = 125, } function Swap(SwapTo, activator) -- print("function called, SwapTo:",SwapTo) local myOldHealth = activator.m_iHealth local myOldMaxHealth = 0 if activator:GetAttributeValue("hidden maxhealth non buffed") ~= nil then myOldMaxHealth = activator:GetAttributeValue("hidden maxhealth non buffed") + baseClassHealth[activator.m_iClass] else myOldMaxHealth = activator.m_iMaxHealth end if myOldHealth < myOldMaxHealth/2 then myOldHealth = myOldMaxHealth/2 end math.remap = function( value, inMin, inMax, outMin, outMax ) return outMin + ( ( ( value - inMin ) / ( inMax - inMin ) ) * ( outMax - outMin ) ) end if string.lower(SwapTo) == "demo samurai" then activator:SwitchClassInPlace(4) activator.m_szNetName = "Samurai Demo" activator:SetFakeClientConVar("name", "Samurai Demo") activator:RunScriptCode( "activator.SetDifficulty(3)", activator, activator ) timer.Simple(0.05, function() activator:GiveItem("The Half-Zatoichi") activator:GiveItem("The Splendid Screen") activator:GiveItem("Demo Kabuto") timer.Simple(0, function() activator:GetPlayerItemBySlot(1):SetAttributeValue("Attack not cancel charge", 1) activator:GetPlayerItemBySlot(2):SetAttributeValue("damage bonus", 1.5) end) activator:SetAttributeValue( "hidden maxhealth non buffed", 650 - 175 ) activator.m_iMaxHealth = 650 activator.m_iHealth = math.remap( myOldHealth, 0, myOldMaxHealth, 0, activator.m_iMaxHealth ) end) elseif string.lower(SwapTo) == "heavy" then activator:SwitchClassInPlace(6) activator.m_szNetName = "HeavyWeapons" activator:SetFakeClientConVar("name", "HeavyWeapons") activator:RunScriptCode( "activator.SetDifficulty(1)", activator, activator ) timer.Simple(0.05, function() activator:GiveItem("Upgradeable TF_WEAPON_MINIGUN") activator:SetAttributeValue( "hidden maxhealth non buffed", nil ) activator.m_iMaxHealth = 300 activator.m_iHealth = math.remap( myOldHealth, 0, myOldMaxHealth, 0, activator.m_iMaxHealth ) end) elseif string.lower(SwapTo) == "sniper huntsman" then activator:SwitchClassInPlace(2) activator.m_szNetName = "Bowman" activator:SetFakeClientConVar("name", "Bowman") activator:RunScriptCode( "activator.SetDifficulty(2)", activator, activator ) timer.Simple(0.05, function() activator:GiveItem("the huntsman") timer.Simple(0, function() activator:GetPlayerItemBySlot(0):SetAttributeValue("damage penalty", 0.5) end) activator:SetAttributeValue( "hidden maxhealth non buffed", nil ) activator.m_iMaxHealth = 125 activator.m_iHealth = math.remap( myOldHealth, 0, myOldMaxHealth, 0, activator.m_iMaxHealth ) end) elseif string.lower(SwapTo) == "scout" then activator:SwitchClassInPlace(1) activator.m_szNetName = "Scout" activator:SetFakeClientConVar("name", "Scout") activator:RunScriptCode( "activator.SetDifficulty(1)", activator, activator ) timer.Simple(0.05, function() activator:GiveItem("Upgradeable TF_WEAPON_SCATTERGUN") activator:SetAttributeValue( "hidden maxhealth non buffed", nil ) activator.m_iMaxHealth = 125 activator.m_iHealth = math.remap( myOldHealth, 0, myOldMaxHealth, 0, activator.m_iMaxHealth ) end) elseif string.lower(SwapTo) == "giant pyro fury" then activator:SwitchClassInPlace(7) activator.m_szNetName = "Giant Dragon's Fury Pyro" activator:SetFakeClientConVar("name", "Giant Dragon's Fury Pyro") activator:RunScriptCode( "activator.SetDifficulty(3)", activator, activator ) activator:SetAttributeValue("is miniboss", 1) --they lose MiniBoss upon class swap timer.Simple(0.05, function() activator:GiveItem("The Dragon's Fury") activator:GiveItem("batter's bracers") activator:GiveItem("The Flame Warrior") timer.Simple(0, function() activator:GetPlayerItemBySlot(0):SetAttributeValue("damage bonus", 1.25) end) activator:SetAttributeValue( "hidden maxhealth non buffed", 3000 - 175 ) activator.m_iMaxHealth = 3000 print("using for math:", myOldHealth , myOldMaxHealth , activator.m_iMaxHealth ) activator.m_iHealth = math.remap( myOldHealth, 0, myOldMaxHealth, 0, activator.m_iMaxHealth ) end) elseif string.lower(SwapTo) == "giant demo" then activator:SwitchClassInPlace(4) activator.m_szNetName = "Giant Rapid Fire Demoman" activator:SetFakeClientConVar("name", "Giant Rapid Fire Demoman") activator:RunScriptCode( "activator.SetDifficulty(3)", activator, activator ) activator:SetAttributeValue("is miniboss", 1) timer.Simple(0.05, function() activator:GiveItem("Upgradeable TF_WEAPON_GRENADELAUNCHER") timer.Simple(0, function() activator:GetPlayerItemBySlot(0):SetAttributeValue("faster reload rate", 0) activator:GetPlayerItemBySlot(0):SetAttributeValue("fire rate bonus", 0.75) end) activator:SetAttributeValue( "hidden maxhealth non buffed", 3300 - 175 ) activator.m_iMaxHealth = 3300 print("using for math:", myOldHealth , myOldMaxHealth , activator.m_iMaxHealth ) activator.m_iHealth = math.remap( myOldHealth, 0, myOldMaxHealth, 0, activator.m_iMaxHealth ) end) else print("IDK man, didn't match") end activator:SetCustomModelWithClassAnimations( ENEMY_MODEL_TABLE[ activator.m_bIsMiniBoss ][activator.m_iClass] ) end