Joe Rod
Discord: joerod1
Hi, i have seen this small system on some ots some years ago (i don't remember which one), maybe someone could find it useful
Ìt saves damage done for a specific combat type, of course is applied only to the monsters you register it (i.e. training monks)
Also there is a command to show damage of a specific combat name: !bestdamage combatname

to register to a monster:
data/scripts/creaturescripts/best_elemental_damage.lua
Ìt saves damage done for a specific combat type, of course is applied only to the monsters you register it (i.e. training monks)
Also there is a command to show damage of a specific combat name: !bestdamage combatname

to register to a monster:
XML:
<script>
<event name="BestElementalDamageHealthChange" />
</script>
data/scripts/creaturescripts/best_elemental_damage.lua
Lua:
local creatureevent = CreatureEvent("BestElementalDamageHealthChange")
local baseStorage = 505050
BestElementalDamage =
{
combatData =
{
[COMBAT_PHYSICALDAMAGE] = {name = 'physical',storage = baseStorage},
[COMBAT_ENERGYDAMAGE] = {name = 'energy',storage = baseStorage + 1},
[COMBAT_EARTHDAMAGE] = {name = 'earth',storage = baseStorage + 2},
[COMBAT_FIREDAMAGE] = {name = 'fire',storage = baseStorage + 3},
[COMBAT_ICEDAMAGE] = {name = 'ice',storage = baseStorage + 4},
[COMBAT_HOLYDAMAGE] = {name = 'holy',storage = baseStorage + 5},
[COMBAT_DEATHDAMAGE] = {name = 'death',storage = baseStorage + 6},
},
combatNames =
{
['physical'] = COMBAT_PHYSICALDAMAGE,
['energy'] = COMBAT_ENERGYDAMAGE,
['earth'] = COMBAT_EARTHDAMAGE,
['fire'] = COMBAT_FIREDAMAGE,
['ice'] = COMBAT_ICEDAMAGE,
['holy'] = COMBAT_HOLYDAMAGE,
['death'] = COMBAT_DEATHDAMAGE,
}
}
function BestElementalDamage:getDamage(player, combatType)
if (player) then
local data = self.combatData[combatType]
if (data) then
return player:getStorageValue(data.storage)
end
end
return 0
end
function BestElementalDamage:setDamage(player, combatType, damage)
if (player) then
local data = self.combatData[combatType]
if (data) then
player:setStorageValue(data.storage, damage)
end
end
end
function BestElementalDamage:checkDamage(player, combatType, damage)
if (player and self.combatData[combatType]) then
if (self:getDamage(player, combatType) < damage) then
local data = self.combatData[combatType]
local str = string.format('New %s damage [%d]!', data.name, damage)
player:say(str, TALKTYPE_MONSTER_SAY)
self:setDamage(player, combatType, damage)
end
end
end
function creatureevent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if (attacker and attacker:isPlayer()) then
BestElementalDamage:checkDamage(attacker, primaryType, primaryDamage)
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
creatureevent:register()
local talk = TalkAction("!bestdamage")
function talk.onSay(player, words, param)
if (BestElementalDamage.combatNames[param:lower()]) then
local combatType = BestElementalDamage.combatNames[param]
local str = string.format('Your best %s damage is %d.', param:lower(), BestElementalDamage:getDamage(player, combatType))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, str)
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'Invalid combat type name.')
end
return false
end
talk:separator(" ")
talk:register()