X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects%2FPerson.cpp;h=95cbf5263a164e175344e6a20601577d29336e14;hb=afdb97f1c3e430801a1fd0c1b04a8a2102e8f1ac;hp=6e286f4b60694fb8e86edfe1e810b5d4bbff37a0;hpb=5b566d01a77224e445ebb683184a1c59830a10b5;p=lugaru.git diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 6e286f4..95cbf52 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -51,7 +51,7 @@ extern float woozy; extern float viewdistance; extern float blackout; extern int difficulty; -extern bool decals; +extern bool decalstoggle; extern float fadestart; extern bool freeze; extern bool winfreeze; @@ -565,8 +565,8 @@ int Person::getIdle() { 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 && + if (hasvictim && (victim != this->shared_from_this())) { + if ((!victim->dead && victim->aitype != passivetype && victim->aitype != searchtype && aitype != passivetype && aitype != searchtype && victim->id < Person::players.size())) { if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) { @@ -588,6 +588,7 @@ int Person::getIdle() if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause) return fightsidestep; } + } if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype) return hurtidleanim; if (howactive == typesitting) return sitanim; @@ -728,7 +729,7 @@ void Person::DoBlood(float howmuch, int which) } } } - if (decals) { + if (decalstoggle) { // FIXME: manipulating attributes bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25; bleedxint = 0; @@ -796,7 +797,7 @@ void Person::DoBloodBig(float howmuch, int which) Game::flash(.5, 0); } - if (bloodtoggle && decals && !Tutorial::active) { + if (bloodtoggle && decalstoggle && !Tutorial::active) { if (bleeding <= 0 && spurt) { spurt = 0; for (int i = 0; i < 3; i++) { @@ -979,7 +980,7 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) float coordsx, coordsy; float total; - if (bloodtoggle && decals && !Tutorial::active) { + if (bloodtoggle && decalstoggle && !Tutorial::active) { where -= coords; if (!skeleton.free) where = DoRotation(where, 0, -yaw, 0); @@ -995,9 +996,9 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) if (whichtri != -1) { // low level geometry math p0 = colpoint; - 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]]; + p1 = skeleton.drawmodel.getTriangleVertex(whichtri, 0); + p2 = skeleton.drawmodel.getTriangleVertex(whichtri, 1); + p3 = skeleton.drawmodel.getTriangleVertex(whichtri, 2); bary.x = distsq(&p0, &p1); bary.y = distsq(&p0, &p2); @@ -1492,35 +1493,39 @@ void Person::Reverse() */ void Person::DoDamage(float howmuch) { - // subtract health (temporary?) - if (!Tutorial::active) - damage += howmuch / power; // stats? - if (id != 0) - damagedealt += howmuch / power; - if (id == 0) + if (id == 0) { damagetaken += howmuch / power; + } else { + damagedealt += howmuch / power; + } // reset bonuses - if (id == 0 && (bonus == solidhit || bonus == twoxcombo || bonus == threexcombo || bonus == fourxcombo || bonus == megacombo)) + if (id == 0 && (bonus == solidhit || bonus == twoxcombo || bonus == threexcombo || bonus == fourxcombo || bonus == megacombo)) { bonus = 0; + } + // subtract health - if (!Tutorial::active) + if (!Tutorial::active) { + damage += howmuch / power; permanentdamage += howmuch / 2 / power; - if (!Tutorial::active) superpermanentdamage += howmuch / 4 / power; + } // visual effects if (permanentdamage > damagetolerance / 2 && permanentdamage - howmuch < damagetolerance / 2 && Random() % 2) DoBlood(1, 255); if ((permanentdamage > damagetolerance * .8 && Random() % 2 && !deathbleeding) || spurt) DoBlood(1, 255); spurt = 0; - if (id == 0) + if (id == 0) { camerashake += howmuch / 100; - if (id == 0 && ((howmuch > 50 && damage > damagetolerance / 2))) - blackout = damage / damagetolerance; - if (blackout > 1) - blackout = 1; + if ((howmuch > 50 && damage > damagetolerance / 2)) { + blackout = damage / damagetolerance; + if (blackout > 1) { + blackout = 1; + } + } + } // cancel attack? if (aitype == passivetype && damage < damagetolerance && ((!Tutorial::active || cananger) && hostile)) @@ -1566,7 +1571,7 @@ void Person::DoDamage(float howmuch) } // play sounds - if (!Tutorial::active || id == 0) + if (!Tutorial::active || id == 0) { if (speechdelay <= 0 && !dead && aitype != playercontrolled) { int whichsound = -1; @@ -1590,6 +1595,7 @@ void Person::DoDamage(float howmuch) addEnvSound(coords); } } + } speechdelay = .3; } @@ -1907,7 +1913,7 @@ void Person::Puff(int whichlabel) /* EFFECT * I think I added this in an attempt to clean up code */ -void Person::setAnimation(int animation) +void Person::setTargetAnimation(int animation) { animTarget = animation; frameTarget = 0; @@ -1940,7 +1946,7 @@ void Person::DoAnimations() vel[2] = velocity.z; if (id == 0) { - OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel); + OPENAL_3D_SetAttributes(channels[whooshsound], gLoc); OPENAL_SetVolume(channels[whooshsound], 64 * findLength(&velocity) / 5); } if (((velocity.y < -15) || (crouchkeydown && velocity.y < -8)) && abs(velocity.y) * 4 > fast_sqrt(velocity.x * velocity.x * velocity.z * velocity.z)) @@ -2342,7 +2348,7 @@ void Person::DoAnimations() } 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) { + if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) { escapednum = 0; if (id == 0) camerashake += .4; @@ -2378,7 +2384,7 @@ void Person::DoAnimations() } 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) { + if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) { escapednum = 0; if (id == 0) camerashake += .4; @@ -2926,8 +2932,9 @@ void Person::DoAnimations() if (hasvictim) 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 (!Tutorial::active) + if (!Tutorial::active) { victim->DoBloodBig(1.5 / victim->armorhigh, 225); + } award_bonus(id, Slicebonus); if (!Tutorial::active) { @@ -2947,11 +2954,12 @@ void Person::DoAnimations() if (aitype != playercontrolled) weaponmissdelay = .6; - if (!Tutorial::active) - if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) + if (!Tutorial::active) { + if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) { weapons[weaponids[weaponactive]].bloody = 1; - if (!Tutorial::active) + } weapons[weaponids[weaponactive]].blooddrip += 3; + } XYZ footvel, footpoint; footvel = 0; @@ -2960,19 +2968,18 @@ void Person::DoAnimations() } else { footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords; } - if (!Tutorial::active) { - if (bloodtoggle) + if (Tutorial::active) { + Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .6, .3); + } else { + if (bloodtoggle) { Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .6, .3); + } footvel = DoRotation(facing, 0, 90, 0) * .8; - //footvel.y-=.3; Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9); Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9); Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .2, 1); Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .2, 1); } - if (Tutorial::active) { - Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .6, .3); - } victim->DoDamage(damagemult * 0); } } @@ -2988,24 +2995,18 @@ void Person::DoAnimations() victim->DoBloodBig(2 / victim->armorhigh, 185); victim->deathbleeding = 1; emit_sound_at(swordslicesound, victim->coords); - } - //victim->jointVel(abdomen)+=relative*damagemult*200; - if (!Tutorial::active) { victim->frameTarget = 0; victim->animTarget = staggerbackhardanim; victim->targetyaw = targetyaw + 180; victim->target = 0; - } - - if (!Tutorial::active) { - if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) + if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) { weapons[weaponids[weaponactive]].bloody = 1; + } weapons[weaponids[weaponactive]].blooddrip += 3; float bloodlossamount; bloodlossamount = 200 + abs((float)(Random() % 40)) - 20; victim->bloodloss += bloodlossamount / victim->armorhigh; - //victim->bloodloss+=100*(6.5-distsq(&coords,&victim->coords)); victim->DoDamage(damagemult * 0); XYZ footvel, footpoint; @@ -3015,8 +3016,9 @@ void Person::DoAnimations() } else { footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords; } - if (bloodtoggle) + if (bloodtoggle) { Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3); + } footvel = DoRotation(facing, 0, 90, 0) * .8; footvel.y -= .3; Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9); @@ -3817,7 +3819,6 @@ void Person::DoAnimations() if (!isnormal(coords.x)) coords = oldcoords; oldcoords = coords; - collided = 0; targetoffset = 0; currentoffset = 0; grabdelay = 1; @@ -4290,7 +4291,7 @@ void Person::DoStuff() static XYZ flatfacing; static XYZ flatvelocity; static float flatvelspeed; - static int i, l; + static int l; static int bloodsize; static int startx, starty, endx, endy; static GLubyte color; @@ -4382,7 +4383,7 @@ void Person::DoStuff() vel[2] = velocity.z; if (id == 0) { - OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel); + OPENAL_3D_SetAttributes(channels[whooshsound], gLoc); OPENAL_SetVolume(channels[whooshsound], 64 * findLength(&velocity) / 5); } } @@ -4540,7 +4541,7 @@ void Person::DoStuff() if (endy < starty) endy = starty; - for (i = startx; i < endx; i++) { + for (int i = startx; i < endx; i++) { for (int j = starty; j < endy; j++) { if (Random() % 2 == 0) { color = Random() % 85 + 170; @@ -4806,8 +4807,9 @@ void Person::DoStuff() } } - if (dead != 1) + if (dead != 1) { unconscioustime = 0; + } if (dead == 1 || howactive == typesleeping) { unconscioustime += multiplier; @@ -4908,13 +4910,12 @@ void Person::DoStuff() damage += 20; } - if (!dead) + if (!dead) { damage -= multiplier * 13; - if (!dead) permanentdamage -= multiplier * 4; - if (isIdle() || isCrouch()) { - if (!dead) + if (isIdle() || isCrouch()) { permanentdamage -= multiplier * 4; + } } if (damage < 0) damage = 0; @@ -5088,7 +5089,7 @@ void Person::DoStuff() canrecover = 0; if (velocity.y < -30) canrecover = 0; - for (i = 0; i < Object::objects.size(); i++) { + for (unsigned int i = 0; i < Object::objects.size(); i++) { if (Object::objects[i]->type != treeleavestype && Object::objects[i]->type != bushtype && Object::objects[i]->type != firetype) { colviewer = startpoint; coltarget = endpoint; @@ -5280,7 +5281,7 @@ void Person::DoStuff() if (aitype != passivetype || skeleton.free == 1) if (findLengthfast(&velocity) > .1) - for (i = 0; i < Object::objects.size(); i++) { + for (unsigned int i = 0; i < Object::objects.size(); i++) { if (Object::objects[i]->type == firetype) if (distsqflat(&coords, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 12 && distsq(&coords, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 49) { if (onfire) { @@ -5433,8 +5434,8 @@ void Person::DoStuff() play = 0; if (play && aitype != playercontrolled) { int whichsound = -1; - i = abs(Random() % 4); if (speechdelay <= 0) { + unsigned int i = abs(Random() % 4); if (creature == rabbittype) { if (i == 0) whichsound = rabbitchitter; @@ -5550,15 +5551,46 @@ void Person::DoStuff() } } - if (animTarget == spinkickanim || animTarget == staffspinhitreversalanim || animTarget == staffspinhitreversedanim || animTarget == staffhitreversalanim || animTarget == staffhitreversedanim || animTarget == hurtidleanim || animTarget == winduppunchanim || animTarget == swordslashreversalanim || animTarget == swordslashreversedanim || animTarget == knifeslashreversalanim || animTarget == knifeslashreversedanim || animTarget == knifethrowanim || animTarget == knifefollowanim || animTarget == knifefollowedanim || animTarget == killanim || animTarget == dropkickanim || animTarget == upunchanim || animTarget == knifeslashstartanim || animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim || animTarget == staffgroundsmashanim || animTarget == spinkickreversalanim || animTarget == sweepreversalanim || animTarget == lowkickanim || animTarget == sweepreversedanim || animTarget == rabbitkickreversalanim || animTarget == rabbitkickreversedanim || animTarget == jumpreversalanim || animTarget == jumpreversedanim) { + if (animTarget == spinkickanim || + animTarget == staffspinhitreversalanim || + animTarget == staffspinhitreversedanim || + animTarget == staffhitreversalanim || + animTarget == staffhitreversedanim || + animTarget == hurtidleanim || + animTarget == winduppunchanim || + animTarget == swordslashreversalanim || + animTarget == swordslashreversedanim || + animTarget == knifeslashreversalanim || + animTarget == knifeslashreversedanim || + animTarget == knifethrowanim || + animTarget == knifefollowanim || + animTarget == knifefollowedanim || + animTarget == killanim || + animTarget == dropkickanim || + animTarget == upunchanim || + animTarget == knifeslashstartanim || + animTarget == swordslashanim || + animTarget == staffhitanim || + animTarget == staffspinhitanim || + animTarget == staffgroundsmashanim || + animTarget == spinkickreversalanim || + animTarget == sweepreversalanim || + animTarget == lowkickanim || + animTarget == sweepreversedanim || + animTarget == rabbitkickreversalanim || + animTarget == rabbitkickreversedanim || + animTarget == jumpreversalanim || + animTarget == jumpreversedanim) { //close hands and yell - if (righthandmorphend != 1 && righthandmorphness == targetrighthandmorphness) { + if (righthandmorphend != 1 && + righthandmorphness == targetrighthandmorphness) { righthandmorphness = 0; righthandmorphend = 1; targetrighthandmorphness = 1; } - if (lefthandmorphend != 1 && lefthandmorphness == targetlefthandmorphness) { + if (lefthandmorphend != 1 && + lefthandmorphness == targetlefthandmorphness) { lefthandmorphness = 0; lefthandmorphend = 1; targetlefthandmorphness = 1; @@ -5618,7 +5650,8 @@ void Person::DoStuff() ReflectVector(&facing, terrainnormal); Normalise(&facing); - if (isRun() || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) { + if (isRun() || + animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) { if (onterrain) targettilt2 = -facing.y * 20; else @@ -5883,8 +5916,9 @@ void Person::DoStuff() velocity.y = 0; if (velspeed < multiplier * 300 * scale) { velocity = 0; - } else + } else { velocity -= velocity / velspeed * multiplier * 300 * scale; + } if (velspeed > 5 && (isLanding() || isLandhard())) { skiddingdelay += multiplier; if (skiddelay <= 0) { @@ -5892,17 +5926,13 @@ void Person::DoStuff() FootLand(rightfoot, .5); skiddelay = .02; } - } else + } else { skiddingdelay = 0; + } } if (isLandhard()) { velspeed = findLength(&velocity); - velocity.y = 0; - if (velspeed < multiplier * 600 * scale) { - velocity = 0; - } else - velocity -= velocity / velspeed * multiplier * 600 * scale; velocity = 0; if (velspeed > 5 && (isLanding() || isLandhard())) { skiddingdelay += multiplier; @@ -5911,8 +5941,9 @@ void Person::DoStuff() FootLand(rightfoot, .5); skiddelay = .02; } - } else + } else { skiddingdelay = 0; + } } if (skiddingdelay < 0) @@ -6059,7 +6090,7 @@ int Person::DrawSkeleton() } static XYZ mid; static float M[16]; - static int i, k; + static int k; static int weaponattachmuscle; static int weaponrotatemuscle; static XYZ weaponpoint; @@ -6099,19 +6130,19 @@ int Person::DrawSkeleton() if (Animation::animations[animTarget].attack == 3) targetheadyaw += 180; } - for (i = 0; i < skeleton.drawmodel.vertexNum; i++) { + for (int i = 0; i < skeleton.drawmodel.vertexNum; i++) { skeleton.drawmodel.vertex[i] = 0; skeleton.drawmodel.vertex[i].y = 999; } - for (i = 0; i < skeleton.drawmodellow.vertexNum; i++) { + for (int i = 0; i < skeleton.drawmodellow.vertexNum; i++) { skeleton.drawmodellow.vertex[i] = 0; skeleton.drawmodellow.vertex[i].y = 999; } - for (i = 0; i < skeleton.drawmodelclothes.vertexNum; i++) { + for (int i = 0; i < skeleton.drawmodelclothes.vertexNum; i++) { skeleton.drawmodelclothes.vertex[i] = 0; skeleton.drawmodelclothes.vertex[i].y = 999; } - for (unsigned i = 0; i < skeleton.muscles.size(); i++) { + for (unsigned 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; @@ -6322,19 +6353,20 @@ int Person::DrawSkeleton() glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glBegin(GL_POINTS); - if (playerdetail) - for (i = 0; i < skeleton.drawmodel.vertexNum; i++) { + if (playerdetail) { + for (int i = 0; i < skeleton.drawmodel.vertexNum; i++) { XYZ &v0 = skeleton.drawmodel.vertex[i]; glVertex3f(v0.x, v0.y, v0.z); } + } glEnd(); glBegin(GL_LINES); - if (playerdetail) - for (i = 0; i < skeleton.drawmodel.TriangleNum; i++) { - XYZ &v0 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]]; - XYZ &v1 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]]; - XYZ &v2 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]]; + if (playerdetail) { + for (unsigned int i = 0; i < skeleton.drawmodel.Triangles.size(); i++) { + const XYZ &v0 = skeleton.drawmodel.getTriangleVertex(i, 0); + const XYZ &v1 = skeleton.drawmodel.getTriangleVertex(i, 1); + const XYZ &v2 = skeleton.drawmodel.getTriangleVertex(i, 2); glVertex3f(v0.x, v0.y, v0.z); glVertex3f(v1.x, v1.y, v1.z); glVertex3f(v1.x, v1.y, v1.z); @@ -6342,6 +6374,7 @@ int Person::DrawSkeleton() glVertex3f(v2.x, v2.y, v2.z); glVertex3f(v0.x, v0.y, v0.z); } + } glEnd(); } @@ -6453,7 +6486,7 @@ int Person::DrawSkeleton() if (num_weapons > 0) { for (k = 0; k < num_weapons; k++) { - i = weaponids[k]; + int i = weaponids[k]; if (weaponactive == k) { if (weapons[i].getType() != staff) { for (unsigned j = 0; j < skeleton.muscles.size(); j++) { @@ -6691,7 +6724,6 @@ int Person::DrawSkeleton() */ int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model) { - static int i, j; static float distance; static float olddistance; static int intersecting; @@ -6709,14 +6741,14 @@ int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, return -1; if (*rotate) *p1 = DoRotation(*p1, 0, -*rotate, 0); - for (i = 0; i < 4; i++) { - for (j = 0; j < model->TriangleNum; j++) { - if (model->facenormals[j].y <= slopethreshold) { + for (int i = 0; i < 4; i++) { + for (unsigned int j = 0; j < model->Triangles.size(); j++) { + if (model->Triangles[j].facenormal.y <= slopethreshold) { intersecting = 0; - distance = abs((model->facenormals[j].x * p1->x) + (model->facenormals[j].y * p1->y) + (model->facenormals[j].z * p1->z) - ((model->facenormals[j].x * model->vertex[model->Triangles[j].vertex[0]].x) + (model->facenormals[j].y * model->vertex[model->Triangles[j].vertex[0]].y) + (model->facenormals[j].z * model->vertex[model->Triangles[j].vertex[0]].z))); + distance = abs((model->Triangles[j].facenormal.x * p1->x) + (model->Triangles[j].facenormal.y * p1->y) + (model->Triangles[j].facenormal.z * p1->z) - ((model->Triangles[j].facenormal.x * model->vertex[model->Triangles[j].vertex[0]].x) + (model->Triangles[j].facenormal.y * model->vertex[model->Triangles[j].vertex[0]].y) + (model->Triangles[j].facenormal.z * model->vertex[model->Triangles[j].vertex[0]].z))); if (distance < radius) { - point = *p1 - model->facenormals[j] * distance; - if (PointInTriangle( &point, model->facenormals[j], &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]])) + point = *p1 - model->Triangles[j].facenormal * distance; + if (PointInTriangle( &point, model->Triangles[j].facenormal, &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]])) intersecting = 1; if (!intersecting) intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]], @@ -6731,11 +6763,11 @@ int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, &model->vertex[model->Triangles[j].vertex[2]], p1, &radius); end = *p1 - point; - if (dotproduct(&model->facenormals[j], &end) > 0 && intersecting) { + if (dotproduct(&model->Triangles[j].facenormal, &end) > 0 && intersecting) { start = *p1; end = *p1; end.y -= radius; - 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)) { + 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->Triangles[j].facenormal, &point)) { p1->y = point.y + radius; if ((animTarget == jumpdownanim || isFlip())) { if (isFlip() && (frameTarget < 5 || targetFrame().label == 7 || targetFrame().label == 4)) @@ -6775,23 +6807,23 @@ int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, } } } - for (j = 0; j < model->TriangleNum; j++) { - if (model->facenormals[j].y > slopethreshold) { + for (unsigned int j = 0; j < model->Triangles.size(); j++) { + if (model->Triangles[j].facenormal.y > slopethreshold) { intersecting = 0; start = *p1; start.y -= radius / 4; XYZ &v0 = model->vertex[model->Triangles[j].vertex[0]]; XYZ &v1 = model->vertex[model->Triangles[j].vertex[1]]; XYZ &v2 = model->vertex[model->Triangles[j].vertex[2]]; - distance = abs((model->facenormals[j].x * start.x) - + (model->facenormals[j].y * start.y) - + (model->facenormals[j].z * start.z) - - ((model->facenormals[j].x * v0.x) - + (model->facenormals[j].y * v0.y) - + (model->facenormals[j].z * v0.z))); + distance = abs((model->Triangles[j].facenormal.x * start.x) + + (model->Triangles[j].facenormal.y * start.y) + + (model->Triangles[j].facenormal.z * start.z) + - ((model->Triangles[j].facenormal.x * v0.x) + + (model->Triangles[j].facenormal.y * v0.y) + + (model->Triangles[j].facenormal.z * v0.z))); if (distance < radius * .5) { - point = start - model->facenormals[j] * distance; - if (PointInTriangle( &point, model->facenormals[j], &v0, &v1, &v2)) + point = start - model->Triangles[j].facenormal * distance; + if (PointInTriangle( &point, model->Triangles[j].facenormal, &v0, &v1, &v2)) intersecting = 1; if (!intersecting) intersecting = sphere_line_intersection(v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, p1->x, p1->y, p1->z, radius / 2); @@ -6800,14 +6832,14 @@ int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, if (!intersecting) intersecting = sphere_line_intersection(v0.x, v0.y, v0.z, v2.x, v2.y, v2.z, p1->x, p1->y, p1->z, radius / 2); end = *p1 - point; - if (dotproduct(&model->facenormals[j], &end) > 0 && intersecting) { + if (dotproduct(&model->Triangles[j].facenormal, &end) > 0 && intersecting) { if ((animTarget == jumpdownanim || animTarget == jumpupanim || isFlip())) { start = velocity; - velocity -= DoRotation(model->facenormals[j], 0, *rotate, 0) * findLength(&velocity) * abs(normaldotproduct(velocity, DoRotation(model->facenormals[j], 0, *rotate, 0))); //(distance-radius*.5)/multiplier; + velocity -= DoRotation(model->Triangles[j].facenormal, 0, *rotate, 0) * findLength(&velocity) * abs(normaldotproduct(velocity, DoRotation(model->Triangles[j].facenormal, 0, *rotate, 0))); //(distance-radius*.5)/multiplier; if (findLengthfast(&start) < findLengthfast(&velocity)) velocity = start; } - *p1 += model->facenormals[j] * (distance - radius * .5); + *p1 += model->Triangles[j].facenormal * (distance - radius * .5); } } if ((distance < olddistance || firstintersecting == -1) && intersecting) { @@ -6829,17 +6861,16 @@ int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, int findPathDist(int start, int end) { - int smallestcount, count, connected; - int last, last2, last3, last4; + int connected; int closest; - smallestcount = 1000; - for (int i = 0; i < 50; i++) { - count = 0; - last = start; - last2 = -1; - last3 = -1; - last4 = -1; + unsigned int smallestcount = 1000; + for (char i = 0; i < 50; i++) { + unsigned int count = 0; + int last = start; + int last2 = -1; + int last3 = -1; + int last4 = -1; while (last != end && count < 30) { closest = -1; for (int j = 0; j < Game::numpathpoints; j++) { @@ -6866,8 +6897,9 @@ int findPathDist(int start, int end) last = closest; count++; } - if (count < smallestcount) + if (count < smallestcount) { smallestcount = count; + } } return smallestcount; } @@ -7207,7 +7239,7 @@ void Person::doAI() if (aitype != passivetype) { if (howactive == typesleeping) - setAnimation(getupfromfrontanim); + setTargetAnimation(getupfromfrontanim); howactive = typeactive; } } @@ -7313,7 +7345,7 @@ void Person::doAI() j = Object::checkcollide(test2, test); if (j == -1) { velocity = 0; - setAnimation(getStop()); + setTargetAnimation(getStop()); targetyaw += 180; stunned = .5; //aitype=passivetype; @@ -7628,15 +7660,17 @@ void Person::doAI() if (Person::players[0]->animTarget != rabbitkickanim && Person::players[0]->weaponactive != -1) { if (weapons[Person::players[0]->weaponids[0]].getType() == knife) { if (isIdle() || isCrouch() || isRun() || isFlip()) { - if (abs(Random() % 2) == 0) - setAnimation(backhandspringanim); - else - setAnimation(rollanim); + if (abs(Random() % 2) == 0) { + setTargetAnimation(backhandspringanim); + } else { + setTargetAnimation(rollanim); + } targetyaw += 90 * (abs(Random() % 2) * 2 - 1); wentforweapon = 0; } - if (animTarget == jumpupanim || animTarget == jumpdownanim) - setAnimation(flipanim); + if (animTarget == jumpupanim || animTarget == jumpdownanim) { + setTargetAnimation(flipanim); + } } } forwardkeydown = 0; @@ -7691,7 +7725,7 @@ void Person::doAI() j = Object::checkcollide(test2, test); if (j == -1) { velocity = 0; - setAnimation(getStop()); + setTargetAnimation(getStop()); targetyaw += 180; stunned = .5; aitype = pathfindtype;