]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/c_forest.cpp
added items to the tavern.dat, added the filename option to the config file
[irc/gameservirc.git] / gameserv / c_forest.cpp
index e58effaf9e5a2d2c0d05a1f5f302ffba90a5fc72..762d1e7710fce19fe736b743f3a022e85689b373 100644 (file)
@@ -2,6 +2,7 @@
 #include "aClient.h"
 #include "list.h"
 #include "extern.h"
+#include "flags.h"
 #include <cctype>
 
 void do_forest(char *u);
@@ -35,39 +36,133 @@ void do_forest(char *u)
 {
     aClient *source;
 
-    int num = rand() % 12;
-
-
-    if (!(source = find(u)) || !source->stats)
+    if (!(source = find(u)))
+    {
+       notice(s_GameServ, u, "Fatal Error in do_forest. Contact a %S admin for help.");
+       return;
+    }
+    else if (!is_playing(source))
     {
         notice(s_GameServ, u, "You must be playing the game to search the forest!");
        return;
     }
-    else if (!is_alive(source))
+    Player *p = source->stats;
+
+    if (!isAlive(p))
     {
        notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more.");
        return;
     }
     else 
     {
-        if (source->stats->forest_fights <= 0)
+       updateTS(source->stats);
+        if (p->forest_fights <= 0)
         {
             notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\
                 "till tomorrow!");
             return;
         }
-        else if (!is_fighting(u))
+        else if (!is_fighting(source))
         {
-            Player *p = source->stats;
-            p->forest_fights--;
-            p->fight = new Monster(monsters[p->level - 1][num]);
-            notice(s_GameServ, u, "You search the forest for something to kill...");
-            notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name);
-            p->fight->hp = p->fight->maxhp;
+           int eventnum = rand() % 100;
+           p->forest_fights--;
+
+           notice(s_GameServ, u, "You search the forest for something to kill...");
+
+           // 88% of forest searching turns up a monster
+           if (eventnum >= 12)
+           {
+               p->fight = new Monster(levels[p->level - 1].randomMonster());
+               notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name.c_str());
+               if (p->fight->hp < p->fight->maxhp)
+                   p->fight->hp = p->fight->maxhp;
+
+               p->battle = NULL; // Just to make sure
+               p->master = NULL; // Just to make sure
+               display_monster(u);
+           }
+           /*
+           else if (eventnum < 12 && eventnum >= 10) // 2% for finding potions
+           {
+               notice(s_GameServ, u, "Fortune smiles upon thee!");
 
-            p->battle = NULL; // Just to make sure
-           p->master = NULL; // Just to make sure
-            display_monster(u);
+               eventnum = 1 + rand() % 4;
+               switch(eventnum)
+               {
+                   case 1:
+                       notice(s_GameServ, u,
+                       "You have found an HP Potion!");
+                       p->inventory.incHP();
+                       break;
+                   case 2:
+                       notice(s_GameServ, u,
+                       "You have found a Strength Potion!");
+                       p->inventory.incStrength();
+                       break;
+                   case 3:
+                       notice(s_GameServ, u,
+                       "You have found a Defense Potion!");
+                       p->inventory.incDefense();
+                       break;
+                   case 4:
+                       notice(s_GameServ, u,
+                       "You have found a Healing Potion!");
+                       p->inventory.incHealing();
+                       break;
+               }
+           }
+           */
+           else if (eventnum < 10 && eventnum >= 5) // 5% for the fountain
+           {
+               if (p->hp < p->maxhp)
+               {
+                   notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life.");
+                   notice(s_GameServ, u, "You wet your lips on the cool blue waters and feel rejuvenated");
+                   p->hp = p->maxhp;
+               }
+               else
+               {
+                   notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life.");
+                   notice(s_GameServ, u, "You are not thirsty, though, and you don't need healing. Best to leave this for the next warrior");
+                   p->forest_fights++;
+               }
+           }
+           else if (eventnum < 5) // 5 % for the wishing well
+           {
+               notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well.");
+               if (p->gold == 0)
+               {
+                   notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today.");
+                   p->forest_fights++;
+                   return;
+               }
+               long newstats;
+               notice(s_GameServ, u, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke.");
+               notice(s_GameServ, u, "In an instant, the puff of smoke materializes into a gnome.");
+               notice(s_GameServ, u, "The gnome is holding something in his hand motioning for you to come closer.");
+               notice(s_GameServ, u, "It is a wand! The gnome is waving it through the air towards you!");
+               // 2% for each wishing well chance except for forest fights
+               if (eventnum < 1) // forest fights
+               {
+                   newstats = (rand() % 11) + 5;
+                   notice(s_GameServ, u, "%ld EXTRA FOREST FIGHTS!!", 
+                               newstats);
+                   p->forest_fights += newstats;
+               }
+               else if (eventnum < 3)
+               {
+                   newstats = levels[p->level - 1].getStrength().random();
+                   notice(s_GameServ, u, "A SACK WITH %ld GOLD!", newstats);
+                   p->gold += newstats;
+               }
+               else
+               {
+                   newstats = levels[p->level - 1].getExp().random();
+                   notice(s_GameServ, u, "Time seems to stand still for a moment.");
+                   notice(s_GameServ, u, " %ld EXTRA EXPERIENCE POINTS", newstats);
+                   p->exp += newstats;
+               }
+           }
         }
         else if (is_fighting(u))
         {
@@ -84,23 +179,9 @@ Monster *getNewMonster(Monster *m)
 
     Monster *newguy;
     newguy = new Monster;
-
-    if (m->name)
-    {
-       newguy->name = new char[strlen(m->name)];
-       strcpy(newguy->name, m->name);
-    }
-    if (m->weapon)
-    {
-       newguy->weapon = new char[strlen(m->weapon)];
-       strcpy(newguy->weapon, m->weapon);
-    }
-    if (m->death)
-    {
-       newguy->death = new char[strlen(m->death)];
-       strcpy(newguy->death, m->death);
-    }
-
+    newguy->name = m->name;
+    newguy->weapon = m->weapon;
+    newguy->death = m->death;
     newguy->strength = m->strength;
     newguy->gold = m->gold;
     newguy->exp = m->exp;