local INTENSITY_FACTOR = 0.5 local MAXIMUM_INTENSITY = 750 local INTENSITY_VALUE_CALM = 0 local INTENSITY_VALUE_LOW = 1 local INTENSITY_VALUE_HIGH = 2 local INTENSITY_VALUE_PEAK = 3 local INTENSITY_DECAY_RATE = 10 local INTENSITY_CHANGE_RELAX = 0 local INTENSITY_CHANGE_RISE = 0 local function GetPlayerIntensityValue(player) if player.intensity >= 75 and player.intensity < 250 then return INTENSITY_VALUE_LOW elseif player.intensity >= 250 and player.intensity < 500 then return INTENSITY_VALUE_HIGH elseif player.intensity >= 500 and player.intensity then return INTENSITY_VALUE_PEAK end return INTENSITY_VALUE_CALM end local messages = { "Taking it slow", "Small encounter", "Actively fighting", "YEAAAA", } function check(_, activator) local tension = GetPlayerIntensityValue(activator) local msg = messages[tension + 1] util.PrintToChatAll(msg) end function OnPlayerConnected(player) player.intensity = 0 player.intensitystate = INTENSITY_CHANGE_RELAX if player:IsBot() then player:AddCallback(ON_DAMAGE_RECEIVED_POST, function(_, damageinfo) local dmg = math.floor(damageinfo.Damage) local attacker = damageinfo.Attacker attacker.intensity = attacker.intensity + (dmg * INTENSITY_FACTOR) if attacker.intensity > MAXIMUM_INTENSITY then attacker.intensity = MAXIMUM_INTENSITY end end) return end player:AddCallback(ON_DAMAGE_RECEIVED_POST, function(_, damageinfo) local taken local dmg = math.floor(damageinfo.Damage) player.intensity = player.intensity + (dmg * INTENSITY_FACTOR) if player.intensity > MAXIMUM_INTENSITY then player.intensity = MAXIMUM_INTENSITY end end) timer.Create(0.25, function() if not IsValid(player) then return false end if player.intensity > 0 then player.intensity = player.intensity - INTENSITY_DECAY_RATE if player.intensity < 0 then player.intensity = 0 end end player:Print(PRINT_TARGET_CENTER, player.intensity) end, 0) player:AddCallback(ON_SPAWN, function() player.intensity = 0 end) player:AddCallback(ON_DEATH, function() player.intensity = 0 end) end