bool is_fighting(char *u); // True if the given nick in the clients list is fighting anything.
bool is_fighting(aClient *user);
-bool is_alive(char *u); // True if the given nick is playing and is alive
-bool is_alive(aClient *user);
-
bool player_fight(char *u); // True if the player is fighting another player.
bool player_fight(aClient *user);
char *spaces(int len, char *seperator);
void refresh(Player *p);
void refreshall();
-void reset(aClient *ni);
+void reset(Player *p);
void init_masters();
void init_monsters();
bool load_monsters();
char *armors[WNA] = { "Nothing", "Clothes", "Leather Vest", "Chain Mail", "Plate Armor",
"Full Body Armor", "Magic Mail", "Graphite Suit", "Steel Suit",
"Force Field", "Armor of Light", "Mythril Vest", "DemiGod Armor",
- "Hades' Cloak", "Dragon Scales", "Mystical Armor"};
+ "Hades' Cloak", "Dragon Scales", "Adamantium"};
int prices[WNA - 1] = {200, 1000, 3000, 10000, 30000, 100000, 150000, 200000, 400000,
1000000, 4000000, 10000000, 40000000, 100000000, 400000000};
do_admin(source);
} else if (stricmp(cmd, "REFRESH") == 0) {
do_refresh(source);
+ } else if (stricmp(cmd, "RESET") == 0) {
+ do_reset(source);
} else if (stricmp(cmd, "TAVERN") == 0) {
do_tavern(source);
} else if (stricmp(cmd, "PRINT") == 0) {
clients.print();
cout << "\nPrinting Player List: " << endl;
players.print();
+ cout << "\nPrinting Level 1 of monsters:" << endl;
+ for (int xx = 0; xx < 12; xx++)
+ {
+ cout << monsters[0][xx]->name << ' ' <<
+monsters[0][xx]->weapon << ' ' << monsters[0][xx]->hp << '/' <<
+monsters[0][xx]->maxhp << ' ' <<
+monsters[0][xx]->strength << ' ' << monsters[0][xx]->exp << ' ' <<
+monsters[0][xx]->gold << ' ' << monsters[0][xx]->death << endl;
+ }
} else if (stricmp(cmd, "LIST") == 0) {
do_list(source);
} else if (stricmp(cmd, "REGISTER") == 0) {
strcpy(masters[3]->name, "Mr. Miagi");
strcpy(masters[3]->weapon, "Petrified Bonsai");
- masters[3]->strength = 100;
+ masters[3]->strength = 120;
masters[3]->gold = 0;
masters[3]->exp = 0;
masters[3]->maxhp = 120;
strcpy(masters[4]->name, "Jackie Chan");
strcpy(masters[4]->weapon, "Kung Fu Kick");
- masters[4]->strength = 125;
+ masters[4]->strength = 135;
masters[4]->gold = 0;
masters[4]->exp = 0;
masters[4]->maxhp = 200;
strcpy(masters[5]->name, "Jet Li");
strcpy(masters[5]->weapon, "Motorcycle");
- masters[5]->strength = 150;
+ masters[5]->strength = 160;
masters[5]->gold = 0;
masters[5]->exp = 0;
masters[5]->maxhp = 400;
strcpy(masters[6]->name, "Muhammad Ali");
strcpy(masters[6]->weapon, "Quick Jab");
- masters[6]->strength = 175;
+ masters[6]->strength = 185;
masters[6]->gold = 0;
masters[6]->exp = 0;
masters[6]->maxhp = 600;
strcpy(masters[7]->name, "Li Mu Bai");
strcpy(masters[7]->weapon, "Green Destiny");
- masters[7]->strength = 200;
+ masters[7]->strength = 210;
masters[7]->gold = 0;
masters[7]->exp = 0;
masters[7]->maxhp = 800;
strcpy(masters[9]->name, "Wong Fei Hung");
strcpy(masters[9]->weapon, "Drunken Boxing");
- masters[9]->strength = 350;
+ masters[9]->strength = 360;
masters[9]->gold = 0;
masters[9]->exp = 0;
masters[9]->maxhp = 1800;
return user->stats != NULL && (stricmp(user->getNick(), "!NULL!") != 0);
}
-bool is_alive(char *u)
-{
- aClient *user;
- if (!(user = find(u)))
- return false;
- else if (user->stats == NULL)
- return false;
- else
- return user->stats->alive;
-}
-
-bool is_alive(aClient *user)
-{
- if (user->stats == NULL)
- return false;
- else
- return user->stats->alive;
-}
-
bool is_fighting(char *u)
{
aClient *user;
else if (!(battle = find(nick)))
{
notice(s_GameServ, u, "You can't attack %s while they aren't playing!", nick);
+ return;
}
else if (!is_playing(ni))
{
notice(s_GameServ, u, "You are not playing!");
+ return;
}
/*
* Offline fighting not implemented yet.
* display_players(u);
* }
*/
- else if (!is_alive(ni))
+ else if (!isAlive(ni->stats))
{
notice(s_GameServ, u, "You are dead. Wait until tomorrow to fight others!");
return;
}
+ else if (player_fight(battle))
+ {
+ notice(s_GameServ, u, "%s is fighting %s already!", battle->stats->name, battle->stats->battle->stats->name);
+ return;
+ }
+ else if (is_fighting(battle))
+ {
+ notice(s_GameServ, u, "%s is fighting %s already!", battle->stats->name, battle->stats->fight->name);
+ return;
+ }
else if (is_playing(ni) && is_playing(battle) && stricmp(ni->stats->name, battle->stats->name) != 0)
{
// Set your battle pointer to the other player
battle->stats->battle = ni;
// The initiator gets the first move (perhaps this should be 50/50)
- ni->stats->yourturn = 1;
- battle->stats->yourturn = 0;
+ setYourTurn(ni->stats);
+ clearYourTurn(battle->stats);
// Initiate Battle sequence!
notice(s_GameServ, u, "You challenge %s to an online duel!", battle->getNick());
int oldstrength = user->stats->strength;
notice(s_GameServ, u, "As you grip the flask containing pure power, you feel adrenaline coarse through your veins!");
notice(s_GameServ, u, "In one swallow you drink the potion and feel your muscle fibers bulging andgrowing!");
- user->stats->strength += rand() % 3;
+ user->stats->strength += 1 + rand() % 2; // 1 - 2 Strength Added
notice(s_GameServ, u, "You gain %d Strength points!", user->stats->strength - oldstrength);
p->decStrength();
}
notice(s_GameServ, u, "You are out of Defense Potions!");
return;
}
- int olddefense = user->stats->strength;
+ int olddefense = user->stats->defense;
notice(s_GameServ, u, "You drink the foul tasting viscous liquid while pinching your nose in disgust.");
notice(s_GameServ, u, "It tasted bad, but you feel like you are unbeatable!");
- user->stats->defense += rand() % 3;
+ user->stats->defense += 1 + rand() % 2; // 1 - 2 Defense Added
notice(s_GameServ, u, "You gain %d Defense points!", user->stats->defense - olddefense);
p->decDefense();
}
+ else if (stricmp(item, "HP") == 0)
+ {
+ if (p->HP() <= 0)
+ {
+ notice(s_GameServ, u, "You are out of HP Potions!");
+ return;
+ }
+ int oldHP = user->stats->maxhp;
+ notice(s_GameServ, u, "You feel your life growing longer as you drink the green glowing liquid.");
+ user->stats->maxhp += 1 + rand() % 5; // 1 - 5 Maxhp
+ notice(s_GameServ, u, "You gain %d Maximum hit points!", user->stats->maxhp - oldHP);
+ p->decHP();
+ }
+ else
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S USE {HEALTH | STRENGTH | DEFENSE}");
+ return;
+ }
end_turn(user); // If they're fighting, end their turn
}
delete p->fight;
p->fight = NULL;
}
- else if (player_fight(user) && p->yourturn)
+ else if (player_fight(user) && isYourTurn(p))
{
notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p2->name);
notice(s_GameServ, p->battle->getNick(), "\ 2%s\ 2 ran away from you like a little baby!", p->name);
p2->battle = NULL;
}
- else if (player_fight(user) && !p->yourturn)
+ else if (player_fight(user) && !isYourTurn(p))
{
notice(s_GameServ, u, "It is not your turn. Please wait until \ 2%s\ 2 decides what to do.", p2->name);
}
user->stats->gold = 0;
user->stats->exp -= (long int)(user->stats->exp * .10);
user->stats->fight = NULL;
- user->stats->alive = false;
+ clearAlive(user->stats);
goto endturn;
}
else
}
else
{
- user->stats->yourturn = 0;
- battle->stats->yourturn = 1;
+ clearYourTurn(user->stats);
+ setYourTurn(battle->stats);
display_players(battle);
}
endturn:
// Unsigned long int maybe? Leave it for now.
ni->stats->exp = ( (ni->stats->exp + fight->exp) > 2000000000 ? 2000000000 :
ni->stats->exp + fight->exp);
+
ni->stats->gold = (ni->stats->gold + fight->gold > 2000000000 ? 2000000000 :
ni->stats->gold + fight->gold);
ni->stats->gold = 0;
ni->stats->exp -= (long int)(ni->stats->exp * .10);
ni->stats->fight = NULL;
- ni->stats->alive = false;
+ clearAlive(ni->stats);
return;
}
else
if (is_playing(battle->getNick()))
{
- if (ni->stats->yourturn == 0)
+ if (!isYourTurn(ni->stats))
{
notice(s_GameServ, u, "Please wait until %s decides what to do!",
battle->getNick());
notice(s_GameServ, battle->getNick(), "%s has hit you with their %s for "\
"\ 2%d\ 2 damage!", u, weapons[ni->stats->weapon],
hit);
- ni->stats->yourturn = 0;
- battle->stats->yourturn = 1;
+ clearYourTurn(ni->stats);
+ setYourTurn(battle->stats);
display_players(battle->getNick());
}
else
{
notice(s_GameServ, u, "You miss \1f%s\1f completely!", battle->getNick());
notice(s_GameServ, battle->getNick(), "%s misses you completely!", u);
- ni->stats->yourturn = 0;
- battle->stats->yourturn = 1;
+ clearYourTurn(ni->stats);
+ setYourTurn(battle->stats);
display_players(battle->getNick());
}
if (hit >= battle->stats->hp)
(long int)(battle->stats->exp * .10), battle->stats->gold);
notice(s_GameServ, battle->getNick(), "You have been killed by \ 2%s\ 2!", u);
battle->stats->hp = 0;
- battle->stats->alive = false;
+ clearAlive(battle->stats);
if (2000000000 - ni->stats->exp > (long int)(battle->stats->exp * .10))
{
{
if (hit > 0)
battle->stats->hp -= hit;
- //display_players(battle->getNick());
- ni->stats->yourturn = 0;
- battle->stats->yourturn = 1;
+ clearYourTurn(ni->stats);
+ setYourTurn(battle->stats);
notice(s_GameServ, u, "Please wait while %s decides what to do!",
battle->getNick());
notice(s_GameServ, u, "You aren't playing!");
return;
}
- else if (!is_alive(ni))
+ else if (!isAlive(ni->stats))
{
notice(s_GameServ, u, "You are dead. Wait until tomorrow for healing.");
return;
it = ptr->getData()->stats;
outfile << it->name << ' ' << it->level << ' ' << it->exp << ' ' << it->gold << ' ' << it->bank << ' '
<< it->hp << ' ' << it->maxhp << ' ' << it->strength << ' ' << it->defense << ' '
- << it->armor << ' ' << it->weapon << ' ' << (it->alive ? "alive" : "dead") << ' '
+ << it->armor << ' ' << it->weapon << ' '
<< it->forest_fights << ' ' << it->player_fights << ' '
- << it->getFlags() << ' ' << it->password << endl;
+ << it->getFlags() << ' ' << it->password << ' ' << it->inventory.Healing()
+ << ' ' << it->inventory.Strength() << ' ' << it->inventory.Defense() << endl;
ptr = ptr->Next();
}
outfile.close();
ifstream infile;
aClient *temp;
Player *p;
- char *alive, *tempname, *buf, *password;
+ char *tempname, *buf, *password;
buf = new char[1023];
infile.open(playerdata);
p->defense = stringtoint(strtok(NULL, " "));
p->armor = stringtoint(strtok(NULL, " "));
p->weapon = stringtoint(strtok(NULL, " "));
- alive = strtok(NULL, " ");
- p->alive = (stricmp(alive, "ALIVE") == 0 ? true : false);
p->forest_fights = stringtoint(strtok(NULL, " "));
p->player_fights = stringtoint(strtok(NULL, " "));
p->setFlags(stringtoint(strtok(NULL, " ")));
+
password = strtok(NULL, " ");
strcpy(p->password, password);
temp->setNick("!NULL!");
- printf("%s %d %ld %ld %ld %d %d %d %d %d %d %s %d %d %s\n", p->name, p->level,
- p->exp, p->gold, p->bank, p->hp, p->maxhp, p->strength, p->defense, p->armor, p->weapon,
- alive, p->forest_fights, p->player_fights, p->password);
+ // Old player databases didn't have these three extra values
+ // If they come up null, leave them to 0 as the default.
+ // On the next gameserv database save, it will save the values.
+ tempname = strtok(NULL, " ");
+ cout << tempname << endl;
+ p->inventory.setHealing(stringtoint(tempname));
+ p->inventory.setStrength(stringtoint(strtok(NULL, " ")));
+ p->inventory.setDefense(stringtoint(strtok(NULL, " ")));
players.insertAtBack(temp);
delete temp;
}
else if (!(user = find(u)) || !is_playing(user))
notice(s_GameServ, u, "You must be playing to use the store!");
- else if (!is_alive(user))
+ else if (!isAlive(user->stats))
{
notice(s_GameServ, u, "You are dead. Wait until tomorrow to purchase weapons and armor!");
return;
notice(s_GameServ, u, "1. Healing Potions for %ld Gold", 1000 * p->level + (p->exp / 10));
notice(s_GameServ, u, "2. Strength Potions for %ld Gold", 2050 * p->level + (p->exp / 10));
notice(s_GameServ, u, "3. Defense Potions for %ld Gold", 2000 * p->level + (p->exp / 10));
+ notice(s_GameServ, u, "4. HP Potions for %ld Gold", 2300 * p->level + (p->exp / 10));
notice(s_GameServ, u, "To buy a potion, type /msg %S TAVERN BUY #");
notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1 buys a healing potion!");
notice(s_GameServ, u, "By something will ya!");
notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1");
return;
}
- if (num < 1 || num > 3)
+ if (num < 1 || num > 4)
{
notice(s_GameServ, u, "Invalid Choice!");
notice(s_GameServ, u, "Here is a list of what we have to offer:");
notice(s_GameServ, u, "1. Healing Potions for %ld Gold", 1000 * p->level + (p->exp / 10));
notice(s_GameServ, u, "2. Strength Potions for %ld Gold", 2050 * p->level + (p->exp / 10));
notice(s_GameServ, u, "3. Defense Potions for %ld Gold", 2000 * p->level + (p->exp / 10));
+ notice(s_GameServ, u, "4. HP Potions for %ld Gold", 2300 * p->level + (p->exp / 10));
notice(s_GameServ, u, "To buy a potion, type /msg %S TAVERN BUY #");
notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1 buys a healing potion!");
+ return;
}
switch(num)
{
{
notice(s_GameServ, u, "One healing potion coming right up!");
p->inventory.incHealing();
+ p->gold -= price;
}
else
notice(s_GameServ, u, "You don't have enough gold!");
{
notice(s_GameServ, u, "One strength boost coming right up!");
p->inventory.incStrength();
+ p->gold -= price;
}
else
notice(s_GameServ, u, "You don't have enough gold!");
{
notice(s_GameServ, u, "One defense boost coming right up!");
p->inventory.incDefense();
+ p->gold -= price;
+ }
+ else
+ notice(s_GameServ, u, "You don't have enough gold!");
+ break;
+ case 4:
+ price = (2300 * p->level) + (p->exp / 10);
+ if (p->gold >= price)
+ {
+ notice(s_GameServ, u, "One HP Potion coming right up!");
+ p->inventory.incHP();
+ p->gold -= price;
}
else
notice(s_GameServ, u, "You don't have enough gold!");
aClient *user;
Player *p;
- if (!cmd || !amount || (stricmp(cmd, "TRANSFER") == 0 && !nick))
+ if (!cmd || (!amount && stricmp(cmd, "BALANCE") != 0) || (stricmp(cmd, "TRANSFER") == 0 && !nick))
{
notice(s_GameServ, u, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}");
notice (s_GameServ, u, "BANK BALANCE");
notice(s_GameServ, u, "You must be playing to use the bank!");
return;
}
- else if (!is_alive(user))
+ else if (!isAlive(user->stats))
{
notice(s_GameServ, u, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!");
return;
notice(s_GameServ, u, "You're in the middle of a fight! Pay attention!");
return;
}
- else if (!is_alive(user))
+ else if (!isAlive(user->stats))
{
notice(s_GameServ, u, "You're dead. Wait until tomorrow to see your master!");
return;
if (!p)
return;
- p->hp = p->maxhp;
+ if (p->hp < p->maxhp)
+ p->hp = p->maxhp;
p->forest_fights = forestfights;
p->player_fights = 3;
- p->alive = true;
+ setAlive(p);
clearMaster(p);
}
}
}
+
+void resetall()
+{
+ ListNode <aClient> *it;
+ Player *p;
+
+ it = players.First();
+
+ while (it)
+ {
+ p = it->getData()->stats;
+ reset(p);
+ it = it->Next();
+ }
+}
+
+void reset(Player *p)
+{
+ if (!p)
+ return;
+
+ p->reset();
+}
+
+void do_reset(char *u)
+{
+ char *nick = strtok(NULL, " ");
+ aClient *user;
+
+ if (!(user = find(u)))
+ {
+ notice(s_GameServ, u, "Error: aClient not found. Contact a %S admin");
+ cout << "Error: aClient not found: " << u << endl;
+ return;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "You must be a %S admin to use this command!");
+ return;
+ }
+ if (!nick)
+ {
+ notice(s_GameServ, u, "SYNTAX: RESET {ALL | NICK}");
+ return;
+ }
+ else if (stricmp(nick, "ALL") == 0)
+ {
+ notice(s_GameServ, u, "Resetting everyone's stats!");
+ resetall();
+ }
+ else if ((user = find(nick)))
+ {
+ if (is_playing(user))
+ {
+ notice(s_GameServ, u, "Resetting %s.", user->getNick());
+ reset(user->stats);
+ }
+ else
+ {
+ notice(s_GameServ, u, "%s is not playing.", user->getNick());
+ }
+ }
+ else
+ {
+ notice(s_GameServ, u, "Nick %s not found.", nick);
+ return;
+ }
+}
+
void do_help(char *u)
{
char *cmd = strtok(NULL, " ");
monsters[l][m]->gold = stringtoint(strtok(NULL, "~"));
monsters[l][m]->exp = stringtoint(strtok(NULL, "~"));
monsters[l][m]->maxhp = stringtoint(strtok(NULL, "~"));
+ monsters[l][m]->hp = monsters[l][m]->maxhp;
strcpy(monsters[l][m]->death, strtok(NULL, ""));
m++;
}