]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Objects/Weapons.cpp
Removed unused defines, changed method names case
[lugaru.git] / Source / Objects / Weapons.cpp
index d762ddcfa0ad17f973171459a46b0dc7c667853f..1cd4cea3f93c21ed6f77eac182afbc06b9354226 100644 (file)
@@ -27,6 +27,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include "Audio/Sounds.hpp"
 #include "Game.hpp"
 #include "Level/Awards.hpp"
+#include "Tutorial.hpp"
 
 extern float multiplier;
 extern Terrain terrain;
@@ -48,7 +49,6 @@ extern float woozy;
 extern float viewdistance;
 extern float blackout;
 extern bool freeze;
-extern int tutoriallevel;
 extern int numthrowkill;
 
 Model Weapon::throwingknifemodel;
@@ -97,7 +97,44 @@ void Weapon::setType(int t)
     }
 }
 
-void Weapon::DoStuff(int i)
+/* Load weapons models and textures */
+void Weapon::Load()
+{
+    LOG("Loading weapon data...");
+
+    knifetextureptr.load("Textures/Knife.png", 0);
+    bloodknifetextureptr.load("Textures/BloodKnife.png", 0);
+    lightbloodknifetextureptr.load("Textures/BloodKnifeLight.png", 0);
+    swordtextureptr.load("Textures/Sword.jpg", 1);
+    bloodswordtextureptr.load("Textures/SwordBlood.jpg", 1);
+    lightbloodswordtextureptr.load("Textures/SwordBloodLight.jpg", 1);
+    stafftextureptr.load("Textures/Staff.jpg", 1);
+
+    throwingknifemodel.load("Models/ThrowingKnife.solid");
+    throwingknifemodel.Scale(.001, .001, .001);
+    throwingknifemodel.Rotate(90, 0, 0);
+    throwingknifemodel.Rotate(0, 90, 0);
+    throwingknifemodel.flat = 0;
+    throwingknifemodel.CalculateNormals(1);
+
+    swordmodel.load("Models/Sword.solid");
+    swordmodel.Scale(.001, .001, .001);
+    swordmodel.Rotate(90, 0, 0);
+    swordmodel.Rotate(0, 90, 0);
+    swordmodel.Rotate(0, 0, 90);
+    swordmodel.flat = 1;
+    swordmodel.CalculateNormals(1);
+
+    staffmodel.load("Models/Staff.solid");
+    staffmodel.Scale(.005, .005, .005);
+    staffmodel.Rotate(90, 0, 0);
+    staffmodel.Rotate(0, 90, 0);
+    staffmodel.Rotate(0, 0, 90);
+    staffmodel.flat = 1;
+    staffmodel.CalculateNormals(1);
+}
+
+void Weapon::doStuff(int i)
 {
     static int whichpatchx, whichpatchz, whichhit;
     static XYZ start, end, colpoint, normalrot, footvel, footpoint;
@@ -166,7 +203,7 @@ void Weapon::DoStuff(int i)
                     if (whichhit != -1) {
                         if (Object::objects[k]->type == treetrunktype) {
                             Object::objects[k]->model.MakeDecal(breakdecal, DoRotation(colpoint - Object::objects[k]->position, 0, -Object::objects[k]->yaw, 0), .1, 1, Random() % 360);
-                            normalrot = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0);
+                            normalrot = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0);
                             velocity = 0;
                             if (type == knife)
                                 position = colpoint - normalrot * .1;
@@ -248,16 +285,16 @@ void Weapon::DoStuff(int i)
                             Person::players[j]->jointVel(neck) += velocity * 2;
                             Person::players[j]->jointVel(rightshoulder) += velocity * 2;
                             Person::players[j]->jointVel(leftshoulder) += velocity * 2;
-                            if (bloodtoggle && tutoriallevel != 1)
+                            if (bloodtoggle && !Tutorial::active)
                                 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
-                            if (tutoriallevel == 1)
+                            if (Tutorial::active)
                                 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .8, .3);
                             footvel = tippoint - position;
                             Normalise(&footvel);
-                            if (bloodtoggle && tutoriallevel != 1)
+                            if (bloodtoggle && !Tutorial::active)
                                 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * -1, 1, 0, 0, .6, 1);
 
-                            if (tutoriallevel != 1) {
+                            if (!Tutorial::active) {
                                 if (Person::players[j]->weaponstuckwhere == 0)
                                     Person::players[j]->DoBloodBig(2, 205);
                                 if (Person::players[j]->weaponstuckwhere == 1)
@@ -451,7 +488,7 @@ void Weapon::DoStuff(int i)
                         if (whichhit != -1) {
                             hitsomething = 1;
                             position = colpoint;
-                            terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1;
+                            terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1;
                             ReflectVector(&velocity, &terrainnormal);
                             position += terrainnormal * .002;
 
@@ -481,7 +518,7 @@ void Weapon::DoStuff(int i)
                         if (whichhit != -1) {
                             hitsomething = 1;
                             tippoint = colpoint;
-                            terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1;
+                            terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1;
                             ReflectVector(&tipvelocity, &terrainnormal);
                             tippoint += terrainnormal * .002;
 
@@ -518,7 +555,7 @@ void Weapon::DoStuff(int i)
                                 if (whichhit != -1) {
                                     hitsomething = 1;
                                     mid = colpoint;
-                                    terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1;
+                                    terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1;
                                     ReflectVector(&velocity, &terrainnormal);
 
                                     bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
@@ -553,7 +590,7 @@ void Weapon::DoStuff(int i)
                                 if (whichhit != -1) {
                                     hitsomething = 1;
                                     mid = colpoint;
-                                    terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1;
+                                    terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1;
                                     ReflectVector(&tipvelocity, &terrainnormal);
 
                                     bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
@@ -920,11 +957,11 @@ void Weapons::DoStuff()
     //Move
     int i = 0;
     for (std::vector<Weapon>::iterator weapon = begin(); weapon != end(); ++weapon) {
-        weapon->DoStuff(i++);
+        weapon->doStuff(i++);
     }
 }
 
-void Weapon::Draw()
+void Weapon::draw()
 {
     static XYZ terrainlight;
     static GLfloat M[16];
@@ -1103,7 +1140,7 @@ int Weapons::Draw()
     glDepthMask(1);
 
     for (std::vector<Weapon>::iterator weapon = begin(); weapon != end(); ++weapon) {
-        weapon->Draw();
+        weapon->draw();
     }
     return 0;
 }