]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/c_forest.cpp
Fixed indents in c_forest.cpp
[irc/gameservirc.git] / gameserv / c_forest.cpp
index 915081776728de23e71372255158ceda47f37b83..87badae48cb696ea6da4fdf7bc55458788983c17 100644 (file)
@@ -3,7 +3,6 @@
 #include "extern.h"
 #include "flags.h"
 #include "item.h"
-#include "list.h"
 #include "pouch.h"
 #include "sockhelp.h"
 
@@ -23,157 +22,162 @@ void forest(char *source, char *buf)
        if (stricmp(cmd, "SEARCH") == 0)
        {
            do_forest(source);
-       } else if (stricmp(cmd, "ATTACK") == 0) {
+       } 
+   else if (stricmp(cmd, "ATTACK") == 0) 
+   {
            do_attack(source);
-        } else if (stricmp(cmd, "RUN") == 0) {
+   } 
+   else if (stricmp(cmd, "RUN") == 0) 
+   {
            do_run(source);
-       } else if (stricmp(cmd, "HEAL") == 0) {
+       }
+   else if (stricmp(cmd, "HEAL") == 0) 
+   {
            do_heal(source);
        }
 
-source--;
+   source--;
 }
 
 void do_forest(char *u)
 {
   aClient *source;
   
-  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;
-    }
-  Player *p = 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;
+   }
+   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 
-    {
-         updateTS(source->stats);
-         if (p->getForestFights() <= 0)
-        {
-                 notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\
-                                "till tomorrow!");
-                 return;
-        }
-         else if (!is_fighting(source))
-        {
-                 int eventnum = rand() % 100;
-                 p->subtractForestFights(1);
+   if (!isAlive(p))
+   {
+      notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more.");
+      return;
+   }
+   else 
+   {
+      updateTS(source->stats);
+      if (p->getForestFights() <= 0)
+      {
+         notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\
+                                 "till tomorrow!");
+         return;
+      }
+      else if (!is_fighting(source))
+      {
+         int eventnum = rand() % 100;
+         p->subtractForestFights(1);
                  
-                 notice(s_GameServ, u, "You search the forest for something to kill...");
+         notice(s_GameServ, u, "You search the forest for something to kill...");
                  
-                 // 90% of forest searching turns up a monster
-                 if (eventnum >= 10)
-                       {
-                         Monster *tempmonster;
-                         tempmonster = new Monster(levels[p->getLevel() - 1].randomMonster());
-                         p->setMonster(tempmonster);
-                         delete tempmonster;
-                         notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->getMonster()->name.c_str());
-                         if (p->getMonster()->hp < p->getMonster()->maxhp)
-                               p->getMonster()->hp = p->getMonster()->maxhp;
-                         
-                         p->delBattle(); // Just to make sure
-                         p->delMaster(); // Just to make sure
-                         display_monster(u);
-                       }
-                 else if (eventnum < 10 && eventnum >= 9) // 1% for finding potions
+         // 90% of forest searching turns up a monster
+         if (eventnum >= 10)
                        {
-                         list<tavernItem>::iterator temp_tavernitem;
-                         
-                         notice(s_GameServ, u, "Fortune smiles upon thee!");
-                         
-                         eventnum = rand() % tavern.size();
-                         temp_tavernitem = tavern.begin();
-                         for (int x = 0;x < eventnum;x++)
-                               {
-                                 temp_tavernitem++;
-                               }
-                         notice(s_GameServ, u, "You have found a %s", (*temp_tavernitem).getItem()->getName().c_str());
-                         p->inventory->addItem((*temp_tavernitem).getItem());
-                       }
-                 else if (eventnum < 9 && eventnum >= 4) // 5% for the fountain
-                       {
-                         if (p->getHP() < p->getMaxHP())
-                               {
-                                 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->healall();
-                               }
-                         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->addForestFights(1);
-                               }
-                       }
-                 else if (eventnum < 4) // 4 % for the wishing well
-                       {
-                         notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well.");
-                         if (p->getGold() == 0)
-                               {
-                                 notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today.");
-                                 p->addForestFights(1);
-                                 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->addForestFights(newstats);
-                               }
-                         else if (eventnum < 3)
-                               {
-                                 newstats = levels[p->getLevel() - 1].getGold().random();
-                                 notice(s_GameServ, u, "A SACK WITH %ld GOLD!", newstats);
-                                 p->addGold(newstats);
-                               }
-                         else
-                               {
-                                 newstats = levels[p->getLevel() - 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->addExp(newstats);
-                               }
+            p->setMonster(levels[p->getLevel() - 1].randomMonster());
+
+            notice(s_GameServ, u, "You have found \ 2%s\ 2!", 
+                   p->getMonster()->name.c_str());
+            if (p->getMonster()->hp < p->getMonster()->maxhp)
+            p->getMonster()->hp = p->getMonster()->maxhp;
+
+            p->delBattle(); // Just to make sure
+            p->delMaster(); // Just to make sure
+            display_monster(u);
                        }
+         else if (eventnum < 10 && eventnum >= 9) // 1% for finding potions
+         {
+            list<tavernItem>::iterator temp_tavernitem;
+
+            notice(s_GameServ, u, "Fortune smiles upon thee!");
+
+            eventnum = rand() % tavern.size();
+            temp_tavernitem = tavern.begin();
+            for (int x = 0;x < eventnum;x++)
+            {
+               temp_tavernitem++;
+            }
+            notice(s_GameServ, u, "You have found a %s", (*temp_tavernitem).getItem()->getName().c_str());
+            p->inventory->addItem((*temp_tavernitem).getItem());
+         }
+         else if (eventnum < 9 && eventnum >= 4) // 5% for the fountain
+         {
+            if (p->getHP() < p->getMaxHP())
+            {
+               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->healall();
+            }
+            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->addForestFights(1);
+            }
+         }
+         else if (eventnum < 4) // 4 % for the wishing well
+         {
+            notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well.");
+            if (p->getGold() == 0)
+            {
+               notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today.");
+               p->addForestFights(1);
+               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->addForestFights(newstats);
+            }
+            else if (eventnum < 3)
+            {
+               newstats = levels[p->getLevel() - 1].getGold().random();
+               notice(s_GameServ, u, "A SACK WITH %ld GOLD!", newstats);
+               p->addGold(newstats);
+            }
+            else
+            {
+               newstats = levels[p->getLevel() - 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->addExp(newstats);
+            }
         }
-         else if (is_fighting(u))
-        {
-                 notice(s_GameServ, u, "You want to fight two monsters at once?");
-        }
-    } 
+      }
+      else if (is_fighting(u))
+      {
+         notice(s_GameServ, u, "You want to fight two monsters at once?");
+      }
+   }  
 }
 
 Monster *getNewMonster(Monster *m)
 {
-    if (!m)
-       return NULL;
+   if (!m)
+      return NULL;
 
-    Monster *newguy;
-    newguy = new Monster;
-    newguy->name = m->name;
-    newguy->weapon = m->weapon;
-    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;
+   Monster *newguy;
+   newguy = new Monster;
+   newguy->name = m->name;
+   newguy->weapon = m->weapon;
+   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;
 }