animCurrent = animTarget;
frameTarget++;
- if (animTarget == removeknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == removeknifeanim && currentFrame().label == 5) {
for (unsigned i = 0; i < weapons.size(); i++) {
if (weapons[i].owner == -1) {
if (distsqflat(&coords, &weapons[i].position) < 4 && weaponactive == -1) {
}
}
- if (animTarget == crouchremoveknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == crouchremoveknifeanim && currentFrame().label == 5) {
for (unsigned i = 0; i < weapons.size(); i++) {
bool willwork = true;
if (weapons[i].owner != -1) {
}
}
- if (animCurrent == drawleftanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == drawleftanim && currentFrame().label == 5) {
if (weaponactive == -1) {
weaponactive = 0;
} else if (weaponactive == 0) {
damagemult /= victim->damagetolerance / 200;
}
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 (animCurrent == spinkickanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == wolfslapanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == wolfslapanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == walljumprightkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == walljumprightkickanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == walljumpleftkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == walljumpleftkickanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == blockhighleftstrikeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == blockhighleftstrikeanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 8) {
+ if (animCurrent == killanim && currentFrame().label == 8) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && victim->dead) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == killanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->dead) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == dropkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ if (animCurrent == dropkickanim && currentFrame().label == 7) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->skeleton.free) {
escapednum = 0;
if (id == 0) {
}
}
- if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if ((animCurrent == crouchstabanim || animCurrent == swordgroundstabanim) && currentFrame().label == 5) {
if (hasvictim) {
if (!victim->skeleton.free) {
}
}
- if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
+ if ((animCurrent == crouchstabanim || animCurrent == swordgroundstabanim) && currentFrame().label == 6) {
if (!hasvictim) {
emit_sound_at(knifedrawsound, coords, 128);
}
}
}
- if (animTarget == upunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == upunchanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == winduppunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == winduppunchanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 2) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == blockhighleftanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == blockhighleftanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
if (victim->id == 0) {
camerashake += .4;
}
}
- if (animTarget == swordslashparryanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == swordslashparryanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
if (victim->id == 0) {
camerashake += .4;
}
}
- if (animTarget == knifethrowanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == knifethrowanim && currentFrame().label == 5) {
if (weaponactive != -1) {
escapednum = 0;
XYZ aim;
}
}
- if (animTarget == knifeslashstartanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == knifeslashstartanim && currentFrame().label == 5) {
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) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 && victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
escapednum = 0;
if (!Tutorial::active) {
victim->DoBloodBig(1.5 / victim->armorhigh, 225);
}
}
}
- if (animTarget == swordslashanim && Animation::animations[animTarget].frames[frameCurrent].label == 5 && victim->animTarget != rollanim) {
+ if (animCurrent == swordslashanim && currentFrame().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);
}
}
- if (animTarget == staffhitanim && Animation::animations[animTarget].frames[frameCurrent].label == 5 && victim->animTarget != rollanim) {
+ if (animCurrent == staffhitanim && currentFrame().label == 5 && victim->animTarget != rollanim) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
if (!Tutorial::active) {
weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 250;
}
}
- if (animTarget == staffspinhitanim && Animation::animations[animTarget].frames[frameCurrent].label == 5 && victim->animTarget != rollanim) {
+ if (animCurrent == staffspinhitanim && currentFrame().label == 5 && victim->animTarget != rollanim) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
if (!Tutorial::active) {
weapons[weaponids[0]].damage += .6 + float(abs(Random() % 100) - 50) / 250;
}
}
- if (animTarget == staffgroundsmashanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == staffgroundsmashanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5) {
escapednum = 0;
if (!Tutorial::active) {
}
}
- if (animTarget == lowkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == lowkickanim && currentFrame().label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != highheight) {
escapednum = 0;
if (id == 0) {
}
}
- if (animTarget == sweepanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == sweepanim && currentFrame().label == 5) {
if ((victim->animTarget != jumpupanim) &&
(distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) &&
(victim != this->shared_from_this())) {
}
}
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) {
+ if (animCurrent == spinkickreversalanim && currentFrame().label == 7) {
escapednum = 0;
if (id == 0) {
camerashake += .4;
}
}
- if (animTarget == staffhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (animCurrent == staffhitreversalanim && currentFrame().label == 5) {
escapednum = 0;
if (id == 0) {
camerashake += .4;
victim->DoDamage(damagemult * 70 / victim->protectionhigh);
}
- if (animTarget == staffspinhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ if (animCurrent == staffspinhitreversalanim && currentFrame().label == 7) {
escapednum = 0;
if (id == 0) {
camerashake += .4;
victim->DoDamage(damagemult * 70 / victim->protectionhigh);
}
- if (animTarget == upunchreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ if (animCurrent == upunchreversalanim && currentFrame().label == 7) {
escapednum = 0;
victim->RagDoll(1);
XYZ relative;
}
}
- if (animTarget == swordslashreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ if (animCurrent == swordslashreversalanim && currentFrame().label == 7) {
escapednum = 0;
victim->RagDoll(1);
XYZ relative;
award_bonus(id, swordreversebonus);
}
- if (hasvictim && animTarget == knifeslashreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ if (hasvictim && animCurrent == knifeslashreversalanim && currentFrame().label == 7) {
escapednum = 0;
if (id == 0) {
camerashake += .4;
award_bonus(id, Reversal);
}
- if (hasvictim && animTarget == sneakattackanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ if (hasvictim && animCurrent == sneakattackanim && currentFrame().label == 7) {
escapednum = 0;
victim->RagDoll(0);
victim->skeleton.spinny = 0;
award_bonus(id, spinecrusher);
}
- if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (hasvictim && (animCurrent == knifefollowanim || animCurrent == knifesneakattackanim) && currentFrame().label == 5) {
if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
escapednum = 0;
if (animTarget == knifefollowanim) {
}
}
- if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
+ if (hasvictim && (animCurrent == knifefollowanim || animCurrent == knifesneakattackanim) && currentFrame().label == 6) {
escapednum = 0;
victim->velocity = 0;
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
}
}
- if (hasvictim && (animTarget == swordsneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (hasvictim && (animCurrent == swordsneakattackanim) && currentFrame().label == 5) {
if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
award_bonus(id, backstab);
}
}
- if (hasvictim && animTarget == swordsneakattackanim && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
+ if (hasvictim && animCurrent == swordsneakattackanim && currentFrame().label == 6) {
escapednum = 0;
victim->velocity = 0;
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
}
}
- if (animTarget == sweepreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ if (animCurrent == sweepreversalanim && currentFrame().label == 7) {
escapednum = 0;
if (id == 0) {
camerashake += .4;
victim->velocity = 0;
}
- 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))) {
+ if (animCurrent == sweepreversalanim && ((currentFrame().label == 9 && victim->damage < victim->damagetolerance) || (currentFrame().label == 7 && victim->damage > victim->damagetolerance))) {
escapednum = 0;
victim->RagDoll(0);
XYZ relative;
}
//Animation end
- if (frameTarget > int(Animation::animations[animCurrent].frames.size()) - 1) {
+ if (frameTarget >= int(Animation::animations[animCurrent].frames.size())) {
frameTarget = 0;
if (wasStop()) {
animTarget = getIdle();
frameCurrent = frameTarget;
target = 1;
}
+
+ if (frameCurrent >= int(Animation::animations[animCurrent].frames.size())) {
+ frameCurrent = Animation::animations[animCurrent].frames.size() - 1;
+ }
+
oldrot = rot;
rot = targetrot * target;
yaw += rot - oldrot;
oldrot = 0;
targetrot = 0;
}
- if (frameCurrent >= int(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 (unsigned i = 0; i < skeleton.joints.size(); i++) {