-- thanks therealscroob! function reprogKnife(damage, activator, caller) --if the caller is a giant or can't be backstabbed - give up local cannotBeBackstabbed = caller:GetAttributeValue("cannot be backstabbed") or 0 if caller.m_bIsMiniBoss == 1 or cannotBeBackstabbed > 0 then return end -- local durationUpgrade = ((activator:GetAttributeValue("throwable fire speed") or 1) - 1) * 5 -- print(durationUpgrade) -- local reprogDuration = 20 + durationUpgrade --this is not a good way to detect backstabs, but it will have to do. local spyLookDirection = activator["m_angEyeAngles[1]"] local callerLookDirection = caller["m_angEyeAngles[1]"] -- print(spyLookDirection) -- print(callerLookDirection) --if the target is not facing you, trigger the effect. Should be identical to actual backstab hit detection. if (callerLookDirection - spyLookDirection) < 90 or (callerLookDirection - spyLookDirection) > 270 then --reprogram caller for 20 seconds and say the attacker did it. caller:AddCond(43, 20, attacker) -- caller:AddCond(43, reprogDuration, attacker) --brief stun on success. more feedback caller:AddCond(71, 0.5, attacker) caller:SetAttributeValue("not solid to players", 1) caller:SetAttributeValue("cannot be teleported", 1) caller:SetAttributeValue("cannot be sapped", 1) caller:SetAttributeValue("crit mod disabled", 0) caller:SetAttributeValue("use robot voice", 1) caller:SetAttributeValue("patient overheal penalty", -5) caller:SetAttributeValue("health from packs decreased", 0) caller:SetAttributeValue("mult_health_fromhealers_penalty_active", 0.25) --timers do not make the script wait for them to end before continuing, both will be started --at the same time timer.Simple(5, function() if caller:IsAlive() == false then return end --make caller take friendly fire after 5 seconds caller:SetAttributeValue("receive friendly fire", 1) caller:SetAttributeValue("mult dmg friendly fire", 0) caller:SetAttributeValue("penetrate teammates", 1) end) --mark for death when only 3 seconds left + stun after reprogram wears off timer.Simple(17, function() -- timer.Simple(reprogDuration - 3, function() if caller:IsAlive() == false then return end caller:AddCond(30, 6, attacker) end) --purge friendly fire attribute after 20 seconds (reprog is removed by cond duration) timer.Simple(20, function() -- timer.Simple(reprogDuration, function() if caller:IsAlive() == false then return end caller:SetAttributeValue("receive friendly fire", 0) caller:SetAttributeValue("not solid to players", 0) caller:SetAttributeValue("cannot be teleported", 0) caller:SetAttributeValue("cannot be sapped", 0) caller:SetAttributeValue("patient overheal penalty", 1) caller:SetAttributeValue("mult dmg friendly fire", 1) caller:SetAttributeValue("penetrate teammates", 0) caller:SetAttributeValue("health from packs decreased", 1) caller:SetAttributeValue("mult_health_fromhealers_penalty_active", 1) --stun target when reprogram wears off caller:AddCond(71, 3, attacker) caller:SetAttributeValue("cannot be backstabbed", 1) --while stuned after getting reprogammed gain temporary backstab immunity timer.Simple(3, function() if caller:IsAlive() == false then return end caller:SetAttributeValue("cannot be backstabbed", 0) end) end) end --Zilloy was here end function testReprogKnife(damage, activator, caller) --if the caller is a giant, can't be backstabbed, same team or already reprogrammed - give up local cannotBeBackstabbed = caller:GetAttributeValue("cannot be backstabbed") or 0 local isMyTeammate = activator.m_iTeamNum == caller.m_iTeamNum --just in case if caller.m_bIsMiniBoss == 1 or cannotBeBackstabbed > 0 or isMyTeammate or caller:InCond(43) then return end --upgradeable reprogramming duration -- local durationUpgrade = ((activator:GetAttributeValue("throwable fire speed") or 1) - 1) * 5 -- print(durationUpgrade) -- local reprogDuration = 20 + durationUpgrade --this is not a good way to detect backstabs, but it will have to do. local spyLookDirection = activator["m_angEyeAngles[1]"] local callerLookDirection = caller["m_angEyeAngles[1]"] -- print(spyLookDirection) -- print(callerLookDirection) local lookDirectionCheck = callerLookDirection - spyLookDirection local isStunned = caller:InCond(71) or caller:InCond(50) --if the target is not facing you or stunned - trigger the effect. --Should be identical to actual backstab hit detection. if (lookDirectionCheck < 90) or (lookDirectionCheck > 270) or isStunned then --reprogram caller for 20 seconds and say the attacker did it. caller:AddCond(43, 20, attacker) -- caller:AddCond(43, reprogDuration, attacker) --play this sound when successfully reprogrammed a robot activator:PlaySoundToSelf("weapons\sapper_plant.wav") if isStunned then --if stunned - unstun, play special sound activator:PlaySoundToSelf("ambient\energy\spark5.wav") timer.Simple(1, function() if caller:IsAlive() == false then return end caller:RemoveCond(50) caller:RemoveCond(71) end) else --brief stun on success. caller:AddCond(71, 0.5, attacker) end caller:SetAttributeValue("not solid to players", 1) caller:SetAttributeValue("cannot be teleported", 1) caller:SetAttributeValue("cannot be sapped", 1) caller:SetAttributeValue("crit mod disabled", 0) caller:SetAttributeValue("use robot voice", 1) caller:SetAttributeValue("patient overheal penalty", -5) caller:SetAttributeValue("health from packs decreased", 0) caller:SetAttributeValue("mult_health_fromhealers_penalty_active", 0.25) caller:SetAttributeValue("force distribute currency on death", 1) caller:SetAttributeValue("collect currency on kill", 1) --make caller go mobber, unless it's a medic, sniper with SR or spy local callerPrimary = caller:GetPlayerItemBySlot(LOADOUT_POSITION_PRIMARY) local callerSecondary = caller:GetPlayerItemBySlot(LOADOUT_POSITION_SECONDARY) local callerMelee = caller:GetPlayerItemBySlot(LOADOUT_POSITION_MELEE) local returnCase = 0 caller:RunScriptCode("self.LeaveSquad()", caller) --change bot behaviour script --if holding medigun - do medic stuff if callerSecondary and caller.m_hActiveWeapon == callerSecondary and callerSecondary:GetClassname() == "tf_weapon_medigun" then callerSecondary.m_hHealingTarget = nil callerSecondary.m_bAttacking = 0 caller:AcceptInput("$botcommand", "$switch_action medic") caller:RunScriptCode("self.AddBotAttribute(1024)", caller) --IgnoreEnemies returnCase = 1 --if sniper: elseif caller.m_iClass == 2 then --if bowman or holds secondary - go mobber if (callerPrimary and callerPrimary:GetClassname() == "tf_weapon_compound_bow") or (callerSecondary and caller.m_hActiveWeapon == callerSecondary) then caller:AcceptInput("$botcommand", "$switch_action mobber") --if holds melee - wait 2 seconds elseif callerMelee and caller.m_hActiveWeapon == callerMelee then timer.Simple(2, function() --if holds melee - go mobber, else don't change if callerMelee and caller.m_hActiveWeapon == callerMelee then caller:AcceptInput("$botcommand", "$switch_action mobber") end end) else --don't change, but mark a special return case returnCase = 3 end --if spy - undisguise and make spy elseif caller.m_iClass == 8 then caller:RemoveCond(TF_COND_DISGUISED) caller:RemoveCond(TF_COND_DISGUISING) caller:AcceptInput("$botcommand", "$switch_action spy") returnCase = 2 --else just make mobber else caller:AcceptInput("$botcommand", "$switch_action mobber") end --if caller dies or unreprograms - cancel the script and undo the attributes local unReprogTimer unReprogTimer = timer.Create(0.05, function() if caller:IsAlive() == false or caller:InCond(43) == false then caller:SetAttributeValue("receive friendly fire", nil) caller:SetAttributeValue("mult dmg friendly fire", nil) caller:SetAttributeValue("penetrate teammates", nil) caller:SetAttributeValue("not solid to players", nil) caller:SetAttributeValue("cannot be teleported", nil) caller:SetAttributeValue("cannot be sapped", nil) caller:SetAttributeValue("crit mod disabled", nil) caller:SetAttributeValue("use robot voice", nil) caller:SetAttributeValue("patient overheal penalty", nil) caller:SetAttributeValue("health from packs decreased", nil) caller:SetAttributeValue("mult_health_fromhealers_penalty_active", nil) caller:SetAttributeValue("force distribute currency on death", nil) caller:SetAttributeValue("collect currency on kill", nil) if returnCase == 2 then caller:RemoveCond(TF_COND_DISGUISED) caller:RemoveCond(TF_COND_DISGUISING) caller:AcceptInput("$botcommand", "$switch_action default") elseif returnCase == 1 then caller:RunScriptCode("self.RemoveBotAttribute(1024)", caller) caller:AcceptInput("$botcommand", "$switch_action default") elseif returnCase == 0 then caller:AcceptInput("$botcommand", "$switch_action default") end --stun target when reprogram wears off --while stunned after getting reprogammed gain temporary backstab immunity if caller:IsAlive() then caller:AddCond(71, 3, attacker) caller:SetAttributeValue("cannot be backstabbed", 1) timer.Simple(3, function() if caller:IsAlive() == false then return end caller:SetAttributeValue("cannot be backstabbed", nil) end) end timer.Stop(unReprogTimer) timer.Stop(friendlyFireTimer) timer.Stop(markTimer) end end, 0) --make caller take friendly fire after 5 seconds local friendlyFireTimer friendlyFireTimer = timer.Create(5, function() caller:SetAttributeValue("receive friendly fire", 1) caller:SetAttributeValue("mult dmg friendly fire", 0) caller:SetAttributeValue("penetrate teammates", 1) end, 1) --mark for death when only 3 seconds left + stun after reprogram wears off local markTimer markTimer = timer.Create(17, function() -- markTimer = timer.Create(reprogDuration - 3, function() caller:AddCond(30, 6, attacker) end, 1) -- else --deal butterknife damage -- caller:TakeDamage() --need to figure this one out end --Zilloy was here end