extern float fadestart;
extern bool freeze;
extern bool winfreeze;
-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;
{
}
+/* Read a person in tfile. Throws an error if it’s not valid */
+Person::Person(FILE *tfile, int mapvers, unsigned i) : Person()
+{
+ id = i;
+ funpackf(tfile, "Bi Bi Bf Bf Bf Bi", &whichskin, &creature, &coords.x, &coords.y, &coords.z, &num_weapons);
+ if (mapvers >= 5) {
+ funpackf(tfile, "Bi", &howactive);
+ } else {
+ howactive = typeactive;
+ }
+ if (mapvers >= 3) {
+ funpackf(tfile, "Bf", &scale);
+ } else {
+ scale = -1;
+ }
+ if (mapvers >= 11) {
+ funpackf(tfile, "Bb", &immobile);
+ } else {
+ immobile = 0;
+ }
+ if (mapvers >= 12) {
+ funpackf(tfile, "Bf", &yaw);
+ } else {
+ yaw = 0;
+ }
+ targetyaw = yaw;
+ if (num_weapons < 0 || num_weapons > 5) {
+ throw InvalidPersonException();
+ }
+ if (num_weapons > 0 && num_weapons < 5) {
+ for (int j = 0; j < num_weapons; j++) {
+ weaponids[j] = weapons.size();
+ int type;
+ funpackf(tfile, "Bi", &type);
+ weapons.push_back(Weapon(type, id));
+ }
+ }
+ funpackf(tfile, "Bi", &numwaypoints);
+ for (int j = 0; j < numwaypoints; j++) {
+ funpackf(tfile, "Bf", &waypoints[j].x);
+ funpackf(tfile, "Bf", &waypoints[j].y);
+ funpackf(tfile, "Bf", &waypoints[j].z);
+ if (mapvers >= 5) {
+ funpackf(tfile, "Bi", &waypointtype[j]);
+ } else {
+ waypointtype[j] = wpkeepwalking;
+ }
+ }
+
+ funpackf(tfile, "Bi", &waypoint);
+ if (waypoint > (numwaypoints - 1)) {
+ waypoint = 0;
+ }
+
+ funpackf(tfile, "Bf Bf Bf", &armorhead, &armorhigh, &armorlow);
+ funpackf(tfile, "Bf Bf Bf", &protectionhead, &protectionhigh, &protectionlow);
+ funpackf(tfile, "Bf Bf Bf", &metalhead, &metalhigh, &metallow);
+ funpackf(tfile, "Bf Bf", &power, &speedmult);
+
+ float headprop, legprop, armprop, bodyprop;
+
+ if (mapvers >= 4) {
+ funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
+ } else {
+ headprop = 1;
+ bodyprop = 1;
+ armprop = 1;
+ legprop = 1;
+ }
+
+ if (creature == wolftype) {
+ proportionhead = 1.1 * headprop;
+ proportionbody = 1.1 * bodyprop;
+ proportionarms = 1.1 * armprop;
+ proportionlegs = 1.1 * legprop;
+ } else if (creature == rabbittype) {
+ proportionhead = 1.2 * headprop;
+ proportionbody = 1.05 * bodyprop;
+ proportionarms = 1.00 * armprop;
+ proportionlegs = 1.1 * legprop;
+ proportionlegs.y = 1.05 * legprop;
+ }
+
+ funpackf(tfile, "Bi", &numclothes);
+ for (int k = 0; k < numclothes; k++) {
+ int templength;
+ funpackf(tfile, "Bi", &templength);
+ for (int l = 0; l < templength; l++)
+ funpackf(tfile, "Bb", &clothes[k][l]);
+ clothes[k][templength] = '\0';
+ funpackf(tfile, "Bf Bf Bf", &clothestintr[k], &clothestintg[k], &clothestintb[k]);
+ }
+}
+
/* EFFECT
*
* USES:
// 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);
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) {
- // FIXME: manipulating attributes
- flashamount = .5;
- flashr = 1;
- flashg = 0;
- flashb = 0;
- flashdelay = 0;
+ Game::flash(.5, 0);
}
if (bloodtoggle && decals && tutoriallevel != 1) {
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);
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;
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) {
weapons[weaponids[weaponactive]].blooddrip += 3;
}
if (weaponactive == -1 && creature == wolftype) {
- ;
emit_sound_at(clawslicesound, victim->coords, 128.);
victim->spurt = 1;
victim->DoBloodBig(2 / victim->armorhigh, 175);
}
if (id == 0) {
- flashamount = .5;
- flashr = 1;
- flashg = 0;
- flashb = 0;
- flashdelay = 0;
+ Game::flash(.5, 0);
}
}
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;
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;
emit_sound_at(landsound, coords, 128.);
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords);
}
}
}
if (terrainheight > 1.7)
terrainheight = 1.7;
- //burnt=0;
glColor4f((1 - (1 - terrainlight.x) / terrainheight) - burnt, (1 - (1 - terrainlight.y) / terrainheight) - burnt, (1 - (1 - terrainlight.z) / terrainheight) - burnt, distance);
glDisable(GL_BLEND);
glAlphaFunc(GL_GREATER, 0.0001);
emit_sound_at(landsound, coords, 128.);
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords);
}
}
}