Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AMCD(do_user_actions)
- {
- char arg1[256];
- const char * line = one_argument(argument, arg1, sizeof(arg1));
- if (*arg1)
- {
- switch(LOWER(*arg1))
- {
- case 'p': // poly
- {
- if (!(ch->IsPolymorphed()))
- return;
- ch->SetPolymorph(0);
- ch->RemoveAffect(AFFECT_POLYMORPH);
- }
- break;
- case 'e': // exp
- {
- }
- break;
- case 's': // safebox
- {
- ch->SetSafeboxOpenPosition();
- ch->ChatPacket(CHAT_TYPE_COMMAND, "ShowMeSafeboxPassword");
- }
- break;
- case 'b': // buy poly
- {
- enum {
- POLYMARBLE_MAX_MONSTER = 7,
- POLYMARBLE_MAX_COUNT = 100,
- POLYMARBLE_ITEM_VNUM = 70104,
- POLYMARBLE_PRICE = 10,
- };
- WORD POLYMARBLE_AVAIL_RACE[POLYMARBLE_MAX_MONSTER] = {
- 101, 102, 103, 104, 105, 106, 107,
- };
- WORD wIndex, wCount;
- char arg2[256];
- char arg3[256];
- two_arguments(line, arg2, sizeof(arg2), arg3, sizeof(arg3));
- if (!*arg2 || !*arg3) return;
- str_to_number(wIndex, arg2);
- str_to_number(wCount, arg3);
- if (wIndex >= POLYMARBLE_MAX_MONSTER || wCount >= POLYMARBLE_MAX_COUNT)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Invalid arguments"));
- return;
- }
- if (ch->GetGold() < POLYMARBLE_PRICE * wCount)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Not enough gold"));
- return;
- }
- LPITEM item = NULL;
- if ((item = ITEM_MANAGER::instance().CreateItem(POLYMARBLE_ITEM_VNUM, wCount)))
- {
- item->SetSocket(0, POLYMARBLE_AVAIL_RACE[wIndex]);
- int iEmptyPos = ch->GetEmptyInventory(item->GetSize());
- if (iEmptyPos != -1)
- {
- item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));
- ch->PointChange(POINT_GOLD, -(POLYMARBLE_PRICE * wCount), true);
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Success"));
- }
- else
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ĽŇÁöÇ°żˇ şó °ř°ŁŔĚ ľř˝Ŕ´Ď´Ů."));
- M2_DESTROY_ITEM(item);
- }
- }
- }
- break;
- case 'l': // position
- {
- char arg2[256];
- char arg3[256];
- two_arguments(line, arg2, sizeof(arg2), arg3, sizeof(arg3));
- if (!*arg3) return;
- if (!isdigit(*arg3)) return;
- BYTE index;
- str_to_number(index, arg3);
- if (index >= POSITION_MAX_COUNT) return;
- if (*arg2)
- {
- enum {
- POSITION_MAX_COUNT = 2 * 10,
- };
- std::string currentQuestFlag = "position.";
- switch(LOWER(*arg2))
- {
- case 's': // save
- {
- std::vector<long> forbiddenIndex {2137, };
- if (std::find(forbiddenIndex.end(), forbiddenIndex.end(), ch->GetMapIndex()) != forbiddenIndex.end())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't do that"));
- return;
- }
- ch->SetQuestFlag((currentQuestFlag + "index_" + arg3).c_str(), ch->GetMapIndex());
- ch->SetQuestFlag((currentQuestFlag + "g_x_" + arg3).c_str(), ch->GetX() / 100);
- ch->SetQuestFlag((currentQuestFlag + "g_y_" + arg3).c_str(), ch->GetY() / 100);
- LPSECTREE_MAP pMap = NULL;
- if ((pMap = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex())))
- {
- ch->SetQuestFlag((currentQuestFlag + "l_x_" + arg3).c_str(), (ch->GetX() - pMap->m_setting.iBaseX) / 100);
- ch->SetQuestFlag((currentQuestFlag + "l_y_" + arg3).c_str(), (ch->GetY() - pMap->m_setting.iBaseY) / 100);
- }
- else
- {
- ch->SetQuestFlag((currentQuestFlag + "l_x_" + arg3).c_str(), ch->GetQuestFlag((currentQuestFlag + "g_x_" + arg3).c_str()));
- ch->SetQuestFlag((currentQuestFlag + "l_y_" + arg3).c_str(), ch->GetQuestFlag((currentQuestFlag + "g_y_" + arg3).c_str()));
- }
- char * buff = new char[CHAT_MAX_LEN + 1];
- snprintf(buff, sizeof(buff), "SavePositionData %u %d %d %d",
- index,
- ch->GetQuestFlag((currentQuestFlag + "index_" + arg3).c_str()),
- ch->GetQuestFlag((currentQuestFlag + "l_x_" + arg3).c_str()),
- ch->GetQuestFlag((currentQuestFlag + "l_y_" + arg3).c_str()),
- );
- ch->ChatPacket(CHAT_TYPE_COMMAND, buff);
- delete[] buff;
- }
- break;
- case 'd': // delete
- {
- PC * pPC;
- if ((pPc = CQuestManager::instance().GetCurrentPC()))
- {
- pPC->DeleteFlag((currentQuestFlag + "index_" + arg3).c_str());
- pPC->DeleteFlag((currentQuestFlag + "g_x_" + arg3).c_str());
- pPC->DeleteFlag((currentQuestFlag + "g_y_" + arg3).c_str());
- pPC->DeleteFlag((currentQuestFlag + "l_x_" + arg3).c_str());
- pPC->DeleteFlag((currentQuestFlag + "l_y_" + arg3).c_str());
- char * buff = new char[CHAT_MAX_LEN + 1];
- snprintf(buff, sizeof(buff), "DeletePositionData %u", index);
- ch->ChatPacket(CHAT_TYPE_COMMAND, buff);
- delete[] buff;
- }
- }
- break;
- case 'r': // read
- {
- if (!(ch->CanWarp()))
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't do this."))
- }
- else
- {
- if (ch->GetQuestFlag((currentQuestFlag + "index_" + arg3).c_str()) != 0)
- {
- ch->WarpSet(
- ch->GetQuestFlag((currentQuestFlag + "g_x_" + arg3).c_str()),
- ch->GetQuestFlag((currentQuestFlag + "g_y_" + arg3).c_str()),
- ch->GetQuestFlag((currentQuestFlag + "index_" + arg3).c_str()),
- );
- }
- }
- }
- break;
- case 'l': // load
- {
- char * buff = new char[CHAT_MAX_LEN + 1];
- char * num = new char[2];
- for (size_t i = 0; i < POSITION_MAX_COUNT; ++i)
- {
- sprintf(num, "%d", i);
- if (ch->GetQuestFlag((currentQuestFlag + "index_" + num).c_str()) != 0)
- {
- snprintf(buff, sizeof(buff), "SavePositionData %u %d %d %d",
- index,
- ch->GetQuestFlag((currentQuestFlag + "index_" + num).c_str()),
- ch->GetQuestFlag((currentQuestFlag + "l_x_" + num).c_str()),
- ch->GetQuestFlag((currentQuestFlag + "l_y_" + num).c_str()),
- );
- ch->ChatPacket(CHAT_TYPE_COMMAND, buff);
- }
- }
- delete[] buff;
- delete[] num;
- }
- break;
- default:
- break;
- }
- }
- }
- break;
- default;
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±×·± ¸í·Éľî´Â ľř˝Ŕ´Ď´Ů"));
- break;
- }
- }
- else
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±×·± ¸í·Éľî´Â ľř˝Ŕ´Ď´Ů"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement