Advertisement
Guest User

Untitled

a guest
Jan 9th, 2015
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.38 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////
  2. // OpenTibia - an opensource roleplaying game
  3. //////////////////////////////////////////////////////////////////////
  4. //
  5. //////////////////////////////////////////////////////////////////////
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the GNU General Public License
  8. // as published by the Free Software Foundation; either version 2
  9. // of the License, or (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software Foundation,
  18. // Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19. //////////////////////////////////////////////////////////////////////
  20.  
  21. #ifndef __OTSERV_CREATUREEVENT_H__
  22. #define __OTSERV_CREATUREEVENT_H__
  23.  
  24. #include "luascript.h"
  25. #include "baseevents.h"
  26. #include "enums.h"
  27.  
  28. enum CreatureEventType_t{
  29.     CREATURE_EVENT_NONE,
  30.     CREATURE_EVENT_LOGIN,
  31.     CREATURE_EVENT_LOGOUT,
  32.     CREATURE_EVENT_DIE,
  33.     CREATURE_EVENT_PREPAREDEATH,
  34.     CREATURE_EVENT_ADVANCE,
  35.     CREATURE_EVENT_SAGA,
  36.     CREATURE_EVENT_KILL
  37. };
  38.  
  39. class CreatureEvent;
  40.  
  41. class CreatureEvents : public BaseEvents
  42. {
  43. public:
  44.     CreatureEvents();
  45.     virtual ~CreatureEvents();
  46.  
  47.     // global events
  48.     uint32_t playerLogIn(Player* player);
  49.     uint32_t playerLogOut(Player* player);
  50.     uint32_t playerAdvance(Player* player, AdvanceType_t stat, uint32_t fromLv, uint32_t toLv);
  51.     CreatureEvent* getEventByName(const std::string& name, bool forceLoaded = true);
  52.  
  53. protected:
  54.  
  55.     virtual LuaScriptInterface& getScriptInterface();
  56.     virtual std::string getScriptBaseName();
  57.     virtual Event* getEvent(const std::string& nodeName);
  58.     virtual bool registerEvent(Event* event, xmlNodePtr p);
  59.     virtual void clear();
  60.  
  61.     //global events
  62.     CreatureEvent* m_logInEvent;
  63.     CreatureEvent* m_logOutEvent;
  64.     CreatureEvent* m_onAdvance;
  65.     //creature events
  66.     typedef std::map<std::string, CreatureEvent*> CreatureEventList;
  67.     CreatureEventList m_creatureEvents;
  68.  
  69.     LuaScriptInterface m_scriptInterface;
  70. };
  71.  
  72. class CreatureEvent : public Event
  73. {
  74. public:
  75.     CreatureEvent(LuaScriptInterface* _interface);
  76.     virtual ~CreatureEvent();
  77.  
  78.     virtual bool configureEvent(xmlNodePtr p);
  79.  
  80.     CreatureEventType_t getEventType() const { return m_type; }
  81.     const std::string& getName() const { return m_eventName; }
  82.     bool isLoaded() const { return m_isLoaded; }
  83.  
  84.     void clearEvent();
  85.     void copyEvent(CreatureEvent* creatureEvent);
  86.  
  87.     //scripting
  88.     uint32_t executeOnLogin(Player* player);
  89.     uint32_t executeOnLogout(Player* player);
  90.     uint32_t executeOnDie(Creature* creature, Item* corpse);
  91.     uint32_t executeOnKill(Creature* creature, Creature* target);
  92.     uint32_t executeOnPrepareDeath(Player* player, Creature* killer);
  93.     uint32_t executeOnSaga(Creature* creature, Creature* killer);
  94.     uint32_t executeOnAdvance(Player* player, AdvanceType_t stat, uint32_t fromLv, uint32_t toLv);
  95.     //
  96.  
  97. protected:
  98.     virtual std::string getScriptEventName();
  99.  
  100.     std::string m_eventName;
  101.     CreatureEventType_t m_type;
  102.     bool m_isLoaded;
  103. };
  104.  
  105.  
  106. #endif // __OTSERV_CREATUREEVENT_H__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement