]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Weapons.cpp
Removed all modifications of Account active from outside Account
[lugaru.git] / Source / Weapons.cpp
index 776711e50bf9921702b20ea60fde6fe48e26d0c8..35f73c291be888e57fe7db026f26a266f87afe20 100644 (file)
@@ -1,28 +1,29 @@
 /*
 Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
 
 This file is part of Lugaru.
 
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
+This file is part of Lugaru.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
-See the GNU General Public License for more details.
+Lugaru is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+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"
@@ -42,7 +43,6 @@ extern float texdetail;
 extern GLubyte bloodText[512 * 512 * 3];
 extern int bloodtoggle;
 extern Objects objects;
-extern bool osx;
 extern bool autoslomo;
 extern float camerashake;
 extern float woozy;
@@ -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;
@@ -214,27 +213,21 @@ void Weapon::DoStuff(int i)
         }
 
         if (velocity.x || velocity.y || velocity.z) {
-            for (int j = 0; j < Person::players.size(); j++) {
+            for (unsigned j = 0; j < Person::players.size(); j++) {
                 footvel = 0;
                 footpoint = DoRotation((Person::players[j]->jointPos(abdomen) + Person::players[j]->jointPos(neck)) / 2, 0, Person::players[j]->yaw, 0) * Person::players[j]->scale + Person::players[j]->coords;
                 if (owner == -1 && distsqflat(&position, &Person::players[j]->coords) < 1.5 &&
                         distsq(&position, &Person::players[j]->coords) < 4 && Person::players[j]->weaponstuck == -1 &&
-                        !Person::players[j]->skeleton.free && j != oldowner) {
+                        !Person::players[j]->skeleton.free && (int(j) != oldowner)) {
                     if ((Person::players[j]->aitype != attacktypecutoff || abs(Random() % 6) == 0 || (Person::players[j]->animTarget != backhandspringanim && Person::players[j]->animTarget != rollanim && Person::players[j]->animTarget != flipanim && Random() % 2 == 0)) && !missed) {
                         if ( (Person::players[j]->creature == wolftype && Random() % 3 != 0 && Person::players[j]->weaponactive == -1 && (Person::players[j]->isIdle() || Person::players[j]->isRun() || Person::players[j]->animTarget == walkanim)) ||
                                 (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);