if (!(user = find(u)))
{
notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
- "Buf: %s LOGOUT", u);
+ "Buf: %s LOGOUT", u);
return;
}
else if (isIgnore(user))
#endif
return;
}
- else if (!name)
+ else if (!name || !cmd)
{
notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
return;
else if (!(target = findplayer(name)))
{
// Back the pointers up... they didn't send a name probably
- cmd2= cmd;
+ cmd2 = cmd;
cmd = name;
target = user;
-
+
if (!is_playing(user))
- {
- notice(s_GameServ, u, "You must be playing to set things for yourself!");
- return;
- }
+ {
+ notice(s_GameServ, u, "You must be playing to set things for yourself!");
+ return;
+ }
}
else
{
cmd2 = strtok(NULL, " ");
}
-
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+ return;
+ }
+
// Regardless of the previous if/else, if it got here, we know we have the cmd pointer at the right spot.
if (stricmp(cmd, "PASSWORD") == 0)
{
// If they're an admin, or it's theirself, allow it
// cmd2 is pointing to the password now
if (isAdmin(user) || user == target)
- {
- target->stats->setPassword(cmd2);
- notice(s_GameServ, u, "Password successfully changed");
- }
+ {
+ target->stats->setPassword(cmd2);
+ notice(s_GameServ, u, "Password successfully changed");
+ }
else if (user != target && !isAdmin(user))
- {
- notice(s_GameServ, u, "You must be a %S admin to set other peoples' passwords.");
- return;
- }
+ {
+ notice(s_GameServ, u, "You must be a %S admin to set other peoples' passwords.");
+ return;
+ }
}
else if (stricmp(cmd, "BANK") == 0 || stricmp(cmd, "BALANCE") == 0)
{
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else if (stricmp(cmd, "BANK") == 0)
- {
- cmd2 = strtok(NULL, " "); // Need an extra parameter for set bank balance
- }
- if (!cmd2)
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] [BANK] BALANCE <NUMBER>");
- return;
- }
-
- target->stats->setBank(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Bank balance changed to %ld!", target->stats->getBank());
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else if (stricmp(cmd, "BANK") == 0)
+ {
+ cmd2 = strtok(NULL, " "); // Need an extra parameter for set bank balance
+ }
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] [BANK] BALANCE <NUMBER>");
+ return;
+ }
+
+ target->stats->setBank(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Bank balance changed to %ld!", target->stats->getBank());
}
else if (stricmp(cmd, "PLAYER") == 0)
{
if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
else if (stricmp(cmd2, "FIGHTS") != 0)
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>");
- return;
- }
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>");
+ return;
+ }
else
- {
- cmd2 = strtok(NULL, " ");
- if (!cmd2)
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>");
- return;
- }
- target->stats->setPlayerFights(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Player fights changed to %d!", target->stats->getPlayerFights());
- }
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>");
+ return;
+ }
+ target->stats->setPlayerFights(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Player fights changed to %d!", target->stats->getPlayerFights());
+ }
}
else if (stricmp(cmd, "FOREST") == 0)
{
if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
else if (stricmp(cmd2, "FIGHTS") != 0)
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <number>");
- return;
- }
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <number>");
+ return;
+ }
else
- {
- cmd2 = strtok(NULL, " ");
- if (!cmd2)
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <NUMBER>");
- return;
- }
-
- target->stats->setForestFights(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Forest fights changed to %d!", target->stats->getForestFights());
- }
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <NUMBER>");
+ return;
+ }
+
+ target->stats->setForestFights(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Forest fights changed to %d!", target->stats->getForestFights());
+ }
}
else if (stricmp(cmd, "GOLD") == 0)
- {
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- if (!cmd2)
{
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] GOLD <NUMBER>");
- return;
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] GOLD <NUMBER>");
+ return;
+ }
+ target->stats->setGold(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Gold set to %ld", target->stats->getGold());
+ return;
+ }
}
- target->stats->setGold(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Gold set to %ld", target->stats->getGold());
- return;
- }
- }
else if (stricmp(cmd, "STRENGTH") == 0 && stricmp(cmd2, "POTIONS") != 0)
- {
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- if (!cmd2)
{
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] STRENGTH <NUMBER>");
- return;
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] STRENGTH <NUMBER>");
+ return;
+ }
+
+ target->stats->setStrength(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Strength set to %d", target->stats->getStrength());
+ return;
+ }
}
-
- target->stats->setStrength(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Strength set to %d", target->stats->getStrength());
- return;
- }
- }
else if (stricmp(cmd, "DEFENSE") == 0 && stricmp(cmd2, "POTIONS") != 0)
- {
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- if (!cmd2)
{
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] DEFENSE <NUMBER>");
- return;
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] DEFENSE <NUMBER>");
+ return;
+ }
+
+ target->stats->setDefense(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Defense set to %d", target->stats->getDefense());
+ return;
+ }
}
-
- target->stats->setDefense(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Defense set to %d", target->stats->getDefense());
- return;
- }
- }
else if (stricmp(cmd, "HP") == 0 && stricmp(cmd2, "POTIONS") != 0)
- {
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- if (!cmd2)
{
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] HP <NUMBER>");
- return;
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] HP <NUMBER>");
+ return;
+ }
+ target->stats->setHP(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "HP set to %d", target->stats->getHP());
+ return;
+ }
}
- target->stats->setHP(stringtoint(cmd2));
-
- notice(s_GameServ, u, "HP set to %d", target->stats->getHP());
- return;
- }
- }
else if (stricmp(cmd, "MAXHP") == 0)
- {
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- if (!cmd2)
{
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] MAXHP <NUMBER>");
- return;
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] MAXHP <NUMBER>");
+ return;
+ }
+ target->stats->setMaxHP(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "MaxHP set to %d", target->stats->getMaxHP());
+ return;
+ }
}
- target->stats->setMaxHP(stringtoint(cmd2));
-
- notice(s_GameServ, u, "MaxHP set to %d", target->stats->getMaxHP());
- return;
- }
- }
else if (stricmp(cmd, "EXPERIENCE") == 0 || stricmp(cmd, "EXP") == 0)
- {
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- if (!cmd2)
{
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {EXPERIENCE|EXP} <NUMBER>");
- return;
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {EXPERIENCE|EXP} <NUMBER>");
+ return;
+ }
+
+ target->stats->setExp(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Exp set to %ld", target->stats->getExp());
+ return;
+ }
}
-
- target->stats->setExp(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Exp set to %ld", target->stats->getExp());
- return;
- }
- }
else if (stricmp(cmd, "LEVEL") == 0)
- {
- if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- if (!cmd2)
{
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] LEVEL <NUMBER>");
- return;
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] LEVEL <NUMBER>");
+ return;
+ }
+ target->stats->setLevel(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Level set to %d", target->stats->getLevel());
+ return;
+ }
}
- target->stats->setLevel(stringtoint(cmd2));
-
- notice(s_GameServ, u, "Level set to %d", target->stats->getLevel());
- return;
- }
- }
else if (stricmp(cmd, "ALIVE") == 0)
- {
- if (!isAdmin(user))
{
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
- else
- {
- cmd2 = strtok(NULL, " ");
- if (!cmd2 || (stricmp(cmd2, "TRUE") != 0 && stricmp(cmd2, "FALSE") != 0))
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET ALIVE TRUE|FALSE");
- return;
- }
- else if (stricmp(cmd2, "TRUE") == 0)
- {
- notice(s_GameServ, u, "%s has been Resurrected!", target->stats->getName().c_str());
- setAlive(target->stats);
- }
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
else
- {
- notice(s_GameServ, u, "%s is now dead!", target->stats->getName().c_str());
- clearAlive(target->stats);
- }
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] ALIVE TRUE|FALSE");
+ return;
+ }
+ else if (stricmp(cmd2, "TRUE") == 0)
+ {
+ notice(s_GameServ, u, "%s has been Resurrected!", target->stats->getName().c_str());
+ setAlive(target->stats);
+ }
+ else
+ {
+ notice(s_GameServ, u, "%s is now dead!", target->stats->getName().c_str());
+ clearAlive(target->stats);
+ }
+ }
}
- }
else if (stricmp(cmd, "SEEN") == 0)
{
if (!isAdmin(user))
- {
- notice(s_GameServ, u, "Admins Only!");
- return;
- }
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
else if (stricmp(cmd2, "MASTER") != 0)
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] SEEN MASTER {TRUE|FALSE}");
- return;
- }
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] SEEN MASTER {TRUE|FALSE}");
+ return;
+ }
else
- {
- cmd2 = strtok(NULL, " ");
- if (!cmd2 || (stricmp(cmd2, "TRUE") != 0 && stricmp(cmd2, "FALSE") != 0))
- {
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NICK] SEEN MASTER {TRUE|FALSE}");
- return;
- }
- else if (stricmp(cmd2, "TRUE") == 0)
- {
- notice(s_GameServ, u, "%s has seen their master now.", target->stats->getName().c_str());
- target->addFlag(FLAG_MASTER);
- }
- else
- {
- notice(s_GameServ, u, "%s has not seen their master now.", target->stats->getName().c_str());
- target->remFlag(FLAG_MASTER);
- }
- }
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NICK] SEEN MASTER {TRUE|FALSE}");
+ return;
+ }
+ else if (stricmp(cmd2, "TRUE") == 0)
+ {
+ notice(s_GameServ, u, "%s has seen their master now.", target->stats->getName().c_str());
+ target->stats->addFlag(FLAG_MASTER);
+ }
+ else
+ {
+ notice(s_GameServ, u, "%s has not seen their master now.", target->stats->getName().c_str());
+ target->stats->remFlag(FLAG_MASTER);
+ }
+ }
}
else
- {
- notice(s_GameServ, u, "Unknown command: SET %s", cmd);
- notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
- return;
- }
+ {
+ notice(s_GameServ, u, "Unknown command: SET %s", cmd);
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+ return;
+ }
}
void do_logout(char *u)
log("Nickname %s registered player %s.", u, user->stats->getName().c_str());
setPlaying(user); // set the playing flag
tempItem = findItemByID(3001);
- user->stats->inventory->addItem((*Items.begin())); // Add the stick
- user->stats->inventory->addItem(tempItem); // Add Clothes
+ user->stats->inventory->addItem((*Items.begin()))->use(user->stats); // Add the stick
+ user->stats->inventory->addItem(tempItem)->use(user->stats); // Add Clothes
}
else
{
if (!is_fighting(user))
notice(s_GameServ, u, "You run in place... try fighting next time.");
- else if (!player_fight(user) && !master_fight(user))
+ else if (!player_fight(user) && !master_fight(user) && !dragon_fight(user))
{
notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p->getMonster()->name.c_str());
p->delMonster();
{
notice(s_GameServ, u, "You cannot run from \ 2%s\ 2! FIGHT!", p->getMaster()->name.c_str());
}
- p->delBattle();
+ else if (dragon_fight(user))
+ {
+ notice(s_GameServ, u, "You cannot run from %s! FIGHT!", dragon.name.c_str());
+ }
}
void end_turn(aClient *user)
password = strtok(NULL, " ");
- p->setPassword(password);
+ p->setRawPassword(password);
temp->setNick("Not Playing");
#ifdef P10
temp->setRealNick("Not Playing");
}
else if (stricmp(cmd, "BUY") == 0)
{
- int amt;
+ int amt = 1;
char *chid = strtok(NULL, " ");
char *amount = strtok(NULL, " ");
- amt = stringtoint(amount);
+ if (amount)
+ amt = stringtoint(amount);
if (!chid)
{
Player *p = user->stats;
temp = new Monster(levels[p->getLevel() - 1].master);
p->setMyMaster(temp);
- p->setMonster(p->getMaster());
+ p->setMonster(temp);
display_monster(u); // Since master is the same structure, use this function
}
}
p->reset();
tempItem = findItemByID(3001);
- p->inventory->addItem((*Items.begin())); // Add the stick
- p->inventory->addItem(tempItem); // Add Clothes
+ p->inventory->addItem((*Items.begin()))->use(p); // Add the stick
+ p->inventory->addItem(tempItem)->use(p); // Add Clothes
}
void updateTS(Player *p)
return;
#ifdef DEBUGMODE
- log("Old timestamp for %s: %ld", p->name.c_str(), p->lastcommand);
+ log("Old timestamp for %s: %ld", p->getName().c_str(), p->lastcommand);
#endif
p->lastcommand = time(NULL);
#ifdef DEBUGMODE
- log("New timestamp for %s: %ld", p->name.c_str(), p->lastcommand);
+ log("New timestamp for %s: %ld", p->getName().c_str(), p->lastcommand);
#endif
}
void timeOutEvent(Player *p)
{
- item *tempItem;
aClient *user = findplayer(p->getName().c_str());
if (!user || !p->getClient()) // then they're not playing
}
else if (!player_fight(user))
{
- tempItem = findItemByID(3001);
- user->stats->inventory->addItem((*Items.begin())); // Add the stick
- user->stats->inventory->addItem(tempItem); // Add Clothes
if (isAlive(user->stats) && user->stats->getGold() > 0)
{
// Place fun stuff here :)