I tried make it in a better way to configure it so that the damage is changed according to the type of attack...
I think had a result + -, if someone is available to make it safe and better
based
I think had a result + -, if someone is available to make it safe and better
based
CreatureEvent - [TFS 1.3] Vocations Balancing [Easiest Way]
Had to write this code for my server because when player PVP they die faster than they should, so i gave players protection through this code depending on their vocation, so this code won't work verses monsters only players, you can easily change it by removing the if function i will show you it...
otland.net
Lua:
local ElementProtect = {
[COMBAT_FIREDAMAGE] = 5,
[COMBAT_ICEDAMAGE] = 5,
[COMBAT_DEATHDAMAGE] = 5,
[COMBAT_ENERGYDAMAGE] = 5,
[COMBAT_EARTHDAMAGE] = 5,
[COMBAT_HOLYDAMAGE] = 5,
[COMBAT_PHYSICALDAMAGE] = 2,
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature or not attacker or creature == attacker then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if creature:isPlayer() and creature:getParty() and attacker:isPlayer() and attacker:getParty() then
if creature:getParty() == attacker:getParty() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
end
if creature:isPlayer() and attacker:isPlayer() then -- remove attacker:isPlayer() to affect monsters fights
primaryDamage = math.floor(primaryDamage - (primaryDamage * 0.20)) -- for EK and pallies when they switch to HP
secondaryDamage = math.floor(secondaryDamage - (secondaryDamage * 0.20)) -- for EK and pallies when they switch to HP
local damage = (primaryDamage + secondaryDamage)
if damage < 0 then
damage = damage * -1
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature or not attacker or creature == attacker then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if creature:isPlayer() and creature:getParty() and attacker:isPlayer() and attacker:getParty() then
if creature:getParty() == attacker:getParty() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
end
-- local protect = 0
-- for i = 1, #ElementProtect do
protect = ElementProtect[primaryType]
-- end
print(ElementProtect[primaryType])
if creature:isPlayer() and attacker:isPlayer() then
if creature:getVocation():getId() == 3 or creature:getVocation():getId() == 7 then
primaryDamage = math.floor(primaryDamage - (primaryDamage * 0.07)) -- PALLIES on MP
secondaryDamage = math.floor(secondaryDamage - (secondaryDamage * 0.07)) -- PALLIES on MP
else
primaryDamage = primaryDamage-((primaryDamage * protect)/100) -- MAGES (SORC/DRUID)
secondaryDamage = secondaryDamage-((secondaryDamage * protect)/100) -- MAGES (SORC/DRUID)
end
local damage = (primaryDamage + secondaryDamage)
if damage < 0 then
damage = damage * -1
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Last edited: