]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/c_forest.cpp
New autoconf
[irc/gameservirc.git] / gameserv / c_forest.cpp
index c75b7fa8947d380ce482016d239bb017ce6321ae..430f0751eaae5f71ab90120122cf030bb86a9e7a 100644 (file)
@@ -5,7 +5,8 @@
 #include <cctype>
 
 void do_forest(char *u);
-
+Monster *getNewMonster(Monster *m);
+void deleteMonster(Monster *m);
 
 void forest(char *source, char *buf)
 {
@@ -21,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);
        }
@@ -51,13 +54,15 @@ void do_forest(char *u)
         }
         else if (isnt_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))
@@ -68,3 +73,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;
+}