]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/c_forest.cpp
Switched the hybrid contrib files to an updated version for configscript. Thank you...
[irc/gameservirc.git] / gameserv / c_forest.cpp
index c7e5a1a1c7cba4dae7036037184abb60ceaf1921..e58effaf9e5a2d2c0d05a1f5f302ffba90a5fc72 100644 (file)
@@ -5,6 +5,8 @@
 #include <cctype>
 
 void do_forest(char *u);
+Monster *getNewMonster(Monster *m);
+void deleteMonster(Monster *m);
 
 void forest(char *source, char *buf)
 {
@@ -20,6 +22,8 @@ void forest(char *source, char *buf)
            do_forest(source);
        } else if (stricmp(cmd, "ATTACK") == 0) {
            do_attack(source);
+        } else if (stricmp(cmd, "RUN") == 0) {
+           do_run(source);
        } else if (stricmp(cmd, "HEAL") == 0) {
            do_heal(source);
        }
@@ -30,15 +34,19 @@ source--;
 void do_forest(char *u)
 {
     aClient *source;
-    char *cmd;
 
     int num = rand() % 12;
 
-    source = find(u);
 
-    if (!is_playing(u))
+    if (!(source = find(u)) || !source->stats)
     {
         notice(s_GameServ, u, "You must be playing the game to search the forest!");
+       return;
+    }
+    else if (!is_alive(source))
+    {
+       notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more.");
+       return;
     }
     else 
     {
@@ -48,15 +56,17 @@ void do_forest(char *u)
                 "till tomorrow!");
             return;
         }
-        else if (isnt_fighting(u))
+        else if (!is_fighting(u))
         {
-            Player *ni = source->stats;
-            ni->forest_fights--;
-            ni->fight = &monsters[ni->level - 1][num];
+            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!", ni->fight->name);
-            ni->fight->hp = ni->fight->maxhp;
-            ni->battle = NULL;
+            notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name);
+            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 (is_fighting(u))
@@ -67,3 +77,34 @@ void do_forest(char *u)
 
 }
 
+Monster *getNewMonster(Monster *m)
+{
+    if (!m)
+       return NULL;
+
+    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->strength = m->strength;
+    newguy->gold = m->gold;
+    newguy->exp = m->exp;
+    newguy->hp = m->hp;
+    newguy->maxhp = m->maxhp;
+    return newguy;
+}