X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/8a5cec4fe1859f7c5b1c818cf1cd7a5369e284aa..1781f48acb7a88a79ef85708ad4afe88ce35b7b1:/gameserv/gameserv.cpp diff --git a/gameserv/gameserv.cpp b/gameserv/gameserv.cpp index 6f43586..59eb75e 100644 --- a/gameserv/gameserv.cpp +++ b/gameserv/gameserv.cpp @@ -108,6 +108,7 @@ void do_admin(char *u); void do_attack(char *u); void do_bank(char *u); void do_check(char *u); +void do_equip(char *u); void do_fight(char *u); void do_heal(char *u); void do_help(char *u); @@ -138,20 +139,6 @@ void showBankBalance(const char *u); void end_turn(aClient *user); #define WNA 16 -char *weapons[WNA] = { "Fists", "Stick", "Dagger", "Quarterstaff", "Short Sword", - "Long Sword", "Silver Spear", "Battle Axe", "The Ragnarok", - "Chain Saw", "Poison Sword", "Flame Sword", "Earth Hammer", - "Light Saber", "Masamune", "Mystical Sword"}; - -char *armors[WNA] = { "Birthday Suit", "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", "Adamantium"}; - -int prices[WNA - 1] = {200, 1000, 3000, 10000, 30000, 100000, 150000, 200000, 400000, - 1000000, 4000000, 10000000, 40000000, 100000000, 400000000}; -int webonus[WNA] = {2, 10, 15, 25, 35, 45, 65, 85, 125, 185, 255, 355, 505, 805, 1205, 1805}; -int arbonus[WNA] = {2, 3, 5, 10, 15, 25, 35, 50, 75, 100, 150, 225, 300, 400, 600, 1000}; int hpbonus[11] = {10, 15, 20, 30, 50, 75, 125, 185, 250, 350, 550}; int strbonus[11] = {5, 7, 10, 12, 20, 35, 50, 75, 110, 150, 200}; @@ -189,52 +176,54 @@ void gameserv(char *source, char *buf) else do_forest(source); - } else if (stricmp(cmd, "FIGHT") == 0) { - do_fight(source); + } else if (stricmp(cmd, "ADMIN") == 0) { + do_admin(source); } else if (stricmp(cmd, "ATTACK") == 0) { do_attack(source); + } else if (stricmp(cmd, "BANK") == 0) { + do_bank(source); } else if (stricmp(cmd, "CHECK") == 0) { do_check(source); - } else if (stricmp(cmd, "RUN") == 0) { - do_run(source); - } else if (stricmp(cmd, "USE") == 0) { - do_use(source); + } else if (stricmp(cmd, "DRAGON") == 0) { + do_dragon(source); + } else if (stricmp(cmd, "EQUIP") == 0) { + do_equip(source); + } else if (stricmp(cmd, "FIGHT") == 0) { + do_fight(source); } else if (stricmp(cmd, "HEAL") == 0) { do_heal(source); + } else if (stricmp(cmd, "HELP") == 0) { + do_help(source); + } else if (stricmp(cmd, "IDENTIFY") == 0) { + do_identify(source); } else if (stricmp(cmd, "INVENTORY") == 0) { do_inventory(source); - } else if (stricmp(cmd, "MASTER") == 0) { - do_master(source); - } else if (stricmp(cmd, "DRAGON") == 0) { - do_dragon(source); - } else if (stricmp(cmd, "STORE") == 0) { - do_store(source); - } else if (stricmp(cmd, "BANK") == 0) { - do_bank(source); - } else if (stricmp(cmd, "ADMIN") == 0) { - 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, "LIST") == 0) { do_list(source); } else if (stricmp(cmd, "LOGOUT") == 0) { do_logout(source); + } else if (stricmp(cmd, "MASTER") == 0) { + do_master(source); } else if (stricmp(cmd, "NEWS") == 0) { do_news(source); } else if (stricmp(cmd, "REGISTER") == 0) { do_register(source); - } else if (stricmp(cmd, "IDENTIFY") == 0) { - do_identify(source); - } else if (stricmp(cmd, "HELP") == 0) { - do_help(source); + } else if (stricmp(cmd, "REFRESH") == 0) { + do_refresh(source); + } else if (stricmp(cmd, "RESET") == 0) { + do_reset(source); + } else if (stricmp(cmd, "RUN") == 0) { + do_run(source); } else if (stricmp(cmd, "SET") == 0) { do_set(source); } else if (stricmp(cmd, "STATS") == 0) { do_stats(source); + } else if (stricmp(cmd, "STORE") == 0) { + do_store(source); + } else if (stricmp(cmd, "TAVERN") == 0) { + do_tavern(source); + } else if (stricmp(cmd, "USE") == 0) { + do_use(source); } else if (stricmp(cmd, "SHUTDOWN") == 0) { aClient *user; @@ -397,16 +386,18 @@ void showstats(const char *u, const char *nick) notice(s_GameServ, sender->getNick(), "Hit Points: %d of %d", ni->stats->hp, ni->stats->maxhp); - sprintf(buf, "Strength: %d", ni->stats->strength + webonus[ni->stats->wea]); + sprintf(buf, "Strength: %d", ni->stats->strength); space = spaces(strlen(buf), " "); notice(s_GameServ, sender->getNick(), "%s%sDefense: %d", - buf, space, ni->stats->defense + arbonus[ni->stats->arm]); + buf, space, ni->stats->defense); delete [] space; - sprintf(buf, "Armor: %s", armors[ni->stats->arm]); + sprintf(buf, "Armor: %s", (ni->stats->getArmor() ? ni->stats->getArmor()->getName().c_str() : "Nothing")); space = spaces(strlen(buf), " "); + log("got here 1"); notice(s_GameServ, sender->getNick(), "%s%sWeapon: %s", buf, space, - weapons[ni->stats->wea]); + (ni->stats->getWeapon() ? ni->stats->getWeapon()->getName().c_str() : "Fists")); + log("got here 2"); delete [] space; sprintf(buf, "Forest Fights: %d", ni->stats->forest_fights); @@ -1185,6 +1176,7 @@ void do_register(char *u) if (!is_playing(user)) { ListNode *temp; + item *tempItem; user->stats = new Player(); user->stats->client = user; // Set the backwards pointer user->stats->reset(); // set the user up @@ -1202,6 +1194,9 @@ void do_register(char *u) notice(s_GameServ, u, "Write this password down. If you lose it, there is no way to retrieve it!"); log("Nickname %s registered player %s.", u, user->stats->name.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 } else { @@ -1650,6 +1645,61 @@ void do_fight(char *u) } } +void do_equip(char *u) +{ + aClient *user; + pouch *p; + itemContainer *equip; + + char *item = strtok(NULL, " "); + int id = stringtoint(item); + + if (!item || int(item[0]) < 48 || int(item[0] > 57)) + { + notice(s_GameServ, u, "SYNTAX: EQUIP ####"); + notice(s_GameServ, u, "Type /msg %S HELP EQUIP for more information."); + return; + } + else if (!(user = find(u))) + { + notice(s_GameServ, u, "Fatal error in do_equip. Contact a(n) %S Admin"); + return; + } + else if (isIgnore(user)) + { +#ifdef DEBUGMODE + log("Ignoring %s.", user->getNick()); +#endif + return; + } + else if (!is_playing(user)) + { + notice(s_GameServ, u, "You must be playing to equip weapons and armor!"); + return; + } + updateTS(user->stats); + p = user->stats->inventory; + + + if (!(equip = p->Find(id))) + { + if (!p->isEmpty()) + { + notice(s_GameServ, u, "You aren't carrying that item!"); + } + showinventory(user, user); + } + else if (equip->getItem()->getType() != ARMOR && equip->getItem()->getType() != WEAPON) + { + notice(s_GameServ, u, "You can't use %s like that. Try /msg %S use", equip->getItem()->getName().c_str()); + } + else + { + // Use the item + notice(s_GameServ, u, "You equip %s.", equip->getItem()->getName().c_str()); + equip->use(user->stats); + } +} void do_use(char *u) { aClient *user; @@ -1787,16 +1837,12 @@ void end_turn(aClient *user) if (!player_fight(user)) { // Opponent's Hit - mhit = (fight->strength / 2) + - (rand() % (fight->strength / 2) - (user->stats->defense + - arbonus[user->stats->arm])); + mhit = (fight->strength / 2) + (rand() % (fight->strength / 2)) - (user->stats->defense); } else { // Opponent's Hit - mhit = (((battle->stats->strength + webonus[battle->stats->wea]) / 2) + - (rand() % ((battle->stats->strength + webonus[battle->stats->wea])) / 2) - - (user->stats->defense + arbonus[user->stats->arm])); + mhit = (battle->stats->strength / 2) + (rand() % (battle->stats->strength / 2)) - user->stats->defense; } if (!player_fight(user)) { @@ -2009,11 +2055,11 @@ int save_gs_dbase() { it = ptr->getData()->stats; clearYourTurn(it); - outfile << it->name.c_str() << ' ' << it->level << ' ' << it->exp << ' ' << it->gold << ' ' << it->bank << ' ' - << it->hp << ' ' << it->maxhp << ' ' << it->strength << ' ' << it->defense << ' ' - << it->arm << ' ' << it->wea << ' ' - << it->forest_fights << ' ' << it->player_fights << ' ' - << it->getFlags() << ' ' << it->password << ' ' << it->lastlogin; + item *w, *a; + w = it->getWeapon(); + a = it->getArmor(); + + outfile << it->name.c_str() << ' ' << it->level << ' ' << it->exp << ' ' << it->gold << ' ' << it->bank << ' '<< it->hp << ' ' << it->maxhp << ' ' << it->strength << ' ' << it->defense << ' ' << it->forest_fights << ' ' << it->player_fights << ' ' << it->getFlags() << ' ' << it->password << ' ' << it->lastlogin << ' ' << (w ? w->getID() : 0) << ' ' << (a ? a->getID() : 0); // Traverse the list and write out each item ID and how many uses are left if (!it->inventory->isEmpty()) @@ -2207,6 +2253,7 @@ int load_gs_dbase() aClient *temp; Player *p; char *tempname, *buf, *password; + int tempnum; buf = new char[100000]; infile.open(playerdata); @@ -2245,8 +2292,6 @@ int load_gs_dbase() p->maxhp = stringtoint(strtok(NULL, " ")); p->strength = stringtoint(strtok(NULL, " ")); p->defense = stringtoint(strtok(NULL, " ")); - p->arm = stringtoint(strtok(NULL, " ")); - p->wea = stringtoint(strtok(NULL, " ")); p->forest_fights = stringtoint(strtok(NULL, " ")); p->player_fights = stringtoint(strtok(NULL, " ")); p->setFlags(stringtoint(strtok(NULL, " "))); @@ -2264,6 +2309,22 @@ int load_gs_dbase() p->lastlogin = stringtoint(tempname); else p->lastlogin = time(NULL); + + tempname = strtok(NULL, " "); + tempnum = stringtoint(tempname); + if (tempnum != 0) + { + p->setWeapon(*findItemByID(tempnum)); + } + + tempname = strtok(NULL, " "); + tempnum = stringtoint(tempname); + + if (tempnum != 0) + { + p->setArmor(*findItemByID(tempnum)); + } + for (tempname = strtok(NULL, " "); tempname != NULL; tempname = strtok(NULL, " ")) { @@ -2333,6 +2394,7 @@ bool check_password(char *name, char *plaintext) void do_store(char *u) { + /* char *cmd = strtok(NULL, " "); char *item = strtok(NULL, " "); char *num = strtok(NULL, " "); @@ -2538,6 +2600,7 @@ void do_store(char *u) notice(s_GameServ, u, " STORE BUY {ARMOR | WEAPON} NUMBER"); return; } + */ } void do_inventory(char *u) { @@ -2923,7 +2986,7 @@ void do_dragon(char *u) "your %s, and venture into the hot, dark cave. "\ "You are surprised at the angle of descent as you climb "\ "lower and lower, deeper into the dragon's den.", - armors[p->arm], weapons[p->wea]); + (p->getArmor() ? p->getArmor()->getName().c_str() : "Fists"), (p->getWeapon() ? p->getWeapon()->getName().c_str() : "Birthday Suit")); notice(s_GameServ, u, "You come to the end of the cave to find "\ "a tooth. It is a large tooth... bigger than your torso."\ " Suddenly the darkness lifts from the gleam of an eye "\