-- TO FIX (lowest last, highest first) -- GiveWeaponToActivator() must trigger when the activator presses +attack3, not when they touch the trigger -- Bots are able to activate GiveWeaponToActivator(), robbing players of their fun >:[ -- Grenade Launchers/Rocket Launchers need to hold fire until full reload to help balance out the burst/spammer variants. Ask royal to help with -- Find a way to detect when players die and make sure the correct bot is despawned -- Players still wear original cosmetics while giantified -- Players dont gain the bots cosmetics function GiveWeaponToActivator(_,activator,trigger) local parent = trigger.m_pParent local oldClass = activator:GetClassname() --local newClass = parent:GetClassname() local parentAttributes = parent:GetAllAttributeValues() local speedBonus = activator:GetAttributeValue("move speed bonus") local resistBlast = activator:GetAttributeValue("dmg taken from blast reduced") local resistFire = activator:GetAttributeValue("dmg taken from fire reduced") local resistBullets = activator:GetAttributeValue("dmg taken from bullets reduced") local resistCrit = activator:GetAttributeValue("dmg taken from bullets reduced") local healthRegen = activator:GetAttributeValue("health regen") local metalRegen = activator:GetAttributeValue("metal regen") local jumpHeight = activator:GetAttributeValue("increased jump height") if not parent or not activator then return end if activator:IsBot() == true then return end if not activator.m_iTeamNum == 2 or activator:GetAttributeValue("is miniboss") == 1 then return end -- trigger:AcceptInput("$botcommand","despawn") -- local params = { -- channel = 4, -- x = -0.48, -- y = 0.2, -- holdTime = 9999, -- } -- activator:GiveItem(weaponName,weaponAttrs) -- activator:ShowHudText(params, "Press +attack3 (Heavy rage, Medic shield) to revert!") activator:SetAttributeValue("no resupply", 1) activator:SetAttributeValue("is miniboss", 1) activator:SetAttributeValue("cannot upgrade", 1) activator:SetAttributeValue("cancel falling damage", 1) activator:SetAttributeValue("health from packs decreased", 0.5) activator:SetAttributeValue("voice pitch scale", 0.7) activator:SetAttributeValue("crit mod disabled", 0) activator:SetAttributeValue("hud overlay", "effects/combine_binocoverlay") activator:SetAttributeValue("dmg taken from blast reduced", nil) activator:SetAttributeValue("dmg taken from fire reduced", nil) activator:SetAttributeValue("dmg taken from crit reduced", nil) activator:SetAttributeValue("dmg taken from bullets reduced", nil) activator:RefillAmmo() activator:AddHealth(9999) --activator:SwitchClassInPlace(newClass) parent:AcceptInput("$TeleportToEntity", "spawnbot_invasion", parent) parent:AddCond(71, 9999) -- get the player loadout for i=0,2 do local wep = parent:GetPlayerItemBySlot(i); local weaponAttrs = wep:GetAllAttributeValues() local weaponName = wep:GetItemName() activator:Giveitem(weaponName); for attr, val in pairs(weaponAttrs) do -- print(attr, val) activator:GetPlayerItemBySlot(i):SetAttributeValue(attr, val); end -- activator:DisplayTextChat("Giving player "..activator:GetPlayerName().." the following weapon: "..weaponName.."!") end -- get the player attributes for attr, val in pairs(parentAttributes) do activator:SetAttributeValue(attr, val); end -- is parent always crit? if parent:InCond(34) then activator:AddCond(34) end -- if players want to get out of the mecha fellow local reload_id = activator:AddCallback(ON_KEY_PRESSED, function(activator, key) -- unsure if it works but just incase something weird happens with the upgrade station if activator.m_bInUpgradeZone == 1 then return end if key == IN_ATTACK3 then RemoveSpecificCallback() -- remove added attributes local playAttributes = activator:GetAllAttributeValues() --remove attributes for attr, val in pairs(playAttributes) do val = nil activator:SetAttributeValue(attr, val); end activator:SetAttributeValue("no resupply", nil) activator:SetAttributeValue("is miniboss", nil) activator:SetAttributeValue("cannot upgrade", nil) activator:SetAttributeValue("hidden maxhealth non buffed", activator.m_iHealth * -1) activator:SetAttributeValue("hidden maxhealth non buffed", 0) activator:SetAttributeValue("voice pitch scale", 1) activator:SetAttributeValue("cancel falling damage", nil) activator:SetAttributeValue("hud overlay", nil) activator:SetAttributeValue("crit mod disabled", nil) activator:SetAttributeValue("health from packs decreased", nil) activator:SwitchClassInPlace(oldClass) parent:AcceptInput("$BotCommand", "despawn", parent) -- dont despawn the bot to control the giant count -- parent:AcceptInput("$botcommand","despawn") -- for some reason these two attributes appear and disappear at random... why is beyond me activator:SetAttributeValue("move speed bonus", speedBonus) activator:SetAttributeValue("dmg taken from blast reduced", resistBlast) activator:SetAttributeValue("dmg taken from fire reduced", resistFire) activator:SetAttributeValue("dmg taken from crit reduced", resistCrit) activator:SetAttributeValue("dmg taken from bullets reduced", resistBullets) activator:SetAttributeValue("health regen", healthRegen) activator:SetAttributeValue("metal regen", metalRegen) activator:SetAttributeValue("increased jump height", jumpHeight) activator:AcceptInput("$RemovePlayerAttribute","move speed penalty") end end ) --remember that you opened a bracket with AddCallback() function RemoveSpecificCallback() -- print(reload_id) activator:RemoveCallback(reload_id) end end -- function BecomeRobot(_, activator) -- local isRobotCallback = activator:AddCallback(ON_KEY_PRESSED, function(activator, key) -- if key == IN_ATTACK3 then -- RemoveSpecificCallbackRobot() -- GiveWeaponToActivator(activator) -- end -- end -- ) --remember that you opened a bracket with AddCallback() -- function RemoveSpecificCallbackRobot() -- -- print(reload_id) -- activator:RemoveCallback(isRobotCallback) -- end -- end -- local reload_id = {} -- if bugs pop up -- print(activator) -- print(trigger)