From: kainazzzo Date: Sat, 29 Nov 2003 04:49:37 +0000 (+0000) Subject: Added a tavern and inventory command. X-Git-Url: https://jfr.im/git/irc/gameservirc.git/commitdiff_plain/9cda831cf07982221052583e94e073bda5d3ef4b?hp=f5c256398e6a35ac1799d309b3ee2cba82f18fff Added a tavern and inventory command. git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@72 bc333340-6410-0410-a689-9d09f3c113fa --- diff --git a/gameserv/Changes b/gameserv/Changes index 768bebe..c325379 100644 --- a/gameserv/Changes +++ b/gameserv/Changes @@ -1,4 +1,8 @@ Version 1.1.6 +* Added an inventory command which allows players to view how many + potions they are storing. +* Added a tavern command which allows players to buy potions and store + them in their inventory for later use. * Made some cosmetic changes to this file. * Added an inventory class Pouch which allows players to carry around things such as potions and such. diff --git a/gameserv/TODO b/gameserv/TODO index 67d87fe..dfe550d 100644 --- a/gameserv/TODO +++ b/gameserv/TODO @@ -2,6 +2,14 @@ - = Started X = Finsihed +- Finish the monsters for all levels. + +* Make all applicable commands take the player name instead of the irc + nickname as their parameter. This way players can have different names + and stay anonymous on IRC while enjoying full game functionality. + +* Add functionality for potions + * Make GameServ a true daemon instead of using nohup * No output unless it's a loading error @@ -10,8 +18,6 @@ X = Finsihed * Town square shouts. Array of 10 strings that gets rotated * Choose how many strings to rotate in the config file -- Tavern where you can buy potions and powerups - - Forest events X Wishing well X Fountain of youth - rejuvination & forest fights @@ -45,7 +51,7 @@ X Fix bug where people can identify while they are two different X Add option to config file for forest fights per day, etc. -* Finish the monsters for all levels. - X Load monsters from a monsters.dat file so they can be changed easily. +X Load monsters from a monsters.dat file so they can be changed easily. X Periodic updates of the gameserv databases to avoid lost data +X Tavern where you can buy potions and powerups diff --git a/gameserv/c_forest.cpp b/gameserv/c_forest.cpp index 3dd0f80..7e1fc2f 100644 --- a/gameserv/c_forest.cpp +++ b/gameserv/c_forest.cpp @@ -59,6 +59,7 @@ void do_forest(char *u) else if (!is_fighting(u)) { int eventnum = rand() % 100; + eventnum = 14; Player *p = source->stats; p->forest_fights--; @@ -97,18 +98,18 @@ void do_forest(char *u) if (eventnum < 5) // forest fights { notice(s_GameServ, u, "EXTRA FOREST FIGHTS!!"); - p->forest_fights += 5; + p->forest_fights += (rand() % 11) + 5; } else if (eventnum < 10) { notice(s_GameServ, u, "A SACK OF GOLD!"); - p->gold += 1000 * p->level; + p->gold += (rand() % 1000) * (p->level + (rand() % 10)); } else { notice(s_GameServ, u, "Time seems to stand still for a moment."); notice(s_GameServ, u, "EXTRA EXPERIENCE POINTS"); - p->exp += 10 * 10 / (p->level / 100); + p->exp += (rand() % 100) * (p->level + rand() % 10); } } } diff --git a/gameserv/extern.h b/gameserv/extern.h index 4bf8509..99ed256 100644 --- a/gameserv/extern.h +++ b/gameserv/extern.h @@ -119,25 +119,28 @@ E void refresh(Player *p); E void refreshall(); E void reset(aClient *ni); -E void do_list(char *u); -E void do_refresh(char *u); -E void do_register(char *u); +E void do_attack(char *u); +E void do_bank(char *u); +E void do_fight(char *u); +E void do_forest(char *u); +E void do_heal(char *u); E void do_identify(char *u); +E void do_invenory(char *u); +E void do_list(char *u); E void do_play(char *u); E void do_quitg(char *u); +E void do_refresh(char *u); +E void do_register(char *u); E void do_reset(char *u); -E void do_fight(char *u); -E void do_store(char *u); -E void do_heal(char *u); -E void do_bank(char *u); -E void do_attack(char *u); E void do_run(char *u); -E void do_visit(char *u); E void do_stats(char *u); -E void do_forest(char *u); +E void do_store(char *u); +E void do_tavern(char *u); +E void do_visit(char *u); E void see_mystic(char *u); -E void showstats(const char *u, const char *nick); +E void showstats(const char *u, const char *nick); +E void showinventory(aClient *from, aClient *to = NULL); /* Database saving stuff */ E int save_gs_dbase(); diff --git a/gameserv/gameserv.cpp b/gameserv/gameserv.cpp index c569cdc..2ac1695 100644 --- a/gameserv/gameserv.cpp +++ b/gameserv/gameserv.cpp @@ -90,6 +90,7 @@ void do_fight(char *u); void do_heal(char *u); void do_help(char *u); void do_identify(char *u); +void do_inventory(char *u); void do_refresh(char *u); void do_register(char *u); void do_list(char *u); @@ -104,6 +105,7 @@ void do_tavern(char *u); void see_master(char *u); void showstats(const char *u, const char *nick); +void showinventory(aClient *from, aClient *to = NULL); void showBankBalance(const char *u); #define WNA 16 @@ -167,6 +169,8 @@ void gameserv(char *source, char *buf) do_run(source); } else if (stricmp(cmd, "HEAL") == 0) { do_heal(source); + } else if (stricmp(cmd, "INVENTORY") == 0) { + do_inventory(source); } else if (stricmp(cmd, "MASTER") == 0) { do_master(source); } else if (stricmp(cmd, "STORE") == 0) { @@ -2878,7 +2882,37 @@ void do_store(char *u) } } } +void do_inventory(char *u) +{ + aClient *user; + if (!(user = find(u))) + { + notice(s_GameServ, u, "Fatal Error. Contact a %S admin!"); + return; + } + else if (!is_playing(user)) + { + notice(s_GameServ, u, "You must be playing to check your inventory!"); + return; + } + showinventory(user, user); +} +void showinventory(aClient *from, aClient *to) +{ + char *nick = to->getNick(); + + if (!to) + to = from; + if (is_playing(from)) + { + Pouch *p = &from->stats->inventory; + notice(s_GameServ, nick, "Inventory for %s:", from->getNick()); + notice(s_GameServ, nick, " Healing Potions: %d", p->Healing()); + notice(s_GameServ, nick, "Strength Potions: %d", p->Strength()); + notice(s_GameServ, nick, " Defense Potions: %d", p->Defense()); + } +} void do_tavern(char *u) { char *cmd = strtok(NULL, " "); @@ -2896,6 +2930,11 @@ void do_tavern(char *u) notice(s_GameServ, u, "You must be playing to go to the Tavern"); return; } + else if (is_fighting(user)) + { + notice(s_GameServ, u, "You cannot go to the Tavern during a fight!"); + return; + } p = user->stats; if (!cmd) { @@ -2972,6 +3011,11 @@ void do_tavern(char *u) break; } } + else + { + notice(s_GameServ, u, "Improper Syntax."); + notice(s_GameServ, u, "Type /msg %S HELP TAVERN for help"); + } } void do_bank(char *u) diff --git a/gameserv/helpfiles/help b/gameserv/helpfiles/help index d62be33..4c5f9a1 100644 --- a/gameserv/helpfiles/help +++ b/gameserv/helpfiles/help @@ -9,6 +9,7 @@ Here are the basic commands available to everyone: HEAL Heal yourself. Replenishes Hit points HELP Brings up this help menu IDENTIFY Identify yourself with a previously registered login + INVENTORY View your inventory LIST List who is currently in the realm MASTER Question and fight your master to gain a level REGISTER Register a login and join the realm diff --git a/gameserv/helpfiles/inventory b/gameserv/helpfiles/inventory new file mode 100644 index 0000000..35d4e3e --- /dev/null +++ b/gameserv/helpfiles/inventory @@ -0,0 +1,4 @@ +The inventory command allows a player to check their inventory to see how +many potions they have on hand. You may check your inventory during a fight. + +SYNTAX: /msg %S INVENTORY