Lopaskurwa
Active Member
- Joined
- Oct 6, 2017
- Messages
- 873
- Solutions
- 2
- Reaction score
- 49
Hello,
how to make that ring deals 5% more COMBAT_ENERGYDAMAGE
TFS 1.2
how to make that ring deals 5% more COMBAT_ENERGYDAMAGE
TFS 1.2
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
primaryDamage = primaryDamage * 1.05
So like this?Not sure if that version has the old attribute for energy damage, if not you can always do it via LUA using onHealthChange creature event.
Code:function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
All you would have to do is check the attackers ring slot item and the primaryType, if they match the ring id and damage type that you want then do
Code:primaryDamage = primaryDamage * 1.05
If you also want it to scale the secondary element (for example if you have an energy sword that deals 50% physical and 50% energy, then also do this for secondaryDamage/secondaryType.
function onEquip(player, item, slot)
primaryDamage = primaryDamage * 1.05
return true
end
local specialRings = {2123, 2124}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not attacker then return true end
local ring = attacker:getSlotItem(CONST_SLOT_RING)
if creature then
if primaryType == COMBAT_ENERGYDAMAGE then
if table.contains(specialRings, ring.itemid) then
primaryDamage = primaryDamage * 1.05
print("> Dealing extra damage")
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Not tested.
Lua:local specialRings = {2123, 2124} function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) if not attacker then return true local ring = attacker:getSlotItem(CONST_SLOT_RING) if creature then if primaryType == COMBAT_ENERGYDAMAGE then if table.contains(specialRings, ring.itemid) then primaryDamage = primaryDamage * 1.05 end end end return primaryDamage, primaryType, secondaryDamage, secondaryType end
Event onEquip not found. scripts/dmgRing.luaEdited my post
doesnt work.The script goes in creaturescripts folder.
creaturescripts.xml
XML:<event type="healthchange" name="ringDamage" script="damage_ring.lua" />
login.lua
Lua:player:registerEvent("ringDamage")
doesnt work and it doesnt print
No nothingAny console error?
local specialRings = {2123, 2124}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
print("This script is being executed")
if not attacker then return true end
local ring = attacker:getSlotItem(CONST_SLOT_RING)
if creature then
if primaryType == COMBAT_ENERGYDAMAGE then
if table.contains(specialRings, ring.itemid) then
primaryDamage = primaryDamage * 1.05
print("> Dealing extra damage")
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Yes i didDid you configure the ID of the ring? Maybe the event is not registered correctly.
Lua:local specialRings = {2123, 2124} function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) print("This script is being executed") if not attacker then return true end local ring = attacker:getSlotItem(CONST_SLOT_RING) if creature then if primaryType == COMBAT_ENERGYDAMAGE then if table.contains(specialRings, ring.itemid) then primaryDamage = primaryDamage * 1.05 print("> Dealing extra damage") end end end return primaryDamage, primaryType, secondaryDamage, secondaryType end
I added a print to make sure the script is being executed properly.
so player:registerEvent("ringDamage") is not enough? How do i need to register on all monsters/playersYou must register that creature event on all monsters/players.
You must check to make sure:
- Attacker exists (onHealthChange) fires when for example a player/monster takes field dmg. (this is already in your script btw)
- In this situation you must ensure that the attacker is a player (monsters cannot have a ring thus ring will be nil)
- Ensure the ring exists and is not nil.
All of them is already in.You must check to make sure:
- Attacker exists (onHealthChange) fires when for example a player/monster takes field dmg. (this is already in your script btw)
- In this situation you must ensure that the attacker is a player (monsters cannot have a ring thus ring will be nil)
- Ensure the ring exists and is not nil.
what?you should check the ring also,
if ring then