function RailgunInitilise(_, activator) if not activator then return end local primaryActive = activator:GetPlayerItemBySlot(0) local equippedSecondary = activator:GetPlayerItemBySlot(1) if equippedSecondary:GetClassname() == "tf_weapon_smg" then activator:WeaponStripSlot(1) end local ReloadTime = 2 local primaryMaxClipSize = activator.m_iAmmo[3] local ChargeCap = 0 local RailgunUltCountCharge = 0 local isReloading = false RailHudText = { channel = 3, --Channel number 0 - 5, -- Channel 0 is used to display wave explanation, -- Channel 1 is used to display cash in reverse mvm, x = -0.2, -- X coordinate from 0 to 1, -- -1 for center positon, -- Text is wrapped so it does not overflow the screen y = 0.75, -- Y coordinate from 0 to 1, -- -1 for center positonText is wrapped so it does not overflow the screen effect = 0, -- 0,1 - fade in/fade out text, -- 2 - typeout text r1 = 124, -- 0 - 255 range, -- The text is rendered additively, black text will not display r2 = 43, -- 0 - 255 range, -- The text is rendered additively, black text will not display g1 = 134, -- 0 - 255 range, -- The text is rendered additively, black text will not display g2 = 98, -- 0 - 255 range, -- The text is rendered additively, black text will not display b1 = 135, -- 0 - 255 range, -- The text is rendered additively, black text will not display b2 = 16, -- 0 - 255 range, -- The text is rendered additively, black text will not display a1 = 0, -- 0 - 255 range, -- 0 - fully visible, 255 - invisible a2 = 0, -- 0 - 255 range, -- 0 - fully visible, 255 - invisible fadeinTime = 0, -- Time to fade in text fadeoutTime = 0, -- Time to fade out text holdTime = 9999, -- Time the text is fully displayed fxTime = 0, -- Time to type a single letter with typeout effect } DisplayTextHUD = timer.Create(0.015, function () if activator.m_iClass == 2 then activator:ShowHudText(RailHudText, "Railgun Charge: "..ChargeCap) end if activator.m_iAmmo[3] == 0 and isReloading == false then -- to save on timers, using hud timer as a checker for if primary ammo is empty isReloading = true ReloadWeapon() end end, 0) --RAILGUN RELOAD LOGIC function ReloadWeapon() if not IsValid(activator) or not activator:IsAlive() or not IsValid(primaryActive) and isReloading == true then return end local getCurAmmo = primaryActive:GetAttributeValue("maxammo secondary increased") if getCurAmmo == nil then getCurAmmo = 1 end IsMidReload = true activator:WeaponSwitchSlot(0) activator:SetAttributeValue("disable weapon switch", 1) activator:AcceptInput("$DisplayTextCenter", "Reloading..."..ReloadTime, activator) ReloadTimer = timer.Create(1, function () ReloadTime = ReloadTime - 1 --print(ReloadTime) activator:AcceptInput("$DisplayTextCenter", "Reloading..."..ReloadTime, activator) if ReloadTime == 0 then activator.m_iAmmo[3] = primaryMaxClipSize * getCurAmmo ReloadTime = 2 activator:SetAttributeValue("disable weapon switch", nil) IsMidReload = false isReloading = false ReloadTimer = nil end end, 2) end local RailReloadCallbacks = activator:AddCallback(ON_KEY_RELEASED, function(user, key) if not IsValid(activator) or key ~= IN_RELOAD or not user:IsAlive() or not activator:IsAlive() or not IsValid(primaryActive) then return end if activator.m_hActiveWeapon ~= primaryActive then return end local getCurMaxClip = activator.m_iAmmo[3] if key == IN_RELOAD and isReloading == false and primaryMaxClipSize > getCurMaxClip then activator.m_iAmmo[3] = 0 end end) --RAILGUN ALT FIRE LOGIC function AddCharge(_,_,caller) if caller:InCond(51) or caller:InCond(5) then return end local randomCharge = math.random(1, 3) -- random as to limit the speed of which player gets charge ChargeCap = ChargeCap + randomCharge --print("charged!") if ChargeCap >= 100 then ChargeCap = 100 end end local RailgunAltCallbacks = activator:AddCallback(ON_KEY_RELEASED, function(user2, key2) if not IsValid(activator) or key2 ~= IN_ATTACK2 or not user2:IsAlive() or not activator:IsAlive() or not IsValid(primaryActive) then return end if activator.m_hActiveWeapon ~= primaryActive then return end if ChargeCap == 0 then return end if key2 == IN_ATTACK2 and ChargeCap > 0 and activator:InCond(46) == false then activator:AddCond(46) primaryActive:SetAttributeValue("sniper fires tracer HIDDEN", 1) primaryActive:SetAttributeValue("fire input on attack", "popscript^$RemoveCharge") primaryActive:SetAttributeValue("fire input on kill", "popscript^$AddRailgunKills") primaryActive:SetAttributeValue("weapon spread bonus", 0) primaryActive:SetAttributeValue("fire rate penalty", 10) primaryActive:SetAttributeValue("can headshot", 1) primaryActive:SetAttributeValue("damage bonus HIDDEN", ChargeCap / 12.25) primaryActive:SetAttributeValue("fire input on hit", nil) ChargeCap = 0 end function RemoveCharge() activator:RemoveCond(46) primaryActive:SetAttributeValue("fire input on kill", nil) primaryActive:SetAttributeValue("sniper fires tracer HIDDEN", nil) primaryActive:SetAttributeValue("fire input on attack", nil) primaryActive:SetAttributeValue("weapon spread bonus", nil) primaryActive:SetAttributeValue("fire rate penalty", nil) primaryActive:SetAttributeValue("can headshot", nil) primaryActive:SetAttributeValue("damage bonus HIDDEN", nil) primaryActive:SetAttributeValue("fire input on hit", "popscript^$AddCharge") end end) --RAILGUN CONSTA CHARGE LOGIC RailUltTextHud = { channel = 4, x = -0.2, y = 0.8, effect = 0, r1 = 124, -- 0 - 255 range, -- The text is rendered additively, black text will not display r2 = 43, -- 0 - 255 range, -- The text is rendered additively, black text will not display g1 = 134, -- 0 - 255 range, -- The text is rendered additively, black text will not display g2 = 98, -- 0 - 255 range, -- The text is rendered additively, black text will not display b1 = 135, -- 0 - 255 range, -- The text is rendered additively, black text will not display b2 = 16, -- 0 - 255 range, -- The text is rendered additively, black text will not display a1 = 0, -- 0 - 255 range, -- 0 - fully visible, 255 - invisible a2 = 0, -- 0 - 255 range, -- 0 - fully visible, 255 - invisible fadeinTime = 0, fadeoutTime = 0, holdTime = 9999, fxTime = 0, } function AddRailgunKills(_,_,caller) local callerHealthCommon = math.floor(caller.m_iMaxHealth / 60) local callerHealthGiant = math.floor(caller.m_iMaxHealth / 12) if caller.m_bIsMiniBoss == 1 then RailgunUltCountCharge = RailgunUltCountCharge + callerHealthGiant end if caller.m_bIsMiniBoss ~= 1 then RailgunUltCountCharge = RailgunUltCountCharge + callerHealthCommon end if RailgunUltCountCharge >= 100 then RailgunUltCountCharge = 100 end end RailgunUlitmateCharge = timer.Create(0.015, function () if activator.m_iClass == 2 then activator:ShowHudText(RailUltTextHud, "Overdrive Power: "..RailgunUltCountCharge.."/100%") end end, 0) function ActivateUltimate() RailgunUlitmateActive = timer.Create(0.05, function () ChargeCap = ChargeCap + 6 RailgunUltCountCharge = RailgunUltCountCharge if ChargeCap >= 100 then ChargeCap = 100 end if RailgunUltCountCharge <= 0 then RailgunUltCountCharge = 0 end -- if ChargeCap >= 100 and activator:InCond(46) == false then -- ChargeCap = 0 -- activator:AddCond(46) -- primaryActive:SetAttributeValue("sniper fires tracer HIDDEN", 1) -- primaryActive:SetAttributeValue("fire input on attack", "popscript^$RemoveCharge") -- primaryActive:SetAttributeValue("fire input on kill", "popscript^$AddRailgunKills") -- primaryActive:SetAttributeValue("weapon spread bonus", 0) -- primaryActive:SetAttributeValue("fire rate penalty", 10) -- primaryActive:SetAttributeValue("can headshot", 1) -- primaryActive:SetAttributeValue("damage bonus HIDDEN", ChargeCap / 12.25) -- primaryActive:SetAttributeValue("fire input on hit", nil) -- end end, 0) RailgunUlitmateTimeActive = timer.Create(1, function () RailgunUltCountCharge = RailgunUltCountCharge - 7.5 if RailgunUltCountCharge <= 0 then timer.Stop(RailgunUlitmateActive) timer.Stop(RailgunUlitmateTimeActive) RailgunUltCountCharge = 0 end end, 0) end local RailUltimateCallbacks = activator:AddCallback(ON_KEY_RELEASED, function(user3, key3) if not IsValid(activator) or key3 ~= IN_DUCK or not user3:IsAlive() or not activator:IsAlive() or not IsValid(primaryActive) then return end if activator.m_hActiveWeapon ~= primaryActive then return end if key3 == IN_DUCK and RailgunUltCountCharge == 100 then ActivateUltimate() end end) --RAILGUN ABILITY LOGIC local isSlideReadyTime = 0 local IsAbilityReeady = true SlideHudText = { channel = 5, --Channel number 0 - 5, -- Channel 0 is used to display wave explanation, -- Channel 1 is used to display cash in reverse mvm, x = -0.2, -- X coordinate from 0 to 1, -- -1 for center positon, -- Text is wrapped so it does not overflow the screen y = 0.85, -- Y coordinate from 0 to 1, -- -1 for center positonText is wrapped so it does not overflow the screen effect = 0, -- 0,1 - fade in/fade out text, -- 2 - typeout text r1 = 124, -- 0 - 255 range, -- The text is rendered additively, black text will not display r2 = 43, -- 0 - 255 range, -- The text is rendered additively, black text will not display g1 = 134, -- 0 - 255 range, -- The text is rendered additively, black text will not display g2 = 98, -- 0 - 255 range, -- The text is rendered additively, black text will not display b1 = 135, -- 0 - 255 range, -- The text is rendered additively, black text will not display b2 = 16, -- 0 - 255 range, -- The text is rendered additively, black text will not display a1 = 0, -- 0 - 255 range, -- 0 - fully visible, 255 - invisible a2 = 0, -- 0 - 255 range, -- 0 - fully visible, 255 - invisible fadeinTime = 0, -- Time to fade in text fadeoutTime = 0, -- Time to fade out text holdTime = 9999, -- Time the text is fully displayed fxTime = 0, -- Time to type a single letter with typeout effect } local RailAbilityCallback = activator:AddCallback(ON_KEY_RELEASED, function(user4, key4) if not IsValid(activator) or key4 ~= IN_ATTACK3 or not user4:IsAlive() or not activator:IsAlive() or not IsValid(primaryActive) then return end if activator.m_hActiveWeapon ~= primaryActive then return end local slideTotalX = activator.m_vecVelocity[1] local slideTotalY = activator.m_vecVelocity[2] local slideTotalZ = activator.m_vecVelocity[3] local slide = Vector(slideTotalX * 2, slideTotalY * 2, slideTotalZ * 2) if key4 == IN_ATTACK3 and IsAbilityReeady == true then IsAbilityReeady = false isSlideReadyTime = 8 activator:AddCond(51) activator:AddCond(64) activator:SetAttributeValue("no_attack", 1) activator:SetAttributeValue("ignored by enemy sentries", 1) activator:SetAttributeValue("ignored by bots", 1) VeloctiyTimer = timer.Create(0.005, function () activator:SetLocalVelocity(slide) end, 5) end end) SlideHudTimer = timer.Create(0.015, function () if activator.m_iClass == 2 then activator:ShowHudText(SlideHudText, "Dash cooldown: "..isSlideReadyTime) end end, 0) AbilityIsReady = timer.Create(1, function () isSlideReadyTime = isSlideReadyTime - 1 if isSlideReadyTime <= 5 then activator:RemoveCond(64) activator:RemoveCond(51) activator:SetAttributeValue("no_attack", nil) activator:SetAttributeValue("ignored by enemy sentries", nil) activator:SetAttributeValue("ignored by bots", nil) end if isSlideReadyTime <= 0 then IsAbilityReeady = true isSlideReadyTime = 0 end end, 0) -- function StealthModeActive() -- CannotUseStealth = false -- local StealthTime = 4 -- activator:AddCond(64) -- RailgunUlitmateTimeActive = timer.Create(1, function () -- StealthTime = StealthTime - 1 -- if StealthTime == 0 then -- activator:RemoveCond(64) -- isSlideReadyTime = 5 -- end -- end, 0) -- end end function OnWaveInit(wave) ReloadTimer = nil RailgunUlitmateActive = nil RailgunUlitmateTimeActive = nil AbilityIsReady = nil RailgunUlitmateCharge = nil ChargeCap = 0 end