]> jfr.im git - irc/gameservirc.git/blame - gameserv/do_equip.cpp
Finished splitting files, and updated dependencies.
[irc/gameservirc.git] / gameserv / do_equip.cpp
CommitLineData
585b7bde 1#include "extern.h"
857510e8 2#include "options.h"
585b7bde 3#include "aClient.h"
4#include "pouch.h"
5#include "item.h"
6#include "flags.h"
7
8void do_equip(char *u)
9{
10 aClient *user;
11 pouch *p;
12 itemContainer *equip;
13 int id;
14
15 char *item = strtok(NULL, " ");
16
17 if (!item || int(item[0]) < 48 || int(item[0] > 57))
18 {
19 notice(s_GameServ, u, "SYNTAX: EQUIP ####");
20 notice(s_GameServ, u, "Type /msg <S HELP EQUIP for more information.");
21 return;
22 }
23 else if (!(user = find(u)))
24 {
25 notice(s_GameServ, u, "Fatal error in do_equip. Contact a(n) <S Admin");
26 return;
27 }
28 else if (isIgnore(user))
29 {
30#ifdef DEBUGMODE
31 log("Ignoring %s.", user->getNick());
32#endif
33 return;
34 }
35 else if (!is_playing(user))
36 {
37 notice(s_GameServ, u, "You must be playing to equip weapons and armor!");
38 return;
39 }
40 id = stringtoint(item);
41 if (!is_fighting(user))
42 updateTS(user->stats);
43 p = user->stats->inventory;
44
45
46 if (!(equip = p->Find(id)))
47 {
48 if (!p->isEmpty())
49 {
50 notice(s_GameServ, u, "You aren't carrying that item!");
51 }
52 showinventory(user->stats, user);
53 }
54 else if (equip->getItem()->getType() != ARMOR && equip->getItem()->getType() != WEAPON)
55 {
56 notice(s_GameServ, u, "You can't use %s like that. Try /msg <S use", equip->getItem()->getName().c_str());
57 }
58 else
59 {
60 // Use the item
61 notice(s_GameServ, u, "You equip %s.", equip->getItem()->getName().c_str());
62 equip->use(user->stats);
63 }
64}