/**> HEADER FILES <**/
#include "Person.h"
#include "openal_wrapper.h"
-#include "Animation.h"
+#include "Animation/Animation.h"
#include "Sounds.h"
#include "Awards.h"
#include "Game.h"
+#include "Dialog.h"
+#include "Utils/Folders.h"
extern float multiplier;
extern Terrain terrain;
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;
extern int hostile;
extern float hostiletime;
-extern int indialogue;
-
extern bool gamestarted;
std::vector<std::shared_ptr<Person>> Person::players(1, std::shared_ptr<Person>(new Person()));
+Person::Person() :
+ whichpatchx(0),
+ whichpatchz(0),
+ animCurrent(bounceidleanim),
+ animTarget(bounceidleanim),
+ frameCurrent(0),
+ frameTarget(1),
+ oldanimCurrent(0),
+ oldanimTarget(0),
+ oldframeCurrent(0),
+ oldframeTarget(0),
+ howactive(typeactive),
+ parriedrecently(0),
+ superruntoggle(false),
+ lastattack(0), lastattack2(0), lastattack3(0),
+ currentoffset(), targetoffset(), offset(),
+ target(0),
+ transspeed(0),
+
+ realoldcoords(),
+ oldcoords(),
+ coords(),
+ velocity(),
+
+ proportionhead(),
+ proportionlegs(),
+ proportionarms(),
+ proportionbody(),
+
+ unconscioustime(0),
+
+ immobile(false),
+
+ velspeed(0),
+ targetyaw(0),
+ targetrot(0),
+ rot(0),
+ oldrot(0),
+ lookyaw(0),
+ lookpitch(0),
+ yaw(0),
+ pitch(0),
+ lowyaw(0),
+ tilt(0),
+ targettilt(0),
+ tilt2(0),
+ targettilt2(0),
+ rabbitkickenabled(false),
+
+ bloodloss(0),
+ bleeddelay(0),
+ skiddelay(0),
+ skiddingdelay(0),
+ deathbleeding(0),
+ tempdeltav(0),
+
+ damagetolerance(200),
+ damage(0),
+ permanentdamage(0),
+ superpermanentdamage(0),
+ lastcollide(0),
+ dead(0),
+
+ jumppower(5),
+ onground(false),
+
+ wentforweapon(0),
+
+ calcrot(false),
+
+ facing(),
+
+ bleeding(0),
+ bleedx(0), bleedy(0),
+ direction(0),
+ texupdatedelay(0),
+
+ headyaw(0), headpitch(0),
+ targetheadyaw(0), targetheadpitch(0),
+
+ onterrain(false),
+ pause(false),
+
+ grabdelay(0),
+
+ victim(nullptr),
+ hasvictim(false),
+
+ updatedelay(0),
+ normalsupdatedelay(0),
+
+ jumpstart(false),
+ forwardkeydown(false),
+ forwardstogglekeydown(false),
+ rightkeydown(false),
+ leftkeydown(false),
+ backkeydown(false),
+ jumpkeydown(false),
+ jumptogglekeydown(false),
+ crouchkeydown(false),
+ crouchtogglekeydown(false),
+ drawkeydown(false),
+ drawtogglekeydown(false),
+ throwkeydown(false),
+ throwtogglekeydown(false),
+ attackkeydown(false),
+ feint(false),
+ lastfeint(false),
+ headless(false),
+
+ crouchkeydowntime(0),
+ jumpkeydowntime(0),
+ freefall(false),
+
+ turnspeed(0),
+
+ aitype(passivetype),
+ aiupdatedelay(0),
+ losupdatedelay(0),
+ ally(0),
+ collide(0),
+ collided(-10),
+ avoidcollided(0),
+ loaded(false),
+ whichdirection(false),
+ whichdirectiondelay(0),
+ avoidsomething(false),
+ avoidwhere(),
+ blooddimamount(0),
+
+ staggerdelay(0),
+ blinkdelay(0),
+ twitchdelay(0),
+ twitchdelay2(0),
+ twitchdelay3(0),
+ lefthandmorphness(0),
+ righthandmorphness(0),
+ headmorphness(0),
+ chestmorphness(0),
+ tailmorphness(0),
+ targetlefthandmorphness(0),
+ targetrighthandmorphness(0),
+ targetheadmorphness(1),
+ targetchestmorphness(0),
+ targettailmorphness(0),
+ lefthandmorphstart(0), lefthandmorphend(0),
+ righthandmorphstart(0), righthandmorphend(0),
+ headmorphstart(0), headmorphend(0),
+ chestmorphstart(0), chestmorphend(0),
+ tailmorphstart(0), tailmorphend(0),
+
+ weaponmissdelay(0),
+ highreversaldelay(0),
+ lowreversaldelay(0),
+
+ creature(rabbittype),
+
+ id(0),
+
+ skeleton(),
+
+ speed(0),
+ scale(-1),
+ power(0),
+ speedmult(0),
+
+ protectionhead(0),
+ protectionhigh(0),
+ protectionlow(0),
+ armorhead(0),
+ armorhigh(0),
+ armorlow(0),
+ metalhead(false),
+ metalhigh(false),
+ metallow(false),
+
+ numclothes(0),
+
+ landhard(false),
+ bled(false),
+ spurt(false),
+ onfire(false),
+ onfiredelay(0),
+ burnt(0),
+
+ flamedelay(0),
+
+ playerdetail(0),
+
+ num_weapons(0),
+ weaponactive(-1),
+ weaponstuck(-1),
+ weaponstuckwhere(0),
+
+ numwaypoints(0),
+ pausetime(0),
+
+ headtarget(),
+ interestdelay(0),
+
+ finalfinaltarget(),
+ finaltarget(),
+ finalpathfindpoint(0),
+ targetpathfindpoint(0),
+ lastpathfindpoint(0),
+ lastpathfindpoint2(0),
+ lastpathfindpoint3(0),
+ lastpathfindpoint4(0),
+
+ waypoint(0),
+
+ lastseen(),
+ lastseentime(0),
+ lastchecktime(0),
+ stunned(0),
+ surprised(0),
+ runninghowlong(0),
+ occluded(0),
+ lastoccluded(0),
+ laststanding(0),
+ escapednum(0),
+
+ speechdelay(0),
+ neckspurtdelay(0),
+ neckspurtparticledelay(0),
+ neckspurtamount(0),
+
+ whichskin(0),
+ rabbitkickragdoll(false),
+
+ tempanimation(),
+
+ jumpclimb(false)
+{
+}
+
+/* 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]);
+ }
+
+ loaded = true;
+
+ if (scale < 0) {
+ if (creature == wolftype) {
+ scale = .23;
+ damagetolerance = 300;
+ } else {
+ scale = .2;
+ }
+ }
+
+ oldcoords = coords;
+ realoldcoords = coords;
+}
+
+void Person::skeletonLoad(bool clothes)
+{
+ skeleton.id = id;
+ if (creature != wolftype) {
+ skeleton.Load(
+ "Skeleton/BasicFigure",
+ "Skeleton/BasicFigureLow",
+ "Skeleton/RabbitBelt",
+ "Models/Body.solid",
+ "Models/Body2.solid",
+ "Models/Body3.solid",
+ "Models/Body4.solid",
+ "Models/Body5.solid",
+ "Models/Body6.solid",
+ "Models/Body7.solid",
+ "Models/BodyLow.solid",
+ "Models/Belt.solid",
+ clothes
+ );
+ } else {
+ skeleton.Load(
+ "Skeleton/BasicFigureWolf",
+ "Skeleton/BasicFigureWolfLow",
+ "Skeleton/RabbitBelt",
+ "Models/Wolf.solid",
+ "Models/Wolf2.solid",
+ "Models/Wolf3.solid",
+ "Models/Wolf4.solid",
+ "Models/Wolf5.solid",
+ "Models/Wolf6.solid",
+ "Models/Wolf7.solid",
+ "Models/WolfLow.solid",
+ "Models/Belt.solid",
+ clothes
+ );
+ }
+
+ skeleton.drawmodel.textureptr.load(creatureskin[creature][whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize);
+}
+
/* EFFECT
*
* USES:
&& !victim->skeleton.free))
return;
- if (animation[victim->animTarget].height != lowheight) {
+ if (Animation::animations[victim->animTarget].height != lowheight) {
float damagemult = (creature == wolftype ? 2.5 : 1.) * power * power;
XYZ relative = velocity;
relative.y = 0;
if (tutoriallevel != 1)
emit_sound_at(heavyimpactsound, victim->coords);
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * 120 * damagemult;
}
victim->Puff(neck);
*
* USES:
* GameTick/doPlayerCollisions - spread fire between players
- * GameTick/doDebugKeys - press f to ignite
+ * GameTick/doDevKeys - press f to ignite
* Person::DoStuff - spread fire from lit campfires and bushes
*/
void Person::CatchFire()
XYZ flatfacing, flatvelocity;
int howmany;
for (int i = 0; i < 10; i++) {
- howmany = abs(Random() % (skeleton.num_joints));
- if (!skeleton.free)
- flatvelocity = velocity;
- if (skeleton.free)
+ howmany = abs(Random() % (skeleton.joints.size()));
+ if (skeleton.free) {
flatvelocity = skeleton.joints[howmany].velocity;
- if (!skeleton.free)
- flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
- if (skeleton.free)
flatfacing = skeleton.joints[howmany].position * scale + coords;
+ } else {
+ flatvelocity = velocity;
+ flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
+ }
Sprite::MakeSprite(flamesprite, flatfacing, flatvelocity, 1, 1, 1, 2, 1);
}
*/
int Person::getIdle()
{
- if (indialogue != -1 && howactive == typeactive && creature == rabbittype)
+ if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype))
return talkidleanim;
if (hasvictim && (victim != this->shared_from_this())/*||(id==0&&attackkeydown)*/)
if (/*(id==0&&attackkeydown)||*/(!victim->dead && victim->aitype != passivetype &&
for (int i = 0; i < 3; i++) {
// emit blood particles
bloodvel = 0;
- if (!skeleton.free) {
- bloodvel.z = 10;
- bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
- }
if (skeleton.free) {
bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
- }
- if (skeleton.free)
bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
- if (!skeleton.free)
- bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- if (skeleton.free) {
Sprite::MakeSprite(bloodsprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .3, 1);
- }
- if (!skeleton.free) {
+ } else {
+ bloodvel.z = 10;
+ bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
+ bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
}
// 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) {
// emit blood particles
// FIXME: copypaste from above
bloodvel = 0;
- if (!skeleton.free) {
- bloodvel.z = 10;
- bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
- }
if (skeleton.free) {
bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
- }
- if (skeleton.free)
bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
- if (!skeleton.free)
- bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- if (skeleton.free) {
Sprite::MakeSprite(bloodsprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .3, 1);
- }
- if (!skeleton.free) {
+ } else {
+ bloodvel.z = 10;
+ bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
+ bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
}
static float rotationpoint;
static int whichtri;
static XYZ p1, p2, p3, p0;
- static XYZ N, temp;
XYZ bary;
XYZ gxx, gyy;
float coordsx, coordsy;
p1 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
p2 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
p3 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
- /*
- CrossProduct(p2-p1,p3-p1,&N);
- CrossProduct(p0-p1,p3-p1,&temp);
- s = dotproduct(&temp,&N)/findLength(&N);
- CrossProduct(p2-p1,p1-p0,&temp);
- t = dotproduct(&temp,&N)/findLength(&N);
- r = 1 - (s + t);*/
bary.x = distsq(&p0, &p1);
bary.y = distsq(&p0, &p2);
coordsx = skeleton.drawmodel.Triangles[whichtri].gx[0] * bary.x + skeleton.drawmodel.Triangles[whichtri].gx[1] * bary.y + skeleton.drawmodel.Triangles[whichtri].gx[2] * bary.z;
coordsy = skeleton.drawmodel.Triangles[whichtri].gy[0] * bary.x + skeleton.drawmodel.Triangles[whichtri].gy[1] * bary.y + skeleton.drawmodel.Triangles[whichtri].gy[2] * bary.z;
- //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
- //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
-
if (bleeding <= 0 && spurt) {
spurt = 0;
for (int i = 0; i < 3; i++) {
// emit blood particles
// FIXME: more copypaste code
bloodvel = 0;
- if (!skeleton.free) {
- bloodvel.z = 10;
- bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
- }
if (skeleton.free) {
bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
- }
- if (skeleton.free)
bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
- if (!skeleton.free)
- bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- if (skeleton.free) {
Sprite::MakeSprite(bloodsprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .3, 1);
- }
- if (!skeleton.free) {
+ } else {
+ bloodvel.z = 10;
+ bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
+ bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
}
if (animTarget == staffhitanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 4 == 0)) {
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
- weapons[victim->weaponids[0]].owner = -1;
- weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
- if (weapons[victim->weaponids[0]].velocity.x == 0)
- weapons[victim->weaponids[0]].velocity.x = .1;
- weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
- weapons[victim->weaponids[0]].missed = 1;
- weapons[victim->weaponids[0]].freetime = 0;
- weapons[victim->weaponids[0]].firstfree = 1;
- weapons[victim->weaponids[0]].physics = 1;
+ XYZ tempVelocity = victim->velocity * .2;
+ if (tempVelocity.x == 0)
+ tempVelocity.x = .1;
+ weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
if (animTarget == staffspinhitanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 2 == 0)) {
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
- weapons[victim->weaponids[0]].owner = -1;
- weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
- if (weapons[victim->weaponids[0]].velocity.x == 0)
- weapons[victim->weaponids[0]].velocity.x = .1;
- weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
- weapons[victim->weaponids[0]].missed = 1;
- weapons[victim->weaponids[0]].freetime = 0;
- weapons[victim->weaponids[0]].firstfree = 1;
- weapons[victim->weaponids[0]].physics = 1;
+ XYZ tempVelocity = victim->velocity * .2;
+ if (tempVelocity.x == 0)
+ tempVelocity.x = .1;
+ weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
if (animTarget == swordslashanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 4 == 0)) {
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
- weapons[victim->weaponids[0]].owner = -1;
- weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
- if (weapons[victim->weaponids[0]].velocity.x == 0)
- weapons[victim->weaponids[0]].velocity.x = .1;
- weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
- weapons[victim->weaponids[0]].missed = 1;
- weapons[victim->weaponids[0]].freetime = 0;
- weapons[victim->weaponids[0]].firstfree = 1;
- weapons[victim->weaponids[0]].physics = 1;
+ XYZ tempVelocity = victim->velocity * .2;
+ if (tempVelocity.x == 0)
+ tempVelocity.x = .1;
+ weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
if (animTarget == knifeslashstartanim && distsq(&victim->coords, &coords) < 2 && (victim->id == 0 || Random() % 4 == 0)) {
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
- weapons[victim->weaponids[0]].owner = -1;
- weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
- if (weapons[victim->weaponids[0]].velocity.x == 0)
- weapons[victim->weaponids[0]].velocity.x = .1;
- weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
- weapons[victim->weaponids[0]].missed = 1;
- weapons[victim->weaponids[0]].freetime = 0;
- weapons[victim->weaponids[0]].firstfree = 1;
- weapons[victim->weaponids[0]].physics = 1;
+ XYZ tempVelocity = victim->velocity * .2;
+ if (tempVelocity.x == 0)
+ tempVelocity.x = .1;
+ weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
victim->animTarget = staggerbackhighanim;
victim->targetyaw = targetyaw + 180;
victim->target = 0;
- weapons[victim->weaponids[0]].owner = -1;
aim = DoRotation(facing, 0, 90, 0) * 21;
aim.y += 7;
- weapons[victim->weaponids[0]].velocity = aim * -.2;
- weapons[victim->weaponids[0]].tipvelocity = aim;
- weapons[victim->weaponids[0]].missed = 1;
- weapons[victim->weaponids[0]].hitsomething = 0;
- weapons[victim->weaponids[0]].freetime = 0;
- weapons[victim->weaponids[0]].firstfree = 1;
- weapons[victim->weaponids[0]].physics = 1;
+ weapons[victim->weaponids[0]].drop(aim * -.2, aim);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[num_weapons];
animTarget = staggerbackhighanim;
targetyaw = targetyaw + 180;
target = 0;
- weapons[weaponids[0]].owner = -1;
aim = DoRotation(facing, 0, 90, 0) * 21;
aim.y += 7;
- weapons[weaponids[0]].velocity = aim * -.2;
- weapons[weaponids[0]].tipvelocity = aim;
- weapons[weaponids[0]].hitsomething = 0;
- weapons[weaponids[0]].missed = 1;
- weapons[weaponids[0]].freetime = 0;
- weapons[weaponids[0]].firstfree = 1;
- weapons[weaponids[0]].physics = 1;
+ weapons[victim->weaponids[0]].drop(aim * -.2, aim);
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
if (aitype != playercontrolled && Random() % 10 == 0 && escapednum < 2 && difficulty == 0)
feint = 1;
- if (victim->id == 0 && animation[victim->animTarget].attack == reversal)
+ if (victim->id == 0 && Animation::animations[victim->animTarget].attack == reversal)
numreversals++;
}
if (howmuch > damagetolerance * 50 && skeleton.free != 2) {
XYZ flatvelocity2;
XYZ flatfacing2;
- for (int i = 0; i < skeleton.num_joints; i++) {
- if (!skeleton.free)
- flatvelocity2 = velocity;
- if (skeleton.free)
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ if (skeleton.free) {
flatvelocity2 = skeleton.joints[i].velocity;
- if (!skeleton.free)
- flatfacing2 = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
- if (skeleton.free)
flatfacing2 = skeleton.joints[i].position * scale + coords;
+ } else {
+ flatvelocity2 = velocity;
+ flatfacing2 = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
+ }
flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
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;
skeleton.specialforward[0] = facing;
//skeleton.specialforward[0]=DoRotation(facing,0,yaw,0);
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible && (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)) {
skeleton.FindRotationMuscle(i, animTarget);
}
if (!isnormal(tilt)) tilt = 0;
if (!isnormal(tilt2)) tilt2 = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].delay = 0;
skeleton.joints[i].locked = 0;
skeleton.joints[i].position = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
skeleton.joints[i].realoldposition = skeleton.joints[i].position * scale + coords;
}
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].velocity = 0;
skeleton.joints[i].velchange = 0;
}
skeleton.DoConstraints(&coords, &scale);
- if (animation[animCurrent].height == lowheight || animation[animTarget].height == lowheight) {
+ if (Animation::animations[animCurrent].height == lowheight || Animation::animations[animTarget].height == lowheight) {
skeleton.DoConstraints(&coords, &scale);
skeleton.DoConstraints(&coords, &scale);
skeleton.DoConstraints(&coords, &scale);
skeleton.DoConstraints(&coords, &scale);
}
- speed = animation[animTarget].speed[frameTarget] * 2;
- if (animation[animCurrent].speed[frameCurrent] > animation[animTarget].speed[frameTarget]) {
- speed = animation[animCurrent].speed[frameCurrent] * 2;
+ speed = targetFrame().speed * 2;
+ if (currentFrame().speed > targetFrame().speed) {
+ speed = currentFrame().speed * 2;
}
if (transspeed)
speed = transspeed * 2;
speed *= speedmult;
- for (int i = 0; i < skeleton.num_joints; i++) {
- if ((animation[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && animation[animCurrent].height == animation[animTarget].height)
- skeleton.joints[i].velocity = velocity / scale + facing * 5 + DoRotation(DoRotation(DoRotation((animation[animTarget].position[i][frameTarget] - animation[animCurrent].position[i][frameCurrent]) * speed, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ if ((Animation::animations[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && Animation::animations[animCurrent].height == Animation::animations[animTarget].height)
+ skeleton.joints[i].velocity = velocity / scale + facing * 5 + DoRotation(DoRotation(DoRotation((targetFrame().joints[i].position - currentFrame().joints[i].position) * speed, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
else
skeleton.joints[i].velocity = velocity / scale + facing * 5;
change.x = (float)(Random() % 100) / 100;
change.y = (float)(Random() % 100) / 100;
change.z = (float)(Random() % 100) / 100;
skeleton.joints[i].velocity += change;
- skeleton.joints[abs(Random() % skeleton.num_joints)].velocity -= change;
+ skeleton.joints[abs(Random() % skeleton.joints.size())].velocity -= change;
change.x = (float)(Random() % 100) / 100;
change.y = (float)(Random() % 100) / 100;
change.z = (float)(Random() % 100) / 100;
skeleton.joints[i].velchange += change;
- skeleton.joints[abs(Random() % skeleton.num_joints)].velchange -= change;
+ skeleton.joints[abs(Random() % skeleton.joints.size())].velchange -= change;
}
if (checkcollision) {
int howmany;
average = 0;
howmany = 0;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
average += skeleton.joints[j].position;
howmany++;
}
average /= howmany;
coords += average * scale;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
skeleton.joints[j].position -= average;
}
updatedelay = 0;
velocity = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
velocity += skeleton.joints[i].velocity * scale;
}
- velocity /= skeleton.num_joints;
+ velocity /= skeleton.joints.size();
// drop weapon
if (Random() % 2 == 0) {
if (weaponactive != -1 && animTarget != rabbitkickanim && num_weapons > 0) {
- weapons[weaponids[0]].owner = -1;
- weapons[weaponids[0]].hitsomething = 0;
- weapons[weaponids[0]].velocity = jointVel(righthand) * scale * -.3;
+ weapons[weaponids[0]].drop(jointVel(righthand) * scale * -.3, jointVel(righthand) * scale);
weapons[weaponids[0]].velocity.x += .01;
- weapons[weaponids[0]].tipvelocity = jointVel(righthand) * scale;
- weapons[weaponids[0]].missed = 1;
- weapons[weaponids[0]].freetime = 0;
- weapons[weaponids[0]].firstfree = 1;
- weapons[weaponids[0]].physics = 1;
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
/* EFFECT
*/
-void Person::FootLand(int which, float opacity)
+void Person::FootLand(bodypart whichfoot, float opacity)
{
+ if ((whichfoot != leftfoot) && (whichfoot != rightfoot)) {
+ cerr << "FootLand called on wrong bodypart" << endl;
+ return;
+ }
static XYZ terrainlight;
static XYZ footvel, footpoint;
- if (opacity >= 1 || skiddelay <= 0)
+ if (opacity >= 1 || skiddelay <= 0) {
if (opacity > 1) {
footvel = 0;
- if (which == 0)
- footpoint = DoRotation(jointPos(leftfoot), 0, yaw, 0) * scale + coords;
- if (which == 1)
- footpoint = DoRotation(jointPos(rightfoot), 0, yaw, 0) * scale + coords;
- //footpoint.y=coords.y;
+ footpoint = DoRotation(jointPos(whichfoot), 0, yaw, 0) * scale + coords;
if (distsq(&footpoint, &viewer))
Sprite::MakeSprite(cloudsprite, footpoint, footvel, 1, 1, 1, .5, .2 * opacity);
- } else if (environment == snowyenvironment && onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
+ } else if (onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
footvel = velocity / 5;
if (footvel.y < .8)
footvel.y = .8;
- if (which == 0)
- footpoint = DoRotation(jointPos(leftfoot), 0, yaw, 0) * scale + coords;
- if (which == 1)
- footpoint = DoRotation(jointPos(rightfoot), 0, yaw, 0) * scale + coords;
+ footpoint = DoRotation(jointPos(whichfoot), 0, yaw, 0) * scale + coords;
footpoint.y = terrain.getHeight(footpoint.x, footpoint.z);
terrainlight = terrain.getLighting(footpoint.x, footpoint.z);
- if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
- Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x, terrainlight.y, terrainlight.z, .5, .7 * opacity);
- if (opacity >= 1 || detail == 2)
- if (detail == 2)
- if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4) {
+ if (environment == snowyenvironment) {
+ Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x, terrainlight.y, terrainlight.z, .5, .7 * opacity);
+ if (detail == 2) {
terrain.MakeDecal(footprintdecal, footpoint, .2, 1 * opacity, yaw);
- } else if (environment == grassyenvironment && onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
- footvel = velocity / 5;
- if (footvel.y < .8)
- footvel.y = .8;
- if (which == 0)
- footpoint = DoRotation(jointPos(leftfoot), 0, yaw, 0) * scale + coords;
- if (which == 1)
- footpoint = DoRotation(jointPos(rightfoot), 0, yaw, 0) * scale + coords;
- footpoint.y = terrain.getHeight(footpoint.x, footpoint.z);
- terrainlight = terrain.getLighting(footpoint.x, footpoint.z);
- if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
- Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x * 90 / 255, terrainlight.y * 70 / 255, terrainlight.z * 8 / 255, .5, .5 * opacity);
- } else if (environment == desertenvironment && onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
- footvel = velocity / 5;
- if (footvel.y < .8)
- footvel.y = .8;
- if (which == 0)
- footpoint = DoRotation(jointPos(leftfoot), 0, yaw, 0) * scale + coords;
- if (which == 1)
- footpoint = DoRotation(jointPos(rightfoot), 0, yaw, 0) * scale + coords;
- footpoint.y = terrain.getHeight(footpoint.x, footpoint.z);
- terrainlight = terrain.getLighting(footpoint.x, footpoint.z);
- if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
- Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x * 190 / 255, terrainlight.y * 170 / 255, terrainlight.z * 108 / 255, .5, .7 * opacity);
- if (opacity >= 1 || detail == 2)
- if (detail == 2)
- if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
+ }
+ } else if (environment == grassyenvironment) {
+ Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x * 90 / 255, terrainlight.y * 70 / 255, terrainlight.z * 8 / 255, .5, .5 * opacity);
+ } else if (environment == desertenvironment) {
+ Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x * 190 / 255, terrainlight.y * 170 / 255, terrainlight.z * 108 / 255, .5, .7 * opacity);
+ if (detail == 2) {
terrain.MakeDecal(footprintdecal, footpoint, .2, .25 * opacity, yaw);
- } else if (isLanding() || animTarget == jumpupanim || isLandhard()) {
+ }
+ }
+ }
+ } else if (isLanding() || (animTarget == jumpupanim) || isLandhard()) {
footvel = velocity / 5;
if (footvel.y < .8)
footvel.y = .8;
- if (which == 0)
- footpoint = DoRotation(jointPos(leftfoot), 0, yaw, 0) * scale + coords;
- if (which == 1)
- footpoint = DoRotation(jointPos(rightfoot), 0, yaw, 0) * scale + coords;
- //footpoint.y=coords.y;
- if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
+ footpoint = DoRotation(jointPos(whichfoot), 0, yaw, 0) * scale + coords;
+ if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, 1, 1, 1, .5, .2 * opacity);
+ }
}
+ }
}
/* EFFECT
normalsupdatedelay = 0;
if (animTarget == tempanim || animCurrent == tempanim) {
- animation[tempanim] = tempanimation;
+ Animation::animations[tempanim] = tempanimation;
}
if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
float gLoc[3];
numflipped++;
}
- if (animation[animTarget].attack != reversed)
+ if (Animation::animations[animTarget].attack != reversed)
feint = 0;
if (!crouchkeydown || (isLanding() || isLandhard()) || (wasLanding() || wasLandhard())) {
crouchtogglekeydown = 0;
if (aitype == playercontrolled)
feint = 0;
} else {
- if (!crouchtogglekeydown && animation[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain))
+ if (!crouchtogglekeydown && Animation::animations[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain))
feint = 1;
if (!isFlip())
crouchtogglekeydown = 1;
}
- if (animation[animTarget].attack || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim) {
+ if (Animation::animations[animTarget].attack || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim) {
if (detail)
normalsupdatedelay = 0;
}
}
}
- if (!drawtogglekeydown && drawkeydown && (weaponactive == -1 || num_weapons == 1) && (animation[animTarget].label[frameTarget] || (animTarget != animCurrent && animCurrent == rollanim)) && num_weapons > 0 && creature != wolftype) {
+ if (!drawtogglekeydown && drawkeydown && (weaponactive == -1 || num_weapons == 1) && (targetFrame().label || (animTarget != animCurrent && animCurrent == rollanim)) && num_weapons > 0 && creature != wolftype) {
if (weapons[weaponids[0]].getType() == knife) {
if (weaponactive == -1)
weaponactive = 0;
}
//Footstep sounds
if (tutoriallevel != 1 || id == 0)
- if ((animation[animTarget].label[frameTarget] && (animation[animTarget].label[frameTarget] < 5 || animation[animTarget].label[frameTarget] == 8))/*||(animTarget==rollanim&&frameTarget==animation[rollanim].numframes-1)*/) {
+ if ((targetFrame().label && (targetFrame().label < 5 || targetFrame().label == 8))) {
int whichsound;
if (onterrain) {
if (terrain.getOpacity(coords.x, coords.z) < .2) {
- if (animation[animTarget].label[frameTarget] == 1)
+ if (targetFrame().label == 1)
whichsound = footstepsound;
else
whichsound = footstepsound2;
- if (animation[animTarget].label[frameTarget] == 1)
- FootLand(0, 1);
- if (animation[animTarget].label[frameTarget] == 2)
- FootLand(1, 1);
- if (animation[animTarget].label[frameTarget] == 3 && isRun()) {
- FootLand(1, 1);
- FootLand(0, 1);
+ if (targetFrame().label == 1)
+ FootLand(leftfoot, 1);
+ if (targetFrame().label == 2)
+ FootLand(rightfoot, 1);
+ if (targetFrame().label == 3 && isRun()) {
+ FootLand(rightfoot, 1);
+ FootLand(leftfoot, 1);
}
}
if (terrain.getOpacity(coords.x, coords.z) >= .2) {
- if (animation[animTarget].label[frameTarget] == 1)
+ if (targetFrame().label == 1)
whichsound = footstepsound3;
else
whichsound = footstepsound4;
}
}
if (!onterrain) {
- if (animation[animTarget].label[frameTarget] == 1)
+ if (targetFrame().label == 1)
whichsound = footstepsound3;
else
whichsound = footstepsound4;
}
- if (animation[animTarget].label[frameTarget] == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
- if (animation[animTarget].attack != neutral) {
+ if (targetFrame().label == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
+ if (Animation::animations[animTarget].attack != neutral) {
unsigned r = abs(Random() % 3);
if (r == 0)
whichsound = lowwhooshsound;
if (r == 2)
whichsound = highwhooshsound;
}
- if (animation[animTarget].attack == neutral)
+ if (Animation::animations[animTarget].attack == neutral)
whichsound = movewhooshsound;
- } else if (animation[animTarget].label[frameTarget] == 4)
+ } else if (targetFrame().label == 4)
whichsound = knifeswishsound;
- if (animation[animTarget].label[frameTarget] == 8 && tutoriallevel != 1)
+ if (targetFrame().label == 8 && tutoriallevel != 1)
whichsound = landsound2;
emit_sound_at(whichsound, coords, 256.);
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) {
+ if (targetFrame().label == 3) {
whichsound--;
emit_sound_at(whichsound, coords, 128.);
}
if (tutoriallevel != 1 || id == 0)
if (speechdelay <= 0)
if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim)
- if ((animation[animTarget].label[frameTarget] && (animation[animTarget].label[frameTarget] < 5 || animation[animTarget].label[frameTarget] == 8))/*||(animTarget==rollanim&&frameTarget==animation[rollanim].numframes-1)*/) {
+ if ((targetFrame().label && (targetFrame().label < 5 || targetFrame().label == 8))) {
int whichsound = -1;
- if (animation[animTarget].label[frameTarget] == 4 && aitype != playercontrolled) {
- if (animation[animTarget].attack != neutral) {
+ if (targetFrame().label == 4 && aitype != playercontrolled) {
+ if (Animation::animations[animTarget].attack != neutral) {
unsigned r = abs(Random() % 4);
if (creature == rabbittype) {
if (r == 0) whichsound = rabbitattacksound;
if ((!wasLanding() && !wasLandhard()) && animCurrent != getIdle() && (isLanding() || isLandhard())) {
- FootLand(0, 1);
- FootLand(1, 1);
+ FootLand(leftfoot, 1);
+ FootLand(rightfoot, 1);
}
transspeed = 0;
animCurrent = animTarget;
frameTarget++;
- if (animTarget == removeknifeanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == removeknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
for (unsigned i = 0; i < weapons.size(); i++) {
if (weapons[i].owner == -1)
if (distsqflat(&coords, &weapons[i].position) < 4 && weaponactive == -1) {
emit_sound_at(knifedrawsound, coords, 128.);
}
- weaponactive = 0;
- weapons[i].owner = id;
- if (num_weapons > 0) {
- weaponids[num_weapons] = weaponids[0];
- }
- num_weapons++;
- weaponids[0] = i;
+ takeWeapon(i);
}
}
}
}
- if (animTarget == crouchremoveknifeanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == crouchremoveknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
for (unsigned i = 0; i < weapons.size(); i++) {
bool willwork = true;
if (weapons[i].owner != -1)
emit_sound_at(knifedrawsound, coords, 128.);
}
}
- weaponactive = 0;
if (weapons[i].owner != -1) {
-
victim = Person::players[weapons[i].owner];
if (victim->num_weapons == 1)
victim->num_weapons = 0;
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int j = 0; j < victim->skeleton.num_joints; j++) {
+ for (int j = 0; j < victim->skeleton.joints.size(); j++) {
victim->skeleton.joints[j].velchange = 0;
victim->skeleton.joints[j].locked = 0;
}
victim->jointVel(rightshoulder) += relative * 6;
victim->jointVel(leftshoulder) += relative * 6;
}
- weapons[i].owner = id;
- if (num_weapons > 0) {
- weaponids[num_weapons] = weaponids[0];
- }
- num_weapons++;
- weaponids[0] = i;
+ takeWeapon(i);
}
}
}
}
- if (animCurrent == drawleftanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animCurrent == drawleftanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (weaponactive == -1)
weaponactive = 0;
else if (weaponactive == 0) {
}
}
if (closestid != -1)
- if (closestdist < 5 && !Person::players[closestid]->dead && animation[Person::players[closestid]->animTarget].height != lowheight && Person::players[closestid]->animTarget != backhandspringanim) {
+ if (closestdist < 5 && !Person::players[closestid]->dead && Animation::animations[Person::players[closestid]->animTarget].height != lowheight && Person::players[closestid]->animTarget != backhandspringanim) {
hasvictim = 1;
victim = Person::players[closestid];
coords = victim->coords;
if (hasvictim) {
damagemult /= victim->damagetolerance / 200;
}
- if ((animation[animTarget].attack == normalattack || animTarget == walljumprightkickanim || animTarget == walljumpleftkickanim) && (!feint) && (victim->skeleton.free != 2 || animTarget == killanim || animTarget == dropkickanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == staffgroundsmashanim)) {
- if (animTarget == spinkickanim && animation[animTarget].label[frameCurrent] == 5) {
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && animation[victim->animTarget].height != lowheight) {
+ if ((Animation::animations[animTarget].attack == normalattack || animTarget == walljumprightkickanim || animTarget == walljumpleftkickanim) && (!feint) && (victim->skeleton.free != 2 || animTarget == killanim || animTarget == dropkickanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == staffgroundsmashanim)) {
+ if (animTarget == spinkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
- //FootLand(1,2);
victim->Puff(head);
victim->DoDamage(damagemult * 100 / victim->protectionhead);
}
}
- if (animTarget == wolfslapanim && animation[animTarget].label[frameCurrent] == 5) {
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && animation[victim->animTarget].height != lowheight) {
+ if (animTarget == wolfslapanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative.y -= 1;
Normalise(&relative);
relative = DoRotation(relative, 0, 90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
victim->jointVel(head) += relative * damagemult * 100;
- //FootLand(1,2);
victim->Puff(head);
victim->DoDamage(damagemult * 50 / victim->protectionhead);
}
}
- if (animTarget == walljumprightkickanim && animation[animTarget].label[frameCurrent] == 5) {
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
+ if (animTarget == walljumprightkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
- //FootLand(1,2);
victim->Puff(head);
victim->DoDamage(damagemult * 150 / victim->protectionhead);
}
}
- if (animTarget == walljumpleftkickanim && animation[animTarget].label[frameCurrent] == 5) {
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
+ if (animTarget == walljumpleftkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, 90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
- //FootLand(1,2);
victim->Puff(head);
victim->DoDamage(damagemult * 150 / victim->protectionhead);
}
}
- if (animTarget == blockhighleftstrikeanim && animation[animTarget].label[frameCurrent] == 5) {
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
+ if (animTarget == blockhighleftstrikeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative = victim->coords - coords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(head) += relative * damagemult * 100;
- //FootLand(1,2);
victim->Puff(head);
victim->DoDamage(damagemult * 50 / victim->protectionhead);
}
}
- if (animTarget == killanim && animation[animTarget].label[frameCurrent] == 8) {
+ if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 8) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && victim->dead) {
escapednum = 0;
if (id == 0)
victim->skeleton.broken = 0;
victim->skeleton.spinny = 1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].delay = 0;
victim->skeleton.joints[i].locked = 0;
relative = 0;
relative.y = 1;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity.y = relative.y * 10;
victim->skeleton.joints[i].position.y += relative.y * .3;
victim->skeleton.joints[i].oldposition.y += relative.y * .3;
}
}
- if (animTarget == killanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->dead) {
escapednum = 0;
if (id == 0)
relative = victim->coords - coords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 90;
}
victim->Puff(abdomen);
}
}
- if (animTarget == dropkickanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (animTarget == dropkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->skeleton.free) {
escapednum = 0;
if (id == 0)
victim->skeleton.broken = 0;
victim->skeleton.spinny = 1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
//victim->skeleton.joints[i].delay=0;
victim->skeleton.joints[i].locked = 0;
Normalise(&relative);
relative.y += .3;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
if (!victim->dead)
}
}
- if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && animation[animTarget].label[frameCurrent] == 5) {
+ if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (hasvictim)
if (!victim->skeleton.free)
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].locked = 0;
//victim->skeleton.joints[i].velocity=0;
}
}
- if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && animation[animTarget].label[frameCurrent] == 6) {
+ if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
if (!hasvictim) {
emit_sound_at(knifedrawsound, coords, 128);
}
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].locked = 0;
//victim->skeleton.joints[i].velocity=0;
}
}
- if (animTarget == upunchanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == upunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
escapednum = 0;
if (id == 0)
relative = victim->coords - coords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * 30;
}
victim->jointVel(head) += relative * damagemult * 150;
}
- if (animTarget == winduppunchanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == winduppunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 2) {
escapednum = 0;
if (id == 0)
camerashake += .4;
- if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && animation[victim->animTarget].height != lowheight) {
+ if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && Animation::animations[victim->animTarget].height != lowheight) {
if (tutoriallevel != 1) {
emit_sound_at(thudsound, victim->coords);
}
- } else if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && animation[victim->animTarget].height == lowheight) {
+ } else if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && Animation::animations[victim->animTarget].height == lowheight) {
if (tutoriallevel != 1) {
emit_sound_at(whooshhitsound, victim->coords);
}
}
}
- if (victim->damage > victim->damagetolerance - 60 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || animation[victim->animTarget].height == lowheight)
+ if (victim->damage > victim->damagetolerance - 60 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || Animation::animations[victim->animTarget].height == lowheight)
victim->RagDoll(0);
XYZ relative;
relative = victim->coords - coords;
Normalise(&relative);
relative.y = .3;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * 5;
}
victim->jointVel(abdomen) += relative * damagemult * 400;
}
}
- if (animTarget == blockhighleftanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == blockhighleftanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
if (victim->id == 0)
camerashake += .4;
}
}
- if (animTarget == swordslashparryanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == swordslashparryanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
if (victim->id == 0)
camerashake += .4;
}
}
- if (animTarget == knifethrowanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == knifethrowanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (weaponactive != -1) {
escapednum = 0;
XYZ aim;
- weapons[weaponids[0]].owner = -1;
aim = victim->coords + DoRotation(victim->jointPos(abdomen), 0, victim->yaw, 0) * victim->scale + victim->velocity * findDistance(&victim->coords, &coords) / 50 - (coords + DoRotation(jointPos(righthand), 0, yaw, 0) * scale);
Normalise(&aim);
- weapons[weaponids[0]].velocity = aim * 50;
- weapons[weaponids[0]].tipvelocity = aim * 50;
- weapons[weaponids[0]].missed = 0;
- weapons[weaponids[0]].hitsomething = 0;
- weapons[weaponids[0]].freetime = 0;
- weapons[weaponids[0]].firstfree = 1;
- weapons[weaponids[0]].physics = 0;
+ weapons[weaponids[0]].thrown(aim * 50);
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
}
}
- if (animTarget == knifeslashstartanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == knifeslashstartanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (hasvictim)
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 &&/*animation[victim->animTarget].height!=lowheight&&*/victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 &&/*Animation::animations[victim->animTarget].height!=lowheight&&*/victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
escapednum = 0;
if (tutoriallevel != 1)
victim->DoBloodBig(1.5 / victim->armorhigh, 225);
emit_sound_at(knifeslicesound, victim->coords);
}
//victim->jointVel(abdomen)+=relative*damagemult*200;
- if (animation[victim->animTarget].attack && (victim->aitype != playercontrolled || victim->animTarget == knifeslashstartanim) && (victim->creature == rabbittype || victim->deathbleeding <= 0)) {
+ if (Animation::animations[victim->animTarget].attack && (victim->aitype != playercontrolled || victim->animTarget == knifeslashstartanim) && (victim->creature == rabbittype || victim->deathbleeding <= 0)) {
if (victim->id != 0 || difficulty == 2) {
victim->frameTarget = 0;
victim->animTarget = staggerbackhardanim;
footvel = 0;
if (skeleton.free) {
footpoint = (victim->jointPos(abdomen) + victim->jointPos(neck)) / 2 * victim->scale + victim->coords;
- }
- if (!skeleton.free) {
+ } else {
footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords;
}
if (tutoriallevel != 1) {
victim->DoDamage(damagemult * 0);
}
}
- if (animTarget == swordslashanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
+ if (animTarget == swordslashanim && Animation::animations[animTarget].frames[frameCurrent].label == 5 && victim->animTarget != rollanim) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim) {
if (victim->weaponactive == -1 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || (Random() % 2 == 0)) {
award_bonus(id, Slashbonus);
footvel = 0;
if (skeleton.free) {
footpoint = (victim->jointPos(abdomen) + victim->jointPos(neck)) / 2 * victim->scale + victim->coords;
- }
- if (!skeleton.free) {
+ } else {
footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords;
}
if (bloodtoggle)
victim->animTarget = staggerbackhighanim;
victim->targetyaw = targetyaw + 180;
victim->target = 0;
- weapons[victim->weaponids[0]].owner = -1;
aim = DoRotation(facing, 0, 90, 0) * 21;
aim.y += 7;
- weapons[victim->weaponids[0]].velocity = aim * -.2;
- weapons[victim->weaponids[0]].tipvelocity = aim;
- weapons[victim->weaponids[0]].missed = 1;
- weapons[weaponids[0]].hitsomething = 0;
- weapons[victim->weaponids[0]].freetime = 0;
- weapons[victim->weaponids[0]].firstfree = 1;
- weapons[victim->weaponids[0]].physics = 1;
+ weapons[victim->weaponids[0]].drop(aim * -.2, aim);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[num_weapons];
}
}
- if (animTarget == staffhitanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
+ if (animTarget == staffhitanim && Animation::animations[animTarget].frames[frameCurrent].label == 5 && victim->animTarget != rollanim) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
if (tutoriallevel != 1) {
weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 250;
relative = DoRotation(relative, 0, 90, 0);
relative.y -= 1;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 60;
}
victim->jointVel(head) += relative * damagemult * 230;
victim->jointVel(neck) += relative * damagemult * 230;
- //FootLand(1,2);
victim->Puff(head);
if (tutoriallevel != 1) {
victim->DoDamage(damagemult * 120 / victim->protectionhigh);
}
}
- if (animTarget == staffspinhitanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
+ if (animTarget == staffspinhitanim && Animation::animations[animTarget].frames[frameCurrent].label == 5 && victim->animTarget != rollanim) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
if (tutoriallevel != 1) {
weapons[weaponids[0]].damage += .6 + float(abs(Random() % 100) - 50) / 250;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 220;
victim->jointVel(neck) += relative * damagemult * 220;
- //FootLand(1,2);
victim->Puff(head);
if (tutoriallevel != 1) {
victim->DoDamage(damagemult * 350 / victim->protectionhead);
}
}
- if (animTarget == staffgroundsmashanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == staffgroundsmashanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5) {
escapednum = 0;
if (tutoriallevel != 1) {
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].locked = 0;
//victim->skeleton.joints[i].velocity=0;
victim->RagDoll(0);
XYZ relative;
relative = 0;
- /*relative=victim->coords-coords;
- relative.y=0;
- Normalise(&relative);
- relative=DoRotation(relative,0,90,0);*/
relative.y = -1;
Normalise(&relative);
if (!victim->dead) {
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * damagemult * 40;
}
- //FootLand(1,2);
victim->jointVel(abdomen) += relative * damagemult * 40;
}
if (victim->dead) {
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * damagemult * abs(Random() % 20);
}
- //FootLand(1,2);
- //victim->jointVel(abdomen)+=relative*damagemult*20;
}
victim->Puff(abdomen);
if (tutoriallevel != 1) {
}
}
- if (animTarget == lowkickanim && animation[animTarget].label[frameCurrent] == 5) {
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != highheight) {
+ if (animTarget == lowkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != highheight) {
escapednum = 0;
if (id == 0)
camerashake += .4;
SolidHitBonus(id);
- if (animation[victim->animTarget].height == lowheight) {
+ if (Animation::animations[victim->animTarget].height == lowheight) {
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 250);
}
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
} else {
if (victim->damage >= victim->damagetolerance)
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 10;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
}
}
- if (animTarget == sweepanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == sweepanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if ((victim->animTarget != jumpupanim) &&
(distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) &&
(victim != this->shared_from_this())) {
relative.y = 0;
Normalise(&relative);
- if (animation[victim->animTarget].height == middleheight || animation[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) {
+ if (Animation::animations[victim->animTarget].height == middleheight || Animation::animations[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) {
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 15;
}
relative = DoRotation(relative, 0, -90, 0);
relative.y += .1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
victim->skeleton.joints[i].velocity = relative * 80;
}
} else {
if (victim->damage >= victim->damagetolerance)
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 10;
}
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
victim->skeleton.joints[i].velocity += relative * damagemult * 80;
}
}
}
}
- if (animation[animTarget].attack == reversal && (!victim->feint || (victim->lastattack == victim->lastattack2 && victim->lastattack2 == victim->lastattack3 && Random() % 2) || animTarget == knifefollowanim)) {
- if (animTarget == spinkickreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (Animation::animations[animTarget].attack == reversal && (!victim->feint || (victim->lastattack == victim->lastattack2 && victim->lastattack2 == victim->lastattack3 && Random() % 2) || animTarget == knifefollowanim)) {
+ if (animTarget == spinkickreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- //relative=DoRotation(relative,0,-90,0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
- //FootLand(1,2);
victim->Puff(abdomen);
victim->DoDamage(damagemult * 150 / victim->protectionhigh);
award_bonus(id, Reversal);
}
- if ((animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim) && animation[animTarget].label[frameCurrent] == 5) {
+ if ((animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (victim->weaponactive != -1 && victim->num_weapons > 0) {
if (weapons[victim->weaponids[victim->weaponactive]].owner == int(victim->id)) {
- weapons[victim->weaponids[victim->weaponactive]].owner = id;
- weaponactive = 0;
- if (num_weapons > 0) {
- weaponids[num_weapons] = weaponids[victim->weaponactive];
- }
- num_weapons++;
- weaponids[0] = victim->weaponids[victim->weaponactive];
+ takeWeapon(victim->weaponids[victim->weaponactive]);
victim->num_weapons--;
if (victim->num_weapons > 0) {
victim->weaponids[victim->weaponactive] = victim->weaponids[victim->num_weapons];
}
}
- if (animTarget == staffhitreversalanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (animTarget == staffhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
victim->DoDamage(damagemult * 70 / victim->protectionhigh);
}
- if (animTarget == staffspinhitreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (animTarget == staffspinhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
victim->DoDamage(damagemult * 70 / victim->protectionhigh);
}
- if (animTarget == upunchreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (animTarget == upunchreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
victim->RagDoll(1);
XYZ relative;
relative.y = 0;
Normalise(&relative);
relative.y -= .1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 70;
}
victim->jointVel(lefthand) *= .1;
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 (animTarget == swordslashreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (animTarget == swordslashreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
victim->RagDoll(1);
XYZ relative;
relative.y = 0;
Normalise(&relative);
relative.y -= .1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 70;
}
victim->jointVel(lefthand) *= .1 - 1;
award_bonus(id, swordreversebonus);
}
- if (hasvictim && animTarget == knifeslashreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (hasvictim && animTarget == knifeslashreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
award_bonus(id, Reversal);
}
- if (hasvictim && animTarget == sneakattackanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (hasvictim && animTarget == sneakattackanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
victim->RagDoll(0);
victim->skeleton.spinny = 0;
Normalise(&relative);
if (victim->id == 0)
relative /= 30;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->damage = victim->damagetolerance;
award_bonus(id, spinecrusher);
}
- if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && animation[animTarget].label[frameCurrent] == 5) {
+ if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
escapednum = 0;
if (animTarget == knifefollowanim)
}
}
- if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && animation[animTarget].label[frameCurrent] == 6) {
+ if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
escapednum = 0;
victim->velocity = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = 0;
}
if (animTarget == knifefollowanim) {
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = 0;
}
}
- if (weaponactive != -1 && animation[victim->animTarget].attack != reversal) {
+ if (weaponactive != -1 && Animation::animations[victim->animTarget].attack != reversal) {
emit_sound_at(fleshstabremovesound, victim->coords);
if (bloodtoggle)
weapons[weaponids[weaponactive]].bloody = 2;
}
}
- if (hasvictim && (animTarget == swordsneakattackanim) && animation[animTarget].label[frameCurrent] == 5) {
+ if (hasvictim && (animTarget == swordsneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
award_bonus(id, backstab);
}
}
- if (hasvictim && animTarget == swordsneakattackanim && animation[animTarget].label[frameCurrent] == 6) {
+ if (hasvictim && animTarget == swordsneakattackanim && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
escapednum = 0;
victim->velocity = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = 0;
}
if (weaponactive != -1) {
}
}
- if (animTarget == sweepreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (animTarget == sweepreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
if (id == 0)
camerashake += .4;
relative = DoRotation(relative, 0, 90, 0);
relative.y = .5;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
victim->jointVel(head) += relative * damagemult * 200;
victim->velocity = 0;
}
- if (animTarget == sweepreversalanim && ((animation[animTarget].label[frameCurrent] == 9 && victim->damage < victim->damagetolerance) || (animation[animTarget].label[frameCurrent] == 7 && victim->damage > victim->damagetolerance))) {
+ if (animTarget == sweepreversalanim && ((Animation::animations[animTarget].frames[frameCurrent].label == 9 && victim->damage < victim->damagetolerance) || (Animation::animations[animTarget].frames[frameCurrent].label == 7 && victim->damage > victim->damagetolerance))) {
escapednum = 0;
victim->RagDoll(0);
XYZ relative;
relative = DoRotation(relative, 0, 90, 0);
relative.y = .5;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
victim->jointVel(head) += relative * damagemult * 200;
//Animation end
- if (frameTarget > animation[animCurrent].numframes - 1) {
+ if (frameTarget > Animation::animations[animCurrent].frames.size() - 1) {
frameTarget = 0;
if (wasStop()) {
animTarget = getIdle();
- FootLand(0, 1);
- FootLand(1, 1);
+ FootLand(leftfoot, 1);
+ FootLand(rightfoot, 1);
}
if (animCurrent == rabbittackleanim || animCurrent == rabbittacklinganim) {
animTarget = rollanim;
}
if (animCurrent == rollanim) {
animTarget = getCrouch();
- FootLand(0, 1);
- FootLand(1, 1);
+ FootLand(leftfoot, 1);
+ FootLand(rightfoot, 1);
}
if (isFlip()) {
if (animTarget == walljumprightkickanim) {
animTarget = getIdle();
lastfeint = 0;
}
- if (animation[animTarget].attack == reversal && animCurrent != sneakattackanim && animCurrent != knifesneakattackanim && animCurrent != swordsneakattackanim && animCurrent != knifefollowanim) {
+ if (Animation::animations[animTarget].attack == reversal && animCurrent != sneakattackanim && animCurrent != knifesneakattackanim && animCurrent != swordsneakattackanim && animCurrent != knifefollowanim) {
float ycoords = oldcoords.y;
animTarget = getStop();
targetyaw += 180;
velocity.y = -5;
RagDoll(0);
}
- if (animation[animTarget].attack == reversed) {
+ if (Animation::animations[animTarget].attack == reversed) {
escapednum++;
if (animTarget == sweepreversedanim)
targetyaw += 90;
oldcoords = coords;
coords += (DoRotation(jointPos(leftfoot), 0, yaw, 0) + DoRotation(jointPos(rightfoot), 0, yaw, 0)) / 2 * scale;
coords.y = oldcoords.y;
- //coords+=DoRotation(animation[animCurrent].offset,0,yaw,0)*scale;
+ //coords+=DoRotation(Animation::animations[animCurrent].offset,0,yaw,0)*scale;
targetoffset.y = coords.y;
if (onterrain)
targetoffset.y = terrain.getHeight(coords.x, coords.z);
- currentoffset = DoRotation(animation[animCurrent].offset * -1, 0, yaw, 0) * scale;
+ currentoffset = DoRotation(Animation::animations[animCurrent].offset * -1, 0, yaw, 0) * scale;
currentoffset.y -= (coords.y - targetoffset.y);
coords.y = targetoffset.y;
targetoffset = 0;
lastfeint = 0;
}
- if (animation[animCurrent].attack == normalattack && !victim->skeleton.free && victim->animTarget != staggerbackhighanim && victim->animTarget != staggerbackhardanim && animTarget != winduppunchblockedanim && animTarget != blockhighleftanim && animTarget != swordslashparryanim && animTarget != swordslashparriedanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim) {
+ if (Animation::animations[animCurrent].attack == normalattack && !victim->skeleton.free && victim->animTarget != staggerbackhighanim && victim->animTarget != staggerbackhardanim && animTarget != winduppunchblockedanim && animTarget != blockhighleftanim && animTarget != swordslashparryanim && animTarget != swordslashparriedanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim) {
animTarget = getupfromfrontanim;
lastfeint = 0;
- } else if (animation[animCurrent].attack == normalattack) {
+ } else if (Animation::animations[animCurrent].attack == normalattack) {
animTarget = getIdle();
lastfeint = 0;
}
}
if (!skeleton.free) {
oldtarget = target;
- if (!transspeed && animation[animTarget].attack != 2 && animation[animTarget].attack != 3) {
+ if (!transspeed && Animation::animations[animTarget].attack != 2 && Animation::animations[animTarget].attack != 3) {
if (!isRun() || !wasRun()) {
- if (animation[animTarget].speed[frameTarget] > animation[animCurrent].speed[frameCurrent])
- target += multiplier * animation[animTarget].speed[frameTarget] * speed * 2;
- if (animation[animTarget].speed[frameTarget] <= animation[animCurrent].speed[frameCurrent])
- target += multiplier * animation[animCurrent].speed[frameCurrent] * speed * 2;
+ if (targetFrame().speed > currentFrame().speed)
+ target += multiplier * targetFrame().speed * speed * 2;
+ if (targetFrame().speed <= currentFrame().speed)
+ target += multiplier * currentFrame().speed * speed * 2;
}
if (isRun() && wasRun()) {
float tempspeed;
tempspeed = velspeed;
if (tempspeed < 10 * speedmult)
tempspeed = 10 * speedmult;
- target += multiplier * animation[animTarget].speed[frameCurrent] * speed * 1.7 * tempspeed / (speed * 45 * scale);
+ /* FIXME - mixed of target and current here, is that intended? */
+ target += multiplier * Animation::animations[animTarget].frames[frameCurrent].speed * speed * 1.7 * tempspeed / (speed * 45 * scale);
}
} else if (transspeed)
target += multiplier * transspeed * speed * 2;
else {
if (!isRun() || !wasRun()) {
- if (animation[animTarget].speed[frameTarget] > animation[animCurrent].speed[frameCurrent])
- target += multiplier * animation[animTarget].speed[frameTarget] * 2;
- if (animation[animTarget].speed[frameTarget] <= animation[animCurrent].speed[frameCurrent])
- target += multiplier * animation[animCurrent].speed[frameCurrent] * 2;
+ if (targetFrame().speed > currentFrame().speed)
+ target += multiplier * targetFrame().speed * 2;
+ if (targetFrame().speed <= currentFrame().speed)
+ target += multiplier * currentFrame().speed * 2;
}
}
oldrot = 0;
targetrot = 0;
}
+ if (frameCurrent >= Animation::animations[animCurrent].frames.size()) {
+ frameCurrent = Animation::animations[animCurrent].frames.size() - 1;
+ }
if (animCurrent != oldanimCurrent || animTarget != oldanimTarget || ((frameCurrent != oldframeCurrent || frameTarget != oldframeTarget) && !calcrot)) {
//Old rotates
- for (int i = 0; i < skeleton.num_joints; i++) {
- skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent];
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ skeleton.joints[i].position = currentFrame().joints[i].position;
}
skeleton.FindForwards();
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
skeleton.FindRotationMuscle(i, animTarget);
}
}
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
skeleton.muscles[i].oldrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
}
//New rotates
- for (int i = 0; i < skeleton.num_joints; i++) {
- skeleton.joints[i].position = animation[animTarget].position[i][frameTarget];
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ skeleton.joints[i].position = targetFrame().joints[i].position;
}
skeleton.FindForwards();
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
skeleton.FindRotationMuscle(i, animTarget);
}
}
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
skeleton.muscles[i].newrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
}
}
}
- if (frameCurrent >= animation[animCurrent].numframes)
- frameCurrent = animation[animCurrent].numframes - 1;
oldanimCurrent = animCurrent;
oldanimTarget = animTarget;
oldframeTarget = frameTarget;
oldframeCurrent = frameCurrent;
- for (int i = 0; i < skeleton.num_joints; i++) {
- skeleton.joints[i].velocity = (animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target) - skeleton.joints[i].position) / multiplier;
- skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target);
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ skeleton.joints[i].velocity = (currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target) - skeleton.joints[i].position) / multiplier;
+ skeleton.joints[i].position = currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target);
}
offset = currentoffset * (1 - target) + targetoffset * target;
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
skeleton.muscles[i].rotate1 = skeleton.muscles[i].oldrotate1 * (1 - target) + skeleton.muscles[i].newrotate1 * (target);
skeleton.muscles[i].rotate2 = skeleton.muscles[i].oldrotate2 * (1 - target) + skeleton.muscles[i].newrotate2 * (target);
}
while (flamedelay < 0 && onfire) {
flamedelay += .006;
- howmany = abs(Random() % (skeleton.num_joints));
- if (!skeleton.free)
- flatvelocity = (coords - oldcoords) / multiplier / 2; //velocity/2;
- if (skeleton.free)
+ howmany = abs(Random() % (skeleton.joints.size()));
+ if (skeleton.free) {
flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
- if (!skeleton.free)
- flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
- if (skeleton.free)
flatfacing = skeleton.joints[howmany].position * scale + coords;
+ } else {
+ flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
+ flatvelocity = (coords - oldcoords) / multiplier / 2;
+ }
Sprite::MakeSprite(flamesprite, flatfacing, flatvelocity, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
}
while (flamedelay < 0 && !onfire && tutoriallevel == 1 && id != 0) {
flamedelay += .05;
- howmany = abs(Random() % (skeleton.num_joints));
- if (!skeleton.free)
- flatvelocity = (coords - oldcoords) / multiplier / 2; //velocity/2;
- if (skeleton.free)
+ howmany = abs(Random() % (skeleton.joints.size()));
+ if (skeleton.free) {
flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
- if (!skeleton.free)
- flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
- if (skeleton.free)
flatfacing = skeleton.joints[howmany].position * scale + coords;
+ } else {
+ flatvelocity = (coords - oldcoords) / multiplier / 2;
+ flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
+ }
Sprite::MakeSprite(breathsprite, flatfacing, flatvelocity, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, .3);
}
if (neckspurtparticledelay < 0 && neckspurtdelay > 2) {
spurt = 0;
bloodvel = 0;
- if (!skeleton.free) {
- bloodvel.z = 5 * neckspurtamount;
- bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale;
- }
if (skeleton.free) {
bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0);
- }
- if (skeleton.free)
bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale;
- if (!skeleton.free)
- bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0) * scale;
- if (skeleton.free)
Sprite::MakeSprite(bloodsprite, (jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5)*scale + coords, bloodvel, 1, 1, 1, .05, .9);
- if (!skeleton.free)
+ } else {
+ bloodvel.z = 5 * neckspurtamount;
+ bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale;
+ bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0) * scale;
Sprite::MakeSprite(bloodsprite, DoRotation(jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, .9);
+ }
neckspurtparticledelay = .05;
}
if (neckspurtdelay < 0) {
XYZ bloodvel;
if (bloodtoggle) {
bloodvel = 0;
- if (skeleton.free)
+ if (skeleton.free) {
bloodvel += DoRotation(jointVel(abdomen), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
- if (!skeleton.free)
- bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- if (skeleton.free)
Sprite::MakeSprite(bloodsprite, jointPos(abdomen) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
- if (!skeleton.free)
+ } else {
+ bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(abdomen) + jointPos(abdomen)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
+ }
}
}
bloodloss += deathbleeding * multiplier * 80;
deathbleeding -= multiplier * 1.6;
if (deathbleeding < 0)
deathbleeding = 0;
- if (bloodloss > damagetolerance && animation[animTarget].attack == neutral) {
+ if (bloodloss > damagetolerance && Animation::animations[animTarget].attack == neutral) {
if (weaponactive != -1) {
- weapons[weaponids[0]].owner = -1;
- weapons[weaponids[0]].velocity = velocity * scale * -.3;
+ weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale);
weapons[weaponids[0]].velocity.x += .01;
- weapons[weaponids[0]].tipvelocity = velocity * scale;
- weapons[weaponids[0]].missed = 1;
- weapons[weaponids[0]].hitsomething = 0;
- weapons[weaponids[0]].freetime = 0;
- weapons[weaponids[0]].firstfree = 1;
- weapons[weaponids[0]].physics = 1;
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
}
if (id == 0) {
- flashamount = .5;
- flashr = 1;
- flashg = 0;
- flashb = 0;
- flashdelay = 0;
+ Game::flash(.5, 0);
}
}
}
dead = 2;
if (animTarget == knifefollowedanim && !skeleton.free) {
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].velocity = 0;
skeleton.joints[i].velocity.y = -2;
}
DoMipmaps();
}
- if (!skeleton.free) {
- bleedy -= 4 / realtexdetail;
- if (detail == 2)
- bleedx += (abs(Random() % 3) - 1) * 2 / realtexdetail;
- else
- bleedx += (abs(Random() % 3) - 1) * 4 / realtexdetail;
- }
if (skeleton.free) {
bleedx += 4 * direction / realtexdetail;
if (detail == 2)
bleedy += (abs(Random() % 3) - 1) * 2 / realtexdetail;
else
bleedy += (abs(Random() % 3) - 1) * 4 / realtexdetail;
+ } else {
+ bleedy -= 4 / realtexdetail;
+ if (detail == 2)
+ bleedx += (abs(Random() % 3) - 1) * 2 / realtexdetail;
+ else
+ bleedx += (abs(Random() % 3) - 1) * 4 / realtexdetail;
}
}
if (environment == snowyenvironment) {
XYZ footpoint;
XYZ footvel;
- if (!skeleton.free)
- footvel = DoRotation(skeleton.specialforward[0], 0, yaw, 0) * -1;
- if (skeleton.free)
+ if (skeleton.free) {
footvel = skeleton.specialforward[0] * -1;
- if (!skeleton.free)
- footpoint = DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords;
- if (skeleton.free)
footpoint = ((jointPos(head) + jointPos(neck)) / 2) * scale + coords;
+ } else {
+ footvel = DoRotation(skeleton.specialforward[0], 0, yaw, 0) * -1;
+ footpoint = DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords;
+ }
if (animTarget == sleepanim)
footvel = DoRotation(footvel, 0, 90, 0);
Sprite::MakeSprite(breathsprite, footpoint + footvel * .2, footvel * .4, 1, 1, 1, .4, .3);
RagDoll(0);
if (weaponactive != -1) {
- weapons[weaponids[0]].owner = -1;
- weapons[weaponids[0]].velocity = velocity * scale * -.3;
+ weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale);
weapons[weaponids[0]].velocity.x += .01;
- weapons[weaponids[0]].tipvelocity = velocity * scale;
- weapons[weaponids[0]].missed = 1;
- weapons[weaponids[0]].hitsomething = 0;
- weapons[weaponids[0]].freetime = 0;
- weapons[weaponids[0]].firstfree = 1;
- weapons[weaponids[0]].physics = 1;
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
dead = 0;
skeleton.free = 1;
damage -= 20;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].velocity = 0;
}
}
DoBlood(1, 255);
if (weaponactive != -1) {
- weapons[weaponids[0]].owner = -1;
- weapons[weaponids[0]].velocity = velocity * scale * -.3;
+ weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale);
weapons[weaponids[0]].velocity.x += .01;
- weapons[weaponids[0]].tipvelocity = velocity * scale;
- weapons[weaponids[0]].missed = 1;
- weapons[weaponids[0]].hitsomething = 0;
- weapons[weaponids[0]].freetime = 0;
- weapons[weaponids[0]].firstfree = 1;
- weapons[weaponids[0]].physics = 1;
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
average = 0;
howmany = 0;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
average += skeleton.joints[j].position;
howmany++;
}
average /= howmany;
coords += average * scale;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
skeleton.joints[j].position -= average;
}
average /= multiplier;
- //velocity=jointVel(groin)*scale;
velocity = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
velocity += skeleton.joints[i].velocity * scale;
}
- velocity /= skeleton.num_joints;
+ velocity /= skeleton.joints.size();
if (!isnormal(velocity.x) && velocity.x) {
velocity = 0;
frameCurrent = 0;
target = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
- tempanimation.position[i][0] = skeleton.joints[i].position;
- tempanimation.position[i][0] = DoRotation(tempanimation.position[i][0], 0, -yaw, 0);
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ tempanimation.frames[0].joints[i].position = skeleton.joints[i].position;
+ tempanimation.frames[0].joints[i].position = DoRotation(tempanimation.frames[0].joints[i].position, 0, -yaw, 0);
}
}
}
if (middle.y > 0 && animTarget != rollanim)
targetoffset.y = middle.y + 1;
- for (int i = 0; i < skeleton.num_joints; i++) {
- tempanimation.position[i][0] = skeleton.joints[i].position;
- tempanimation.position[i][0] = DoRotation(tempanimation.position[i][0], 0, -yaw, 0);
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ tempanimation.frames[0].joints[i].position = skeleton.joints[i].position;
+ tempanimation.frames[0].joints[i].position = DoRotation(tempanimation.frames[0].joints[i].position, 0, -yaw, 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;
if (hasvictim) {
if ((victim != this->shared_from_this()) && !victim->dead && (victim->aitype != passivetype) &&
(victim->aitype != searchtype) && (aitype != passivetype) &&
- (aitype != searchtype) && (victim->id < Person::players.size()) && (aitype != passivetype)) {
+ (aitype != searchtype) && (victim->id < Person::players.size())) {
behind = (normaldotproduct(facing, coords - victim->coords) > 0);
}
}
terrainnormal = terrain.getNormal(coords.x, coords.z);
- if (animation[animTarget].attack != reversal) {
+ if (Animation::animations[animTarget].attack != reversal) {
if (!isnormal(coords.x))
coords = oldcoords;
oldcoords = coords;
targettilt2 = 0;
}
onterrain = 0;
- if (!isRun() && !animation[animTarget].attack && animTarget != getupfromfrontanim && animTarget != getupfrombackanim && animTarget != sneakanim)
+ if (!isRun() && !Animation::animations[animTarget].attack && animTarget != getupfromfrontanim && animTarget != getupfrombackanim && animTarget != sneakanim)
targettilt2 = 0;
if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
flatvelocity = velocity;
} else if (tilt2 < targettilt2) {
tilt2 += multiplier * 400;
}
- if (!animation[animTarget].attack && animTarget != getupfrombackanim && animTarget != getupfromfrontanim) {
+ if (!Animation::animations[animTarget].attack && animTarget != getupfrombackanim && animTarget != getupfromfrontanim) {
if (tilt2 > 25)
tilt2 = 25;
if (tilt2 < -25)
velocity = flatfacing * velspeed;
}
- if (animTarget == rollanim && animation[animTarget].label[frameTarget] != 6) {
+ if (animTarget == rollanim && targetFrame().label != 6) {
velocity += facing * multiplier * speed * 700 * scale;
velspeed = findLength(&velocity);
if (velspeed > speed * 45 * scale) {
coords -= facing * multiplier * speed * 16 * scale;
velocity = 0;
}
- if (animTarget == staggerbackhardanim && animation[staggerbackhardanim].label[frameTarget] != 6) {
+ if (animTarget == staggerbackhardanim && Animation::animations[staggerbackhardanim].frames[frameTarget].label != 6) {
coords -= facing * multiplier * speed * 20 * scale;
velocity = 0;
}
coords += velocity * multiplier;
if (coords.y < terrain.getHeight(coords.x, coords.z) && (animTarget == jumpdownanim || animTarget == jumpupanim || isFlip())) {
- if (isFlip() && animation[animTarget].label[frameTarget] == 7)
+ if (isFlip() && targetFrame().label == 7)
RagDoll(0);
if (animTarget == jumpupanim) {
emit_sound_at(landsound, coords, 128.);
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords);
}
}
}
}
- if (isIdle() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || isStop() || animTarget == removeknifeanim || animTarget == crouchremoveknifeanim || isLanding() || isCrouch() || animation[animTarget].attack || (animTarget == rollanim && animation[animTarget].label[frameTarget] == 6)) {
+ if (isIdle() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || isStop() || animTarget == removeknifeanim || animTarget == crouchremoveknifeanim || isLanding() || isCrouch() || Animation::animations[animTarget].attack || (animTarget == rollanim && targetFrame().label == 6)) {
velspeed = findLength(&velocity);
velocity.y = 0;
if (velspeed < multiplier * 300 * scale) {
if (velspeed > 5 && (isLanding() || isLandhard())) {
skiddingdelay += multiplier;
if (skiddelay <= 0) {
- FootLand(0, .5);
- FootLand(1, .5);
+ FootLand(leftfoot, .5);
+ FootLand(rightfoot, .5);
skiddelay = .02;
}
} else
if (velspeed > 5 && (isLanding() || isLandhard())) {
skiddingdelay += multiplier;
if (skiddelay <= 0) {
- FootLand(0, .5);
- FootLand(1, .5);
+ FootLand(leftfoot, .5);
+ FootLand(rightfoot, .5);
skiddelay = .02;
}
} else
}
}
- if (animation[animTarget].attack == normalattack && animTarget != rabbitkickanim && !victim->skeleton.free) {
+ if (Animation::animations[animTarget].attack == normalattack && animTarget != rabbitkickanim && !victim->skeleton.free) {
terrainnormal = victim->coords - coords;
Normalise(&terrainnormal);
targetyaw = -asin(0 - terrainnormal.x);
targettilt2 = -asin(terrainnormal.y) * 360 / 6.28; //*-70;
}
- if (animation[animTarget].attack == reversal && animTarget != rabbittacklinganim) {
+ if (Animation::animations[animTarget].attack == reversal && animTarget != rabbittacklinganim) {
targetyaw = victim->targetyaw;
}
if (animTarget == rabbittacklinganim) {
*/
void IKHelper(Person *p, float interp)
{
- XYZ point, newpoint, change, change2;
+ XYZ point, change, change2;
float heightleft, heightright;
// TODO: implement localToWorld and worldToLocal
}
}
- if (!skeleton.free && (!animation[animTarget].attack && animTarget != getupfrombackanim && ((animTarget != rollanim && !isFlip()) || animation[animTarget].label[frameTarget] == 6) && animTarget != getupfromfrontanim && animTarget != wolfrunninganim && animTarget != rabbitrunninganim && animTarget != backhandspringanim && animTarget != walljumpfrontanim && animTarget != hurtidleanim && !isLandhard() && !isSleeping()))
+ if (!skeleton.free && (!Animation::animations[animTarget].attack && animTarget != getupfrombackanim && ((animTarget != rollanim && !isFlip()) || targetFrame().label == 6) && animTarget != getupfromfrontanim && animTarget != wolfrunninganim && animTarget != rabbitrunninganim && animTarget != backhandspringanim && animTarget != walljumpfrontanim && animTarget != hurtidleanim && !isLandhard() && !isSleeping()))
DoHead();
else {
targetheadyaw = -targetyaw;
targetheadpitch = 0;
- if (animation[animTarget].attack == 3)
+ if (Animation::animations[animTarget].attack == 3)
targetheadyaw += 180;
}
for (i = 0; i < skeleton.drawmodel.vertexNum; i++) {
skeleton.drawmodelclothes.vertex[i] = 0;
skeleton.drawmodelclothes.vertex[i].y = 999;
}
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
// convenience renames
const int p1 = skeleton.muscles[i].parent1->label;
const int p2 = skeleton.muscles[i].parent2->label;
- if ((skeleton.muscles[i].numvertices > 0 && playerdetail) || (skeleton.muscles[i].numverticeslow > 0 && !playerdetail)) {
+ if ((skeleton.muscles[i].vertices.size() > 0 && playerdetail) || (skeleton.muscles[i].verticeslow.size() > 0 && !playerdetail)) {
morphness = 0;
start = 0;
endthing = 0;
glRotatef(-skeleton.muscles[i].lastrotate3, 0, 1, 0);
if (playerdetail || skeleton.free == 3) {
- for (j = 0; j < skeleton.muscles[i].numvertices; j++) {
+ for (j = 0; j < skeleton.muscles[i].vertices.size(); j++) {
XYZ &v0 = skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]];
XYZ &v1 = skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]];
glMatrixMode(GL_MODELVIEW);
}
}
if (!playerdetail || skeleton.free == 3) {
- for (j = 0; j < skeleton.muscles[i].numverticeslow; j++) {
+ for (j = 0; j < skeleton.muscles[i].verticeslow.size(); j++) {
XYZ &v0 = skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
}
glPopMatrix();
}
- if (skeleton.clothes && skeleton.muscles[i].numverticesclothes > 0) {
+ if (skeleton.clothes && skeleton.muscles[i].verticesclothes.size() > 0) {
mid = (skeleton.muscles[i].parent1->position + skeleton.muscles[i].parent2->position) / 2;
glMatrixMode(GL_MODELVIEW);
skeleton.muscles[i].lastrotate3 = skeleton.muscles[i].rotate3;
glRotatef(-skeleton.muscles[i].lastrotate3, 0, 1, 0);
- for (j = 0; j < skeleton.muscles[i].numverticesclothes; j++) {
+ for (j = 0; j < skeleton.muscles[i].verticesclothes.size(); j++) {
XYZ &v0 = skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- if (!skeleton.free)
- glTranslatef(coords.x, coords.y - .02, coords.z);
- if (skeleton.free)
- glTranslatef(coords.x, coords.y - .02, coords.z);
- if (!skeleton.free)
+ glTranslatef(coords.x, coords.y - .02, coords.z);
+ if (!skeleton.free) {
glTranslatef(offset.x * scale, offset.y * scale, offset.z * scale);
- if (!skeleton.free)
glRotatef(yaw, 0, 1, 0);
+ }
if (showpoints) {
glPointSize(5);
glColor4f(.4, 1, .4, 1);
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);
glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
if (canattack && cananger)
- if (animation[animTarget].attack == normalattack || animation[animTarget].attack == reversed) {
+ if (Animation::animations[animTarget].attack == normalattack || Animation::animations[animTarget].attack == reversed) {
glDisable(GL_TEXTURE_2D);
glColor4f(1, 0, 0, 0.8);
}
skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
}
- if (!(animation[animTarget].attack == normalattack || animation[animTarget].attack == reversed))
+ if (!(Animation::animations[animTarget].attack == normalattack || Animation::animations[animTarget].attack == reversed))
if (tutoriallevel && id != 0) {
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
if (canattack && cananger)
- if (animation[animTarget].attack == normalattack || animation[animTarget].attack == reversed) {
+ if (Animation::animations[animTarget].attack == normalattack || Animation::animations[animTarget].attack == reversed) {
glDisable(GL_TEXTURE_2D);
glColor4f(1, 0, 0, 0.8);
}
i = weaponids[k];
if (weaponactive == k) {
if (weapons[i].getType() != staff) {
- for (j = 0; j < skeleton.num_muscles; j++) {
- if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].numvertices > 0) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
+ if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].vertices.size() > 0) {
weaponattachmuscle = j;
}
}
- for (j = 0; j < skeleton.num_muscles; j++) {
- if ((skeleton.muscles[j].parent1->label == rightwrist || skeleton.muscles[j].parent2->label == rightwrist) && (skeleton.muscles[j].parent1->label != righthand && skeleton.muscles[j].parent2->label != righthand) && skeleton.muscles[j].numvertices > 0) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
+ if ((skeleton.muscles[j].parent1->label == rightwrist || skeleton.muscles[j].parent2->label == rightwrist) && (skeleton.muscles[j].parent1->label != righthand && skeleton.muscles[j].parent2->label != righthand) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
}
weaponpoint = (jointPos(rightwrist) * .7 + jointPos(righthand) * .3);
}
if (weapons[i].getType() == staff) {
- for (j = 0; j < skeleton.num_muscles; j++) {
- if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].numvertices > 0) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
+ if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].vertices.size() > 0) {
weaponattachmuscle = j;
}
}
- for (j = 0; j < skeleton.num_muscles; j++) {
- if ((skeleton.muscles[j].parent1->label == rightelbow || skeleton.muscles[j].parent2->label == rightelbow) && (skeleton.muscles[j].parent1->label != rightshoulder && skeleton.muscles[j].parent2->label != rightshoulder) && skeleton.muscles[j].numvertices > 0) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
+ if ((skeleton.muscles[j].parent1->label == rightelbow || skeleton.muscles[j].parent2->label == rightelbow) && (skeleton.muscles[j].parent1->label != rightshoulder && skeleton.muscles[j].parent2->label != rightshoulder) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
}
weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
if (weapons[i].getType() == staff)
weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
- for (j = 0; j < skeleton.num_muscles; j++) {
- if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].numvertices > 0) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
+ if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
}
weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 - skeleton.forward * .8;
else
weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 + skeleton.forward * .8;
- for (j = 0; j < skeleton.num_muscles; j++) {
- if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].numvertices > 0) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
+ if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
}
weapons[i].smallrotation2 = 50;
}
if ((animCurrent == crouchstabanim && animTarget == crouchstabanim) || (animCurrent == backhandspringanim && animTarget == backhandspringanim)) {
- XYZ temppoint1, temppoint2, tempforward;
+ XYZ temppoint1, temppoint2;
float distance;
temppoint1 = jointPos(righthand);
- temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
+ temppoint2 = currentFrame().weapontarget * (1 - target) + targetFrame().weapontarget * (target);
distance = findDistance(&temppoint1, &temppoint2);
weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
weapons[i].rotation2 *= 360 / 6.28;
weapons[i].rotation1 = 360 - weapons[i].rotation1;
}
if ((animCurrent == knifeslashreversalanim && animTarget == knifeslashreversalanim) || (animCurrent == knifeslashreversedanim && animTarget == knifeslashreversedanim)) {
- XYZ temppoint1, temppoint2, tempforward;
+ XYZ temppoint1, temppoint2;
float distance;
temppoint1 = jointPos(righthand);
- temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
+ temppoint2 = currentFrame().weapontarget * (1 - target) + targetFrame().weapontarget * (target);
distance = findDistance(&temppoint1, &temppoint2);
weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
weapons[i].rotation2 *= 360 / 6.28;
weapons[i].rotation3 = 0;
}
if ((animTarget == swordgroundstabanim && animCurrent == swordgroundstabanim) || (animTarget == swordsneakattackanim && animCurrent == swordsneakattackanim) || (animTarget == swordslashparryanim && animCurrent == swordslashparryanim) || (animTarget == swordslashparriedanim && animCurrent == swordslashparriedanim) || (animTarget == swordslashreversalanim && animCurrent == swordslashreversalanim) || (animTarget == swordslashreversedanim && animCurrent == swordslashreversedanim) || (animTarget == knifeslashreversalanim && animCurrent == knifeslashreversalanim) || (animTarget == knifeslashreversedanim && animCurrent == knifeslashreversedanim) || (animTarget == swordslashanim && animCurrent == swordslashanim) || (animTarget == drawleftanim && animCurrent == drawleftanim) || (animCurrent == backhandspringanim && animTarget == backhandspringanim)) {
- XYZ temppoint1, temppoint2, tempforward;
+ XYZ temppoint1, temppoint2;
float distance;
- temppoint1 = animation[animCurrent].position[skeleton.jointlabels[righthand]][frameCurrent] * (1 - target) + animation[animTarget].position[skeleton.jointlabels[righthand]][frameTarget] * (target); //jointPos(righthand);
- temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
+ temppoint1 = currentFrame().joints[skeleton.jointlabels[righthand]].position * (1 - target) + targetFrame().joints[skeleton.jointlabels[righthand]].position * (target); //jointPos(righthand);
+ temppoint2 = currentFrame().weapontarget * (1 - target) + targetFrame().weapontarget * (target);
distance = findDistance(&temppoint1, &temppoint2);
weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
weapons[i].rotation2 *= 360 / 6.28;
weapons[i].smallrotation = 100;
weapons[i].smallrotation2 = 0;
if ((animTarget == staffhitanim && animCurrent == staffhitanim) || (animTarget == staffhitreversedanim && animCurrent == staffhitreversedanim) || (animTarget == staffspinhitreversedanim && animCurrent == staffspinhitreversedanim) || (animTarget == staffgroundsmashanim && animCurrent == staffgroundsmashanim) || (animTarget == staffspinhitanim && animCurrent == staffspinhitanim)) {
- XYZ temppoint1, temppoint2, tempforward;
+ XYZ temppoint1, temppoint2;
float distance;
- temppoint1 = animation[animCurrent].position[skeleton.jointlabels[righthand]][frameCurrent] * (1 - target) + animation[animTarget].position[skeleton.jointlabels[righthand]][frameTarget] * (target); //jointPos(righthand);
- temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
+ temppoint1 = currentFrame().joints[skeleton.jointlabels[righthand]].position * (1 - target) + targetFrame().joints[skeleton.jointlabels[righthand]].position * (target); //jointPos(righthand);
+ temppoint2 = currentFrame().weapontarget * (1 - target) + targetFrame().weapontarget * (target);
distance = findDistance(&temppoint1, &temppoint2);
weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
weapons[i].rotation2 *= 360 / 6.28;
calcrot = 0;
if (skeleton.free)
calcrot = 1;
- if (animation[animTarget].attack || isRun() || animTarget == staggerbackhardanim || isFlip() || animTarget == climbanim || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim || animTarget == backhandspringanim || isFlip() || isWallJump())
+ if (Animation::animations[animTarget].attack || isRun() || animTarget == staggerbackhardanim || isFlip() || animTarget == climbanim || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim || animTarget == backhandspringanim || isWallJump())
calcrot = 1;
if (animCurrent != animTarget)
calcrot = 1;
if (LineFacetd(&start, &end, &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]], &model->facenormals[j], &point)) {
p1->y = point.y + radius;
if ((animTarget == jumpdownanim || isFlip())) {
- if (isFlip() && (frameTarget < 5 || animation[animTarget].label[frameTarget] == 7 || animation[animTarget].label[frameTarget] == 4))
+ if (isFlip() && (frameTarget < 5 || targetFrame().label == 7 || targetFrame().label == 4))
RagDoll(0);
if (animTarget == jumpupanim) {
emit_sound_at(landsound, coords, 128.);
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords);
}
}
}
return firstintersecting;
}
+void Person::takeWeapon(int weaponId)
+{
+ weaponactive = 0;
+ weapons[weaponId].owner = id;
+ if (num_weapons > 0) {
+ weaponids[num_weapons] = weaponids[0];
+ }
+ num_weapons++;
+ weaponids[0] = weaponId;
+}
+
+void Person::addClothes()
+{
+ if (numclothes > 0) {
+ for (int i = 0; i < numclothes; i++) {
+ addClothes(i);
+ }
+ DoMipmaps();
+ }
+}
+
+bool Person::addClothes(const int& clothesId)
+{
+ LOGFUNC;
+ const std::string fileName = clothes[clothesId];
+
+ GLubyte* array = &skeleton.skinText[0];
+
+ //Load Image
+ ImageRec texture;
+ bool opened = load_image(Folders::getResourcePath(fileName).c_str(), texture);
+
+ float alphanum;
+ //Is it valid?
+ if (opened) {
+ float tintr = clothestintr[clothesId];
+ float tintg = clothestintg[clothesId];
+ float tintb = clothestintb[clothesId];
+
+ if (tintr > 1) tintr = 1;
+ if (tintg > 1) tintg = 1;
+ if (tintb > 1) tintb = 1;
+
+ if (tintr < 0) tintr = 0;
+ if (tintg < 0) tintg = 0;
+ if (tintb < 0) tintb = 0;
+
+ int bytesPerPixel = texture.bpp / 8;
+
+ int tempnum = 0;
+ alphanum = 255;
+ for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
+ if (bytesPerPixel == 3)
+ alphanum = 255;
+ else if ((i + 1) % 4 == 0)
+ alphanum = texture.data[i];
+ if ((i + 1) % 4 || bytesPerPixel == 3) {
+ if ((i % 4) == 0)
+ texture.data[i] *= tintr;
+ if ((i % 4) == 1)
+ texture.data[i] *= tintg;
+ if ((i % 4) == 2)
+ texture.data[i] *= tintb;
+ array[tempnum] = (float)array[tempnum] * (1 - alphanum / 255) + (float)texture.data[i] * (alphanum / 255);
+ tempnum++;
+ }
+ }
+ return 1;
+ } else {
+ return 0;
+ }
+}