Advertisement
Guest User

Untitled

a guest
Jul 27th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////
  2. // OpenTibia - an opensource roleplaying game
  3. ////////////////////////////////////////////////////////////////////////
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ////////////////////////////////////////////////////////////////////////
  17.  
  18. #ifndef __TALKACTION__
  19. #define __TALKACTION__
  20. #include "otsystem.h"
  21.  
  22. #include "enums.h"
  23. #include "player.h"
  24.  
  25. #include "tools.h"
  26. #include "luascript.h"
  27. #include "baseevents.h"
  28.  
  29. enum TalkActionFilter
  30. {
  31. TALKFILTER_QUOTATION,
  32. TALKFILTER_WORD,
  33. TALKFILTER_WORD_SPACED,
  34. TALKFILTER_LAST
  35. };
  36.  
  37. class TalkAction;
  38. typedef std::map<std::string, TalkAction*> TalkActionsMap;
  39.  
  40. class TalkActions : public BaseEvents
  41. {
  42. public:
  43. TalkActions();
  44. virtual ~TalkActions();
  45.  
  46. bool onPlayerSay(Creature* creature, uint16_t channelId, const std::string& words, bool ignoreAccess);
  47.  
  48. inline TalkActionsMap::const_iterator getFirstTalk() const {return talksMap.begin();}
  49. inline TalkActionsMap::const_iterator getLastTalk() const {return talksMap.end();}
  50.  
  51. TalkAction* defaultTalkAction;
  52. TalkActionsMap talksMap;
  53.  
  54. virtual std::string getScriptBaseName() const {return "talkactions";}
  55. virtual void clear();
  56.  
  57. virtual Event* getEvent(const std::string& nodeName);
  58. virtual bool registerEvent(Event* event, xmlNodePtr p, bool override);
  59.  
  60. virtual LuaInterface& getInterface() {return m_interface;}
  61. LuaInterface m_interface;
  62. };
  63.  
  64. typedef bool (TalkFunction)(Creature* creature, const std::string& words, const std::string& param);
  65. class TalkAction : public Event
  66. {
  67. public:
  68. TalkAction(const TalkAction* copy);
  69. TalkAction(LuaInterface* _interface);
  70. virtual ~TalkAction() {}
  71.  
  72. virtual bool configureEvent(xmlNodePtr p);
  73. virtual bool loadFunction(const std::string& functionName);
  74.  
  75. int32_t executeSay(Creature* creature, const std::string& words, std::string param, uint16_t channel);
  76.  
  77. std::string getFunctionName() const {return m_functionName;}
  78. std::string getWords() const {return m_words;}
  79. void setWords(const std::string& words) {m_words = words;}
  80.  
  81. TalkActionFilter getFilter() const {return m_filter;}
  82. uint32_t getAccess() const {return m_access;}
  83. int32_t getChannel() const {return m_channel;}
  84.  
  85. StringVec getExceptions() {return m_exceptions;}
  86. TalkFunction* getFunction() {return m_function;}
  87.  
  88. bool isLogged() const {return m_logged;}
  89. bool isHidden() const {return m_hidden;}
  90. bool isSensitive() const {return m_sensitive;}
  91.  
  92. bool hasGroups() const {return !m_groups.empty();}
  93. bool hasGroup(int32_t value) const {return std::find(m_groups.begin(), m_groups.end(), value) != m_groups.end();}
  94.  
  95. IntegerVec::const_iterator getGroupsBegin() const {return m_groups.begin();}
  96. IntegerVec::const_iterator getGroupsEnd() const {return m_groups.end();}
  97.  
  98. protected:
  99. virtual std::string getScriptEventName() const {return "onSay";}
  100. virtual std::string getScriptEventParams() const {return "cid, words, param, channel";}
  101.  
  102. static TalkFunction houseBuy;
  103. static TalkFunction houseSell;
  104. static TalkFunction houseKick;
  105. static TalkFunction houseDoorList;
  106. static TalkFunction houseGuestList;
  107. static TalkFunction houseSubOwnerList;
  108. static TalkFunction guildJoin;
  109. static TalkFunction guildCreate;
  110. static TalkFunction thingProporties;
  111. static TalkFunction banishmentInfo;
  112. static TalkFunction diagnostics;
  113. static TalkFunction ghost;
  114. static TalkFunction software;
  115.  
  116. std::string m_words, m_functionName;
  117. TalkFunction* m_function;
  118. TalkActionFilter m_filter;
  119. uint32_t m_access;
  120. int32_t m_channel;
  121. bool m_logged, m_hidden, m_sensitive;
  122. StringVec m_exceptions;
  123. IntegerVec m_groups;
  124. };
  125. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement