]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/c_forest.cpp
Implemented the myString class in the player and monster classes. This should make...
[irc/gameservirc.git] / gameserv / c_forest.cpp
index e2f76dce055ecd36b65b6d9a3cc298de1689677e..b72586d090ea1a3ca6a5e21f11503a0b3c63c8e2 100644 (file)
@@ -36,9 +36,6 @@ void do_forest(char *u)
 {
     aClient *source;
 
-    int num = rand() % 12;
-
-
     if (!(source = find(u)))
     {
        notice(s_GameServ, u, "Fatal Error in do_forest. Contact a %S admin for help.");
@@ -75,8 +72,8 @@ void do_forest(char *u)
            // 88% of forest searching turns up a monster
            if (eventnum >= 12)
            {
-               p->fight = new Monster(monsters[p->level - 1][num]);
-               notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name);
+               p->fight = new Monster(levels[p->level - 1].randomMonster());
+               notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name.getString());
                if (p->fight->hp < p->fight->maxhp)
                    p->fight->hp = p->fight->maxhp;
 
@@ -88,29 +85,30 @@ void do_forest(char *u)
            {
                notice(s_GameServ, u, "Fortune smiles upon thee!");
 
-               eventnum = 1 + rand() % 4;
-               switch(eventnum)
+               eventnum = 1 + rand() % 4000;
+               if (eventnum < 1000)
                {
-                   case 1:
-                       notice(s_GameServ, u,
+                   notice(s_GameServ, u,
                        "You have found an HP Potion!");
-                       p->inventory.incHP();
-                       break;
-                   case 2:
-                       notice(s_GameServ, u,
+                   p->inventory.incHP();
+               }
+               else if (eventnum < 2000)
+               {       
+                   notice(s_GameServ, u,
                        "You have found a Strength Potion!");
-                       p->inventory.incStrength();
-                       break;
-                   case 3:
-                       notice(s_GameServ, u,
+                   p->inventory.incStrength();
+               }
+               else if (eventnum < 3000)
+               {
+                   notice(s_GameServ, u,
                        "You have found a Defense Potion!");
-                       p->inventory.incDefense();
-                       break;
-                   case 4:
-                       notice(s_GameServ, u,
+                   p->inventory.incDefense();
+               }
+               else
+               {
+                   notice(s_GameServ, u,
                        "You have found a Healing Potion!");
-                       p->inventory.incHealing();
-                       break;
+                   p->inventory.incHealing();
                }
            }
            else if (eventnum < 10 && eventnum >= 5) // 5% for the fountain
@@ -134,6 +132,7 @@ void do_forest(char *u)
                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;
@@ -180,22 +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;