]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Person.cpp
Cleaned up handling of envsounds array through a function
[lugaru.git] / Source / Person.cpp
index 4ccecd4cfaa70e3fc102bf9db48e5047232cf932..a95794520d7684204181c46ac80fc39693509209 100644 (file)
@@ -57,16 +57,6 @@ extern float flashamount, flashr, flashg, flashb;
 extern int flashdelay;
 extern bool showpoints;
 extern bool immediate;
-extern int test;
-extern bool tilt2weird;
-extern bool tiltweird;
-extern bool midweird;
-extern bool proportionweird;
-extern bool vertexweird[6];
-extern XYZ envsound[30];
-extern float envsoundvol[30];
-extern float envsoundlife[30];
-extern int numenvsounds;
 extern int tutoriallevel;
 extern float smoketex;
 extern int tutorialstage;
@@ -105,7 +95,6 @@ Person::Person() :
     realoldcoords(),
     oldcoords(),
     coords(),
-    originalcoords(),
     velocity(),
 
     proportionhead(),
@@ -149,14 +138,11 @@ Person::Person() :
 
     jumppower(0),
     onground(false),
-    madskills(0),
 
     wentforweapon(0),
 
     calcrot(false),
 
-    backwardsanim(false),
-
     facing(),
 
     bleeding(0),
@@ -207,7 +193,6 @@ Person::Person() :
     aiupdatedelay(0),
     losupdatedelay(0),
     ally(0),
-    movetarget(),
     collide(0),
     collided(0),
     avoidcollided(0),
@@ -242,7 +227,6 @@ Person::Person() :
     weaponmissdelay(0),
     highreversaldelay(0),
     lowreversaldelay(0),
-    nocollidedelay(0),
 
     creature(rabbittype),
 
@@ -273,10 +257,8 @@ Person::Person() :
     onfire(false),
     onfiredelay(0),
     burnt(0),
-    fireduration(0),
 
     flamedelay(0),
-    updatestuffdelay(0),
 
     playerdetail(0),
 
@@ -287,8 +269,6 @@ Person::Person() :
 
     numwaypoints(0),
     pausetime(0),
-    hastempwaypoint(false),
-    tempwaypoint(),
 
     headtarget(),
     interestdelay(0),
@@ -301,10 +281,8 @@ Person::Person() :
     lastpathfindpoint2(0),
     lastpathfindpoint3(0),
     lastpathfindpoint4(0),
-    onpath(false),
 
     waypoint(0),
-    jumppath(false),
 
     lastseen(),
     lastseentime(0),
@@ -324,9 +302,6 @@ Person::Person() :
     whichskin(0),
     rabbitkickragdoll(false),
 
-    averageloc(),
-    oldaverageloc(),
-
     tempanimation(),
 
     occluded(0),
@@ -646,17 +621,12 @@ void Person::DoBloodBig(float howmuch, int which)
             // play pain sounds
             int whichsound = -1;
 
-            // FIXME: seems to be spawning sounds by manipulating attributes... MESSY!
             if (creature == wolftype) {
                 int i = abs(Random() % 2);
                 if (i == 0)
                     whichsound = snarlsound;
                 if (i == 1)
                     whichsound = snarl2sound;
-                envsound[numenvsounds] = coords;
-                envsoundvol[numenvsounds] = 16;
-                envsoundlife[numenvsounds] = .4;
-                numenvsounds++;
             }
             if (creature == rabbittype) {
                 int i = abs(Random() % 2);
@@ -664,14 +634,12 @@ void Person::DoBloodBig(float howmuch, int which)
                     whichsound = rabbitpainsound;
                 if (i == 1 && howmuch >= 2)
                     whichsound = rabbitpain1sound;
-                envsound[numenvsounds] = coords;
-                envsoundvol[numenvsounds] = 16;
-                envsoundlife[numenvsounds] = .4;
-                numenvsounds++;
             }
 
-            if (whichsound != -1)
+            if (whichsound != -1) {
                 emit_sound_at(whichsound, coords);
+                addEnvSound(coords);
+            }
         }
 
     if (id == 0 && howmuch > 0) {
@@ -1462,10 +1430,6 @@ void Person::DoDamage(float howmuch)
                     whichsound = snarlsound;
                 if (i == 1)
                     whichsound = snarl2sound;
-                envsound[numenvsounds] = coords;
-                envsoundvol[numenvsounds] = 16;
-                envsoundlife[numenvsounds] = .4;
-                numenvsounds++;
             }
             if (creature == rabbittype) {
                 int i = abs(Random() % 2);
@@ -1473,14 +1437,11 @@ void Person::DoDamage(float howmuch)
                     whichsound = rabbitpainsound;
                 if (i == 1 && damage > damagetolerance)
                     whichsound = rabbitpain1sound;
-                envsound[numenvsounds] = coords;
-                envsoundvol[numenvsounds] = 16;
-                envsoundlife[numenvsounds] = .4;
-                numenvsounds++;
             }
 
             if (whichsound != -1) {
                 emit_sound_at(whichsound, coords);
+                addEnvSound(coords);
             }
         }
     speechdelay = .3;
@@ -2008,13 +1969,11 @@ void Person::DoAnimations()
 
                     if (id == 0)
                         if (whichsound == footstepsound || whichsound == footstepsound2 || whichsound == footstepsound3 || whichsound == footstepsound4) {
-                            envsound[numenvsounds] = coords;
-                            if (animTarget == wolfrunninganim || animTarget == rabbitrunninganim)
-                                envsoundvol[numenvsounds] = 15;
-                            else
-                                envsoundvol[numenvsounds] = 6;
-                            envsoundlife[numenvsounds] = .4;
-                            numenvsounds++;
+                            if (animTarget == wolfrunninganim || animTarget == rabbitrunninganim) {
+                                addEnvSound(coords, 15);
+                            } else {
+                                addEnvSound(coords, 6);
+                            }
                         }
 
                     if (animation[animTarget].label[frameTarget] == 3) {
@@ -5250,10 +5209,7 @@ void Person::DoStuff()
                             emit_sound_at(bushrustle, coords, 40 * findLength(&velocity));
 
                             if (id == 0) {
-                                envsound[numenvsounds] = coords;
-                                envsoundvol[numenvsounds] = 4 * findLength(&velocity);
-                                envsoundlife[numenvsounds] = .4;
-                                numenvsounds++;
+                                addEnvSound(coords, 4 * findLength(&velocity));
                             }
 
                             int howmany;
@@ -5313,10 +5269,7 @@ void Person::DoStuff()
                             emit_sound_at(bushrustle, coords, 40 * findLength(&velocity));
 
                             if (id == 0) {
-                                envsound[numenvsounds] = coords;
-                                envsoundvol[numenvsounds] = 4 * findLength(&velocity);
-                                envsoundlife[numenvsounds] = .4;
-                                numenvsounds++;
+                                addEnvSound(coords, 4 * findLength(&velocity));
                             }
 
                             int howmany;
@@ -5805,10 +5758,7 @@ void Person::DoStuff()
                 emit_sound_at(landsound, coords, 128.);
 
                 if (id == 0) {
-                    envsound[numenvsounds] = coords;
-                    envsoundvol[numenvsounds] = 16;
-                    envsoundlife[numenvsounds] = .4;
-                    numenvsounds++;
+                    addEnvSound(coords);
                 }
             }
         }
@@ -6705,10 +6655,7 @@ int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate,
                                     emit_sound_at(landsound, coords, 128.);
 
                                     if (id == 0) {
-                                        envsound[numenvsounds] = coords;
-                                        envsoundvol[numenvsounds] = 16;
-                                        envsoundlife[numenvsounds] = .4;
-                                        numenvsounds++;
+                                        addEnvSound(coords);
                                     }
                                 }
                             }