• 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-movement attribute

yoiker

Member
Joined
Jan 21, 2012
Messages
194
Solutions
1
Reaction score
9
Good morning to everyone from Venezuela. I make post because I need your help so that the slightest problem for it to an expert I can not solve and that's why I come to ask for your help.


The first problem is via movements . As you know well at least those attributes are to fire on stepping up the item not to harm the player nor acquire the status

Code:
    <item id="2647" name="plate legs">
        <attribute key="weight" value="5000" />
        <attribute key="armor" value="7" />
        <attribute key="suppressDrown" value="50" />
        <attribute key="suppressFire" value="100" />
        <attribute key="suppressPoison" value="100" />
        <attribute key="suppressEnergy" value="100" />
        <attribute key="slotType" value="legs" />
    </item>


But then to work I have to put it in movements.xml

Code:
 <movevent event="Equip" itemid="2647" slot="legs" function="onEquipItem" />
    <movevent event="DeEquip" itemid="2647" slot="legs" function="onDeEquipItem" />


Now the point is that I pass lua because I'm using a script with the same pants

Code:
<movevent event="Equip" itemid="2647" slot="legs" script="xxx.lua">
    </movevent>
<movevent event="DeEquip" itemid="2647" slot="legs" script="xxx.lua"/>


And it has stopped working the attribute that has items.xml (suppress)

I appreciate your time to see the post and respond.

And if you want to see the lua leave the message and posting :D
 
<movevent event="Equip" itemid="2647" slot="legs" function="onEquipItem" script="upgrade/epic legs.lua">
</movevent>
<movevent event="DeEquip" itemid="2647" slot="legs" function="onDeEquipItem" script="upgrade/epic legs.lua"/>

I just did and put my pants automatically closes
 
I finaly had time to take a closer look on it, here are the changes needed (tested and works)
actions.cpp
Code:
bool Action::loadFunction(const pugi::xml_attribute& attr)
to
Code:
bool Action::loadFunction(const pugi::xml_attribute& attr, bool isScripted)
{
   const char* functionName = attr.as_string();
   if (strcasecmp(functionName, "increaseitemid") == 0) {
     function = increaseItemId;
   } else if (strcasecmp(functionName, "decreaseitemid") == 0) {
     function = decreaseItemId;
   } else if (strcasecmp(functionName, "market") == 0) {
     function = enterMarket;
   } else {
     if (!isScripted) {
       std::cout << "[Warning - Action::loadFunction] Function \"" << functionName << "\" does not exist." << std::endl;
       return false;
     }
   }

   if (!isScripted) {
     scripted = false;
   }
   return true;
}
actions.h
Code:
bool loadFunction(const pugi::xml_attribute& attr) override;
to
Code:
bool loadFunction(const pugi::xml_attribute& attr, bool isScripted) override;
baseevents.cpp
Code:
bool BaseEvents::loadFromXml()
to
Code:
bool BaseEvents::loadFromXml()
{
   if (loaded) {
     std::cout << "[Error - BaseEvents::loadFromXml] It's already loaded." << std::endl;
     return false;
   }

   std::string scriptsName = getScriptBaseName();
   std::string basePath = "data/" + scriptsName + "/";
   if (getScriptInterface().loadFile(basePath + "lib/" + scriptsName + ".lua") == -1) {
     std::cout << "[Warning - BaseEvents::loadFromXml] Can not load " << scriptsName << " lib/" << scriptsName << ".lua" << std::endl;
   }

   std::string filename = basePath + scriptsName + ".xml";

   pugi::xml_document doc;
   pugi::xml_parse_result result = doc.load_file(filename.c_str());
   if (!result) {
     printXMLError("Error - BaseEvents::loadFromXml", filename, result);
     return false;
   }

   loaded = true;

   for (auto node : doc.child(scriptsName.c_str()).children()) {
     Event* event = getEvent(node.name());
     if (!event) {
       continue;
     }

     if (!event->configureEvent(node)) {
       std::cout << "[Warning - BaseEvents::loadFromXml] Failed to configure event" << std::endl;
       delete event;
       continue;
     }

     bool success;

     pugi::xml_attribute scriptAttribute = node.attribute("script");
     if (scriptAttribute) {
       std::string scriptFile = "scripts/" + std::string(scriptAttribute.as_string());
       success = event->checkScript(basePath, scriptsName, scriptFile) && event->loadScript(basePath + scriptFile);
       event->loadFunction(node.attribute("function"), true);
     } else {
       success = event->loadFunction(node.attribute("function"), false);
     }

     if (!success || !registerEvent(event, node)) {
       delete event;
     }
   }
   return true;
}
baseevents.h
Code:
virtual bool loadFunction(const pugi::xml_attribute&) {
       return false;
     }
to
Code:
virtual bool loadFunction(const pugi::xml_attribute&, bool) {
       return false;
     }
weapons.h
Code:
bool loadFunction(const pugi::xml_attribute&) final {
       return true;
     }
to
Code:
bool loadFunction(const pugi::xml_attribute&, bool) final {
       return true;
     }
spells.h (there are 3 loadfunctions in spells.h)
Code:
bool loadFunction(const pugi::xml_attribute& attr) override;
to
Code:
bool loadFunction(const pugi::xml_attribute& attr, bool isScripted) override;
spells.cpp
Code:
bool InstantSpell::loadFunction(const pugi::xml_attribute& attr)
to
Code:
bool InstantSpell::loadFunction(const pugi::xml_attribute& attr, bool isScripted)
{
   const char* functionName = attr.as_string();
   if (strcasecmp(functionName, "edithouseguest") == 0) {
     function = HouseGuestList;
   } else if (strcasecmp(functionName, "edithousesubowner") == 0) {
     function = HouseSubOwnerList;
   } else if (strcasecmp(functionName, "edithousedoor") == 0) {
     function = HouseDoorList;
   } else if (strcasecmp(functionName, "housekick") == 0) {
     function = HouseKick;
   } else if (strcasecmp(functionName, "searchplayer") == 0) {
     function = SearchPlayer;
   } else if (strcasecmp(functionName, "levitate") == 0) {
     function = Levitate;
   } else if (strcasecmp(functionName, "illusion") == 0) {
     function = Illusion;
   } else if (strcasecmp(functionName, "summonmonster") == 0) {
     function = SummonMonster;
   } else {
     if (!isScripted) {
       std::cout << "[Warning - InstantSpell::loadFunction] Function \"" << functionName << "\" does not exist." << std::endl;
       return false;
     }
   }

   if (!isScripted) {
     scripted = false;
   }
   return true;
}
Code:
bool ConjureSpell::loadFunction(const pugi::xml_attribute&)
to
Code:
bool ConjureSpell::loadFunction(const pugi::xml_attribute&, bool isScripted)
{
   if (isScripted) {
     scripted = false;
   }
   return true;
}
Code:
bool RuneSpell::loadFunction(const pugi::xml_attribute& attr)
to
Code:
bool RuneSpell::loadFunction(const pugi::xml_attribute& attr, bool isScripted)
{
   const char* functionName = attr.as_string();
   if (strcasecmp(functionName, "chameleon") == 0) {
     runeFunction = Illusion;
   } else if (strcasecmp(functionName, "convince") == 0) {
     runeFunction = Convince;
   } else {
     if (!isScripted) {
       std::cout << "[Warning - RuneSpell::loadFunction] Function \"" << functionName << "\" does not exist." << std::endl;
       return false;
     }
   }

   if (!isScripted) {
     scripted = false;
   }
   return true;
}
movement.h
Code:
bool loadFunction(const pugi::xml_attribute& attr) final;
to
Code:
bool loadFunction(const pugi::xml_attribute& attr, bool isScripted) final;
movement.cpp
Code:
bool MoveEvent::loadFunction(const pugi::xml_attribute& attr)
to
Code:
bool MoveEvent::loadFunction(const pugi::xml_attribute& attr, bool isScripted)
{
   const char* functionName = attr.as_string();
   if (strcasecmp(functionName, "onstepinfield") == 0) {
     stepFunction = StepInField;
   } else if (strcasecmp(functionName, "onstepoutfield") == 0) {
     stepFunction = StepOutField;
   } else if (strcasecmp(functionName, "onaddfield") == 0) {
     moveFunction = AddItemField;
   } else if (strcasecmp(functionName, "onremovefield") == 0) {
     moveFunction = RemoveItemField;
   } else if (strcasecmp(functionName, "onequipitem") == 0) {
     equipFunction = EquipItem;
   } else if (strcasecmp(functionName, "ondeequipitem") == 0) {
     equipFunction = DeEquipItem;
   } else {
     if (!isScripted) {
       std::cout << "[Warning - MoveEvent::loadFunction] Function \"" << functionName << "\" does not exist." << std::endl;
       return false;
     }
   }

   if (!isScripted) {
     scripted = false;
   }
   return true;
}
 
I have only one companion doubt the part you indicate that there are 3
bool loadFunction(const pugi::xml_attribute& attr)

Would something like that? The 3;

bool loadFunction(const pugi::xml_attribute& attr, bool isScripted) override;
bool loadFunction(const pugi::xml_attribute& attr, bool isScripted) final; < x2
 
sorry yea noticed while you wrote that 2x are final and one is an override
I just didn't wanted to bloat the post up anymore
 
I'm glad someone took time to help me be, and I appreciate the time you took even more...
Although my English is terrible I am grateful!!
 
Back
Top