• 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!

Lua Adding Magic Level to items [INGAME]

angelobodj

Lazy OT Researcher
Joined
Dec 24, 2009
Messages
107
Reaction score
3
Location
Spain
Well I was wondering if there is ANY way to add magic level to items directly from the game, the same way you can do:
Lua:
doItemSetAttribute(uid,"defense",1)

How could it be done to get the same effect that this code would cause if it existed?
Lua:
doItemSetAttribute(uid,"magiclevelpoints",1)

I've searched but I didn't find how to actually achieve this. I also see that in items sources there isn't any attribute related to Magic Level :(

How would you do it?

Thanks.
 
Knowing what TFS you use may help...

---

Considering items.xml uses this:

XML:
<attribute key="magicpoints" value="1"/>
Have you tried this?

Lua:
doItemSetAttribute(uid, "magicpoints", 1)
Lua:
doItemSetAttribute(uid, "magic", 1)
 
Last edited:
I've tried both but they don't work :/

I'm using 0.3.7 but yeah, it uses this on item.xml:
XML:
<attribute key="magicpoints" value="1" />
 
As @J.Dre said. You create a script with onEquip and onDeEquip ( or whatever it is, haven't scripted in a while ) and make it add +1 magic level when equip and -1 magic level when deequiping the item.

Or you could just fix your broken source..

OOOOOOR maybe you're not adding it to movements in the first place? If i remember correctly you have to add it in movements.xml for the attributes to work properly.
 
Hmmm... as I read somewhere, it can be added in sources to set "magiclevel" as an item attribute, but I have no idea on how to do it.

I also discovered that you can do it through combat conditions (as permanent buffs), but it looks too rudimentary to me.

I'm sure this can be done somehow, although I think best solution would be adding it as a new attribute to the items class.

Maybe one of these pro otlanders would have an idea on how to fix it? :) (In my opinion it should be a default attr in items :p)
 
Same problem here. I would want add extra mlvls for items like skull staff etc. But how add a new movement? I see that unequip and equip the same item are splitted between 2 others <movement> ;o If skull staff has 2436 ID, how I need to edit focus cape code (for example)?
Code:
    <movevent event="DeEquip" itemid="8870" slot="armor" function="onDeEquipItem"/>
    <movevent event="Equip" itemid="8871" slot="armor" function="onEquipItem"> <!-- FOCUS CAPE-->
        <vocation name="Sorcerer"/>
        <vocation name="Master Sorcerer" showInDescription="0"/>
        <vocation name="Druid"/>
        <vocation name="Elder Druid" showInDescription="0"/>
    </movevent>
   <movevent event="DeEquip" itemid="8871" slot="armor" function="onDeEquipItem"/> <!-- FOCUS CAPE-->
    <movevent event="Equip" itemid="8872" slot="armor" function="onEquipItem">
        <vocation name="Paladin"/>
        <vocation name="Royal Paladin" showInDescription="0"/>
    </movevent>

TFS 1.1
 
The onDe/EquipItem is a default value used by the server, you would need to change.
<movevent event="DeEquip" itemid="8870" slot="armor" function="onDeEquipItem"/>
<movevent event="Equip" itemid="8871" slot="armor" function="onEquipItem"> <!-- FOCUS CAPE-->
<vocation name="Sorcerer"/>
<vocation name="Master Sorcerer" showInDescription="0"/>
<vocation name="Druid"/>
<vocation name="Elder Druid" showInDescription="0"/>
</movevent>
to
<movevent event="DeEquip" itemid="8870" slot="armor" script="name of script" />
<movevent event="Equip" itemid="8871" slot="armor" script="name of script"> <!-- FOCUS CAPE-->

<vocation name="Sorcerer"/>
<vocation name="Master Sorcerer" showInDescription="0"/>
<vocation name="Druid"/>
<vocation name="Elder Druid" showInDescription="0"/>
</movevent>


Of course you would then need to write a script to do the things you want it to do.

Here is a base script.
Code:
function onEquip(player, item, slot)
    -- code goes here
    return true
end

function onDeEquip(player, item, slot)
    -- code goes here
    return true
end
 
Where is the file with this?
Code:
function onEquip(player, item, slot)
-- code goes here
return true
end

function onDeEquip(player, item, slot)
-- code goes here
return true
end

Could you give me an example on other item?
 
question if onEquip and deEquip works what will happen to player with redskull that loses item? will he keep magic level *yes i know this is old thread*
 
question if onEquip and deEquip works what will happen to player with redskull that loses item? will he keep magic level *yes i know this is old thread*
Haven't tested, but they kinda 'deEquip' when they drop the item, so, they won't keep the magic level.
 
Back
Top