• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Item that deals 5% more

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
 
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.
 
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.
So like this?
Lua:
function onEquip(player, item, slot)  
    primaryDamage = primaryDamage * 1.05
    return true
end
 
Not tested.
Lua:
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
 
Last edited:
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
34412
 
Edited my post
Event onEquip not found. scripts/dmgRing.lua

<movevent event="Equip" itemid="1526" slot="ring" function="onEquipItem" script="dmgRing.lua" />
<movevent event="DeEquip" itemid="1526" slot="ring" function="onDeEquipItem" />

hmmm?
 
The script goes in creaturescripts folder.

creaturescripts.xml
XML:
<event type="healthchange" name="ringDamage" script="damage_ring.lua" />

login.lua
Lua:
player:registerEvent("ringDamage")
 
Did 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.
 
Did 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.
Yes i did
You must register that creature event on all monsters/players.
so player:registerEvent("ringDamage") is not enough? How do i need to register on all monsters/players
 
You have to add it to each monsters xml. Not sure if there is a method to add it to every monster yet.
Code:
<script>
    <event name="ringDamage"/>
</script>
 
You must check to make sure:
  1. Attacker exists (onHealthChange) fires when for example a player/monster takes field dmg. (this is already in your script btw)
  2. In this situation you must ensure that the attacker is a player (monsters cannot have a ring thus ring will be nil)
  3. Ensure the ring exists and is not nil.
 
You must check to make sure:
  1. Attacker exists (onHealthChange) fires when for example a player/monster takes field dmg. (this is already in your script btw)
  2. In this situation you must ensure that the attacker is a player (monsters cannot have a ring thus ring will be nil)
  3. Ensure the ring exists and is not nil.
You must check to make sure:
  1. Attacker exists (onHealthChange) fires when for example a player/monster takes field dmg. (this is already in your script btw)
  2. In this situation you must ensure that the attacker is a player (monsters cannot have a ring thus ring will be nil)
  3. Ensure the ring exists and is not nil.
All of them is already in.
you should check the ring also,
if ring then
what?
 
Back
Top