• 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 item with stats + movement.xml script TFS 1.2

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
746
Solutions
9
Reaction score
125
Hello everyone and thanks for your time!

Well, i've been messing around with some custom items i'm doing and i've seen this problem.

if I use something like this:

Code:
  <item id="24855" article="a" name="Magma Rainment Vision">
    <attribute key="weight" value="3500" />
    <attribute key="armor" value="10" />
    <attribute key="magiclevelpoints" value="5" />
    <attribute key="slotType" value="head" />
    <attribute key="absorbPercentFire" value="5" />
    <attribute key="absorbPercentIce" value="-5" />
    <attribute key="showattributes" value="1" />   
  </item>

and i do this on movements.xml:

Code:
  <movevent event="Equip" itemid="24855" slot="head" function="onEquipItem" script="config.lua">
    <vocation name="Wizard" />
    <vocation name="Sage Wizard" showInDescription="0" />
  </movevent>
  <movevent event="DeEquip" itemid="24855" slot="head" function="onDeEquipItem" script="config.lua"/>

The item won't give magiclevelpoints :/
but, if i use it like this:

Code:
  <movevent event="Equip" itemid="24855" slot="head" function="onEquipItem">
    <vocation name="Wizard" />
    <vocation name="Sage Wizard" showInDescription="0" />
  </movevent>
  <movevent event="DeEquip" itemid="24855" slot="head" function="onDeEquipItem"/>

It works perfectly. So why using a script on an item mess it up?

Is there a way to work around this to make it work? Thanks to everyone!

~Aeronx TLKserver
 
The script overrides the attributes of item, the work around is apply a condition to the item, I helped @Codex NG write his magical items library, i am not going to tell you to learn to code because I know you won't so that is a waste of time but I will tell you if you did know how to code you could apply his library to your equipment without issue.
 
movements.cpp
Code:
uint32_t MoveEvent::fireEquip(Player* player, Item* item, slots_t slot, bool boolean)
{
   if (scripted) {
     return executeEquip(player, item, slot);
   } else {
     return equipFunction(this, player, item, slot, boolean);
   }
}
to
Code:
uint32_t MoveEvent::fireEquip(Player* player, Item* item, slots_t slot, bool boolean)
{
   if (!executeEquip(player, item, slot)) {
     return false;
   }
   if (!equipFunction(this, player, item, slot, boolean)) {
     return false;
   }
   return true;
}
This is experimental can't tell for sure if this doesn't bring up bugs, so please test it before using it on a live server.
 
Another quick question regarding this matter..

Having an actionid on a weapon to do X, will be overrided by the script in movements?

(Im not at home and i cant test it xD)
 
Back
Top