]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/do_attack.cpp
implemented equipping weapons and armor and saving what is equipped
[irc/gameservirc.git] / gameserv / do_attack.cpp
index 222ebf01ea19a015977b6da3a976edc59602e302..053e1c79ed0c89d560777039e3be5ba0fdf8a7c6 100644 (file)
@@ -1,14 +1,14 @@
-
 #include "aClient.h"
 #include "extern.h"
 #include "flags.h"
 #include "level.h"
 #include "player.h"
+#include "item.h"
 
 
 void do_attack(char *u)
 {
-  int hit, mhit;
+  int hit = 0, mhit = 0;
   aClient *ni, *battle; // The player and perhaps the player they're fighting
   Monster *fight; // The monster they may be fighting
 
@@ -51,32 +51,43 @@ void do_attack(char *u)
   if (!player_fight(ni))
     {
       // Player's Hit
-      hit = ((ni->stats->strength + webonus[ni->stats->wea]) / 2) +
-       (rand() % ((ni->stats->strength + webonus[ni->stats->wea]) / 2)) - 
-       fight->defense;
+      if ((ni->stats->strength / 2) == 0)
+       {
+         hit = 0;
+       }
+      else
+       {
+         hit = (ni->stats->strength / 2) +     (rand() % (ni->stats->strength / 2)) - fight->defense;
+       }
 
       // Opponent's Hit
-      mhit = (fight->strength / 2) +
-       (rand() % (fight->strength / 2) - (ni->stats->defense +
-                                          arbonus[ni->stats->arm]));
+      if ((fight->strength / 2) == 0)
+       {
+         mhit = 0;
+       }
+      else
+       {
+         mhit = (fight->strength / 2) +
+           (rand() % (fight->strength / 2) - (ni->stats->defense));
+       }
     }
   else
     {
       // Opponent's Hit
-      mhit = (((battle->stats->strength + webonus[battle->stats->wea]) / 2) +
-             (rand() % ((battle->stats->strength + webonus[battle->stats->wea])) / 2) -
-             (ni->stats->defense + arbonus[ni->stats->arm]));
+      mhit = (((battle->stats->strength) / 2) +
+             (rand() % ((battle->stats->strength)) / 2) -
+             (ni->stats->defense));
 
       // Player's Hit
-      hit = (((ni->stats->strength + webonus[ni->stats->wea]) / 2) +
-            (rand() % ((ni->stats->strength + webonus[ni->stats->wea])) / 2) -
-            (battle->stats->defense + arbonus[battle->stats->arm]));
+      hit = (((ni->stats->strength) / 2) +
+            (rand() % ((ni->stats->strength)) / 2) -
+            (battle->stats->defense));
     }
 
   if (!player_fight(ni))
     {
       if (hit > 0)
-        notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 points!", fight->name.c_str(), hit);
+        notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 hp!", fight->name.c_str(), hit);
       else
         notice(s_GameServ, u, "You miss \1f%s\1f completely!", fight->name.c_str());
 
@@ -103,9 +114,9 @@ void do_attack(char *u)
            ni->stats->name.c_str(), ni->stats->name.c_str(),
            ni->stats->fight->name.c_str(), ni->stats->name.c_str());
            dragon.name = "DRAGON-" + ni->stats->name;
-           dragon.weapon = weapons[ni->stats->wea];
-           dragon.strength = ni->stats->strength + webonus[ni->stats->wea];
-           dragon.defense = ni->stats->defense + arbonus[ni->stats->arm];
+           dragon.weapon = "Breath of Fire";
+           dragon.strength = ni->stats->strength;
+           dragon.defense = ni->stats->defense;
            dragon.hp = ni->stats->maxhp;
            dragon.maxhp = ni->stats->maxhp;
            save_dragon();
@@ -222,7 +233,7 @@ void do_attack(char *u)
 
              notice(s_GameServ, battle->getNick(), "%s has hit you with their %s for "\
                     "^B%d^B damage!", ni->stats->name.c_str(),
-                    weapons[ni->stats->wea], hit);
+                    (ni->stats->getWeapon() ? ni->stats->getWeapon()->getName().c_str() : "Fists"), hit);
            }
          else
            {