Advertisement
idontusemyphone

Untitled

Nov 15th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.58 KB | None | 0 0
  1. AMCD(do_user_actions)
  2. {
  3. char arg1[256];
  4. const char * line = one_argument(argument, arg1, sizeof(arg1));
  5.  
  6. if (*arg1)
  7. {
  8. switch(LOWER(*arg1))
  9. {
  10. case 'p': // poly
  11. {
  12. if (!(ch->IsPolymorphed()))
  13. return;
  14.  
  15. ch->SetPolymorph(0);
  16. ch->RemoveAffect(AFFECT_POLYMORPH);
  17. }
  18. break;
  19. case 'e': // exp
  20. {
  21.  
  22. }
  23. break;
  24. case 's': // safebox
  25. {
  26. ch->SetSafeboxOpenPosition();
  27. ch->ChatPacket(CHAT_TYPE_COMMAND, "ShowMeSafeboxPassword");
  28. }
  29. break;
  30. case 'b': // buy poly
  31. {
  32. enum {
  33. POLYMARBLE_MAX_MONSTER = 7,
  34. POLYMARBLE_MAX_COUNT = 100,
  35. POLYMARBLE_ITEM_VNUM = 70104,
  36. POLYMARBLE_PRICE = 10,
  37. };
  38.  
  39. WORD POLYMARBLE_AVAIL_RACE[POLYMARBLE_MAX_MONSTER] = {
  40. 101, 102, 103, 104, 105, 106, 107,
  41. };
  42.  
  43. WORD wIndex, wCount;
  44.  
  45. char arg2[256];
  46. char arg3[256];
  47.  
  48. two_arguments(line, arg2, sizeof(arg2), arg3, sizeof(arg3));
  49.  
  50. if (!*arg2 || !*arg3) return;
  51.  
  52. str_to_number(wIndex, arg2);
  53. str_to_number(wCount, arg3);
  54.  
  55. if (wIndex >= POLYMARBLE_MAX_MONSTER || wCount >= POLYMARBLE_MAX_COUNT)
  56. {
  57. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Invalid arguments"));
  58. return;
  59. }
  60.  
  61. if (ch->GetGold() < POLYMARBLE_PRICE * wCount)
  62. {
  63. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Not enough gold"));
  64. return;
  65. }
  66.  
  67. LPITEM item = NULL;
  68. if ((item = ITEM_MANAGER::instance().CreateItem(POLYMARBLE_ITEM_VNUM, wCount)))
  69. {
  70. item->SetSocket(0, POLYMARBLE_AVAIL_RACE[wIndex]);
  71.  
  72. int iEmptyPos = ch->GetEmptyInventory(item->GetSize());
  73. if (iEmptyPos != -1)
  74. {
  75. item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));
  76.  
  77. ch->PointChange(POINT_GOLD, -(POLYMARBLE_PRICE * wCount), true);
  78. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Success"));
  79. }
  80. else
  81. {
  82. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ĽŇÁöÇ°żˇ şó °ř°ŁŔĚ ľř˝Ŕ´Ď´Ů."));
  83. M2_DESTROY_ITEM(item);
  84. }
  85. }
  86. }
  87. break;
  88. case 'l': // position
  89. {
  90. char arg2[256];
  91. char arg3[256];
  92.  
  93. two_arguments(line, arg2, sizeof(arg2), arg3, sizeof(arg3));
  94.  
  95. if (!*arg3) return;
  96. if (!isdigit(*arg3)) return;
  97.  
  98. BYTE index;
  99. str_to_number(index, arg3);
  100.  
  101. if (index >= POSITION_MAX_COUNT) return;
  102.  
  103. if (*arg2)
  104. {
  105. enum {
  106. POSITION_MAX_COUNT = 2 * 10,
  107. };
  108.  
  109. std::string currentQuestFlag = "position.";
  110.  
  111. switch(LOWER(*arg2))
  112. {
  113. case 's': // save
  114. {
  115. std::vector<long> forbiddenIndex {2137, };
  116. if (std::find(forbiddenIndex.end(), forbiddenIndex.end(), ch->GetMapIndex()) != forbiddenIndex.end())
  117. {
  118. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't do that"));
  119. return;
  120. }
  121.  
  122. ch->SetQuestFlag((currentQuestFlag + "index_" + arg3).c_str(), ch->GetMapIndex());
  123. ch->SetQuestFlag((currentQuestFlag + "g_x_" + arg3).c_str(), ch->GetX() / 100);
  124. ch->SetQuestFlag((currentQuestFlag + "g_y_" + arg3).c_str(), ch->GetY() / 100);
  125.  
  126. LPSECTREE_MAP pMap = NULL;
  127. if ((pMap = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex())))
  128. {
  129. ch->SetQuestFlag((currentQuestFlag + "l_x_" + arg3).c_str(), (ch->GetX() - pMap->m_setting.iBaseX) / 100);
  130. ch->SetQuestFlag((currentQuestFlag + "l_y_" + arg3).c_str(), (ch->GetY() - pMap->m_setting.iBaseY) / 100);
  131. }
  132. else
  133. {
  134. ch->SetQuestFlag((currentQuestFlag + "l_x_" + arg3).c_str(), ch->GetQuestFlag((currentQuestFlag + "g_x_" + arg3).c_str()));
  135. ch->SetQuestFlag((currentQuestFlag + "l_y_" + arg3).c_str(), ch->GetQuestFlag((currentQuestFlag + "g_y_" + arg3).c_str()));
  136. }
  137.  
  138. char * buff = new char[CHAT_MAX_LEN + 1];
  139. snprintf(buff, sizeof(buff), "SavePositionData %u %d %d %d",
  140. index,
  141. ch->GetQuestFlag((currentQuestFlag + "index_" + arg3).c_str()),
  142. ch->GetQuestFlag((currentQuestFlag + "l_x_" + arg3).c_str()),
  143. ch->GetQuestFlag((currentQuestFlag + "l_y_" + arg3).c_str()),
  144. );
  145. ch->ChatPacket(CHAT_TYPE_COMMAND, buff);
  146. delete[] buff;
  147. }
  148. break;
  149. case 'd': // delete
  150. {
  151. PC * pPC;
  152. if ((pPc = CQuestManager::instance().GetCurrentPC()))
  153. {
  154. pPC->DeleteFlag((currentQuestFlag + "index_" + arg3).c_str());
  155. pPC->DeleteFlag((currentQuestFlag + "g_x_" + arg3).c_str());
  156. pPC->DeleteFlag((currentQuestFlag + "g_y_" + arg3).c_str());
  157. pPC->DeleteFlag((currentQuestFlag + "l_x_" + arg3).c_str());
  158. pPC->DeleteFlag((currentQuestFlag + "l_y_" + arg3).c_str());
  159.  
  160. char * buff = new char[CHAT_MAX_LEN + 1];
  161. snprintf(buff, sizeof(buff), "DeletePositionData %u", index);
  162. ch->ChatPacket(CHAT_TYPE_COMMAND, buff);
  163. delete[] buff;
  164. }
  165. }
  166. break;
  167. case 'r': // read
  168. {
  169. if (!(ch->CanWarp()))
  170. {
  171. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't do this."))
  172. }
  173. else
  174. {
  175. if (ch->GetQuestFlag((currentQuestFlag + "index_" + arg3).c_str()) != 0)
  176. {
  177. ch->WarpSet(
  178. ch->GetQuestFlag((currentQuestFlag + "g_x_" + arg3).c_str()),
  179. ch->GetQuestFlag((currentQuestFlag + "g_y_" + arg3).c_str()),
  180. ch->GetQuestFlag((currentQuestFlag + "index_" + arg3).c_str()),
  181. );
  182. }
  183. }
  184. }
  185. break;
  186. case 'l': // load
  187. {
  188. char * buff = new char[CHAT_MAX_LEN + 1];
  189. char * num = new char[2];
  190. for (size_t i = 0; i < POSITION_MAX_COUNT; ++i)
  191. {
  192. sprintf(num, "%d", i);
  193.  
  194. if (ch->GetQuestFlag((currentQuestFlag + "index_" + num).c_str()) != 0)
  195. {
  196. snprintf(buff, sizeof(buff), "SavePositionData %u %d %d %d",
  197. index,
  198. ch->GetQuestFlag((currentQuestFlag + "index_" + num).c_str()),
  199. ch->GetQuestFlag((currentQuestFlag + "l_x_" + num).c_str()),
  200. ch->GetQuestFlag((currentQuestFlag + "l_y_" + num).c_str()),
  201. );
  202. ch->ChatPacket(CHAT_TYPE_COMMAND, buff);
  203. }
  204. }
  205. delete[] buff;
  206. delete[] num;
  207. }
  208. break;
  209. default:
  210. break;
  211. }
  212. }
  213. }
  214. break;
  215. default;
  216. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±×·± ¸í·Éľî´Â ľř˝Ŕ´Ď´Ů"));
  217. break;
  218. }
  219. }
  220. else
  221. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±×·± ¸í·Éľî´Â ľř˝Ŕ´Ď´Ů"));
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement