Hello, I have a small problem. I’m using a script in creaturescripts -> onHealthChange and onManaChange.
onHealth:
onMana:
The script is supposed to deal damage based on the monster’s level.
The problem is, for example: a monster hits for 2000 damage. When a player has 1000 mana and is using utamo vita, it should work like this: when the monster hits, it should take 1000 mana and 1000 HP from the player.
Right now it works like this: it only takes 1000 mana and that’s it. If I had 300 mana, it would only hit for 300 and wouldn’t take anything from HP.
How can I achieve the desired effect?
TFS 1.2
onHealth:
LUA:
if attacker and attacker:isMonster() then
local name = attacker:getName():lower()
local desc = attacker:getDescription():lower()
if desc:find("survival monster") and name:find("lv]") then
local monsterLevel = Survival.getMonsterLevelByName(attacker)
local percent = SurvivalConfig.settings.damagePerLevel
local multiplier = 1 + (monsterLevel * percent)
primaryDamage = math.floor(primaryDamage * multiplier)
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
end
onMana:
LUA:
if attacker and attacker:isMonster() then
local name = attacker:getName():lower()
local desc = attacker:getDescription():lower()
if desc:find("survival monster") and name:find("lv]") then
local monsterLevel = Survival.getMonsterLevelByName(attacker)
local percent = SurvivalConfig.settings.damagePerLevel
local multiplier = 1 + (monsterLevel * percent)
manaChange = math.floor(manaChange * multiplier)
return manaChange
end
end
The script is supposed to deal damage based on the monster’s level.
The problem is, for example: a monster hits for 2000 damage. When a player has 1000 mana and is using utamo vita, it should work like this: when the monster hits, it should take 1000 mana and 1000 HP from the player.
Right now it works like this: it only takes 1000 mana and that’s it. If I had 300 mana, it would only hit for 300 and wouldn’t take anything from HP.
How can I achieve the desired effect?
TFS 1.2
