Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.95 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "utils.h"
  3. #include "char.h"
  4. #include "char_manager.h"
  5. #include "motion.h"
  6. #include "packet.h"
  7. #include "buffer_manager.h"
  8. #include "unique_item.h"
  9. #include "wedding.h"
  10.  
  11. #define NEED_TARGET (1 << 0)
  12. #define NEED_PC (1 << 1)
  13. #define WOMAN_ONLY (1 << 2)
  14. #define OTHER_SEX_ONLY (1 << 3)
  15. #define SELF_DISARM (1 << 4)
  16. #define TARGET_DISARM (1 << 5)
  17. #define BOTH_DISARM (SELF_DISARM | TARGET_DISARM)
  18.  
  19. struct emotion_type_s
  20. {
  21. const char * command;
  22. const char * command_to_client;
  23. long flag;
  24. float extra_delay;
  25. } emotion_types[] = {
  26. { "Ĺ°˝ş", "french_kiss", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, 2.0f },
  27. { "ȂȂ", "kiss", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, 1.5f },
  28. { "µű±Í", "slap", NEED_PC | SELF_DISARM, 1.5f },
  29. { "ąÚĽö", "clap", 0, 1.0f },
  30. { "żÍ", "cheer1", 0, 1.0f },
  31. { "¸¸ĽĽ", "cheer2", 0, 1.0f },
  32.  
  33. // DANCE
  34. { "´í˝ş1", "dance1", 0, 1.0f },
  35. { "´í˝ş2", "dance2", 0, 1.0f },
  36. { "´í˝ş3", "dance3", 0, 1.0f },
  37. { "´í˝ş4", "dance4", 0, 1.0f },
  38. { "´í˝ş5", "dance5", 0, 1.0f },
  39. { "´í˝ş6", "dance6", 0, 1.0f },
  40. // END_OF_DANCE
  41. { "ĂŕÇĎ", "congratulation", 0, 1.0f },
  42. { "żëĽ­", "forgive", 0, 1.0f },
  43. { "Č­ł˛", "angry", 0, 1.0f },
  44. { "ŔŻČ¤", "attractive", 0, 1.0f },
  45. { "˝˝ÇÄ", "sad", 0, 1.0f },
  46. { "şę˛ô", "shy", 0, 1.0f },
  47. { "ŔŔżř", "cheerup", 0, 1.0f },
  48. { "ÁúĹő", "banter", 0, 1.0f },
  49. { "±â»Ý", "joy", 0, 1.0f },
  50. { "\n", "\n", 0, 0.0f },
  51. /*
  52. //{ "Ĺ°˝ş", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_FRENCH_KISS, 1.0f },
  53. { "ȂȂ", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_KISS, 1.0f },
  54. { "˛¸ľČ±â", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_SHORT_HUG, 1.0f },
  55. { "Ć÷żË", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_LONG_HUG, 1.0f },
  56. { "ľî±úµżą«", NEED_PC | SELF_DISARM, MOTION_ACTION_PUT_ARMS_SHOULDER, 0.0f },
  57. { "ĆČÂŻ", NEED_PC | WOMAN_ONLY | SELF_DISARM, MOTION_ACTION_FOLD_ARM, 0.0f },
  58. { "µű±Í", NEED_PC | SELF_DISARM, MOTION_ACTION_SLAP, 1.5f },
  59.  
  60. { "ČÖĆĶ÷", 0, MOTION_ACTION_CHEER_01, 0.0f },
  61. { "¸¸ĽĽ", 0, MOTION_ACTION_CHEER_02, 0.0f },
  62. { "ąÚĽö", 0, MOTION_ACTION_CHEER_03, 0.0f },
  63.  
  64. { "ČŁČŁ", 0, MOTION_ACTION_LAUGH_01, 0.0f },
  65. { "űű", 0, MOTION_ACTION_LAUGH_02, 0.0f },
  66. { "żěÇĎÇĎ", 0, MOTION_ACTION_LAUGH_03, 0.0f },
  67.  
  68. { "ľűľű", 0, MOTION_ACTION_CRY_01, 0.0f },
  69. { "ČćČć", 0, MOTION_ACTION_CRY_02, 0.0f },
  70.  
  71. { "Ŕλç", 0, MOTION_ACTION_GREETING_01, 0.0f },
  72. { "ąŮŔĚ", 0, MOTION_ACTION_GREETING_02, 0.0f },
  73. { "Á¤ÁßŔλç", 0, MOTION_ACTION_GREETING_03, 0.0f },
  74.  
  75. { "şńł­", 0, MOTION_ACTION_INSULT_01, 0.0f },
  76. { "¸đżĺ", SELF_DISARM, MOTION_ACTION_INSULT_02, 0.0f },
  77. { "żěŔˇ", 0, MOTION_ACTION_INSULT_03, 0.0f },
  78.  
  79. { "°Ľżě¶×", 0, MOTION_ACTION_ETC_01, 0.0f },
  80. { "˛ô´ö˛ô´ö", 0, MOTION_ACTION_ETC_02, 0.0f },
  81. { "µµ¸®µµ¸®", 0, MOTION_ACTION_ETC_03, 0.0f },
  82. { "±ÜŔű±ÜŔű", 0, MOTION_ACTION_ETC_04, 0.0f },
  83. { "ơ", 0, MOTION_ACTION_ETC_05, 0.0f },
  84. { "»×", 0, MOTION_ACTION_ETC_06, 0.0f },
  85. */
  86. };
  87.  
  88.  
  89. std::set<std::pair<DWORD, DWORD> > s_emotion_set;
  90.  
  91. ACMD(do_emotion_allow)
  92. {
  93. if ( ch->GetArena() )
  94. {
  95. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´ë·ĂŔ忡Ľ­ »çżëÇĎ˝Ç Ľö ľř˝Ŕ´Ď´Ů."));
  96. return;
  97. }
  98.  
  99. char arg1[256];
  100. one_argument(argument, arg1, sizeof(arg1));
  101.  
  102. if (!*arg1)
  103. return;
  104.  
  105. DWORD val = 0; str_to_number(val, arg1);
  106. s_emotion_set.insert(std::make_pair(ch->GetVID(), val));
  107. }
  108.  
  109. bool CHARACTER_CanEmotion(CHARACTER& rch)
  110.  
  111. {
  112. // °áČĄ˝Ä ¸ĘżˇĽ­´Â »çżëÇŇ Ľö ŔÖ´Ů.
  113. if (marriage::WeddingManager::instance().IsWeddingMap(rch.GetMapIndex()))
  114. return true;
  115.  
  116. // ż­Á¤ŔÇ °ˇ¸é Âřżë˝Ă »çżëÇŇ Ľö ŔÖ´Ů.
  117. if (rch.IsEquipUniqueItem(UNIQUE_ITEM_EMOTION_MASK))
  118. return true;
  119.  
  120. if (rch.IsEquipUniqueItem(UNIQUE_ITEM_EMOTION_MASK2))
  121. return true;
  122.  
  123. return false;
  124. }
  125.  
  126. ACMD(do_emotion)
  127. {
  128. int i;
  129. {
  130. if (ch->IsRiding())
  131. {
  132. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¸»Ŕ» Ĺş »óĹÂżˇĽ­ °¨Á¤ÇĄÇöŔ» ÇŇ Ľö ľř˝Ŕ´Ď´Ů."));
  133. return;
  134. }
  135. }
  136.  
  137. for (i = 0; *emotion_types[i].command != '\n'; ++i)
  138. {
  139. if (!strcmp(cmd_info[cmd].command, emotion_types[i].command))
  140. break;
  141.  
  142. if (!strcmp(cmd_info[cmd].command, emotion_types[i].command_to_client))
  143. break;
  144. }
  145.  
  146. if (*emotion_types[i].command == '\n')
  147. {
  148. sys_err("cannot find emotion");
  149. return;
  150. }
  151.  
  152. if (!CHARACTER_CanEmotion(*ch))
  153. {
  154. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ż­Á¤ŔÇ °ˇ¸éŔ» Âřżë˝Ăżˇ¸¸ ÇŇ Ľö ŔÖ˝Ŕ´Ď´Ů."));
  155. return;
  156. }
  157.  
  158. if (IS_SET(emotion_types[i].flag, WOMAN_ONLY) && SEX_MALE==GET_SEX(ch))
  159. {
  160. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ż©ŔÚ¸¸ ÇŇ Ľö ŔÖ˝Ŕ´Ď´Ů."));
  161. return;
  162. }
  163.  
  164. char arg1[256];
  165. one_argument(argument, arg1, sizeof(arg1));
  166.  
  167. LPCHARACTER victim = NULL;
  168.  
  169. if (*arg1)
  170. victim = ch->FindCharacterInView(arg1, IS_SET(emotion_types[i].flag, NEED_PC));
  171.  
  172. if (IS_SET(emotion_types[i].flag, NEED_TARGET | NEED_PC))
  173. {
  174. if (!victim)
  175. {
  176. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±×·± »ç¶÷ŔĚ ľř˝Ŕ´Ď´Ů."));
  177. return;
  178. }
  179. }
  180.  
  181. if (victim)
  182. {
  183. if (!victim->IsPC() || victim == ch)
  184. return;
  185.  
  186. if (victim->IsRiding())
  187. {
  188. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¸»Ŕ» Ĺş »ó´ëżÍ °¨Á¤ÇĄÇöŔ» ÇŇ Ľö ľř˝Ŕ´Ď´Ů."));
  189. return;
  190. }
  191.  
  192. long distance = DISTANCE_APPROX(ch->GetX() - victim->GetX(), ch->GetY() - victim->GetY());
  193.  
  194. if (distance < 10)
  195. {
  196. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("łĘą« °ˇ±îŔĚ ŔÖ˝Ŕ´Ď´Ů."));
  197. return;
  198. }
  199.  
  200. if (distance > 500)
  201. {
  202. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("łĘą« ¸Ö¸® ŔÖ˝Ŕ´Ď´Ů"));
  203. return;
  204. }
  205.  
  206. if (IS_SET(emotion_types[i].flag, OTHER_SEX_ONLY))
  207. {
  208. if (GET_SEX(ch)==GET_SEX(victim))
  209. {
  210. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ŔĚĽş°Łżˇ¸¸ ÇŇ Ľö ŔÖ˝Ŕ´Ď´Ů."));
  211. return;
  212. }
  213. }
  214.  
  215. if (IS_SET(emotion_types[i].flag, NEED_PC))
  216. {
  217. if (s_emotion_set.find(std::make_pair(victim->GetVID(), ch->GetVID())) == s_emotion_set.end())
  218. {
  219. if (true == marriage::CManager::instance().IsMarried( ch->GetPlayerID() ))
  220. {
  221. const marriage::TMarriage* marriageInfo = marriage::CManager::instance().Get( ch->GetPlayerID() );
  222.  
  223. const DWORD other = marriageInfo->GetOther( ch->GetPlayerID() );
  224.  
  225. if (0 == other || other != victim->GetPlayerID())
  226. {
  227. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ŔĚ ÇൿŔş »óČŁµżŔÇ ÇĎżˇ °ˇ´É ÇŐ´Ď´Ů."));
  228. return;
  229. }
  230. }
  231. else
  232. {
  233. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ŔĚ ÇൿŔş »óČŁµżŔÇ ÇĎżˇ °ˇ´É ÇŐ´Ď´Ů."));
  234. return;
  235. }
  236. }
  237.  
  238. s_emotion_set.insert(std::make_pair(ch->GetVID(), victim->GetVID()));
  239. }
  240. }
  241.  
  242. char chatbuf[256+1];
  243. int len = snprintf(chatbuf, sizeof(chatbuf), "%s %u %u",
  244. emotion_types[i].command_to_client,
  245. (DWORD) ch->GetVID(), victim ? (DWORD) victim->GetVID() : 0);
  246.  
  247. if (len < 0 || len >= (int) sizeof(chatbuf))
  248. len = sizeof(chatbuf) - 1;
  249.  
  250. ++len; // \0 ą®ŔÚ Ć÷ÇÔ
  251.  
  252. TPacketGCChat pack_chat;
  253. pack_chat.header = HEADER_GC_CHAT;
  254. pack_chat.size = sizeof(TPacketGCChat) + len;
  255. pack_chat.type = CHAT_TYPE_COMMAND;
  256. pack_chat.id = 0;
  257. TEMP_BUFFER buf;
  258. buf.write(&pack_chat, sizeof(TPacketGCChat));
  259. buf.write(chatbuf, len);
  260.  
  261. ch->PacketAround(buf.read_peek(), buf.size());
  262.  
  263. if (victim)
  264. sys_log(1, "ACTION: %s TO %s", emotion_types[i].command, victim->GetName());
  265. else
  266. sys_log(1, "ACTION: %s", emotion_types[i].command);
  267. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement