local REPAIR_AMOUNT = 80 local MIN_METAL = 20 local lol = ents.FindByClass("worldspawn") -- worst hack ever??? local TF_TEAM_RED = 2 -- i swear TF_TEAM globals existed before the last rafmod update local PlayerManager = ents.FindByClass("tf_player_manager") precache.PrecacheParticle("healthgained_red_giant") precache.PrecacheParticle("healthgained_blu_giant") local function IsSameTeam(ent1, ent2) if ent1.m_iTeamNum == ent2.m_iTeamNum then return true end return false end local function TankHealParticle(tank) local OFFSET = Vector(0, 0, 220) local particleorigin = tank:GetAbsOrigin() + OFFSET -- if not red assume its the other team particle = "healthgained_blu_giant" if tank.m_iTeamNum == TF_TEAM_RED then particle = "healthgained_red_giant" end util.ParticleEffect(particle, particleorigin, nil, tank) end local tank_dmg_callback = function(tank, damageinfo) local atk = damageinfo.Attacker local wep = damageinfo.Weapon local oldhealth = tank.m_iHealth if IsSameTeam(atk, tank) then if wep ~= nil and wep:GetClassname() == "tf_weapon_wrench" and atk.m_iAmmo[TF_AMMO_METAL] >= MIN_METAL then local repairattribute = wep:GetAttributeValueByClass("mult_repair_value", 1) tank.m_iHealth = tank.m_iHealth + ((REPAIR_AMOUNT * repairattribute) + 1) --util.PrintToChatAll("whoa nothing broke!") tank:TakeDamage({ -- make the tank take 1 damage so the healthbar updates Damage = 1, Attacker = lol, Weapon = lol, }) if tank.m_iHealth > tank.m_iMaxHealth then tank.m_iHealth = tank.m_iMaxHealth --util.PrintToChatAll("the machine exceeded it's capacity and may it's power be within it's limits") end local newhealth = tank.m_iHealth if oldhealth < newhealth then TankHealParticle(tank) local healthgiven = newhealth - oldhealth local hudparams = { channel = 2, x = -1, y = 0.26, effect = 1, r1 = 0, g1 = 255, b1 = 0, a1 = 255, r2 = 0, holdTime = 0.5, fadeinTime = 0, fadeoutTime = 1.5, } timer.Simple(0.015, function() wep:AcceptInput("runscriptcode", "self.StopSound(`Weapon_Wrench.HitWorld`)") end) wep:PlaySound("Weapon_Wrench.HitBuilding_Success") atk:PlaySoundToSelf("Weapon_Wrench.HitBuilding_Success") atk:ShowHudText(hudparams, "+".. healthgiven) atk.m_iAmmo[TF_AMMO_METAL] = atk.m_iAmmo[TF_AMMO_METAL] - MIN_METAL --[[ NEVERMIND IT DOESNT FUCKING WORK -- give credit to the healer local index = atk:GetNetIndex() + 1 local healthgiven = newhealth - oldhealth PlayerManager.m_iHealing[index] = PlayerManager.m_iHealing[index] + healthgiven PlayerManager.m_iTotalScore[index] = PlayerManager.m_iTotalScore[index] + 1 ]] end end end end ents.AddCreateCallback("tank_boss", function(tank) tank:AddCallback(ON_DAMAGE_RECEIVED_PRE, tank_dmg_callback) end) ents.AddCreateCallback("obj_attachment_sapper", function(ent) util.PrintToChatAll("sap") timer.Simple(0.015, function() local bot = ent.m_hBuiltOnEntity if ent.m_iTeamNum == TEAM_BLUE and bot:IsPlayer() and bot.m_iTeamNum == TEAM_RED and bot:IsBot() and bot:InCond(12) then ents.FindByName("realtimer"):Trigger() ent:AddCallback(ON_REMOVE, function() ents.FindByName("realtimer"):CancelPending() end) end) end end) end