PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/client/cmdusers.cpp

https://gitlab.com/GreatShift/PSExtended
C++ | 1918 lines | 1642 code | 174 blank | 102 comment | 608 complexity | ec5c8cb7f61fb0b0696bd6931b109243 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * cmdusers.h - Author: Keith Fulton
  3. *
  4. * Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
  5. *
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation (version 2 of the License)
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. */
  19. #include <psconfig.h>
  20. //=============================================================================
  21. // Crystal Space Includes
  22. //=============================================================================
  23. #include <ctype.h>
  24. #include <iengine/movable.h>
  25. #include <iengine/mesh.h>
  26. #include <imesh/sprite3d.h>
  27. #include <csgeom/math3d.h>
  28. //=============================================================================
  29. // Project Includes
  30. //=============================================================================
  31. #include "net/cmdhandler.h"
  32. #include "net/clientmsghandler.h"
  33. #include "net/messages.h"
  34. #include "net/npcmessages.h"
  35. #include "util/strutil.h"
  36. #include "gui/chatwindow.h"
  37. #include "gui/pawsdetailwindow.h"
  38. #include "gui/pawsinfowindow.h"
  39. #include "gui/inventorywindow.h"
  40. #include "gui/pawsactivemagicwindow.h"
  41. #include "gui/pawspetstatwindow.h"
  42. #include "gui/pawscontrolwindow.h"
  43. #include "gui/psmainwidget.h"
  44. #include "gui/pawsgameboard.h"
  45. #include "gui/pawsslot.h"
  46. #include "gui/shortcutwindow.h"
  47. #include "paws/pawsmanager.h"
  48. #include "paws/pawsyesnobox.h"
  49. //=============================================================================
  50. // Local Includes
  51. //=============================================================================
  52. #include "cmdusers.h"
  53. #include "pscelclient.h"
  54. #include "modehandler.h"
  55. #include "pscharcontrol.h"
  56. #include "globals.h"
  57. #include "psclientchar.h"
  58. psUserCommands::psUserCommands(ClientMsgHandler* mh, CmdHandler *ch, iObjectRegistry* obj)
  59. : psCmdBase(mh, ch, obj)
  60. {
  61. // msgqueue->Subscribe(MSGTYPE_CHAT,this);
  62. cmdsource->Subscribe("/?", this);
  63. cmdsource->Subscribe("/admin", this);
  64. cmdsource->Subscribe("/advice", this);
  65. cmdsource->Subscribe("/advisor", this);
  66. cmdsource->Subscribe("/assist", this);
  67. cmdsource->Subscribe("/attack", this);
  68. cmdsource->Subscribe("/queue", this);
  69. cmdsource->Subscribe("/away", this);
  70. cmdsource->Subscribe("/bank", this);
  71. cmdsource->Subscribe("/brightness", this);
  72. cmdsource->Subscribe("/buddy", this); // add named player to buddy list
  73. cmdsource->Subscribe("/buy", this);
  74. cmdsource->Subscribe("/storage", this); //allows to access the storage of an npc.
  75. cmdsource->Subscribe("/cast", this);
  76. cmdsource->Subscribe("/challenge", this);
  77. cmdsource->Subscribe("/clear", this);
  78. cmdsource->Subscribe("/combine", this);
  79. cmdsource->Subscribe("/uncombine", this);
  80. cmdsource->Subscribe("/construct", this);
  81. cmdsource->Subscribe("/date", this);
  82. cmdsource->Subscribe("/dequip", this);
  83. cmdsource->Subscribe("/die", this);
  84. cmdsource->Subscribe("/dig", this);
  85. cmdsource->Subscribe("/drop", this);
  86. cmdsource->Subscribe("/emote", this);
  87. cmdsource->Subscribe("/equip", this);
  88. cmdsource->Subscribe("/examine", this);
  89. cmdsource->Subscribe("/fish", this);
  90. cmdsource->Subscribe("/harvest", this);
  91. cmdsource->Subscribe("/game", this);
  92. cmdsource->Subscribe("/give", this);
  93. cmdsource->Subscribe("/guard", this);
  94. cmdsource->Subscribe("/help", this);
  95. cmdsource->Subscribe("/ignore", this);
  96. cmdsource->Subscribe("/introduce", this);
  97. cmdsource->Subscribe("/join", this);
  98. cmdsource->Subscribe("/leave", this);
  99. cmdsource->Subscribe("/loot", this);
  100. cmdsource->Subscribe("/marriage", this);
  101. cmdsource->Subscribe("/motd", this);
  102. cmdsource->Subscribe("/mount", this);
  103. cmdsource->Subscribe("/note", this);
  104. cmdsource->Subscribe("/npcmenu", this);
  105. cmdsource->Subscribe("/pet", this);
  106. cmdsource->Subscribe("/picklock", this);
  107. cmdsource->Subscribe("/pickup", this);
  108. cmdsource->Subscribe("/pos", this);
  109. //cmdsource->Subscribe("/quests", this);
  110. cmdsource->Subscribe("/repair", this);
  111. cmdsource->Subscribe("/roll", this);
  112. cmdsource->Subscribe("/rotate", this);
  113. cmdsource->Subscribe("/selecttab", this);
  114. cmdsource->Subscribe("/sell", this);
  115. cmdsource->Subscribe("/show", this);
  116. cmdsource->Subscribe("/sit", this);
  117. //cmdsource->Subscribe("/spawn", this);
  118. cmdsource->Subscribe("/stand", this);
  119. cmdsource->Subscribe("/starttrading", this);
  120. cmdsource->Subscribe("/stopattack", this);
  121. cmdsource->Subscribe("/stoptrading", this);
  122. cmdsource->Subscribe("/study", this);
  123. cmdsource->Subscribe("/target", this);
  124. cmdsource->Subscribe("/targetcontext", this);
  125. cmdsource->Subscribe("/targetinfo", this);
  126. cmdsource->Subscribe("/tip", this);
  127. cmdsource->Subscribe("/trade", this);
  128. cmdsource->Subscribe("/train", this);
  129. cmdsource->Subscribe("/unmount", this);
  130. cmdsource->Subscribe("/unstick", this);
  131. cmdsource->Subscribe("/use", this);
  132. cmdsource->Subscribe("/who", this); // list players on server
  133. cmdsource->Subscribe("/window", this); // handles extended window options
  134. cmdsource->Subscribe("/write", this);
  135. cmdsource->Subscribe("/yield", this);
  136. cmdsource->Subscribe("/takeall", this); // Take all items from a container
  137. cmdsource->Subscribe("/takestackall", this); // Take all items from a container and stack not precisely
  138. cmdsource->Subscribe("/attacklist", this); //temp
  139. cmdsource->Subscribe("/setdesc", this); // set the description of a char
  140. cmdsource->Subscribe("/setoocdesc", this); // set the ooc description of a char
  141. cmdsource->Subscribe("/loaddesc", this); // load a description for this char from a file
  142. cmdsource->Subscribe("/loadoocdesc", this); // load a ooc description for this char from a file
  143. cmdsource->Subscribe("/loadshortcuts", this); // load shortcuts bar from a named file
  144. cmdsource->Subscribe("/saveshortcuts", this); // load shortcuts bar from a named file
  145. cmdsource->Subscribe("/togglerun", this); // Change the run/walk status of the character
  146. cmdsource->Subscribe("/rename", this); // Rename an item
  147. }
  148. psUserCommands::~psUserCommands()
  149. {
  150. // msgqueue->Unsubscribe(MSGTYPE_CHAT,this);
  151. cmdsource->Unsubscribe("/admin", this);
  152. cmdsource->Unsubscribe("/advice", this);
  153. cmdsource->Unsubscribe("/advisor", this);
  154. cmdsource->Unsubscribe("/assist", this);
  155. cmdsource->Unsubscribe("/attack", this);
  156. cmdsource->Unsubscribe("/away", this);
  157. cmdsource->Unsubscribe("/bank", this);
  158. cmdsource->Unsubscribe("/brightness", this);
  159. cmdsource->Unsubscribe("/buddy", this);
  160. cmdsource->Unsubscribe("/buy", this);
  161. cmdsource->Unsubscribe("/storage", this);
  162. cmdsource->Unsubscribe("/cast", this);
  163. cmdsource->Unsubscribe("/challenge", this);
  164. cmdsource->Unsubscribe("/clear", this);
  165. cmdsource->Unsubscribe("/combine", this);
  166. cmdsource->Unsubscribe("/uncombine", this);
  167. cmdsource->Unsubscribe("/construct", this);
  168. cmdsource->Unsubscribe("/date", this);
  169. cmdsource->Unsubscribe("/dequip", this);
  170. cmdsource->Unsubscribe("/die", this);
  171. cmdsource->Unsubscribe("/dig", this);
  172. cmdsource->Unsubscribe("/drop", this);
  173. cmdsource->Unsubscribe("/emote", this);
  174. cmdsource->Unsubscribe("/equip", this);
  175. cmdsource->Unsubscribe("/examine", this);
  176. cmdsource->Unsubscribe("/fish", this);
  177. cmdsource->Unsubscribe("/harvest", this);
  178. cmdsource->Unsubscribe("/game", this);
  179. cmdsource->Unsubscribe("/give", this);
  180. cmdsource->Unsubscribe("/guard", this);
  181. cmdsource->Unsubscribe("/help", this);
  182. cmdsource->Unsubscribe("/ignore", this);
  183. cmdsource->Unsubscribe("/introduce", this);
  184. cmdsource->Unsubscribe("/join", this);
  185. cmdsource->Unsubscribe("/leave", this);
  186. cmdsource->Unsubscribe("/loot", this);
  187. cmdsource->Unsubscribe("/marriage", this);
  188. cmdsource->Unsubscribe("/motd", this);
  189. cmdsource->Unsubscribe("/mount", this);
  190. cmdsource->Unsubscribe("/note", this);
  191. cmdsource->Unsubscribe("/npcmenu", this);
  192. cmdsource->Unsubscribe("/pet", this);
  193. cmdsource->Unsubscribe("/picklock", this);
  194. cmdsource->Unsubscribe("/pickup", this);
  195. cmdsource->Unsubscribe("/pos", this);
  196. //cmdsource->Unsubscribe("/quests", this);
  197. cmdsource->Unsubscribe("/repair", this);
  198. cmdsource->Unsubscribe("/roll", this);
  199. cmdsource->Unsubscribe("/rotate", this);
  200. cmdsource->Unsubscribe("/selecttab", this);
  201. cmdsource->Unsubscribe("/sell", this);
  202. cmdsource->Unsubscribe("/show", this);
  203. cmdsource->Unsubscribe("/sit", this);
  204. //cmdsource->Unsubscribe("/spawn", this);
  205. cmdsource->Unsubscribe("/stand", this);
  206. cmdsource->Unsubscribe("/starttrading", this);
  207. cmdsource->Unsubscribe("/stopattack", this);
  208. cmdsource->Unsubscribe("/stoptrading", this);
  209. cmdsource->Unsubscribe("/study", this);
  210. cmdsource->Unsubscribe("/target", this);
  211. cmdsource->Unsubscribe("/targetcontext", this);
  212. cmdsource->Unsubscribe("/targetinfo", this);
  213. cmdsource->Unsubscribe("/tip", this);
  214. cmdsource->Unsubscribe("/trade", this);
  215. cmdsource->Unsubscribe("/train", this);
  216. cmdsource->Unsubscribe("/unmount", this);
  217. cmdsource->Unsubscribe("/unstick", this);
  218. cmdsource->Unsubscribe("/use", this);
  219. cmdsource->Unsubscribe("/who", this);
  220. cmdsource->Unsubscribe("/window", this); // handles extended window options
  221. cmdsource->Unsubscribe("/write", this);
  222. cmdsource->Unsubscribe("/yield", this);
  223. cmdsource->Unsubscribe("/takeall", this);
  224. cmdsource->Unsubscribe("/takestackall", this);
  225. cmdsource->Unsubscribe("/attacklist", this); //temp
  226. cmdsource->Unsubscribe("/setdesc", this);
  227. cmdsource->Unsubscribe("/setoocdesc", this);
  228. cmdsource->Unsubscribe("/loaddesc", this);
  229. cmdsource->Unsubscribe("/loadoocdesc", this);
  230. cmdsource->Unsubscribe("/loadshortcuts", this);
  231. cmdsource->Unsubscribe("/saveshortcuts", this);
  232. cmdsource->Unsubscribe("/togglerun", this);
  233. cmdsource->Unsubscribe("/rename", this); // Rename an item
  234. // Unsubscribe emotes.
  235. for(unsigned int i = 0; i < emoteList.GetSize(); i++)
  236. {
  237. // unsubscribe emotes which are subscribed earlier
  238. if(emoteList[i].enabled)
  239. cmdsource->Unsubscribe(emoteList[i].command, this);
  240. }
  241. }
  242. bool psUserCommands::LoadEmotes()
  243. {
  244. iVFS* vfs = psengine->GetVFS();
  245. if(!vfs)
  246. return false;
  247. iDocumentSystem* xml = psengine->GetXMLParser();
  248. csRef<iDocument> doc = xml->CreateDocument();
  249. csRef<iFile> file = vfs->Open("/planeshift/data/emotes.xml", VFS_FILE_READ);
  250. if(!file)
  251. return false;
  252. const char* error = doc->Parse(file);
  253. if(error)
  254. {
  255. Error2("Error loading emotes: %s", error);
  256. return false;
  257. }
  258. csRef<iDocumentNodeIterator> emoteIter = doc->GetRoot()->GetNode("emotes")->GetNodes("emote");
  259. while(emoteIter->HasNext())
  260. {
  261. csRef<iDocumentNode> emoteNode = emoteIter->Next();
  262. EMOTE emote;
  263. emote.command = emoteNode->GetAttributeValue("command");
  264. emote.general = emoteNode->GetAttributeValue("general");
  265. emote.specific = emoteNode->GetAttributeValue("specific");
  266. emote.anim = emoteNode->GetAttributeValue("anim");
  267. // take the value of enabled and check whether its 0 or not
  268. emote.enabled = emoteNode->GetAttributeValueAsBool("enabled", true);
  269. emoteList.Push(emote);
  270. }
  271. // Subscribe emotes.
  272. for(unsigned int i = 0; i < emoteList.GetSize(); i++)
  273. {
  274. // only subscribe emotes that are enabled
  275. if(emoteList[i].enabled)
  276. cmdsource->Subscribe(emoteList[i].command, this);
  277. }
  278. return true;
  279. }
  280. void psUserCommands::HandleSlay(bool answeredYes, void *data)
  281. {
  282. psMessageCracker *msg = (psMessageCracker*)data;
  283. if(answeredYes)
  284. msg->SendMessage();
  285. delete msg;
  286. }
  287. void psUserCommands::AskToSlayBeforeSending(psMessageCracker *msg)
  288. {
  289. // If target is defeated, prompt to slay...otherwise, just send the message.
  290. GEMClientActor *target = dynamic_cast<GEMClientActor*> (psengine->GetCharManager()->GetTarget());
  291. if(target && target->GetMode() == psModeMessage::DEFEATED)
  292. {
  293. pawsYesNoBox *confirm = (pawsYesNoBox*)PawsManager::GetSingleton().FindWidget("YesNoWindow");
  294. confirm->SetCallBack(psUserCommands::HandleSlay, msg, "This will likely kill your opponent! Are you sure you want to attack?");
  295. confirm->Show();
  296. }
  297. else
  298. {
  299. msg->SendMessage();
  300. delete msg;
  301. }
  302. }
  303. const char *psUserCommands::HandleCommand(const char *cmd)
  304. {
  305. WordArray words(cmd, false);
  306. int wordCount = words.GetCount();
  307. if(wordCount == 0)
  308. {
  309. return "";
  310. }
  311. //this section handles the over lap between the original /show command and the newer /window [name] show/hide command both are kept to allow legacy use
  312. if(words[0] == "/show" || (words[0] == "/window" && wordCount == 3 && (words[2] == "show" || words[2] == "hide")))
  313. {
  314. if(words[0] == "/show" && wordCount == 2)
  315. {
  316. pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
  317. if(!ctrlWindow || ctrlWindow->HandleWindowName(words[1]))
  318. {
  319. return NULL;
  320. }
  321. else
  322. {
  323. return "That window cannot be found.";
  324. }
  325. }
  326. else if(wordCount == 3)
  327. {
  328. if(words[2] == "show")
  329. {
  330. pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
  331. if(!ctrlWindow || ctrlWindow->ShowWindowName(words[1]))
  332. {
  333. return NULL;
  334. }
  335. else
  336. {
  337. return "That window cannot be found.";
  338. }
  339. }
  340. if(words[2] == "hide")
  341. {
  342. pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
  343. if(!ctrlWindow || ctrlWindow->HideWindowName(words[1]))
  344. {
  345. return NULL;
  346. }
  347. else
  348. {
  349. return "That window cannot be found.";
  350. }
  351. }
  352. }
  353. return "Usage: /[show|window] [windowname] [hide|show]";
  354. }
  355. else if(words[0] == "/window")
  356. {
  357. if(wordCount == 5 && words[2] == "setposition")
  358. {
  359. pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
  360. if(!ctrlWindow)
  361. {
  362. return "Control window could not be found.";
  363. }
  364. // negative coordinates are relative to the lower right corner
  365. int x = atoi(words[3]);
  366. int y = atoi(words[4]);
  367. if(x < 0)
  368. {
  369. x = psengine->GetG2D()->GetWidth() + x;
  370. }
  371. if(y < 0)
  372. {
  373. y = psengine->GetG2D()->GetHeight() + y;
  374. }
  375. if(ctrlWindow->SetWindowPositionName(words[1], x, y))
  376. {
  377. return NULL;
  378. }
  379. else
  380. {
  381. return "That window cannot be found.";
  382. }
  383. return "Usage: /window [windowname] setposition [x] [y]";
  384. }
  385. else if(wordCount == 3 && words[2] == "getinfo")
  386. {
  387. pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
  388. if(!ctrlWindow)
  389. {
  390. return "Control window could not be found.";
  391. }
  392. pawsChatWindow* chatWindow = (pawsChatWindow*)PawsManager::GetSingleton().FindWidget("ChatWindow");
  393. if(chatWindow)
  394. {
  395. csString info = ctrlWindow->GetWindowInfo(words[1]);
  396. if(info.Length() < 1)
  397. {
  398. return "That window cannot be found.";
  399. }
  400. chatWindow->ChatOutput(info);
  401. return NULL;
  402. }
  403. else
  404. {
  405. return "Could not write window names to Chat";
  406. }
  407. return "Usage: /window [windowname] getinfo";
  408. }
  409. else if(wordCount == 5 && words[2] == "setsize")
  410. {
  411. pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
  412. if(!ctrlWindow)
  413. {
  414. return "Control window could not be found.";
  415. }
  416. int x = atoi(words[3]);
  417. int y = atoi(words[4]);
  418. if(x < 1 || y < 1)
  419. {
  420. return "window size must be greater than 0";
  421. }
  422. if(ctrlWindow->SetWindowSizeName(words[1], x, y))
  423. {
  424. return NULL;
  425. }
  426. else
  427. {
  428. return "That window cannot be found.";
  429. }
  430. return "Usage: /window [windowname] setsize [x] [y]";
  431. }
  432. else if(words[1] == "list")
  433. {
  434. pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
  435. if(!ctrlWindow)
  436. {
  437. return "Control window could not be found.";
  438. }
  439. pawsChatWindow* chatWindow = (pawsChatWindow*)PawsManager::GetSingleton().FindWidget("ChatWindow");
  440. if(chatWindow)
  441. {
  442. chatWindow->ChatOutput(ctrlWindow->GetWindowNames());
  443. return NULL;
  444. }
  445. else
  446. {
  447. return "Could not write window names to Chat";
  448. }
  449. return "Usage: /window list";
  450. }
  451. else
  452. {
  453. return "Usage: /window [list|name|all] [getinfo|setposition|setsize|show|hide] [x] [y]";
  454. }
  455. }
  456. else if ( words[0] == "/study" )
  457. {
  458. pawsWidget * widget = PawsManager::GetSingleton().FindWidget("CraftWindow");
  459. if ( widget )
  460. widget->Show();
  461. return NULL;
  462. }
  463. else if (words[0] == "/equip" || (words[0] == "/use" && wordCount > 1))
  464. {
  465. if ( wordCount < 2 )
  466. return "Usage: /equip [stack count] [slot] [item name]";
  467. int tail = 1;
  468. int quantity = atoi(words[1]);
  469. if (quantity > 0)
  470. {
  471. tail++;
  472. if ( tail >= wordCount )
  473. return "Usage: /equip [stack count] [slot] [item name]";
  474. }
  475. else
  476. quantity = 1;
  477. pawsInventoryWindow* window = (pawsInventoryWindow*)PawsManager::GetSingleton().FindWidget("InventoryWindow");
  478. int slotID = -1;
  479. pawsSlot* toSlot = dynamic_cast <pawsSlot*>(window->FindWidget(words[tail]));
  480. if (toSlot)
  481. {
  482. slotID = toSlot->ID();
  483. tail++;
  484. if ( tail >= wordCount )
  485. return "Usage: /equip [stack count] [slot] [item name]";
  486. }
  487. csString itemName;
  488. itemName = words.GetTail(tail);
  489. if (!window->Equip( itemName, quantity, slotID ))
  490. return "Usage: /equip [stack count] [slot] [item name]";
  491. }
  492. else if ( words[0] == "/dequip" )
  493. {
  494. if ( wordCount < 2 )
  495. return "Usage: /dequip [item name|slot name]";
  496. pawsInventoryWindow* window = (pawsInventoryWindow*)PawsManager::GetSingleton().FindWidget("InventoryWindow");
  497. csString itemName( words.GetTail(1) );
  498. window->Dequip( itemName );
  499. }
  500. else if ( words[0] == "/write" )
  501. {
  502. if ( wordCount < 2 )
  503. return "Usage: /write [item name|slot name]";
  504. pawsInventoryWindow* window = (pawsInventoryWindow*)PawsManager::GetSingleton().FindWidget("InventoryWindow");
  505. csString itemName( words.GetTail(1) );
  506. window->Write( itemName );
  507. }
  508. else if (words[0] == "/rotate")
  509. {
  510. if ( wordCount < 2 )
  511. return "Usage: /rotate [target] [x|reset] [y|reset] [z|reset] or /rotate [target] [x|y|z] [angle]";
  512. bool targetGiven = false;
  513. csString targetString;
  514. // if the command's target is not precised, get the object currently targeted
  515. // isdigit(words[1][0] checks if the first argument is a number
  516. if(words[1] == "x" || words[1] == "y" || words[1] == "z" ||
  517. words[1] == "reset" || isdigit(words[1].GetAt(0)) || atoi(words[1]))
  518. targetString = FormatTarget();
  519. else
  520. {
  521. targetString = FormatTarget(words[1]);
  522. targetGiven = true;
  523. }
  524. if(!targetString.IsEmpty())
  525. {
  526. csString newCmd;
  527. newCmd.Append("/rotate ");
  528. newCmd.Append(targetString);
  529. newCmd.Append(" ");
  530. if(targetGiven)
  531. newCmd.Append(words.GetTail(2).GetDataSafe());
  532. else
  533. newCmd.Append(words.GetTail(1).GetDataSafe());
  534. psUserCmdMessage cmdmsg(newCmd);
  535. cmdmsg.SendMessage();
  536. }
  537. else
  538. return "You need to precise a target or to select one";
  539. }
  540. else if(words[0] == "/sell")
  541. {
  542. csString buff;
  543. if(wordCount > 1){
  544. csString tail = words.GetTail(1);
  545. buff.Format("<R TYPE=\"SELL\" TARGET=\"%s\"/>", tail.GetData());
  546. }
  547. else
  548. {
  549. buff.Format("<R TYPE=\"SELL\"/>"); // If no target specified by user use active target
  550. }
  551. psGUIMerchantMessage exchange(psGUIMerchantMessage::REQUEST, buff);
  552. exchange.SendMessage();
  553. }
  554. else if(words[0] == "/attacklist")
  555. {
  556. pawsWidget* window = PawsManager::GetSingleton().FindWidget("AttackBookWindow");
  557. if(!window)
  558. return "Attack List Not Found";
  559. else
  560. window->Show();
  561. }
  562. else if(words[0] == "/brightness")
  563. {
  564. const char* usage = "Usage: /brightness [<value>|increase|decrease|reset]";
  565. if(wordCount != 2) //if there were no arguments open the buddy window
  566. {
  567. return usage;
  568. }
  569. else //else send the data to the server for parsing
  570. {
  571. if(csStrNCaseCmp(words[1].GetDataSafe(), "increase", 1) == 0) // Only need to compare first to make uniq
  572. {
  573. psengine->AdjustBrightnessCorrectionUp();
  574. }
  575. else if(csStrNCaseCmp(words[1].GetDataSafe(), "decrease", 1) == 0) // Only need to compare first to make uniq
  576. {
  577. psengine->AdjustBrightnessCorrectionDown();
  578. }
  579. else if(csStrNCaseCmp(words[1].GetDataSafe(), "reset", 1) == 0) // Only need to compare first to make uniq
  580. {
  581. psengine->ResetBrightnessCorrection();
  582. }
  583. else if(words.IsFloat(1))
  584. {
  585. csString sysMsg;
  586. float brightnessCorrection = words.GetFloat(1);
  587. // Cap values
  588. if(brightnessCorrection > 3.0)
  589. {
  590. brightnessCorrection = 3.0;
  591. }
  592. else if(brightnessCorrection < -1.0)
  593. {
  594. brightnessCorrection = -1.0;
  595. }
  596. // Update engine
  597. psengine->SetBrightnessCorrection(brightnessCorrection);
  598. psengine->UpdateLights();
  599. // Inform user
  600. sysMsg.Format("Brightness correction: %0.1f", brightnessCorrection);
  601. psSystemMessage ackMsg(0, MSG_OK, sysMsg);
  602. ackMsg.FireEvent();
  603. }
  604. else
  605. {
  606. return usage;
  607. }
  608. }
  609. }
  610. else if(words[0] == "/buddy")
  611. {
  612. if(wordCount < 2) //if there were no arguments open the buddy window
  613. {
  614. pawsWidget* window = PawsManager::GetSingleton().FindWidget("BuddyWindow");
  615. if(!window)
  616. return "Buddy List Not Found";
  617. else
  618. window->Show();
  619. }
  620. else //else send the data to the server for parsing
  621. {
  622. psUserCmdMessage cmdmsg(cmd);
  623. cmdmsg.SendMessage();
  624. }
  625. }
  626. else if(words[0] == "/buy")
  627. {
  628. csString buff;
  629. if(wordCount > 1){
  630. csString tail = words.GetTail(1);
  631. buff.Format("<R TYPE=\"BUY\" TARGET=\"%s\"/>", tail.GetData());
  632. }
  633. else
  634. {
  635. buff.Format("<R TYPE=\"BUY\"/>"); // If no target specified by user use active target
  636. }
  637. psGUIMerchantMessage exchange(psGUIMerchantMessage::REQUEST, buff);
  638. exchange.SendMessage();
  639. }
  640. else if(words[0] == "/storage")
  641. {
  642. csString buff;
  643. if(wordCount > 1)
  644. {
  645. csString tail = words.GetTail(1);
  646. buff.Format("<R TYPE=\"STORE\" TARGET=\"%s\"/>", tail.GetData());
  647. }
  648. else
  649. {
  650. buff.Format("<R TYPE=\"STORE\"/>"); // If no target specified by user use active target
  651. }
  652. psGUIStorageMessage storage(psGUIStorageMessage::REQUEST, buff);
  653. storage.SendMessage();
  654. }
  655. else if(words[0] == "/trade")
  656. {
  657. psExchangeRequestMsg exchange(true);
  658. exchange.SendMessage();
  659. }
  660. else if(words[0] == "/give")
  661. {
  662. psExchangeRequestMsg exchange(false);
  663. exchange.SendMessage();
  664. }
  665. else if(words[0] == "/ignore")
  666. {
  667. bool onoff = false;
  668. bool toggle = false;
  669. pawsIgnoreWindow* window = (pawsIgnoreWindow*)PawsManager::GetSingleton().FindWidget("IgnoreWindow");
  670. if(!window)
  671. return "Ignore Window Not Found";
  672. if(wordCount < 2) //If the player didn't provide arguments just open the ignore window
  673. window->Show();
  674. else //If the player provided a name apply the setting
  675. {
  676. if(words[2] == "add") //The player provided an on so set ignore
  677. onoff = true;
  678. else if(words[2] == "remove") //The player provided an off so unset ignore
  679. onoff = false;
  680. else //The player didn't provide anything so toggle the option
  681. toggle = true;
  682. csString person(words[1]);
  683. //normalize the name
  684. person.Downcase();
  685. person.SetAt(0, toupper(person.GetAt(0)));
  686. if(toggle) //No options were sent so toggle the option
  687. {
  688. if(window->IsIgnored(person)) //If the person is ignored...
  689. window->RemoveIgnore(person); //Remove his/her ignore status
  690. else
  691. window->AddIgnore(person);//else add the person to the ignore list
  692. }
  693. else
  694. {
  695. if(onoff) //The player requested explictly to add the ignore
  696. window->AddIgnore(person);
  697. else if(window->IsIgnored(person)) //the player requested explictly to remove the ignore
  698. window->RemoveIgnore(person);
  699. }
  700. }
  701. }
  702. else if(words[0] == "/cast")
  703. {
  704. if(wordCount <= 1)
  705. return "You must specify a spell name";
  706. csString spell;
  707. float KFactor;
  708. if(wordCount > 2 && sscanf(words[1], "%f", &KFactor) == 1)
  709. {
  710. spell = words.GetTail(2);
  711. }
  712. else
  713. {
  714. KFactor = psengine->GetKFactor();
  715. spell = words.GetTail(1);
  716. }
  717. if(KFactor < 0 || KFactor > 100)
  718. return "Spell power must be a percentage.";
  719. AskToSlayBeforeSending(new psSpellCastMessage(spell, KFactor));
  720. }
  721. else if(words[0] == "/away")
  722. {
  723. pawsChatWindow* ChatWindow = (pawsChatWindow*)PawsManager::GetSingleton().FindWidget("ChatWindow");
  724. if(wordCount > 1)
  725. {
  726. ChatWindow->SetAway(words.GetTail(1));
  727. }
  728. else
  729. {
  730. ChatWindow->SetAway("");
  731. }
  732. }
  733. else if(words[0] == "/clear")
  734. {
  735. int tab;
  736. const char* output = "/clear <all|main|channels/chat|npc|tell/whisper|guild|alliance|group|auction|system|help>";
  737. if(wordCount > 2)
  738. {
  739. return output;
  740. }
  741. else if(wordCount == 2)
  742. {
  743. if(words[1] == "all")
  744. {
  745. tab = -2;
  746. }
  747. else if(words[1] == "main")
  748. {
  749. tab = 0; // IDs defined in chat.xml
  750. }
  751. else if(words[1] == "channels" || words[1] == "chat")
  752. {
  753. tab = 1;
  754. }
  755. else if(words[1] == "npc")
  756. {
  757. tab = 2;
  758. }
  759. else if(words[1] == "whisper" || words[1] == "tell")
  760. {
  761. tab = 3;
  762. }
  763. else if(words[1] == "guild")
  764. {
  765. tab = 4;
  766. }
  767. else if(words[1] == "group")
  768. {
  769. tab = 5;
  770. }
  771. else if(words[1] == "alliance")
  772. {
  773. tab = 6;
  774. }
  775. else if(words[1] == "auction")
  776. {
  777. tab = 7;
  778. }
  779. else if(words[1] == "system")
  780. {
  781. tab = 8;
  782. }
  783. else if(words[1] == "help")
  784. {
  785. tab = 9;
  786. }
  787. else
  788. {
  789. return output;
  790. }
  791. }
  792. else
  793. {
  794. tab = -1; // current selected tab
  795. }
  796. pawsChatWindow* ChatWindow = dynamic_cast<pawsChatWindow*>(PawsManager::GetSingleton().FindWidget("ChatWindow"));
  797. ChatWindow->Clear(tab);
  798. }
  799. else if(words[0] == "/selecttab")
  800. {
  801. int tab;
  802. const char* output = "/selecttab <main|channels|npc|whisper|guild|alliance|group|auction|system|help>";
  803. if(wordCount > 2)
  804. {
  805. return output;
  806. }
  807. else if(wordCount == 2)
  808. {
  809. if(words[1] == "main")
  810. {
  811. tab = 0; // IDs defined in chat.xml
  812. }
  813. else if(words[1] == "channels")
  814. {
  815. tab = 1;
  816. }
  817. else if(words[1] == "npc")
  818. {
  819. tab = 2;
  820. }
  821. else if(words[1] == "whisper")
  822. {
  823. tab = 3;
  824. }
  825. else if(words[1] == "guild")
  826. {
  827. tab = 4;
  828. }
  829. else if(words[1] == "group")
  830. {
  831. tab = 5;
  832. }
  833. else if(words[1] == "alliance")
  834. {
  835. tab = 6;
  836. }
  837. else if(words[1] == "auction")
  838. {
  839. tab = 7;
  840. }
  841. else if(words[1] == "system")
  842. {
  843. tab = 8;
  844. }
  845. else if(words[1] == "help")
  846. {
  847. tab = 9;
  848. }
  849. else
  850. {
  851. return output;
  852. }
  853. }
  854. else
  855. {
  856. return output;
  857. }
  858. pawsChatWindow* ChatWindow = dynamic_cast<pawsChatWindow*>(PawsManager::GetSingleton().FindWidget("ChatWindow"));
  859. ChatWindow->SelectChatTab(tab);
  860. }
  861. else if(words[0] == "/target")
  862. {
  863. if(words[1].IsEmpty())
  864. {
  865. return "/target [self|clear] or /target [prev|next|nearest] <item|npc|player>|[alive|dead|any]";
  866. }
  867. else if(words[1] == "self")
  868. psengine->GetCharManager()->SetTarget(psengine->GetCelClient()->GetMainPlayer(), "select");
  869. else
  870. {
  871. SearchDirection dir;
  872. csString tail;
  873. if(words[1] == "next")
  874. {
  875. dir = SEARCH_FORWARD;
  876. tail = words.GetTail(2);
  877. }
  878. else if(words[1] == "prev")
  879. {
  880. dir = SEARCH_BACK;
  881. tail = words.GetTail(2);
  882. }
  883. else if(words[1] == "nearest")
  884. {
  885. dir = SEARCH_NONE;
  886. tail = words.GetTail(2);
  887. }
  888. else
  889. {
  890. dir = SEARCH_NONE;
  891. tail = words.GetTail(1);
  892. }
  893. if(tail == "item")
  894. UpdateTarget(dir, PSENTITYTYPE_ITEM, NULL);
  895. else if(tail == "npc")
  896. UpdateTarget(dir, PSENTITYTYPE_NON_PLAYER_CHARACTER, NULL);
  897. else if(tail == "player" || tail == "pc")
  898. UpdateTarget(dir, PSENTITYTYPE_PLAYER_CHARACTER, NULL);
  899. else if(tail == "alive")
  900. UpdateTarget(dir, PSENTITYTYPE_ALIVE_CHARACTER, NULL);
  901. else if(tail == "dead")
  902. UpdateTarget(dir, PSENTITYTYPE_DEAD_CHARACTER, NULL);
  903. else if(tail == "any")
  904. UpdateTarget(dir, PSENTITYTYPE_NO_TARGET, NULL);
  905. else if(tail == "clear")
  906. psengine->GetCharManager()->SetTarget(NULL, "select");
  907. else
  908. UpdateTarget(dir, PSENTITYTYPE_NAME, tail);
  909. }
  910. }
  911. else if(words[0] == "/targetcontext")
  912. {
  913. GEMClientObject *object = NULL;
  914. if(words[1].IsEmpty())
  915. object = psengine->GetCharManager()->GetTarget();
  916. else
  917. object = FindEntityWithName(words[1]);
  918. if(object)
  919. psengine->GetCharManager()->SetTarget(object, "context");
  920. }
  921. else if(words[0] == "/use" ||
  922. words[0] == "/combine" ||
  923. words[0] == "/uncombine" ||
  924. words[0] == "/construct" ||
  925. words[0] == "/dig" ||
  926. words[0] == "/fish" ||
  927. words[0] == "/harvest" ||
  928. words[0] == "/repair")
  929. {
  930. psWorkCmdMessage work(cmd);
  931. work.SendMessage();
  932. }
  933. else if(words[0] == "/picklock")
  934. {
  935. psLockpickMessage lockpick("");
  936. lockpick.SendMessage();
  937. }
  938. else if(words[0] == "/targetinfo")
  939. {
  940. pawsDetailWindow* detail = (pawsDetailWindow*)PawsManager::GetSingleton().FindWidget("DetailWindow");
  941. detail->RequestDetails();
  942. return NULL;
  943. }
  944. else if(words[0] == "/advisor") //this manages all the subcases of advisor: on, off, list, listsessions, reuquests
  945. {
  946. csString pPerson;
  947. csString pText;
  948. psAdviceMessage advice(0, words[1].GetDataSafe(), pPerson.GetDataSafe(), pText.GetDataSafe());
  949. advice.SendMessage();
  950. return NULL;
  951. }
  952. else if(words[0] == "/help") //used to request help
  953. {
  954. //get the chatwindow for use later
  955. pawsChatWindow* chatWindow = dynamic_cast<pawsChatWindow*>(PawsManager::GetSingleton().FindWidget("ChatWindow"));
  956. csString pPerson;
  957. csString pText(words.GetTail(1));
  958. if(pText.IsEmpty())
  959. return "You must enter the text. e.g /help [text]";
  960. if(chatWindow && chatWindow->GetSettings().enableBadWordsFilterOutgoing) //check for badwords filtering
  961. chatWindow->BadWordsFilter(pText); //if enabled apply it
  962. psAdviceMessage advice(0, words[0].GetDataSafe(), pPerson.GetDataSafe(), pText.GetDataSafe());
  963. advice.SendMessage();
  964. return NULL;
  965. }
  966. else if(words[0] == "/advice") //used to give help
  967. {
  968. //get the chatwindow for use later
  969. pawsChatWindow* chatWindow = dynamic_cast<pawsChatWindow*>(PawsManager::GetSingleton().FindWidget("ChatWindow"));
  970. if(wordCount < 2)
  971. return "You must enter the text. e.g /Advice [user] <text>";
  972. csString pPerson(words[1]);
  973. csString pText(words.GetTail(2));
  974. if(chatWindow && chatWindow->GetSettings().enableBadWordsFilterOutgoing) //check for badwords filtering
  975. chatWindow->BadWordsFilter(pText); //if enabled apply it
  976. psAdviceMessage advice(0, words[0], pPerson, pText);
  977. advice.SendMessage();
  978. return NULL;
  979. }
  980. else if(words[0] == "/pet")
  981. {
  982. const char* errorMsg = "Usage: /pet [petnumber,] <assist|attack|dismiss|follow|guard|name|run|stay|stopattack|summon|target|walk> [options]";
  983. if(wordCount < 2)
  984. return errorMsg;
  985. csString pCommand = words[1];
  986. csString target, options;
  987. // Check for "," in word 2. This could
  988. // happen if the pet name is in quotes.
  989. if(wordCount > 2 && words[2] == ",")
  990. {
  991. pCommand += ",";
  992. words.DeleteIndex(2);
  993. }
  994. // Is there a , for pet name?
  995. if(pCommand.FindFirst(',') != (size_t)-1)
  996. {
  997. // Pet name specified
  998. if(wordCount < 3)
  999. return errorMsg;
  1000. pCommand = words[2];
  1001. target = words[1];
  1002. options = words.GetTail(3);
  1003. }
  1004. else
  1005. {
  1006. // No pet specified, use default
  1007. pCommand = words[1];
  1008. target.Clear();
  1009. options = words.GetTail(2);
  1010. }
  1011. pCommand.Upcase();
  1012. int command;
  1013. if(pCommand == "ASSIST") { command = psPETCommandMessage::CMD_ASSIST; }
  1014. else if(pCommand == "ATTACK") { command = psPETCommandMessage::CMD_ATTACK; }
  1015. else if(pCommand == "DISMISS") { command = psPETCommandMessage::CMD_DISMISS; }
  1016. else if(pCommand == "FOLLOW") { command = psPETCommandMessage::CMD_FOLLOW; }
  1017. else if(pCommand == "GUARD") { command = psPETCommandMessage::CMD_GUARD; }
  1018. else if(pCommand == "NAME") { command = psPETCommandMessage::CMD_NAME; }
  1019. else if(pCommand == "RUN") { command = psPETCommandMessage::CMD_RUN; }
  1020. else if(pCommand == "STAY") { command = psPETCommandMessage::CMD_STAY; }
  1021. else if(pCommand == "STOPATTACK"){ command = psPETCommandMessage::CMD_STOPATTACK; }
  1022. else if(pCommand == "SUMMON") { command = psPETCommandMessage::CMD_SUMMON; }
  1023. else if(pCommand == "TARGET") { command = psPETCommandMessage::CMD_TARGET; }
  1024. else if(pCommand == "WALK") { command = psPETCommandMessage::CMD_WALK; }
  1025. else { return errorMsg; }
  1026. switch(command)
  1027. {
  1028. case psPETCommandMessage::CMD_DISMISS:
  1029. {
  1030. // If we're dismissing the pet, we should close the stat window
  1031. pawsPetStatWindow* petwindow = (pawsPetStatWindow*)PawsManager::GetSingleton().FindWidget("PetStatWindow");
  1032. if(!petwindow)
  1033. {
  1034. return "Pet stat window not found!";
  1035. }
  1036. petwindow->Hide();
  1037. }
  1038. break;
  1039. case psPETCommandMessage::CMD_TARGET:
  1040. // If no name give use target name if exists
  1041. if(options.Length() == 0 && psengine->GetCharManager()->GetTarget())
  1042. {
  1043. options.Format("eid:%u", psengine->GetCharManager()->GetTarget()->GetEID().Unbox());
  1044. }
  1045. default:
  1046. // Most cases do nothing
  1047. break;
  1048. }
  1049. psPETCommandMessage cmd(0, command, target.GetData(), options.GetData());
  1050. cmd.SendMessage();
  1051. return NULL;
  1052. }
  1053. else if(words[0] == "/guard")
  1054. {
  1055. unsigned int onoff = 0;
  1056. csString targetString;
  1057. if(words[1].IsEmpty())
  1058. {
  1059. targetString = FormatTarget();
  1060. }
  1061. else if(words[1] == "on" || words[1] == "off")
  1062. {
  1063. onoff = 1;
  1064. targetString = FormatTarget();
  1065. }
  1066. else
  1067. {
  1068. targetString = FormatTarget(words[1]);
  1069. if(!words[2].IsEmpty())
  1070. {
  1071. onoff = 2;
  1072. }
  1073. }
  1074. if(!targetString.IsEmpty())
  1075. {
  1076. csString newCmd;
  1077. newCmd.Append("/guard ");
  1078. newCmd.Append(targetString);
  1079. if(onoff > 0)
  1080. {
  1081. newCmd.Append(" ");
  1082. newCmd.Append(words[onoff]);
  1083. }
  1084. psUserCmdMessage cmdmsg(newCmd);
  1085. cmdmsg.SendMessage();
  1086. }
  1087. else
  1088. return "You need to specify a target or to select one";
  1089. }
  1090. else if(words[0] == "/pickup")
  1091. {
  1092. csString targetString;
  1093. if(words[1].IsEmpty())
  1094. {
  1095. targetString = FormatTarget();
  1096. }
  1097. else
  1098. {
  1099. targetString = FormatTarget(words[1]);
  1100. }
  1101. if(!targetString.IsEmpty())
  1102. {
  1103. csString newCmd;
  1104. newCmd.Append("/pickup ");
  1105. newCmd.Append(targetString);
  1106. psUserCmdMessage cmdmsg(newCmd);
  1107. cmdmsg.SendMessage();
  1108. }
  1109. else
  1110. return "You need to specify a target or to select one";
  1111. }
  1112. // Handle /takestackall command
  1113. else if(words[0] == "/takestackall")
  1114. {
  1115. //printf("cmdusers 801, sending /takestackall to server.\n");
  1116. csString newCmd;
  1117. newCmd.Append("/takestackall");
  1118. psUserCmdMessage cmdmsg(newCmd);
  1119. cmdmsg.SendMessage();
  1120. }
  1121. // Handle /takeall command
  1122. else if(words[0] == "/takeall")
  1123. {
  1124. //printf("cmdusers 801, sending /takeall to server.\n");
  1125. csString newCmd;
  1126. newCmd.Append("/takeall");
  1127. psUserCmdMessage cmdmsg(newCmd);
  1128. cmdmsg.SendMessage();
  1129. }
  1130. else if(words[0] == "/game")
  1131. {
  1132. // Find the game board window and start a new game session.
  1133. pawsGameBoard *gameWindow = dynamic_cast<pawsGameBoard *>
  1134. (PawsManager::GetSingleton().FindWidget("GameBoardWindow"));
  1135. if(gameWindow)
  1136. gameWindow->StartGame();
  1137. else
  1138. Error1("Couldn't find widget GameBoardWindow");
  1139. // The window will be shown when the server responds back with the game layout.
  1140. return NULL;
  1141. }
  1142. else if(words[0] == "/attack")
  1143. {
  1144. AskToSlayBeforeSending(new psUserCmdMessage(cmd));
  1145. }
  1146. else if(words[0] == "/introduce")
  1147. {
  1148. psCharIntroduction introduce;
  1149. introduce.SendMessage();
  1150. }
  1151. else if(words[0] == "/unstick")
  1152. {
  1153. psUserCmdMessage cmdmsg(cmd);
  1154. cmdmsg.SendMessage();
  1155. psengine->GetCharControl()->GetMovementManager()->StopAllMovement();
  1156. }
  1157. else if(words[0] == "/drop")
  1158. {
  1159. if(wordCount < 2)
  1160. {
  1161. return "Usage: /drop [quantity | <all>] <any> <noguard> <inplace> [item name | <next>]";
  1162. }
  1163. int quantity;
  1164. csString itemName;
  1165. bool any = false;
  1166. bool guard = true;
  1167. bool inplace = false;
  1168. int moneySlot = 0;
  1169. unsigned int i = 1;
  1170. // if the first word is a number, use that for quantity
  1171. quantity = atoi(words[1]);
  1172. if(quantity)
  1173. {
  1174. i++;
  1175. }
  1176. else if(words[1] == "all")
  1177. {
  1178. quantity = 65;
  1179. i++;
  1180. }
  1181. else
  1182. {
  1183. quantity = 1;
  1184. }
  1185. if(words[i] == "any")
  1186. {
  1187. i++;
  1188. any = true;
  1189. }
  1190. if(words[i] == "noguard")
  1191. {
  1192. i++;
  1193. guard = false;
  1194. }
  1195. if(words[i] == "inplace")
  1196. {
  1197. i++;
  1198. inplace = true;
  1199. }
  1200. // Search for money, and assign the moneySlot according to type of
  1201. // coins found.
  1202. if(words[i] == "tria" || (words[i] == "hexa" && (moneySlot = 1)) ||
  1203. (words[i] == "octa" && (moneySlot = 2)) || (words[i] == "circle" && (moneySlot = 3)))
  1204. {
  1205. psSlotMovementMsg moneydropmsg(CONTAINER_INVENTORY_MONEY, moneySlot,
  1206. CONTAINER_WORLD, 0, quantity, 0, 0, guard, inplace);
  1207. moneydropmsg.SendMessage();
  1208. return NULL;
  1209. }
  1210. else
  1211. {
  1212. itemName = words.GetTail(i);
  1213. if(itemName.IsEmpty())
  1214. {
  1215. return "Please specify [item name | <next>]!";
  1216. }
  1217. else if(itemName.CompareNoCase("next"))
  1218. {
  1219. pawsInventoryWindow* inventoryWindow = dynamic_cast<pawsInventoryWindow*>(PawsManager::GetSingleton().FindWidget("InventoryWindow"));
  1220. pawsSlot* notFreeSlot = inventoryWindow->GetNotFreeSlot();
  1221. if(notFreeSlot)
  1222. {
  1223. itemName = notFreeSlot->GetToolTip();
  1224. }
  1225. else
  1226. {
  1227. return "Your inventory is empty!";
  1228. }
  1229. }
  1230. psCmdDropMessage cmddrop(quantity, itemName, any, guard, inplace);
  1231. cmddrop.SendMessage();
  1232. }
  1233. }
  1234. else if(words[0] == "/emote")
  1235. {
  1236. if(wordCount < 2 || words[1] == "list")
  1237. {
  1238. //generate a message
  1239. csString emotelistmsg = "List of emotes:\n";
  1240. for(unsigned int i = 0; i < emoteList.GetSize(); i++)
  1241. {
  1242. emotelistmsg += emoteList[i].command.Slice(1);
  1243. emotelistmsg += ", ";
  1244. }
  1245. pawsChatWindow* chatWindow = (pawsChatWindow*)PawsManager::GetSingleton().FindWidget("ChatWindow");
  1246. if(chatWindow)
  1247. chatWindow->ChatOutput(emotelistmsg);
  1248. }
  1249. else
  1250. {
  1251. for(unsigned int i = 0; i < emoteList.GetSize(); i++)
  1252. {
  1253. if(emoteList[i].command.Slice(1) == words[1])
  1254. {
  1255. psUserCmdMessage cmdmsg(emoteList[i].command);
  1256. cmdmsg.SendMessage();
  1257. break;
  1258. }
  1259. }
  1260. }
  1261. }
  1262. else if(words[0] == "/mount")
  1263. {
  1264. GEMClientObject *object = NULL;
  1265. csString newCmd;
  1266. if(words[1].IsEmpty())
  1267. object = psengine->GetCharManager()->GetTarget();
  1268. else
  1269. object = FindEntityWithName(words[1]);
  1270. if(object)
  1271. {
  1272. psengine->GetCharManager()->SetTarget(object, "select");
  1273. EID mappedID = object->GetEID();
  1274. newCmd.Format("/mount eid:%u", mappedID.Unbox());
  1275. }
  1276. else
  1277. {
  1278. newCmd.Format("/mount");
  1279. }
  1280. psUserCmdMessage cmdmsg(newCmd);
  1281. cmdmsg.SendMessage();
  1282. }
  1283. else if(words[0] == "/note")
  1284. {
  1285. if(wordCount < 3)
  1286. {
  1287. return "/note [TYPE] [Note]";
  1288. }
  1289. extern const char* CHAT_TYPES[];
  1290. int chattype;
  1291. csString type;
  1292. type.Format("CHAT_%s", words[1].GetDataSafe());
  1293. for(int i = 0; i <= CHAT_END; i++)
  1294. {
  1295. if(i == CHAT_END)
  1296. {
  1297. csString output;
  1298. output.Format("%s not found!", type.GetData());
  1299. return output;
  1300. }
  1301. if(!strcasecmp(CHAT_TYPES[i], type.GetData()))
  1302. {
  1303. chattype = i;
  1304. break;
  1305. }
  1306. }
  1307. csString msg;
  1308. msg.Format("Note: %s", words.GetTail(2).GetDataSafe());
  1309. pawsChatWindow* ChatWindow = dynamic_cast<pawsChatWindow*>(PawsManager::GetSingleton().FindWidget("ChatWindow"));
  1310. ChatWindow->LogMessage(msg, chattype);
  1311. PawsManager::GetSingleton().Publish(CHAT_TYPES[chattype], msg);
  1312. }
  1313. else if(words[0] == "/unmount")
  1314. {
  1315. csString newCmd;
  1316. newCmd.Format("/unmount");
  1317. psUserCmdMessage cmdmsg(newCmd);
  1318. cmdmsg.SendMessage();
  1319. }
  1320. else if(words[0] == "/?")
  1321. {
  1322. pawsWidget* widget = PawsManager::GetSingleton().FindWidget("HelpWindow");
  1323. if(widget)
  1324. widget->Show();
  1325. }
  1326. else if(words[0] == "/join")
  1327. {
  1328. if(wordCount < 2)
  1329. {
  1330. return "Please specify a channel name to join.";
  1331. }
  1332. else
  1333. {
  1334. pawsChatWindow* ChatWindow = (pawsChatWindow*)PawsManager::GetSingleton().FindWidget("ChatWindow");
  1335. ChatWindow->JoinChannel(words.GetTail(1));
  1336. }
  1337. }
  1338. else if(words[0] == "/leave")
  1339. {
  1340. if(wordCount < 2)
  1341. {
  1342. return "Please specify a channel hotkey number to leave.";
  1343. }
  1344. else
  1345. {
  1346. pawsChatWindow* ChatWindow = (pawsChatWindow*)PawsManager::GetSingleton().FindWidget("ChatWindow");
  1347. int hotkeyChannel = words.GetInt(1);
  1348. if(hotkeyChannel < 1 || hotkeyChannel > 10)
  1349. {
  1350. return "Please specify a channel hotkey number to leave.";
  1351. }
  1352. if(!ChatWindow->LeaveChannel(hotkeyChannel))
  1353. return "You have not joined that channel.";
  1354. }
  1355. }
  1356. else if(words[0] == "/setdesc")
  1357. {
  1358. if(wordCount < 2)
  1359. {
  1360. return "Please specify the description for this character.";
  1361. }
  1362. else
  1363. {
  1364. csString newDesc = words.GetTail(1);
  1365. // change all "\n" to real linefeeds
  1366. newDesc.ReplaceAll("\\n", "\n");
  1367. psCharacterDescriptionUpdateMessage descUpdate(newDesc, DESC_IC);
  1368. descUpdate.SendMessage();
  1369. return "Character description set.";
  1370. }
  1371. }
  1372. else if(words[0] == "/setoocdesc")
  1373. {
  1374. if(wordCount < 2)
  1375. {
  1376. return "Please specify the OOC description for this character.";
  1377. }
  1378. else
  1379. {
  1380. csString newDesc = words.GetTail(1);
  1381. // change all "\n" to real linefeeds
  1382. newDesc.ReplaceAl

Large files files are truncated, but you can click here to view the full file