]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Weapons.cpp
Moved Skeleton and Animation to their own folder.
[lugaru.git] / Source / Weapons.cpp
index 5170ece2529e51d91e881e962d2069b13a0ba96c..35f73c291be888e57fe7db026f26a266f87afe20 100644 (file)
@@ -23,7 +23,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 /**> HEADER FILES <**/
 #include "Weapons.h"
 #include "openal_wrapper.h"
-#include "Animation.h"
+#include "Animation/Animation.h"
 #include "Sounds.h"
 #include "Game.h"
 #include "Awards.h"
@@ -117,7 +117,6 @@ void Weapon::DoStuff(int i)
     static XYZ point[3];
     static XYZ closestpoint;
     static XYZ closestswordpoint;
-    static XYZ extramove;
     static float tempmult;
 
     if (owner != -1) {
@@ -174,7 +173,7 @@ void Weapon::DoStuff(int i)
                                 position = colpoint - normalrot * .2;
                             else if (type == staff)
                                 position = colpoint - normalrot * .2;
-                            XYZ temppoint1, temppoint2, tempforward;
+                            XYZ temppoint1, temppoint2;
                             float distance;
 
                             temppoint1 = 0;
@@ -225,16 +224,10 @@ void Weapon::DoStuff(int i)
                                 (Person::players[j]->creature == rabbittype && Random() % 2 == 0 && Person::players[j]->aitype == attacktypecutoff && Person::players[j]->weaponactive == -1)) {
                             emit_sound_at(knifedrawsound, Person::players[j]->coords, 128.);
 
-                            Person::players[j]->weaponactive = 0;
                             Person::players[j]->animTarget = removeknifeanim;
                             Person::players[j]->frameTarget = 1;
                             Person::players[j]->target = 1;
-                            owner = Person::players[j]->id;
-                            if (Person::players[j]->num_weapons > 0) {
-                                Person::players[j]->weaponids[Person::players[j]->num_weapons] = Person::players[j]->weaponids[0];
-                            }
-                            Person::players[j]->num_weapons++;
-                            Person::players[j]->weaponids[0] = i;
+                            Person::players[j]->takeWeapon(i);
 
                             Person::players[j]->aitype = attacktypecutoff;
                         } else {
@@ -278,7 +271,7 @@ void Weapon::DoStuff(int i)
 
                             emit_sound_at(fleshstabsound, position, 128.);
 
-                            if (animation[Person::players[0]->animTarget].height == highheight)
+                            if (Animation::animations[Person::players[0]->animTarget].height == highheight)
                                 award_bonus(0, ninja);
                             else
                                 award_bonus(0, Bullseyebonus);
@@ -320,7 +313,7 @@ void Weapon::DoStuff(int i)
                 tippoint.z = M[14];
                 glPopMatrix();
                 position -= tippoint * .15;
-                XYZ temppoint1, temppoint2, tempforward;
+                XYZ temppoint1, temppoint2;
 
                 rotation3 = 0;
                 smallrotation = 90;
@@ -356,7 +349,7 @@ void Weapon::DoStuff(int i)
         if (velocity.x != 0 || velocity.z != 0 || velocity.y != 0) {
             velocity.y += gravity * multiplier;
 
-            XYZ temppoint1, temppoint2, tempforward;
+            XYZ temppoint1, temppoint2;
             float distance;
 
             temppoint1 = 0;
@@ -830,7 +823,7 @@ void Weapon::DoStuff(int i)
             tipvelocity.y += gravity * multiplier;
 
             //Rotation
-            XYZ temppoint1, temppoint2, tempforward;
+            XYZ temppoint1, temppoint2;
             float distance;
 
             temppoint1 = position;
@@ -1078,6 +1071,27 @@ void Weapon::Draw()
     }
 }
 
+void Weapon::drop(XYZ v, XYZ tv, bool sethitsomething)
+{
+    owner = -1;
+    velocity = v;
+    tipvelocity = tv;
+    missed = 1;
+    if (sethitsomething) {
+        hitsomething = 0;
+    }
+    freetime = 0;
+    firstfree = 1;
+    physics = 1;
+}
+
+void Weapon::thrown(XYZ v, bool sethitsomething)
+{
+    drop(v, v, sethitsomething);
+    missed = 0;
+    physics = 0;
+}
+
 int Weapons::Draw()
 {
     glAlphaFunc(GL_GREATER, 0.9);