Ir para conteúdo

NiCaDo

Novato
  • Total de itens

    4
  • Registro em

  • Última visita

Sobre NiCaDo

Informações

  • Forma que conheci o xTibia
    Otservs
  • Sou
    OT-Admin
  1. Base: PokeZr/otpokemon revolution (OpenSource) Quando tento compilar as sources do servidor mostra o seguinte erro Compiling project changes... -------- - Project Filename: C:\Users\micael\Documents\Projetos\serve teste\Base teste\sources\[SOURCE] PokeZR By Kyyah\dev-cpp\TheForgottenServer.dev - Compiler Name: TDM-GCC 4.9.2 64-bit Release Building makefile... -------- - Filename: C:\Users\micael\Documents\Projetos\serve teste\Base teste\sources\[SOURCE] PokeZR By Kyyah\dev-cpp\Makefile.win - Resource File: C:\Users\micael\Documents\Projetos\serve teste\Base teste\sources\[SOURCE] PokeZR By Kyyah\dev-cpp\obj\TheForgottenServer_private.res Processing makefile... -------- - Makefile Processor: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\mingw32-make.exe - Command: mingw32-make.exe -f "C:\Users\micael\Documents\Projetos\serve teste\Base teste\sources\[SOURCE] PokeZR By Kyyah\dev-cpp\Makefile.win" all g++.exe obj//actions.o obj//allocator.o obj//baseevents.o obj//beds.o obj//chat.o obj//combat.o obj//protocolold.o obj//condition.o obj//configmanager.o obj//connection.o obj//container.o obj//creature.o obj//creatureevent.o obj//cylinder.o obj//database.o obj//databasemysql.o obj//databasesqlite.o obj//depot.o obj//exception.o obj//fileloader.o obj//game.o obj//gui.o obj//house.o obj//housetile.o obj//inputbox.o obj//ioguild.o obj//iologindata.o obj//iomap.o obj//iomapserialize.o obj//item.o obj//items.o obj//luascript.o obj//mailbox.o obj//map.o obj//md5.o obj//monster.o obj//monsters.o obj//movement.o obj//networkmessage.o obj//npc.o obj//otserv.o obj//outfit.o obj//outputmessage.o obj//party.o obj//player.o obj//playerbox.o obj//position.o obj//protocol.o obj//protocolgame.o obj//protocollogin.o obj//quests.o obj//raids.o obj//rsa.o obj//scheduler.o obj//scriptmanager.o obj//server.o obj//sha1.o obj//spawn.o obj//spells.o obj//status.o obj//talkaction.o obj//tasks.o obj//teleport.o obj//textlogger.o obj//thing.o obj//tile.o obj//tools.o obj//trashholder.o obj//vocation.o obj//waitlist.o obj//weapons.o obj//ioban.o obj//globalevent.o obj//gameservers.o obj//databasemanager.o obj//admin.o obj//itemattributes.o obj//group.o obj//TheForgottenServer_private.res -o TheForgottenServer.exe -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc -mwindows -O2 -lboost_system -lgmp -llua5.1 -lmysql -lboost_regex -lsqlite3 -lwsock32 -lxml2 -lmysql -lws2_32 -s -lboost_filesystem -lboost_thread C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_system C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgmp C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llua5.1 C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmysql C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_regex C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsqlite3 C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lxml2 C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmysql C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_filesystem C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_thread collect2.exe: error: ld returned 1 exit status C:\Users\micael\Documents\Projetos\serve teste\Base teste\sources\[SOURCE] PokeZR By Kyyah\dev-cpp\Makefile.win:26: recipe for target 'TheForgottenServer.exe' failed mingw32-make.exe: *** [TheForgottenServer.exe] Error 1 Compilation results... -------- - Errors: 1 - Warnings: 0 - Compilation Time: 2,50s Obs: não alterei nada nas sources, tentei compilar para verificar se tinha algum erro pois quero adicionar Opcodes Arquivo Makefile.win Makefile.rar Ou Hastebin: https://hastebin.com/iqumawanew.makefile Scan: https://www.virustotal.com/gui/file/07925ebb2a084a1bf8eb77cd0f7318c362a53ae03aed78907ca05402cd1d9a3b/detection { não sei se e necessário }
  2. Erro em compilar sources sources luascript.h //////////////////////////////////////////////////////////////////////// // OpenTibia - an opensource roleplaying game //////////////////////////////////////////////////////////////////////// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////// #ifndef __LUASCRIPT__ #define __LUASCRIPT__ #include "otsystem.h" extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include "database.h" #include "position.h" enum LuaVariantType_t { VARIANT_NONE = 0, VARIANT_NUMBER, VARIANT_POSITION, VARIANT_TARGETPOSITION, VARIANT_STRING }; struct LuaVariant { LuaVariant() { type = VARIANT_NONE; text = ""; pos = PositionEx(); number = 0; } LuaVariantType_t type; std::string text; PositionEx pos; uint32_t number; }; class Game; class Thing; class LuaScriptInterface; class Creature; class Player; class Npc; class Item; class Container; class Combat; class CombatArea; class Condition; struct Outfit_t; class ScriptEnviroment { public: ScriptEnviroment(); virtual ~ScriptEnviroment(); static bool saveGameState(); static bool loadGameState(); bool getStorage(const uint32_t key, std::string& value) const; void setStorage(const uint32_t key, const std::string& value) {m_storageMap[key] = value;} void eraseStorage(const uint32_t key) {m_storageMap.erase(key);} int32_t getScriptId() {return m_scriptId;} void setScriptId(int32_t scriptId, LuaScriptInterface* interface) {m_scriptId = scriptId; m_interface = interface;} int32_t getCallbackId() {return m_callbackId;} bool setCallbackId(int32_t callbackId, LuaScriptInterface* interface); std::string getEventDesc() {return m_eventdesc;} void setEventDesc(const std::string& desc) {m_eventdesc = desc;} Position getRealPos() {return m_realPos;} void setRealPos(const Position& realPos) {m_realPos = realPos;} Npc* getNpc() const {return m_curNpc;} void setNpc(Npc* npc) {m_curNpc = npc;} static uint32_t addCombatArea(CombatArea* area); static CombatArea* getCombatArea(uint32_t areaId); static uint32_t addCombatObject(Combat* combat); static Combat* getCombatObject(uint32_t combatId); static uint32_t addConditionObject(Condition* condition); static Condition* getConditionObject(uint32_t conditionId); Thing* getThingByUID(uint32_t uid); Item* getItemByUID(uint32_t uid); Container* getContainerByUID(uint32_t uid); Creature* getCreatureByUID(uint32_t uid); Player* getPlayerByUID(uint32_t uid); uint32_t addThing(Thing* thing); void insertThing(uint32_t uid, Thing* thing); void removeThing(uint32_t uid); static void addTempItem(ScriptEnviroment* env, Item* item); static void removeTempItem(ScriptEnviroment* env, Item* item); static void removeTempItem(Item* item); DBResult* getResultByID(uint32_t id); uint32_t addResult(DBResult* res); bool removeResult(uint32_t id); static void addUniqueThing(Thing* thing); static void removeUniqueThing(Thing* thing); static uint32_t getLastConditionId() {return m_lastConditionId;} static uint32_t getLastCombatId() {return m_lastCombatId;} static uint32_t getLastAreaId() {return m_lastAreaId;} void setTimerEvent() {m_timerEvent = true;} void resetTimerEvent() {m_timerEvent = false;} LuaScriptInterface* getInterface() {return m_interface;} void getInfo(int32_t& scriptId, std::string& desc, LuaScriptInterface*& interface, int32_t& callbackId, bool& timerEvent); void reset(); void resetCallback() {m_callbackId = 0;} void streamVariant(std::stringstream& stream, const std::string& local, const LuaVariant& var); void streamThing(std::stringstream& stream, const std::string& local, Thing* thing, uint32_t id = 0); void streamPosition(std::stringstream& stream, const std::string& local, const PositionEx& position) {streamPosition(stream, local, position, position.stackpos);} void streamPosition(std::stringstream& stream, const std::string& local, const Position& position, uint32_t stackpos); void streamOutfit(std::stringstream& stream, const std::string& local, const Outfit_t& outfit); private: typedef std::map<uint64_t, Thing*> ThingMap; typedef std::vector<const LuaVariant*> VariantVector; typedef std::map<uint32_t, std::string> StorageMap; typedef std::map<uint32_t, CombatArea*> AreaMap; typedef std::map<uint32_t, Combat*> CombatMap; typedef std::map<uint32_t, Condition*> ConditionMap; typedef std::list<Item*> ItemList; typedef std::map<ScriptEnviroment*, ItemList> TempItemListMap; typedef std::map<uint32_t, DBResult*> DBResultMap; LuaScriptInterface* m_interface; int32_t m_scriptId, m_callbackId; std::string m_eventdesc; bool m_timerEvent; ThingMap m_localMap; DBResultMap m_tempResults; static TempItemListMap m_tempItems; static StorageMap m_storageMap; static ThingMap m_globalMap; static uint32_t m_lastAreaId; static AreaMap m_areaMap; static uint32_t m_lastCombatId; static CombatMap m_combatMap; static uint32_t m_lastConditionId; static ConditionMap m_conditionMap; int32_t m_lastUID; bool m_loaded; Position m_realPos; Npc* m_curNpc; }; enum ErrorCode_t { LUA_ERROR_PLAYER_NOT_FOUND, LUA_ERROR_MONSTER_NOT_FOUND, LUA_ERROR_NPC_NOT_FOUND, LUA_ERROR_CREATURE_NOT_FOUND, LUA_ERROR_ITEM_NOT_FOUND, LUA_ERROR_THING_NOT_FOUND, LUA_ERROR_TILE_NOT_FOUND, LUA_ERROR_HOUSE_NOT_FOUND, LUA_ERROR_COMBAT_NOT_FOUND, LUA_ERROR_CONDITION_NOT_FOUND, LUA_ERROR_AREA_NOT_FOUND, LUA_ERROR_CONTAINER_NOT_FOUND, LUA_ERROR_VARIANT_NOT_FOUND, LUA_ERROR_VARIANT_UNKNOWN, LUA_ERROR_SPELL_NOT_FOUND }; #define errorEx(a) error(__FUNCTION__, a) class LuaScriptInterface { public: LuaScriptInterface(std::string interfaceName); virtual ~LuaScriptInterface(); virtual bool initState(); bool reInitState(); static bool reserveEnv() { ++m_scriptEnvIndex; if(m_scriptEnvIndex > 20) { --m_scriptEnvIndex; return false; } return true; } static void releaseEnv() { if(m_scriptEnvIndex >= 0) { m_scriptEnv[m_scriptEnvIndex].reset(); --m_scriptEnvIndex; } } bool loadBuffer(const std::string& text, Npc* npc = NULL); bool loadFile(const std::string& file, Npc* npc = NULL); bool loadDirectory(const std::string& dir, Npc* npc = NULL); std::string getName() {return m_interfaceName;} std::string getScript(int32_t scriptId); std::string getLastError() const {return m_lastError;} int32_t getEvent(const std::string& eventName); lua_State* getState() {return m_luaState;} static ScriptEnviroment* getEnv() { assert(m_scriptEnvIndex >= 0 && m_scriptEnvIndex < 21); return &m_scriptEnv[m_scriptEnvIndex]; } bool pushFunction(int32_t functionId); bool callFunction(uint32_t params); static int32_t handleFunction(lua_State* L); void dumpStack(lua_State* L = NULL); //push/pop common structures static void pushThing(lua_State* L, Thing* thing, uint32_t id = 0); static void pushVariant(lua_State* L, const LuaVariant& var); static void pushPosition(lua_State* L, const PositionEx& position) {pushPosition(L, position, position.stackpos);} static void pushPosition(lua_State* L, const Position& position, uint32_t stackpos); static void pushOutfit(lua_State* L, const Outfit_t& outfit); static void pushCallback(lua_State* L, int32_t callback); static LuaVariant popVariant(lua_State* L); static void popPosition(lua_State* L, PositionEx& position); static void popPosition(lua_State* L, Position& position, uint32_t& stackpos); static bool popBoolean(lua_State* L); static int64_t popNumber(lua_State* L); static double popFloatNumber(lua_State* L); static std::string popString(lua_State* L); static int32_t popCallback(lua_State* L); static Outfit_t popOutfit(lua_State* L); static int64_t getField(lua_State* L, const char* key); static uint64_t getFieldUnsigned(lua_State* L, const char* key); static std::string getFieldString(lua_State* L, const char* key); static bool getFieldBool(lua_State* L, const char* key); static void setField(lua_State* L, const char* index, int32_t val); static void setField(lua_State* L, const char* index, const std::string& val); static void setFieldBool(lua_State* L, const char* index, bool val); static void setFieldFloat(lua_State* L, const char* index, double val); static void createTable(lua_State* L, const char* index); static void createTable(lua_State* L, const char* index, int32_t narr, int32_t nrec); static void createTable(lua_State* L, int32_t index); static void createTable(lua_State* L, int32_t index, int32_t narr, int32_t nrec); static void pushTable(lua_State* L); static std::string getGlobalString(lua_State* L, const std::string& _identifier, const std::string& _default = ""); static bool getGlobalBool(lua_State* L, const std::string& _identifier, bool _default = false); static int32_t getGlobalNumber(lua_State* L, const std::string& _identifier, const int32_t _default = 0); static double getGlobalDouble(lua_State* L, const std::string& _identifier, const double _default = 0); static void getValue(const std::string& key, lua_State* L, lua_State* _L); static void moveValue(lua_State* from, lua_State* to); static void error(const char* function, const std::string& desc); protected: virtual bool closeState(); static std::string getError(ErrorCode_t code); static bool getArea(lua_State* L, std::list<uint32_t>& list, uint32_t& rows); virtual void registerFunctions(); //lua functions static int32_t luaDoSendPlayerExtendedOpcode(lua_State* L); static int32_t luaDoRemoveItem(lua_State* L); static int32_t luaDoCreatureSetNick(lua_State* L); static int32_t luaDoFeedPlayer(lua_State* L); static int32_t luaDoPlayerSendCancel(lua_State* L); static int32_t luaDoSendDefaultCancel(lua_State* L); static int32_t luaGetSearchString(lua_State* L); static int32_t luaGetClosestFreeTile(lua_State* L); static int32_t luaDoTeleportThing(lua_State* L); static int32_t luaDoTransformItem(lua_State* L); static int32_t luaDoSendMagicEffect(lua_State* L); static int32_t luaDoSendAnimatedText(lua_State* L); static int32_t luaDoSendDistanceShoot(lua_State* L); static int32_t luaDoShowTextWindow(lua_State* L); static int32_t luaDoShowTextDialog(lua_State* L); static int32_t luaDoDecayItem(lua_State* L); static int32_t luaDoCreateItem(lua_State* L); static int32_t luaDoCreateItemEx(lua_State* L); static int32_t luaDoCreateTeleport(lua_State* L); static int32_t luaDoCreateMonster(lua_State* L); static int32_t luaDoCreateNpc(lua_State* L); static int32_t luaDoSummonMonster(lua_State* L); static int32_t luaDoConvinceCreature(lua_State* L); static int32_t luaGetMonsterTargetList(lua_State* L); static int32_t luaGetMonsterFriendList(lua_State* L); static int32_t luaDoMonsterSetTarget(lua_State* L); static int32_t luaDoMonsterChangeTarget(lua_State* L); static int32_t luaDoAddCondition(lua_State* L); static int32_t luaDoRemoveCondition(lua_State* L); static int32_t luaDoRemoveConditions(lua_State* L); static int32_t luaDoRemoveCreature(lua_State* L); static int32_t luaDoMoveCreature(lua_State* L); static int32_t luaDoCreatureSay(lua_State* L); static int32_t luaDoPlayerAddSkillTry(lua_State* L); static int32_t luaDoCreatureAddHealth(lua_State* L); static int32_t luaDoCreatureAddMana(lua_State* L); static int32_t luaSetCreatureMaxHealth(lua_State* L); static int32_t luaSetCreatureMaxMana(lua_State* L); static int32_t luaDoPlayerSetMaxCapacity(lua_State* L); static int32_t luaDoPlayerAddSpentMana(lua_State* L); static int32_t luaDoPlayerAddItem(lua_State* L); static int32_t luaDoPlayerAddItemEx(lua_State* L); static int32_t luaDoTileAddItemEx(lua_State* L); static int32_t luaDoAddContainerItemEx(lua_State* L); static int32_t luaDoRelocate(lua_State* L); static int32_t luaDoCleanTile(lua_State* L); static int32_t luaDoPlayerSendTextMessage(lua_State* L); static int32_t luaDoPlayerSendChannelMessage(lua_State* L); static int32_t luaDoPlayerSendToChannel(lua_State* L); static int32_t luaDoPlayerAddMoney(lua_State* L); static int32_t luaDoPlayerRemoveMoney(lua_State* L); static int32_t luaDoPlayerTransferMoneyTo(lua_State* L); static int32_t luaDoPlayerSetPzLocked(lua_State* L); static int32_t luaDoPlayerSetTown(lua_State* L); static int32_t luaDoPlayerSetVocation(lua_State* L); static int32_t luaDoPlayerRemoveItem(lua_State* L); static int32_t luaDoPlayerAddSoul(lua_State* L); static int32_t luaDoPlayerAddStamina(lua_State* L); static int32_t luaDoPlayerSetStamina(lua_State* L); static int32_t luaDoPlayerAddExperience(lua_State* L); static int32_t luaDoPlayerSetGuildId(lua_State* L); static int32_t luaDoPlayerSetGuildLevel(lua_State* L); static int32_t luaDoPlayerSetGuildNick(lua_State* L); static int32_t luaDoPlayerSetSex(lua_State* L); static int32_t luaDoPlayerSetIdleTime(lua_State* L); static int32_t luaGetPlayerIdleTime(lua_State* L); static int32_t luaDoSetCreatureLight(lua_State* L); static int32_t luaDoCreatureSetLookDir(lua_State* L); static int32_t luaGetCreatureHideHealth(lua_State* L); static int32_t luaDoCreatureSetHideHealth(lua_State* L); static int32_t luaGetCreatureSpeakType(lua_State* L); static int32_t luaDoCreatureSetSpeakType(lua_State* L); static int32_t luaGetCreatureSkullType(lua_State* L); static int32_t luaDoCreatureSetSkullType(lua_State* L); static int32_t luaGetPlayerSkullEnd(lua_State* L); static int32_t luaDoPlayerSetSkullEnd(lua_State* L); static int32_t luaDoPlayerSwitchSaving(lua_State* L); static int32_t luaDoPlayerSave(lua_State* L); static int32_t luaDoPlayerSendOutfitWindow(lua_State* L); static int32_t luaDoCreatureExecuteTalkAction(lua_State* L); static int32_t luaGetCreatureByName(lua_State* L); static int32_t luaGetPlayerByGUID(lua_State* L); static int32_t luamoveCreatureTo(lua_State* L); static int32_t luaGetPlayerByNameWildcard(lua_State* L); static int32_t luaGetPlayerGUIDByName(lua_State* L); static int32_t luaGetPlayerNameByGUID(lua_State* L); static int32_t luaGetPlayersByAccountId(lua_State* L); static int32_t luaGetAccountIdByName(lua_State* L); static int32_t luaGetAccountByName(lua_State* L); static int32_t luaGetAccountIdByAccount(lua_State* L); static int32_t luaGetAccountByAccountId(lua_State* L); static int32_t luaGetIpByName(lua_State* L); static int32_t luaGetPlayersByIp(lua_State* L); static int32_t luaIsIpBanished(lua_State* L); static int32_t luaIsPlayerBanished(lua_State* L); static int32_t luaIsAccountBanished(lua_State* L); static int32_t luaDoAddIpBanishment(lua_State* L); static int32_t luaDoAddPlayerBanishment(lua_State* L); static int32_t luaDoAddAccountBanishment(lua_State* L); static int32_t luaDoAddNotation(lua_State* L); static int32_t luaDoAddStatement(lua_State* L); static int32_t luaDoRemoveIpBanishment(lua_State* L); static int32_t luaDoRemovePlayerBanishment(lua_State* L); static int32_t luaDoRemoveAccountBanishment(lua_State* L); static int32_t luaDoRemoveNotations(lua_State* L); static int32_t luaDoRemoveStatements(lua_State* L); static int32_t luaGetNotationsCount(lua_State* L); static int32_t luaGetStatementsCount(lua_State* L); static int32_t luaGetBanData(lua_State* L); static int32_t luaGetBanReason(lua_State* L); static int32_t luaGetBanAction(lua_State* L); static int32_t luaGetBanList(lua_State* L); static int32_t luaGetPlayerRates(lua_State* L); static int32_t luaDoPlayerSetRate(lua_State* L); static int32_t luaDoCreatureSetDropLoot(lua_State* L); static int32_t luaGetPlayerLossPercent(lua_State* L); static int32_t luaDoPlayerSetLossPercent(lua_State* L); static int32_t luaDoPlayerSetLossSkill(lua_State* L); static int32_t luaGetPlayerLossSkill(lua_State* L); static int32_t luaGetThing(lua_State* L); static int32_t luaGetThingPosition(lua_State* L); static int32_t luaDoItemRaidUnref(lua_State* L); static int32_t luaHasItemProperty(lua_State* L); static int32_t luaGetThingFromPos(lua_State* L); static int32_t luaGetTileItemById(lua_State* L); static int32_t luaGetTileItemByType(lua_State* L); static int32_t luaGetTileThingByPos(lua_State* L); static int32_t luaGetTopCreature(lua_State* L); static int32_t luaGetTileInfo(lua_State* L); static int32_t luaDoTileQueryAdd(lua_State* L); static int32_t luaGetHouseInfo(lua_State* L); static int32_t luaGetHouseAccessList(lua_State* L); static int32_t luaGetHouseByPlayerGUID(lua_State* L); static int32_t luaGetHouseFromPos(lua_State* L); static int32_t luaSetHouseOwner(lua_State* L); static int32_t luaSetHouseAccessList(lua_State* L); static int32_t luaDoPlayerSetNameDescription(lua_State* L); static int32_t luaGetPlayerNameDescription(lua_State* L); static int32_t luaDoPlayerSetSpecialDescription(lua_State* L); static int32_t luaGetPlayerSpecialDescription(lua_State* L); static int32_t luaGetPlayerFood(lua_State* L); static int32_t luaGetPlayerAccess(lua_State* L); static int32_t luaGetPlayerGhostAccess(lua_State* L); static int32_t luaGetPlayerLevel(lua_State* L); static int32_t luaGetPlayerExperience(lua_State* L); static int32_t luaGetPlayerMagLevel(lua_State* L); static int32_t luaGetPlayerSpentMana(lua_State* L); static int32_t luaGetCreatureMana(lua_State* L); static int32_t luaGetCreatureMaxMana(lua_State* L); static int32_t luaGetCreatureHealth(lua_State* L); static int32_t luaOpenChannelDialog(lua_State* L); static int32_t luaGetCreatureMaxHealth(lua_State* L); static int32_t luaGetCreatureSpeed(lua_State* L); static int32_t luaGetCreatureBaseSpeed(lua_State* L); static int32_t luaGetCreatureTarget(lua_State* L); static int32_t luaGetCreatureLookDirection(lua_State* L); static int32_t luaGetPlayerSkillLevel(lua_State* L); static int32_t luaGetPlayerSkillTries(lua_State* L); static int32_t luaGetPlayerVocation(lua_State* L); static int32_t luaGetPlayerTown(lua_State* L); static int32_t luaGetPlayerItemCount(lua_State* L); static int32_t luaGetPlayerMoney(lua_State* L); static int32_t luaGetPlayerSoul(lua_State* L); static int32_t luaGetPlayerStamina(lua_State* L); static int32_t luaGetPlayerFreeCap(lua_State* L); static int32_t luaGetPlayerLight(lua_State* L); static int32_t luaGetPlayerSlotItem(lua_State* L); static int32_t luaGetPlayerWeapon(lua_State* L); static int32_t luaGetPlayerItemById(lua_State* L); static int32_t luaGetPlayerRequiredMana(lua_State* L); static int32_t luaGetPlayerRequiredSkillTries(lua_State* L); static int32_t luaGetPlayerIp(lua_State* L); static int32_t luaGetPlayerLastLoad(lua_State* L); static int32_t luaGetPlayerLastLogin(lua_State* L); static int32_t luaGetPlayerAccountManager(lua_State* L); static int32_t luaGetPlayerAccountId(lua_State* L); static int32_t luaGetPlayerAccount(lua_State* L); static int32_t luaGetPlayerDepotItems(lua_State* L); static int32_t luaGetPlayerGuildId(lua_State* L); static int32_t luaGetPlayerGuildName(lua_State* L); static int32_t luaGetPlayerGuildRank(lua_State* L); static int32_t luaGetPlayerGuildRankId(lua_State* L); static int32_t luaGetPlayerGuildLevel(lua_State* L); static int32_t luaGetPlayerGuildNick(lua_State* L); static int32_t luaGetPlayerSex(lua_State* L); static int32_t luaGetPlayerGUID(lua_State* L); static int32_t luaGetPlayerFlagValue(lua_State* L); static int32_t luaGetPlayerCustomFlagValue(lua_State* L); static int32_t luaGetCreatureCondition(lua_State* L); static int32_t luaHasPlayerClient(lua_State* L); static int32_t luaGetDepotId(lua_State* L); static int32_t luaGetVocationInfo(lua_State* L); static int32_t luaGetGroupInfo(lua_State* L); static int32_t luaGetMonsterInfo(lua_State* L); static int32_t luaGetPlayerPromotionLevel(lua_State* L); static int32_t luaDoPlayerSetPromotionLevel(lua_State* L); static int32_t luaGetPlayerGroupId(lua_State* L); static int32_t luaDoPlayerSetGroupId(lua_State* L); static int32_t luaDoPlayerLearnInstantSpell(lua_State* L); static int32_t luaDoPlayerUnlearnInstantSpell(lua_State* L); static int32_t luaGetPlayerLearnedInstantSpell(lua_State* L); static int32_t luaGetPlayerInstantSpellCount(lua_State* L); static int32_t luaGetPlayerInstantSpellInfo(lua_State* L); static int32_t luaGetInstantSpellInfo(lua_State* L); static int32_t luaGetPlayerPartner(lua_State* L); static int32_t luaDoPlayerSetPartner(lua_State* L); static int32_t luaGetPlayerParty(lua_State* L); static int32_t luaDoPlayerJoinParty(lua_State* L); static int32_t luaGetPartyMembers(lua_State* L); static int32_t luaGetCreatureStorage(lua_State* L); static int32_t luaDoCreatureSetStorage(lua_State* L); static int32_t luaDoPlayerAddBlessing(lua_State* L); static int32_t luaGetPlayerBlessing(lua_State* L); static int32_t luaGetStorage(lua_State* L); static int32_t luaDoSetStorage(lua_State* L); static int32_t luaDoPlayerAddOutfit(lua_State* L); static int32_t luaDoPlayerRemoveOutfit(lua_State* L); static int32_t luaDoPlayerAddOutfitId(lua_State* L); static int32_t luaDoPlayerRemoveOutfitId(lua_State* L); static int32_t luaCanPlayerWearOutfit(lua_State* L); static int32_t luaCanPlayerWearOutfitId(lua_State* L); static int32_t luaGetWorldType(lua_State* L); static int32_t luaSetWorldType(lua_State* L); static int32_t luaGetWorldTime(lua_State* L); static int32_t luaGetWorldLight(lua_State* L); static int32_t luaGetWorldCreatures(lua_State* L); static int32_t luaGetWorldUpTime(lua_State* L); static int32_t luaGetGuildId(lua_State* L); static int32_t luaGetGuildMotd(lua_State* L); static int32_t luaIsPlayerPzLocked(lua_State* L); static int32_t luaIsPlayerSaving(lua_State* L); static int32_t luaIsCreature(lua_State* L); static int32_t luaIsContainer(lua_State* L); static int32_t luaIsMovable(lua_State* L); static int32_t luaGetContainerSize(lua_State* L); static int32_t luaGetContainerCap(lua_State* L); static int32_t luaGetContainerItem(lua_State* L); static int32_t luaDoAddContainerItem(lua_State* L); static int32_t luaCreateCombatObject(lua_State* L); static int32_t luaCreateCombatArea(lua_State* L); static int32_t luaSetCombatArea(lua_State* L); static int32_t luaSetCombatCondition(lua_State* L); static int32_t luaSetCombatParam(lua_State* L); static int32_t luaCreateConditionObject(lua_State* L); static int32_t luaSetConditionParam(lua_State* L); static int32_t luaAddDamageCondition(lua_State* L); static int32_t luaAddOutfitCondition(lua_State* L); static int32_t luaSetCombatCallBack(lua_State* L); static int32_t luaSetCombatFormula(lua_State* L); static int32_t luaSetConditionFormula(lua_State* L); static int32_t luaDoCombat(lua_State* L); static int32_t luaDoCombatAreaHealth(lua_State* L); static int32_t luaDoTargetCombatHealth(lua_State* L); static int32_t luaDoCombatAreaMana(lua_State* L); static int32_t luaDoTargetCombatMana(lua_State* L); static int32_t luaDoCombatAreaCondition(lua_State* L); static int32_t luaDoTargetCombatCondition(lua_State* L); static int32_t luaDoCombatAreaDispel(lua_State* L); static int32_t luaDoTargetCombatDispel(lua_State* L); static int32_t luaDoChallengeCreature(lua_State* L); static int32_t luaNumberToVariant(lua_State* L); static int32_t luaStringToVariant(lua_State* L); static int32_t luaPositionToVariant(lua_State* L); static int32_t luaTargetPositionToVariant(lua_State* L); static int32_t luaVariantToNumber(lua_State* L); static int32_t luaVariantToString(lua_State* L); static int32_t luaVariantToPosition(lua_State* L); static int32_t luaDoChangeSpeed(lua_State* L); static int32_t luaGetExperienceStage(lua_State* L); static int32_t luaDoCreatureChangeOutfit(lua_State* L); static int32_t luaSetCreatureOutfit(lua_State* L); static int32_t luaGetCreatureOutfit(lua_State* L); static int32_t luaSetMonsterOutfit(lua_State* L); static int32_t luaSetItemOutfit(lua_State* L); static int32_t luaGetCreatureLastPosition(lua_State* L); static int32_t luaGetCreatureName(lua_State* L); static int32_t luaGetCreatureMaster(lua_State* L); static int32_t luaGetCreatureSummons(lua_State* L); static int32_t luaGetHighscoreString(lua_State* L); static int32_t luaIsSightClear(lua_State* L); static int32_t luaIsInArray(lua_State* L); static int32_t luaAddEvent(lua_State* L); static int32_t luaStopEvent(lua_State* L); static int32_t luaRegisterCreatureEvent(lua_State* L); static int32_t luaGetPlayerBalance(lua_State* L); static int32_t luaDoPlayerSetBalance(lua_State* L); static int32_t luaDoPlayerPopupFYI(lua_State* L); static int32_t luaDoPlayerSendTutorial(lua_State* L); static int32_t luaDoPlayerSendMailByName(lua_State* L); static int32_t luaDoPlayerAddMapMark(lua_State* L); static int32_t luaGetPlayerPremiumDays(lua_State* L); static int32_t luaDoPlayerAddPremiumDays(lua_State* L); static int32_t luaGetCreatureNoMove(lua_State* L); static int32_t luaDoCreatureSetNoMove(lua_State* L); static int32_t luaGetTownId(lua_State* L); static int32_t luaGetTownName(lua_State* L); static int32_t luaGetTownTemplePosition(lua_State* L); static int32_t luaGetTownHouses(lua_State* L); static int32_t luaGetSpectators(lua_State* L); static int32_t luaGetGameState(lua_State* L); static int32_t luaDoSetGameState(lua_State* L); static int32_t luaGetChannelUsers(lua_State* L); static int32_t luaDoPlayerOpenChannel(lua_State* L); static int32_t luaGetPlayersOnline(lua_State* L); static int32_t luaDoExecuteRaid(lua_State* L); static int32_t luaDoReloadInfo(lua_State* L); static int32_t luaDoSaveServer(lua_State* L); static int32_t luaDoCleanHouse(lua_State* L); static int32_t luaDoCleanMap(lua_State* L); static int32_t luaDoRefreshMap(lua_State* L); static int32_t luaDoUpdateHouseAuctions(lua_State* L); static int32_t luaGetItemIdByName(lua_State* L); static int32_t luaGetItemInfo(lua_State* L); static int32_t luaGetItemWeight(lua_State* L); static int32_t luaGetItemAttribute(lua_State* L); static int32_t luaDoItemSetAttribute(lua_State* L); static int32_t luaDoItemEraseAttribute(lua_State* L); static int32_t luaGetTalkActionList(lua_State* L); static int32_t luaGetExperienceStageList(lua_State* L); static int32_t luaGetWaypointList(lua_State* L); static int32_t luaGetWaypointPosition(lua_State* L); static int32_t luaDoWaypointAddTemporial(lua_State* L); static int32_t luaGetDataDir(lua_State* L); static int32_t luaGetLogsDir(lua_State* L); static int32_t luaGetConfigFile(lua_State* L); static int32_t luaGetConfigValue(lua_State* L); static int32_t luaGetModList(lua_State* L); static int32_t luaL_loadmodlib(lua_State* L); static int32_t luaL_domodlib(lua_State* L); static int32_t luaL_dodirectory(lua_State* L); static const luaL_Reg luaDatabaseTable[8]; static int32_t luaDatabaseExecute(lua_State* L); static int32_t luaDatabaseStoreQuery(lua_State* L); static int32_t luaDatabaseEscapeString(lua_State* L); static int32_t luaDatabaseEscapeBlob(lua_State* L); static int32_t luaDatabaseLastInsertId(lua_State* L); static int32_t luaDatabaseStringComparison(lua_State* L); static int32_t luaDatabaseUpdateLimiter(lua_State* L); static const luaL_Reg luaResultTable[7]; static int32_t luaResultGetDataInt(lua_State* L); static int32_t luaResultGetDataLong(lua_State* L); static int32_t luaResultGetDataString(lua_State* L); static int32_t luaResultGetDataStream(lua_State* L); static int32_t luaResultNext(lua_State* L); static int32_t luaResultFree(lua_State* L); static const luaL_Reg luaBitTable[13]; static int32_t luaBitNot(lua_State* L); static int32_t luaBitAnd(lua_State* L); static int32_t luaBitOr(lua_State* L); static int32_t luaBitXor(lua_State* L); static int32_t luaBitLeftShift(lua_State* L); static int32_t luaBitRightShift(lua_State* L); static int32_t luaBitUNot(lua_State* L); static int32_t luaBitUAnd(lua_State* L); static int32_t luaBitUOr(lua_State* L); static int32_t luaBitUXor(lua_State* L); static int32_t luaBitULeftShift(lua_State* L); static int32_t luaBitURightShift(lua_State* L); static const luaL_Reg luaStdTable[6]; static int32_t luaStdCout(lua_State* L); static int32_t luaStdCerr(lua_State* L); static int32_t luaStdClog(lua_State* L); static int32_t luaStdMD5(lua_State* L); static int32_t luaStdSHA1(lua_State* L); lua_State* m_luaState; std::string m_lastError; private: void executeTimer(uint32_t eventIndex); enum PlayerInfo_t { PlayerInfoFood, PlayerInfoAccess, PlayerInfoGhostAccess, PlayerInfoLevel, PlayerInfoExperience, PlayerInfoManaSpent, PlayerInfoVocation, PlayerInfoTown, PlayerInfoPromotionLevel, PlayerInfoSoul, PlayerInfoFreeCap, PlayerInfoGuildId, PlayerInfoGuildName, PlayerInfoGuildRankId, PlayerInfoGuildRank, PlayerInfoGuildLevel, PlayerInfoGuildNick, PlayerInfoGroupId, PlayerInfoGUID, PlayerInfoAccountId, PlayerInfoAccount, PlayerInfoPremiumDays, PlayerInfoBalance, PlayerInfoStamina, PlayerInfoLossSkill, PlayerInfoMarriage, PlayerInfoPzLock, PlayerInfoSaving, PlayerInfoIp, PlayerInfoSkullEnd, PlayerInfoOutfitWindow, PlayerInfoNameDescription, PlayerInfoSpecialDescription, PlayerInfoIdleTime, PlayerInfoClient, PlayerInfoLastLoad, PlayerInfoLastLogin, PlayerInfoAccountManager }; static int32_t internalGetPlayerInfo(lua_State* L, PlayerInfo_t info); int32_t m_runningEventId; uint32_t m_lastEventTimerId; std::string m_loadingFile, m_interfaceName; static ScriptEnviroment m_scriptEnv[21]; static int32_t m_scriptEnvIndex; //events information struct LuaTimerEvent { int32_t scriptId, function; std::list<int32_t> parameters; }; typedef std::map<uint32_t , LuaTimerEvent > LuaTimerEvents; LuaTimerEvents m_timerEvents; //script file cache typedef std::map<int32_t , std::string> ScriptsCache; ScriptsCache m_cacheFiles; }; #endif creatureevent.h //////////////////////////////////////////////////////////////////////// // OpenTibia - an opensource roleplaying game //////////////////////////////////////////////////////////////////////// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////// #ifndef __CREATUREEVENT__ #define __CREATUREEVENT__ #include "enums.h" #include "baseevents.h" #include "tile.h" enum CreatureEventType_t { CREATURE_EVENT_NONE, CREATURE_EVENT_LOGIN, CREATURE_EVENT_LOGOUT, CREATURE_EVENT_CHANNEL_JOIN, CREATURE_EVENT_CHANNEL_LEAVE, CREATURE_EVENT_ADVANCE, CREATURE_EVENT_LOOK, CREATURE_EVENT_DIRECTION, CREATURE_EVENT_OUTFIT, CREATURE_EVENT_MAIL_SEND, CREATURE_EVENT_MAIL_RECEIVE, CREATURE_EVENT_TRADE_REQUEST, CREATURE_EVENT_TRADE_ACCEPT, CREATURE_EVENT_TEXTEDIT, CREATURE_EVENT_REPORTBUG, CREATURE_EVENT_THINK, CREATURE_EVENT_STATSCHANGE, CREATURE_EVENT_COMBAT_AREA, CREATURE_EVENT_PUSH, CREATURE_EVENT_TARGET, CREATURE_EVENT_FOLLOW, CREATURE_EVENT_COMBAT, CREATURE_EVENT_ATTACK, CREATURE_EVENT_CAST, CREATURE_EVENT_KILL, CREATURE_EVENT_DEATH, CREATURE_EVENT_PREPAREDEATH, CREATURE_EVENT_EXTENDED_OPCODE, // otclient additional network opcodes CREATURE_EVENT_SPAWN, CREATURE_EVENT_EXTENDED_OPCODE // otclient additional network opcodes }; enum StatsChange_t { STATSCHANGE_HEALTHGAIN, STATSCHANGE_HEALTHLOSS, STATSCHANGE_MANAGAIN, STATSCHANGE_MANALOSS }; class CreatureEvent; class CreatureEvents : public BaseEvents { public: CreatureEvents(); virtual ~CreatureEvents(); // global events bool playerLogin(Player* player); bool playerLogout(Player* player, bool forceLogout); CreatureEvent* getEventByName(const std::string& name, bool forceLoaded = true); protected: virtual std::string getScriptBaseName() const {return "creaturescripts";} virtual void clear(); virtual Event* getEvent(const std::string& nodeName); virtual bool registerEvent(Event* event, xmlNodePtr p, bool override); virtual LuaScriptInterface& getInterface() {return m_interface;} LuaScriptInterface m_interface; //creature events typedef std::map<std::string, CreatureEvent*> CreatureEventList; CreatureEventList m_creatureEvents; }; struct DeathEntry; typedef std::vector<DeathEntry> DeathList; typedef std::map<uint32_t, Player*> UsersMap; class CreatureEvent : public Event { public: CreatureEvent(LuaScriptInterface* _interface); virtual ~CreatureEvent() {} virtual bool configureEvent(xmlNodePtr p); bool isLoaded() const {return m_isLoaded;} const std::string& getName() const {return m_eventName;} CreatureEventType_t getEventType() const {return m_type;} void copyEvent(CreatureEvent* creatureEvent); void clearEvent(); //scripting uint32_t executeLogin(Player* player); uint32_t executeLogout(Player* player, bool forceLogout); uint32_t executeChannelJoin(Player* player, uint16_t channelId, UsersMap usersMap); uint32_t executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap); uint32_t executeAdvance(Player* player, skills_t skill, uint32_t oldLevel, uint32_t newLevel); uint32_t executeLook(Player* player, Thing* thing, const Position& position, int16_t stackpos, int32_t lookDistance); uint32_t executeMailSend(Player* player, Player* receiver, Item* item, bool openBox); uint32_t executeMailReceive(Player* player, Player* sender, Item* item, bool openBox); uint32_t executeTradeRequest(Player* player, Player* target, Item* item); uint32_t executeTradeAccept(Player* player, Player* target, Item* item, Item* targetItem); uint32_t executeTextEdit(Player* player, Item* item, std::string newText); uint32_t executeReportBug(Player* player, std::string comment); uint32_t executeThink(Creature* creature, uint32_t interval); uint32_t executeDirection(Creature* creature, Direction old, Direction current); uint32_t executeOutfit(Creature* creature, const Outfit_t& old, const Outfit_t& current); uint32_t executeStatsChange(Creature* creature, Creature* attacker, StatsChange_t type, CombatType_t combat, int32_t value); uint32_t executeCombatArea(Creature* creature, Tile* tile, bool isAggressive); uint32_t executePush(Player* player, Creature* target); uint32_t executeTarget(Creature* creature, Creature* target); uint32_t executeFollow(Creature* creature, Creature* target); uint32_t executeCombat(Creature* creature, Creature* target); uint32_t executeAttack(Creature* creature, Creature* target); uint32_t executeCast(Creature* creature, Creature* target = NULL); uint32_t executeKill(Creature* creature, Creature* target, bool lastHit); uint32_t executeDeath(Creature* creature, Item* corpse, DeathList deathList); uint32_t executePrepareDeath(Creature* creature, DeathList deathList); uint32_t executeExtendedOpcode(Creature* creature, uint8_t opcode, const std::string& buffer); uint32_t executeOnSpawn(Creature* creature); // protected: virtual std::string getScriptEventName() const; virtual std::string getScriptEventParams() const; bool m_isLoaded; std::string m_eventName; CreatureEventType_t m_type; }; #endif creatureevent.cp //////////////////////////////////////////////////////////////////////// // OpenTibia - an opensource roleplaying game //////////////////////////////////////////////////////////////////////// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////// #include "otpch.h" #ifdef __DEBUG_LUASCRIPTS__ #include <sstream> #endif #include "creatureevent.h" #include "player.h" #include "tools.h" CreatureEvents::CreatureEvents(): m_interface("CreatureScript Interface") { m_interface.initState(); } CreatureEvents::~CreatureEvents() { CreatureEventList::iterator it; for(it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it) delete it->second; } void CreatureEvents::clear() { //clear creature events for(CreatureEventList::iterator it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it) it->second->clearEvent(); //clear lua state m_interface.reInitState(); } Event* CreatureEvents::getEvent(const std::string& nodeName) { std::string tmpNodeName = asLowerCaseString(nodeName); if(tmpNodeName == "event" || tmpNodeName == "creaturevent" || tmpNodeName == "creatureevent" || tmpNodeName == "creaturescript") return new CreatureEvent(&m_interface); return NULL; } bool CreatureEvents::registerEvent(Event* event, xmlNodePtr p, bool override) { CreatureEvent* creatureEvent = dynamic_cast<CreatureEvent*>(event); if(!creatureEvent) return false; if(creatureEvent->getEventType() == CREATURE_EVENT_NONE) { std::cout << "[Error - CreatureEvents::registerEvent] Trying to register event without type!" << std::endl; return false; uint32_t CreatureEvent::executeExtendedOpcode(Creature* creature, uint8_t opcode, const std::string& buffer) { //onExtendedOpcode (cid, opcode, buffer)if(m_interface->reserveEnv()){ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER){env->setRealPos(creature->getPosition()); std::stringstream scriptstream;scriptstream << "local cid = " << env->addThing(creature) << std::endl;scriptstream << "local opcode = " << (int)opcode << std::endl;scriptstream << "local buffer = " << buffer.c_str() << std::endl;scriptstream << m_scriptData;bool result = true; if(m_interface->loadBuffer(scriptstream.str())){lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true);}m_interface->releaseEnv(); return result;} else{#ifdef __DEBUG_LUASCRIPTS__char desc[35];sprintf(desc, "%s", player->getName().c_str()); env->setEvent(desc); #endifenv->setScriptId(m_scriptId, m_interface);env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId);lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, opcode);lua_pushlstring(L, buffer.c_str(), buffer.length()); bool result = m_interface->callFunction(3);m_interface->releaseEnv(); return result;}} else{std::cout << "[Error - CreatureEvent::executeRemoved] Call stack overflow." << std::endl; return 0;}} } if(CreatureEvent* oldEvent = getEventByName(creatureEvent->getName(), false)) { //if there was an event with the same type that is not loaded (happens when realoading), it is reused if(oldEvent->getEventType() == creatureEvent->getEventType() && (!oldEvent->isLoaded() || override)) oldEvent->copyEvent(creatureEvent); /*delete creatureEvent; return override;*/ return false; } //if not, register it normally m_creatureEvents[creatureEvent->getName()] = creatureEvent; return true; } CreatureEvent* CreatureEvents::getEventByName(const std::string& name, bool forceLoaded /*= true*/) { CreatureEventList::iterator it = m_creatureEvents.find(name); if(it != m_creatureEvents.end()) { if(!forceLoaded || it->second->isLoaded()) return it->second; } return NULL; } bool CreatureEvents::playerLogin(Player* player) { //fire global event if is registered bool result = true; for(CreatureEventList::iterator it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it) { if(it->second->getEventType() == CREATURE_EVENT_LOGIN && !it->second->executeLogin(player) && result) result = false; } return result; } bool CreatureEvents::playerLogout(Player* player, bool forceLogout) { //fire global event if is registered bool result = true; for(CreatureEventList::iterator it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it) { if(it->second->getEventType() == CREATURE_EVENT_LOGOUT && !it->second->executeLogout(player, forceLogout) && result) result = false; } return forceLogout || result; } ///////////////////////////////////// CreatureEvent::CreatureEvent(LuaScriptInterface* _interface): Event(_interface) { m_type = CREATURE_EVENT_NONE; m_isLoaded = false; } bool CreatureEvent::configureEvent(xmlNodePtr p) { std::string str; if(!readXMLString(p, "name", str)) { std::cout << "[Error - CreatureEvent::configureEvent] No name for creature event." << std::endl; return false; } m_eventName = str; if(!readXMLString(p, "type", str)) { std::cout << "[Error - CreatureEvent::configureEvent] No type for creature event." << std::endl; return false; } std::string tmpStr = asLowerCaseString(str); if(tmpStr == "login") m_type = CREATURE_EVENT_LOGIN; else if(tmpStr == "logout") m_type = CREATURE_EVENT_LOGOUT; else if(tmpStr == "joinchannel") m_type = CREATURE_EVENT_CHANNEL_JOIN; else if(tmpStr == "leavechannel") m_type = CREATURE_EVENT_CHANNEL_LEAVE; else if(tmpStr == "advance") m_type = CREATURE_EVENT_ADVANCE; else if(tmpStr == "sendmail") m_type = CREATURE_EVENT_MAIL_SEND; else if(tmpStr == "receivemail") m_type = CREATURE_EVENT_MAIL_RECEIVE; else if(tmpStr == "traderequest") m_type = CREATURE_EVENT_TRADE_REQUEST; else if(tmpStr == "tradeaccept") m_type = CREATURE_EVENT_TRADE_ACCEPT; else if(tmpStr == "textedit") m_type = CREATURE_EVENT_TEXTEDIT; else if(tmpStr == "reportbug") m_type = CREATURE_EVENT_REPORTBUG; else if(tmpStr == "look") m_type = CREATURE_EVENT_LOOK; else if(tmpStr == "think") m_type = CREATURE_EVENT_THINK; else if(tmpStr == "direction") m_type = CREATURE_EVENT_DIRECTION; else if(tmpStr == "outfit") m_type = CREATURE_EVENT_OUTFIT; else if(tmpStr == "statschange") m_type = CREATURE_EVENT_STATSCHANGE; else if(tmpStr == "areacombat") m_type = CREATURE_EVENT_COMBAT_AREA; else if(tmpStr == "push") m_type = CREATURE_EVENT_PUSH; else if(tmpStr == "target") m_type = CREATURE_EVENT_TARGET; else if(tmpStr == "follow") m_type = CREATURE_EVENT_FOLLOW; else if(tmpStr == "combat") m_type = CREATURE_EVENT_COMBAT; else if(tmpStr == "attack") m_type = CREATURE_EVENT_ATTACK; else if(tmpStr == "cast") m_type = CREATURE_EVENT_CAST; else if(tmpStr == "kill") m_type = CREATURE_EVENT_KILL; else if(tmpStr == "death") m_type = CREATURE_EVENT_DEATH; else if(tmpStr == "extendedopcode") m_type = CREATURE_EVENT_EXTENDED_OPCODE; else if(tmpStr == "preparedeath") m_type = CREATURE_EVENT_PREPAREDEATH; else if(tmpStr == "spawn") m_type = CREATURE_EVENT_SPAWN; else if(tmpStr == "extendedopcode") m_type = CREATURE_EVENT_EXTENDED_OPCODE; else { std::cout << "[Error - CreatureEvent::configureEvent] No valid type for creature event." << str << std::endl; return false; } m_isLoaded = true; return true; } std::string CreatureEvent::getScriptEventName() const { switch(m_type) { case CREATURE_EVENT_LOGIN: return "onLogin"; case CREATURE_EVENT_LOGOUT: return "onLogout"; case CREATURE_EVENT_CHANNEL_JOIN: return "onJoinChannel"; case CREATURE_EVENT_CHANNEL_LEAVE: return "onLeaveChannel"; case CREATURE_EVENT_THINK: return "onThink"; case CREATURE_EVENT_ADVANCE: return "onAdvance"; case CREATURE_EVENT_LOOK: return "onLook"; case CREATURE_EVENT_DIRECTION: return "onDirection"; case CREATURE_EVENT_OUTFIT: return "onOutfit"; case CREATURE_EVENT_MAIL_SEND: return "onSendMail"; case CREATURE_EVENT_MAIL_RECEIVE: return "onReceiveMail"; case CREATURE_EVENT_TRADE_REQUEST: return "onTradeRequest"; case CREATURE_EVENT_TRADE_ACCEPT: return "onTradeAccept"; case CREATURE_EVENT_TEXTEDIT: return "onTextEdit"; case CREATURE_EVENT_REPORTBUG: return "onReportBug"; case CREATURE_EVENT_STATSCHANGE: return "onStatsChange"; case CREATURE_EVENT_COMBAT_AREA: return "onAreaCombat"; case CREATURE_EVENT_PUSH: return "onPush"; case CREATURE_EVENT_TARGET: return "onTarget"; case CREATURE_EVENT_FOLLOW: return "onFollow"; case CREATURE_EVENT_COMBAT: return "onCombat"; case CREATURE_EVENT_ATTACK: return "onAttack"; case CREATURE_EVENT_CAST: return "onCast"; case CREATURE_EVENT_KILL: return "onKill"; case CREATURE_EVENT_DEATH: return "onDeath"; case CREATURE_EVENT_EXTENDED_OPCODE: return "onExtendedOpcode"; case CREATURE_EVENT_EXTENDED_OPCODE: return "onExtendedOpcode"; case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath"; case CREATURE_EVENT_SPAWN: return "onSpawn"; case CREATURE_EVENT_NONE: default: break; } return ""; } std::string CreatureEvent::getScriptEventParams() const { switch(m_type) { case CREATURE_EVENT_LOGIN: return "cid"; case CREATURE_EVENT_LOGOUT: return "cid, forceLogout"; case CREATURE_EVENT_CHANNEL_JOIN: case CREATURE_EVENT_CHANNEL_LEAVE: return "cid, channel, users"; case CREATURE_EVENT_ADVANCE: return "cid, skill, oldLevel, newLevel"; case CREATURE_EVENT_LOOK: return "cid, thing, position, lookDistance"; case CREATURE_EVENT_MAIL_SEND: return "cid, receiver, item, openBox"; case CREATURE_EVENT_MAIL_RECEIVE: return "cid, sender, item, openBox"; case CREATURE_EVENT_TRADE_REQUEST: case CREATURE_EVENT_TRADE_ACCEPT: return "cid, target, item"; case CREATURE_EVENT_TEXTEDIT: return "cid, item, newText"; case CREATURE_EVENT_REPORTBUG: return "cid, comment"; case CREATURE_EVENT_THINK: return "cid, interval"; case CREATURE_EVENT_DIRECTION: case CREATURE_EVENT_OUTFIT: return "cid, old, current"; case CREATURE_EVENT_STATSCHANGE: return "cid, attacker, type, combat, value"; case CREATURE_EVENT_COMBAT_AREA: return "cid, ground, position, aggressive"; case CREATURE_EVENT_PUSH: case CREATURE_EVENT_TARGET: case CREATURE_EVENT_FOLLOW: case CREATURE_EVENT_COMBAT: case CREATURE_EVENT_ATTACK: case CREATURE_EVENT_CAST: return "cid, target"; case CREATURE_EVENT_KILL: return "cid, target, lastHit"; case CREATURE_EVENT_DEATH: return "cid, corpse, deathList"; case CREATURE_EVENT_EXTENDED_OPCODE: return "cid, opcode, buffer"; case CREATURE_EVENT_EXTENDED_OPCODE: return "cid, opcode, buffer"; case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList"; case CREATURE_EVENT_SPAWN: return "cid"; case CREATURE_EVENT_NONE: default: break; } return ""; } void CreatureEvent::copyEvent(CreatureEvent* creatureEvent) { m_scriptId = creatureEvent->m_scriptId; m_interface = creatureEvent->m_interface; m_scripted = creatureEvent->m_scripted; m_isLoaded = creatureEvent->m_isLoaded; } void CreatureEvent::clearEvent() { m_scriptId = 0; m_interface = NULL; m_scripted = EVENT_SCRIPT_FALSE; m_isLoaded = false; } uint32_t CreatureEvent::executeLogin(Player* player) { //onLogin(cid) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); bool result = m_interface->callFunction(1); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeLogin] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeLogout(Player* player, bool forceLogout) { //onLogout(cid, forceLogout) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local forceLogout = " << (forceLogout ? "true" : "false") << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushboolean(L, forceLogout); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeLogout] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeChannelJoin(Player* player, uint16_t channelId, UsersMap usersMap) { //onJoinChannel(cid, channel, users) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local channel = " << channelId << std::endl; scriptstream << "local users = {}" << std::endl; for(UsersMap::iterator it = usersMap.begin(); it != usersMap.end(); ++it) scriptstream << "users:insert(" << env->addThing(it->second) << ")" << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, channelId); UsersMap::iterator it = usersMap.begin(); lua_newtable(L); for(int32_t i = 1; it != usersMap.end(); ++it, ++i) { lua_pushnumber(L, i); lua_pushnumber(L, env->addThing(it->second)); lua_settable(L, -3); } bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeChannelJoin] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap) { //onLeaveChannel(cid, channel, users) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local channel = " << channelId << std::endl; scriptstream << "local users = {}" << std::endl; for(UsersMap::iterator it = usersMap.begin(); it != usersMap.end(); ++it) scriptstream << "users:insert(" << env->addThing(it->second) << ")" << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, channelId); UsersMap::iterator it = usersMap.begin(); lua_newtable(L); for(int32_t i = 1; it != usersMap.end(); ++it, ++i) { lua_pushnumber(L, i); lua_pushnumber(L, env->addThing(it->second)); lua_settable(L, -3); } bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeChannelLeave] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeAdvance(Player* player, skills_t skill, uint32_t oldLevel, uint32_t newLevel) { //onAdvance(cid, skill, oldLevel, newLevel) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local skill = " << skill << std::endl; scriptstream << "local oldLevel = " << oldLevel << std::endl; scriptstream << "local newLevel = " << newLevel << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, (uint32_t)skill); lua_pushnumber(L, oldLevel); lua_pushnumber(L, newLevel); bool result = m_interface->callFunction(4); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeAdvance] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeMailSend(Player* player, Player* receiver, Item* item, bool openBox) { //onSendMail(cid, receiver, item, openBox) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local receiver = " << env->addThing(receiver) << std::endl; env->streamThing(scriptstream, "item", item, env->addThing(item)); scriptstream << "local openBox = " << (openBox ? "true" : "false") << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, env->addThing(receiver)); LuaScriptInterface::pushThing(L, item, env->addThing(item)); lua_pushboolean(L, openBox); bool result = m_interface->callFunction(4); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeMailSend] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeMailReceive(Player* player, Player* sender, Item* item, bool openBox) { //onReceiveMail(cid, sender, item, openBox) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local sender = " << env->addThing(sender) << std::endl; env->streamThing(scriptstream, "item", item, env->addThing(item)); scriptstream << "local openBox = " << (openBox ? "true" : "false") << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, env->addThing(sender)); LuaScriptInterface::pushThing(L, item, env->addThing(item)); lua_pushboolean(L, openBox); bool result = m_interface->callFunction(4); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeMailReceive] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeTradeRequest(Player* player, Player* target, Item* item) { //onTradeRequest(cid, target, item) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; env->streamThing(scriptstream, "item", item, env->addThing(item)); scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, env->addThing(target)); LuaScriptInterface::pushThing(L, item, env->addThing(item)); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeTradeRequest] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeTradeAccept(Player* player, Player* target, Item* item, Item* targetItem) { //onTradeAccept(cid, target, item, targetItem) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; env->streamThing(scriptstream, "item", item, env->addThing(item)); scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, env->addThing(target)); LuaScriptInterface::pushThing(L, item, env->addThing(item)); LuaScriptInterface::pushThing(L, targetItem, env->addThing(targetItem)); bool result = m_interface->callFunction(4); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeTradeAccept] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeLook(Player* player, Thing* thing, const Position& position, int16_t stackpos, int32_t lookDistance) { //onLook(cid, thing, position, lookDistance) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local thing = " << env->addThing(thing) << std::endl; env->streamPosition(scriptstream, "position", position, stackpos); scriptstream << "local lookDistance = " << lookDistance << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); LuaScriptInterface::pushThing(L, thing, env->addThing(thing)); LuaScriptInterface::pushPosition(L, position, stackpos); lua_pushnumber(L, lookDistance); bool result = m_interface->callFunction(4); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeLook] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeDirection(Creature* creature, Direction old, Direction current) { //onDirection(cid, old, current) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local old = " << old << std::endl; scriptstream << "local current = " << current << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, old); lua_pushnumber(L, current); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeDirection] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeOutfit(Creature* creature, const Outfit_t& old, const Outfit_t& current) { //onOutfit(cid, old, current) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; env->streamOutfit(scriptstream, "old", old); env->streamOutfit(scriptstream, "current", current); scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); LuaScriptInterface::pushOutfit(L, old); LuaScriptInterface::pushOutfit(L, current); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeOutfit] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeThink(Creature* creature, uint32_t interval) { //onThink(cid, interval) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local interval = " << interval << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, interval); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeThink] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeStatsChange(Creature* creature, Creature* attacker, StatsChange_t type, CombatType_t combat, int32_t value) { //onStatsChange(cid, attacker, type, combat, value) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local attacker = " << env->addThing(attacker) << std::endl; scriptstream << "local type = " << (uint32_t)type << std::endl; scriptstream << "local combat = " << (uint32_t)combat << std::endl; scriptstream << "local value = " << value << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(attacker)); lua_pushnumber(L, (uint32_t)type); lua_pushnumber(L, (uint32_t)combat); lua_pushnumber(L, value); bool result = m_interface->callFunction(5); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeStatsChange] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeCombatArea(Creature* creature, Tile* tile, bool aggressive) { //onAreaCombat(cid, ground, position, aggressive) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; env->streamThing(scriptstream, "ground", tile->ground, env->addThing(tile->ground)); env->streamPosition(scriptstream, "position", tile->getPosition(), 0); scriptstream << "local aggressive = " << (aggressive ? "true" : "false") << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); LuaScriptInterface::pushThing(L, tile->ground, env->addThing(tile->ground)); LuaScriptInterface::pushPosition(L, tile->getPosition(), 0); lua_pushboolean(L, aggressive); bool result = m_interface->callFunction(4); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeAreaCombat] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeCombat(Creature* creature, Creature* target) { //onCombat(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeCombat] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeAttack(Creature* creature, Creature* target) { //onAttack(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeAttack] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeCast(Creature* creature, Creature* target/* = NULL*/) { //onCast(cid[, target]) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = "; if(target) scriptstream << env->addThing(target); else scriptstream << "nil"; scriptstream << std::endl << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeCast] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeKill(Creature* creature, Creature* target, bool lastHit) { //onKill(cid, target, lastHit) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; scriptstream << "local lastHit = " << (lastHit ? "true" : "false") << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); lua_pushboolean(L, lastHit); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeKill] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeDeath(Creature* creature, Item* corpse, DeathList deathList) { //onDeath(cid, corpse, deathList) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; env->streamThing(scriptstream, "corpse", corpse, env->addThing(corpse)); scriptstream << "local deathList = {}" << std::endl; for(DeathList::iterator it = deathList.begin(); it != deathList.end(); ++it) { scriptstream << "deathList:insert("; if(it->isCreatureKill()) scriptstream << env->addThing(it->getKillerCreature()); else scriptstream << it->getKillerName(); scriptstream << ")" << std::endl; } scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); LuaScriptInterface::pushThing(L, corpse, env->addThing(corpse)); lua_newtable(L); DeathList::iterator it = deathList.begin(); for(int32_t i = 1; it != deathList.end(); ++it, ++i) { lua_pushnumber(L, i); if(it->isCreatureKill()) lua_pushnumber(L, env->addThing(it->getKillerCreature())); else lua_pushstring(L, it->getKillerName().c_str()); lua_settable(L, -3); } bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeDeath] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executePrepareDeath(Creature* creature, DeathList deathList) { //onPrepareDeath(cid, deathList) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local deathList = {}" << std::endl; for(DeathList::iterator it = deathList.begin(); it != deathList.end(); ++it) { scriptstream << "deathList:insert("; if(it->isCreatureKill()) scriptstream << env->addThing(it->getKillerCreature()); else scriptstream << it->getKillerName(); scriptstream << ")" << std::endl; } scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_newtable(L); DeathList::iterator it = deathList.begin(); for(int32_t i = 1; it != deathList.end(); ++it, ++i) { lua_pushnumber(L, i); if(it->isCreatureKill()) lua_pushnumber(L, env->addThing(it->getKillerCreature())); else lua_pushstring(L, it->getKillerName().c_str()); lua_settable(L, -3); } bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executePrepareDeath] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeTextEdit(Player* player, Item* item, std::string newText) { //onTextEdit(cid, item, newText) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; env->streamThing(scriptstream, "item", item, env->addThing(item)); scriptstream << "local newText = " << newText.c_str() << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); LuaScriptInterface::pushThing(L, item, env->addThing(item)); lua_pushstring(L, newText.c_str()); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeTextEdit] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeReportBug(Player* player, std::string comment) { //onReportBug(cid, comment) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local comment = " << comment.c_str() << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushstring(L, comment.c_str()); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeReportBug] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executePush(Player* player, Creature* target) { //onPush(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << player->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executePush] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeTarget(Creature* creature, Creature* target) { //onTarget(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeTarget] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeFollow(Creature* creature, Creature* target) { //onFollow(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEventDesc(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeFollow] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeExtendedOpcode(Creature* creature, uint8_t opcode, const std::string& buffer) { //onExtendedOpcode(cid, opcode, buffer) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local opcode = " << (int)opcode << std::endl; scriptstream << "local buffer = " << buffer.c_str() << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEvent(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, opcode); lua_pushlstring(L, buffer.c_str(), buffer.length()); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeRemoved] Call stack overflow." << std::endl; return 0; } } uint32_t CreatureEvent::executeOnSpawn(Creature* creature) { //onSpawn(cid) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::stringstream desc; desc << creature->getName(); env->setEvent(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); bool result = m_interface->callFunction(1); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::executeCast] Call stack overflow." << std::endl; return 0; } } erro no dev Compilador: Default compiler Building Makefile: "C:\Users\micael\Documents\Projetos\serve teste\Base teste\[SOURCE] PokeZR By Kyyah\dev-cpp\Makefile.win" Executando make... mingw32-make -f "C:\Users\micael\Documents\Projetos\serve teste\Base teste\[SOURCE] PokeZR By Kyyah\dev-cpp\Makefile.win" all g++.exe -c ../creatureevent.cpp -o obj//creatureevent.o -I"C:/Users/micael/Documents/Projetos/serve teste/Base teste/Stian's Repack Dev-Cpp 0.2, 64bit/include" -D__USE_MYSQL__ -D__USE_SQLITE__ -D__ENABLE_SERVER_DIAGNOSTIC__ -fexpensive-optimizations -O1 In file included from ../baseevents.h:22, from ../creatureevent.h:22, from ../creatureevent.cpp:22: ../luascript.h:314: error: stray '\357' in program ../luascript.h:314: error: stray '\273' in program ../luascript.h:314: error: stray '\277' in program In file included from ../creatureevent.cpp:23: ../player.h:532: error: stray '\357' in program ../player.h:532: error: stray '\273' in program ../player.h:532: error: stray '\277' in program ../player.h:532: error: stray '\357' in program ../player.h:532: error: stray '\273' in program ../player.h:532: error: stray '\277' in program ../player.h:532: error: stray '\357' in program ../player.h:532: error: stray '\273' in program ../player.h:532: error: stray '\277' in program ../creatureevent.cpp:77: error: stray '#' in program ../creatureevent.cpp:79:6: error: invalid preprocessing directive #endifenv In file included from ../creatureevent.cpp:22: ../creatureevent.h:56: error: redefinition of 'CREATURE_EVENT_EXTENDED_OPCODE' ../creatureevent.h:54: error: 'CREATURE_EVENT_EXTENDED_OPCODE' previously defined here In file included from ../creatureevent.cpp:23: ../player.h: In member function 'void Player::sendExtendedOpcode(uint8_t, const std::string&)': ../player.h:532: error: 'clien' was not declared in this scope ../player.h:532: error: expected ')' before 't' ../player.h:532: error: 'buffe' was not declared in this scope ../creatureevent.cpp: In member function 'virtual bool CreatureEvents::registerEvent(Event*, xmlNode*, bool)': ../creatureevent.cpp:69: error: a function-definition is not allowed here before '{' token ../creatureevent.cpp:2024: error: expected '}' at end of input ../creatureevent.cpp:2024: error: expected '}' at end of input mingw32-make: *** [obj//creatureevent.o] Error 1 Execução terminada
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...