Person::players[i]->skeleton.oldfree == 0 &&
(Person::players[i]->animTarget == jumpupanim ||
Person::players[k]->animTarget == jumpupanim) &&
- (Person::players[i]->aitype == playercontrolled ||
- Person::players[k]->aitype == playercontrolled) &&
+ (Person::players[i]->isPlayerControlled() ||
+ Person::players[k]->isPlayerControlled()) &&
((Person::players[i]->aitype == attacktypecutoff && Person::players[i]->stunned <= 0) ||
(Person::players[k]->aitype == attacktypecutoff && Person::players[k]->stunned <= 0))) {
if (distsq(&Person::players[i]->coords, &Person::players[k]->coords) < 10 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5) &&
Person::players[k]->animTarget != getupfromfrontanim &&
Animation::animations[Person::players[k]->animTarget].height == middleheight &&
normaldotproduct(Person::players[i]->velocity, Person::players[k]->coords - Person::players[i]->coords) < 0 &&
- ((Person::players[k]->aitype == playercontrolled && Person::players[k]->attackkeydown) ||
- Person::players[k]->aitype != playercontrolled)) {
+ ((Person::players[k]->isPlayerControlled() && Person::players[k]->attackkeydown) ||
+ !Person::players[k]->isPlayerControlled())) {
Person::players[i]->victim = Person::players[k];
Person::players[i]->velocity = 0;
Person::players[i]->animCurrent = jumpreversedanim;
Person::players[i]->animTarget != getupfromfrontanim &&
Animation::animations[Person::players[i]->animTarget].height == middleheight &&
normaldotproduct(Person::players[k]->velocity, Person::players[i]->coords - Person::players[k]->coords) < 0 &&
- ((Person::players[i]->aitype == playercontrolled && Person::players[i]->attackkeydown) ||
- Person::players[i]->aitype != playercontrolled)) {
+ ((Person::players[i]->isPlayerControlled() && Person::players[i]->attackkeydown) ||
+ !Person::players[i]->isPlayerControlled())) {
Person::players[k]->victim = Person::players[i];
Person::players[k]->velocity = 0;
Person::players[k]->animCurrent = jumpreversedanim;
for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
unsigned int i = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
if (Object::objects[i]->type != rocktype ||
- Object::objects[i]->scale > .5 && Person::players[k]->aitype == playercontrolled ||
+ Object::objects[i]->scale > .5 && Person::players[k]->isPlayerControlled() ||
Object::objects[i]->position.y > Person::players[k]->coords.y) {
lowpoint = Person::players[k]->coords;
if (Person::players[k]->animTarget != jumpupanim &&
tempcollide = 1;
//wall jumps
//TODO: refactor four similar blocks
- if (Person::players[k]->aitype == playercontrolled &&
+ if (Person::players[k]->isPlayerControlled() &&
(Person::players[k]->animTarget == jumpupanim ||
Person::players[k]->animTarget == jumpdownanim ||
Person::players[k]->isFlip()) &&
Person::players[k]->coords.y -= 1.35;
Person::players[k]->collide = 1;
- if ((Person::players[k]->grabdelay <= 0 || Person::players[k]->aitype != playercontrolled) &&
+ if ((Person::players[k]->grabdelay <= 0 || !Person::players[k]->isPlayerControlled()) &&
(Person::players[k]->animCurrent != climbanim &&
Person::players[k]->animCurrent != hanganim &&
!Person::players[k]->isWallJump() ||
playerrealattackkeydown = Input::isKeyDown(attackkey);
}
if ((Person::players[0]->parriedrecently <= 0 ||
- Person::players[0]->weaponactive == -1) &&
+ !Person::players[0]->hasWeapon()) &&
(!oldattackkey ||
(realthreat &&
Person::players[0]->lastattack != swordslashanim &&
Person::players[k]->attackkeydown = 0;
}
if (Person::players[k]->animTarget != rabbitrunninganim && Person::players[k]->animTarget != wolfrunninganim) {
- if (Person::players[k]->aitype != playercontrolled) {
+ if (!Person::players[k]->isPlayerControlled()) {
Person::players[k]->victim = Person::players[0];
}
//attack key pressed
Person::players[k]->animTarget == walkanim ||
Person::players[k]->animTarget == sneakanim ||
Person::players[k]->isCrouch())) {
- const int attackweapon = Person::players[k]->weaponactive == -1 ? 0 : weapons[Person::players[k]->weaponids[Person::players[k]->weaponactive]].getType();
+ const int attackweapon = (Person::players[k]->hasWeapon() ? weapons[Person::players[k]->weaponids[Person::players[k]->weaponactive]].getType() : 0);
//normal attacks (?)
Person::players[k]->hasvictim = 0;
if (Person::players.size() > 1) {
Person::players[i]->animTarget != getupfromfrontanim) {
Person::players[k]->victim = Person::players[i];
Person::players[k]->hasvictim = 1;
- if (Person::players[k]->aitype == playercontrolled) { //human player
+ if (Person::players[k]->isPlayerControlled()) { //human player
//sweep
if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
Person::players[k]->crouchkeydown &&
}
}
}
- if (Person::players[k]->aitype == playercontrolled) {
+ if (Person::players[k]->isPlayerControlled()) {
//rabbit kick
if (Person::players[k]->attackkeydown &&
Person::players[k]->isRun() &&
Person::players[k]->victim->animTarget != getupfrombackanim &&
Person::players[k]->victim->animTarget != getupfromfrontanim &&
Animation::animations[Person::players[k]->victim->animTarget].height != lowheight &&
- Person::players[k]->aitype != playercontrolled && //wat???
+ !Person::players[k]->isPlayerControlled() && //wat???
normaldotproduct(Person::players[k]->facing, Person::players[k]->victim->coords - Person::players[k]->coords) > 0 &&
Person::players[k]->rabbitkickenabled) ||
Person::players[k]->jumpkeydown)) {
Person::players[i]->targetheadyaw = yaw;
Person::players[i]->targetheadpitch = pitch;
}
- if (i != 0 && Person::players[i]->aitype == playercontrolled && !Dialog::inDialog()) {
+ if (i != 0 && Person::players[i]->isPlayerControlled() && !Dialog::inDialog()) {
if (!Animation::animations[Person::players[i]->animTarget].attack &&
Person::players[i]->animTarget != staggerbackhighanim &&
Person::players[i]->animTarget != staggerbackhardanim &&
//pick up weapon
if (Person::players[i]->throwkeydown && !Person::players[i]->throwtogglekeydown) {
- if (Person::players[i]->weaponactive == -1 &&
+ if (!Person::players[i]->hasWeapon() &&
Person::players[i]->num_weapons < 2 &&
(Person::players[i]->isIdle() ||
Person::players[i]->isCrouch() ||
Person::players[i]->animTarget == rollanim ||
Person::players[i]->animTarget == backhandspringanim ||
Person::players[i]->isFlip() ||
- Person::players[i]->aitype != playercontrolled)) {
+ !Person::players[i]->isPlayerControlled())) {
for (unsigned j = 0; j < weapons.size(); j++) {
if ((weapons[j].velocity.x == 0 && weapons[j].velocity.y == 0 && weapons[j].velocity.z == 0 ||
- Person::players[i]->aitype == playercontrolled) &&
+ Person::players[i]->isPlayerControlled()) &&
weapons[j].owner == -1 &&
- Person::players[i]->weaponactive == -1) {
+ !Person::players[i]->hasWeapon()) {
if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2) {
if (distsq(&Person::players[i]->coords, &weapons[j].position) < 2) {
if (Person::players[i]->isCrouch() ||
Person::players[i]->animTarget == sneakanim ||
Person::players[i]->isRun() ||
Person::players[i]->isIdle() ||
- Person::players[i]->aitype != playercontrolled) {
+ !Person::players[i]->isPlayerControlled()) {
Person::players[i]->throwtogglekeydown = 1;
Person::players[i]->setTargetAnimation(crouchremoveknifeanim);
Person::players[i]->targetyaw = roughDirectionTo(Person::players[i]->coords, weapons[j].position);
Person::players[i]->hasvictim = 0;
if ((weapons[j].velocity.x == 0 && weapons[j].velocity.y == 0 && weapons[j].velocity.z == 0 ||
- Person::players[i]->aitype == playercontrolled) &&
+ Person::players[i]->isPlayerControlled()) &&
weapons[j].owner == -1 ||
Person::players[i]->victim &&
weapons[j].owner == int(Person::players[i]->victim->id)) {
- if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2 && Person::players[i]->weaponactive == -1) {
+ if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2 && !Person::players[i]->hasWeapon()) {
if (distsq(&Person::players[i]->coords, &weapons[j].position) < 1 || Person::players[i]->victim) {
if (weapons[j].getType() != staff) {
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
}
} else if ((Person::players[i]->isIdle() ||
Person::players[i]->isFlip() ||
- Person::players[i]->aitype != playercontrolled) &&
+ !Person::players[i]->isPlayerControlled()) &&
distsq(&Person::players[i]->coords, &weapons[j].position) < 5 &&
Person::players[i]->coords.y < weapons[j].position.y) {
if (!Person::players[i]->isFlip()) {
Person::players[i]->hasvictim = 0;
for (unsigned k = 0; k < weapons.size(); k++) {
- if (Person::players[i]->weaponactive == -1) {
+ if (!Person::players[i]->hasWeapon()) {
if ((weapons[k].velocity.x == 0 && weapons[k].velocity.y == 0 && weapons[k].velocity.z == 0 ||
- Person::players[i]->aitype == playercontrolled) &&
+ Person::players[i]->isPlayerControlled()) &&
weapons[k].owner == -1 ||
Person::players[i]->victim &&
weapons[k].owner == int(Person::players[i]->victim->id)) {
if (distsqflat(&Person::players[i]->coords, &weapons[k].position) < 3 &&
- Person::players[i]->weaponactive == -1) {
+ !Person::players[i]->hasWeapon()) {
if (weapons[k].getType() != staff) {
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
}
Person::players[i]->animTarget == backhandspringanim) {
if (Person::players.size() > 1) {
for (unsigned j = 0; j < Person::players.size(); j++) {
- if (Person::players[i]->weaponactive == -1) {
+ if (!Person::players[i]->hasWeapon()) {
if (j != i) {
if (Person::players[j]->num_weapons &&
Person::players[j]->skeleton.free &&
}
}
}
- if (Person::players[i]->weaponactive != -1 && Person::players[i]->aitype == playercontrolled) {
+ if (Person::players[i]->hasWeapon() && Person::players[i]->isPlayerControlled()) {
if (weapons[Person::players[i]->weaponids[0]].getType() == knife) {
if (Person::players[i]->isIdle() ||
Person::players[i]->isRun() ||
Person::players[i]->targettilt2 = pitchTo(Person::players[i]->coords, Person::players[j]->coords);
}
if (Person::players[i]->isFlip()) {
- if (Person::players[i]->weaponactive != -1) {
+ if (Person::players[i]->hasWeapon()) {
Person::players[i]->throwtogglekeydown = 1;
Person::players[i]->victim = Person::players[j];
XYZ aim;
}
}
}
- if (Person::players[i]->weaponactive != -1 && Person::players[i]->aitype == playercontrolled) {
+ if (Person::players[i]->hasWeapon() && Person::players[i]->isPlayerControlled()) {
if (Person::players[i]->isCrouch() || Person::players[i]->animTarget == sneakanim) {
Person::players[i]->throwtogglekeydown = 1;
XYZ tempVelocity = Person::players[i]->velocity * .2;
}
//draw weapon
- if (i == 0 || !Person::players[0]->dead || (Person::players[i]->weaponactive != -1)) {
+ if (i == 0 || !Person::players[0]->dead || (Person::players[i]->hasWeapon())) {
if (Person::players[i]->drawkeydown && !Person::players[i]->drawtogglekeydown ||
(Person::players[i]->num_weapons == 2) &&
- (Person::players[i]->weaponactive == -1) &&
+ (!Person::players[i]->hasWeapon()) &&
Person::players[i]->isIdle() ||
Person::players[0]->dead &&
- (Person::players[i]->weaponactive != -1) &&
+ (Person::players[i]->hasWeapon()) &&
i != 0) {
bool isgood = true;
- if (Person::players[i]->weaponactive != -1) {
+ if (Person::players[i]->hasWeapon()) {
if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == staff) {
isgood = false;
}
Person::players[i]->drawtogglekeydown = 1;
}
if ((Person::players[i]->isIdle() ||
- (Person::players[i]->aitype != playercontrolled &&
- Person::players[0]->weaponactive != -1 &&
+ (!Person::players[i]->isPlayerControlled() &&
+ Person::players[0]->hasWeapon() &&
Person::players[i]->isRun())) &&
Person::players[i]->num_weapons &&
weapons[Person::players[i]->weaponids[0]].getType() == sword) {
}
//clean weapon
- if (Person::players[i]->weaponactive != -1) {
+ if (Person::players[i]->hasWeapon()) {
if (Person::players[i]->isCrouch() &&
weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].bloody &&
bloodtoggle &&
}
Person::players[i]->frameTarget = 0;
}
- if (Person::players[i]->animTarget == hanganim /*&&(!Person::players[i]->forwardstogglekeydown||Person::players[i]->aitype!=playercontrolled)*/) {
+ if (Person::players[i]->animTarget == hanganim /*&&(!Person::players[i]->forwardstogglekeydown||!Person::players[i]->isPlayerControlled())*/) {
Person::players[i]->setTargetAnimation(climbanim);
Person::players[i]->frameTarget = 1;
Person::players[i]->jumpclimb = 1;
}
if (target >= 0) {
Person::players[i]->velocity.y = 1;
- } else if (Person::players[i]->crouchkeydown || Person::players[i]->aitype != playercontrolled) {
+ } else if (Person::players[i]->crouchkeydown || !Person::players[i]->isPlayerControlled()) {
Person::players[i]->velocity.y = 7;
Person::players[i]->crouchtogglekeydown = 1;
} else {
(((!floatjump &&
!editorenabled) ||
!devtools) ||
- Person::players[i]->aitype != playercontrolled)) {
+ !Person::players[i]->isPlayerControlled())) {
if (Person::players[i]->jumppower > multiplier * 6) {
Person::players[i]->velocity.y += multiplier * 6;
Person::players[i]->jumppower -= multiplier * 6;
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) {
+ if ((isPlayerControlled() && (stunned <= 0) && !hasWeapon()) || pause) {
return PersonType::types[creature].animFightIdle;
}
- if (aitype == playercontrolled && stunned <= 0 && weaponactive != -1) {
+ if (isPlayerControlled() && (stunned <= 0) && hasWeapon()) {
if (weapons[weaponids[weaponactive]].getType() == knife) {
return knifefightidleanim;
}
- if (weapons[weaponids[weaponactive]].getType() == sword && victim->weaponactive != -1) {
+ if (weapons[weaponids[weaponactive]].getType() == sword && victim->hasWeapon()) {
return swordfightidlebothanim;
}
if (weapons[weaponids[weaponactive]].getType() == sword) {
return swordfightidleanim;
}
}
- if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause) {
+ if (!isPlayerControlled() && (stunned <= 0) && creature != wolftype) {
return fightsidestep;
}
}
*/
int Person::getRun()
{
- if (superruntoggle && (weaponactive == -1)) {
+ if (superruntoggle && (!hasWeapon())) {
return PersonType::types[creature].animRunning;
} else {
return PersonType::types[creature].animRun;
}
if (!Tutorial::active || id == 0) {
- if (aitype != playercontrolled && howmuch > 0) {
+ if (!isPlayerControlled() && howmuch > 0) {
// play pain sounds
int whichsound = -1;
deathbleeding += bleeding;
bloodloss += bleeding * 3;
- if (!Tutorial::active && aitype != playercontrolled && bloodloss > damagetolerance * 2 / 3 && bloodloss < damagetolerance && creature == rabbittype) {
+ if (!Tutorial::active && !isPlayerControlled() && bloodloss > damagetolerance * 2 / 3 && bloodloss < damagetolerance && creature == rabbittype) {
if (abs(Random() % 2) == 0) {
aitype = gethelptype;
lastseentime = 12;
deathbleeding += bleeding;
bloodloss += bleeding * 3;
- if (!Tutorial::active && aitype != playercontrolled && bloodloss > damagetolerance * 2 / 3 && bloodloss < damagetolerance && creature == rabbittype) {
+ if (!Tutorial::active && !isPlayerControlled() && bloodloss > damagetolerance * 2 / 3 && bloodloss < damagetolerance && creature == rabbittype) {
if (abs(Random() % 2) == 0) {
aitype = gethelptype;
lastseentime = 12;
*/
void Person::Reverse()
{
- if (!((victim->aitype == playercontrolled || hostiletime > 1 || staggerdelay <= 0) && victim->animTarget != jumpupanim && victim->animTarget != jumpdownanim && (!Tutorial::active || cananger) && hostile)) {
+ if (!((victim->isPlayerControlled() || hostiletime > 1 || staggerdelay <= 0) && victim->animTarget != jumpupanim && victim->animTarget != jumpdownanim && (!Tutorial::active || cananger) && hostile)) {
return;
}
victim->animTarget = upunchreversalanim;
}
if (animTarget == staffhitanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 4 == 0)) {
- if (victim->weaponactive != -1) {
+ if (victim->hasWeapon()) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
if (tempVelocity.x == 0) {
victim->animTarget = staffhitreversalanim;
}
if (animTarget == staffspinhitanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 2 == 0)) {
- if (victim->weaponactive != -1) {
+ if (victim->hasWeapon()) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
if (tempVelocity.x == 0) {
victim->animTarget = staffspinhitreversalanim;
}
if (animTarget == swordslashanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 4 == 0)) {
- if (victim->weaponactive != -1) {
+ if (victim->hasWeapon()) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
if (tempVelocity.x == 0) {
victim->animTarget = swordslashreversalanim;
}
if (animTarget == knifeslashstartanim && distsq(&victim->coords, &coords) < 2 && (victim->id == 0 || Random() % 4 == 0)) {
- if (victim->weaponactive != -1) {
+ if (victim->hasWeapon()) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
if (tempVelocity.x == 0) {
victim->victim = this->shared_from_this();
victim->targetyaw = targetyaw + 180;
}
- if ((animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim) && victim->weaponactive != -1) {
+ if ((animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim) && victim->hasWeapon()) {
animTarget = swordslashparriedanim;
parriedrecently = .4;
victim->parriedrecently = 0;
victim->targetyaw = targetyaw + 180;
if (abs(Random() % 20) == 0 || weapons[victim->weaponids[victim->weaponactive]].getType() == knife) {
- if (victim->weaponactive != -1) {
+ if (victim->hasWeapon()) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
}
if (abs(Random() % 20) == 0) {
- if (weaponactive != -1) {
+ if (hasWeapon()) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
velocity = 0;
victim->velocity = 0;
- if (aitype != playercontrolled) {
+ if (!isPlayerControlled()) {
feint = 0;
if (escapednum < 2) {
int chances = ((difficulty == 2) ? 3 : ((difficulty == 1) ? 5 : 10));
if (aitype == passivetype && damage < damagetolerance && ((!Tutorial::active || cananger) && hostile)) {
aitype = attacktypecutoff;
}
- if (!Tutorial::active && aitype != playercontrolled && damage < damagetolerance && damage > damagetolerance * 2 / 3 && creature == rabbittype) {
+ if (!Tutorial::active && !isPlayerControlled() && damage < damagetolerance && damage > damagetolerance * 2 / 3 && creature == rabbittype) {
if (abs(Random() % 2) == 0) {
aitype = gethelptype;
lastseentime = 12;
// play sounds
if (!Tutorial::active || id == 0) {
- if (speechdelay <= 0 && !dead && aitype != playercontrolled) {
+ if (speechdelay <= 0 && !dead && !isPlayerControlled()) {
int whichsound = -1;
if (creature == wolftype) {
// drop weapon
if (Random() % 2 == 0) {
- if (weaponactive != -1 && animTarget != rabbitkickanim && num_weapons > 0) {
+ if (hasWeapon() && animTarget != rabbitkickanim && num_weapons > 0) {
weapons[weaponids[0]].drop(jointVel(righthand) * scale * -.3, jointVel(righthand) * scale);
weapons[weaponids[0]].velocity.x += .01;
num_weapons--;
}
if (!crouchkeydown || (isLanding() || isLandhard()) || (wasLanding() || wasLandhard())) {
crouchtogglekeydown = 0;
- if (aitype == playercontrolled) {
+ if (isPlayerControlled()) {
feint = 0;
}
} else {
- if (!crouchtogglekeydown && Animation::animations[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain)) {
+ if (!crouchtogglekeydown && Animation::animations[animTarget].attack == reversed && isPlayerControlled() && (escapednum < 2 || reversaltrain)) {
feint = 1;
}
if (!isFlip()) {
}
}
- if (!drawtogglekeydown && drawkeydown && (weaponactive == -1 || num_weapons == 1) && (targetFrame().label || (animTarget != animCurrent && animCurrent == rollanim)) && num_weapons > 0 && creature != wolftype) {
+ if (!drawtogglekeydown && drawkeydown && (!hasWeapon() || num_weapons == 1) && (targetFrame().label || (animTarget != animCurrent && animCurrent == rollanim)) && num_weapons > 0 && creature != wolftype) {
if (weapons[weaponids[0]].getType() == knife) {
- if (weaponactive == -1) {
+ if (!hasWeapon()) {
weaponactive = 0;
+ emit_sound_at(knifedrawsound, coords, 128);
} else if (weaponactive == 0) {
weaponactive = -1;
- }
-
- if (weaponactive == -1) {
emit_sound_at(knifesheathesound, coords);
}
- if (weaponactive != -1) {
- emit_sound_at(knifedrawsound, coords, 128);
- }
}
drawtogglekeydown = 1;
}
whichsound = footstepsound4;
}
}
- if (targetFrame().label == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
+ if (targetFrame().label == 4 && (!hasWeapon() || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
if (Animation::animations[animTarget].attack != neutral) {
unsigned r = abs(Random() % 3);
if (r == 0) {
if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim) {
if ((targetFrame().label && (targetFrame().label < 5 || targetFrame().label == 8))) {
int whichsound = -1;
- if (targetFrame().label == 4 && aitype != playercontrolled) {
+ if (targetFrame().label == 4 && !isPlayerControlled()) {
if (Animation::animations[animTarget].attack != neutral) {
unsigned r = abs(Random() % 4);
whichsound = PersonType::types[creature].soundsAttack[r];
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 (distsqflat(&coords, &weapons[i].position) < 4 && !hasWeapon()) {
if (distsq(&coords, &weapons[i].position) >= 1) {
if (weapons[i].getType() != staff) {
emit_sound_at(knifedrawsound, coords, 128.);
}
}
if ((weapons[i].owner == -1) || (hasvictim && (weapons[i].owner == int(victim->id)) && victim->skeleton.free)) {
- if (willwork && distsqflat(&coords, &weapons[i].position) < 3 && weaponactive == -1) {
+ if (willwork && distsqflat(&coords, &weapons[i].position) < 3 && !hasWeapon()) {
if (distsq(&coords, &weapons[i].position) < 1 || hasvictim) {
bool fleshstuck = false;
if (weapons[i].owner != -1) {
}
if (animCurrent == drawleftanim && currentFrame().label == 5) {
- if (weaponactive == -1) {
+ if (!hasWeapon()) {
weaponactive = 0;
+ emit_sound_at(knifedrawsound, coords, 128.);
} else if (weaponactive == 0) {
weaponactive = -1;
if (num_weapons == 2) {
weaponids[0] = weaponids[1];
weaponids[1] = buffer;
}
- }
- if (weaponactive == -1) {
emit_sound_at(knifesheathesound, coords, 128.);
}
- if (weaponactive != -1) {
- emit_sound_at(knifedrawsound, coords, 128.);
- }
}
if ((animCurrent == walljumprightkickanim && animTarget == walljumprightkickanim) || (animCurrent == walljumpleftkickanim && animTarget == walljumpleftkickanim)) {
camerashake += .4;
}
- if (weaponactive != -1) {
+ if (hasWeapon()) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
}
if (animCurrent == knifethrowanim && currentFrame().label == 5) {
- if (weaponactive != -1) {
+ if (hasWeapon()) {
escapednum = 0;
XYZ aim;
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);
emit_sound_at(knifeslicesound, victim->coords);
}
//victim->jointVel(abdomen)+=relative*damagemult*200;
- if (Animation::animations[victim->animTarget].attack && (victim->aitype != playercontrolled || victim->animTarget == knifeslashstartanim) && (victim->creature == rabbittype || victim->deathbleeding <= 0)) {
+ if (Animation::animations[victim->animTarget].attack && (!victim->isPlayerControlled() || victim->animTarget == knifeslashstartanim) && (victim->creature == rabbittype || victim->deathbleeding <= 0)) {
if (victim->id != 0 || difficulty == 2) {
victim->frameTarget = 0;
victim->animTarget = staggerbackhardanim;
}
victim->lowreversaldelay = 0;
victim->highreversaldelay = 0;
- if (aitype != playercontrolled) {
+ if (!isPlayerControlled()) {
weaponmissdelay = .6;
}
}
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)) {
+ if (!victim->hasWeapon() || normaldotproduct(victim->facing, victim->coords - coords) > 0 || (Random() % 2 == 0)) {
award_bonus(id, Slashbonus);
escapednum = 0;
if (!Tutorial::active) {
Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
}
} else {
- if (victim->weaponactive != -1) {
+ if (victim->hasWeapon()) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
}
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 (victim->hasWeapon() && victim->num_weapons > 0) {
if (weapons[victim->weaponids[victim->weaponactive]].owner == int(victim->id)) {
takeWeapon(victim->weaponids[victim->weaponactive]);
victim->num_weapons--;
award_bonus(id, Reversal);
bool doslice;
- if (weaponactive == -1) {
- doslice = PersonType::types[creature].hasClaws;
- } else {
+ if (hasWeapon()) {
doslice = (weapons[weaponids[0]].getType() != staff);
+ } else {
+ doslice = PersonType::types[creature].hasClaws;
}
if (doslice) {
- if (weaponactive == -1) {
+ if (!hasWeapon()) {
emit_sound_at(clawslicesound, victim->coords, 128.);
victim->spurt = 1;
victim->DoBloodBig(2 / victim->armorhigh, 175);
victim->damage = victim->damagetolerance;
victim->permanentdamage = victim->damagetolerance - 1;
bool doslice;
- if (weaponactive == -1) {
- doslice = PersonType::types[creature].hasClaws;
- } else {
+ if (hasWeapon()) {
doslice = (weapons[weaponids[0]].getType() != staff);
+ } else {
+ doslice = PersonType::types[creature].hasClaws;
}
if (doslice) {
- if (weaponactive == -1) {
+ if (!hasWeapon()) {
emit_sound_at(clawslicesound, victim->coords, 128.);
victim->spurt = 1;
victim->DoBloodBig(2, 175);
}
if (hasvictim && (animCurrent == knifefollowanim || animCurrent == knifesneakattackanim) && currentFrame().label == 5) {
- if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
+ if (hasWeapon() && victim->bloodloss < victim->damagetolerance) {
escapednum = 0;
if (animTarget == knifefollowanim) {
victim->DoBloodBig(200, 210);
victim->skeleton.joints[i].velocity = 0;
}
}
- if (weaponactive != -1 && Animation::animations[victim->animTarget].attack != reversal) {
+ if (hasWeapon() && Animation::animations[victim->animTarget].attack != reversal) {
emit_sound_at(fleshstabremovesound, victim->coords);
if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
}
if (hasvictim && (animCurrent == swordsneakattackanim) && currentFrame().label == 5) {
- if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
+ if (hasWeapon() && victim->bloodloss < victim->damagetolerance) {
award_bonus(id, backstab);
escapednum = 0;
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = 0;
}
- if (weaponactive != -1) {
+ if (hasWeapon()) {
emit_sound_at(fleshstabremovesound, victim->coords);
if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
victim->spurt = 1;
DoBlood(.2, 240);
}
- if (weaponactive == -1) {
+ if (!hasWeapon()) {
if (!Tutorial::active) {
emit_sound_at(heavyimpactsound, victim->coords, 128.);
}
}
bool doslice;
- if (weaponactive == -1) {
- doslice = PersonType::types[creature].hasClaws;
- } else {
+ if (hasWeapon()) {
doslice = (weapons[weaponids[0]].getType() != staff);
+ } else {
+ doslice = PersonType::types[creature].hasClaws;
}
if (doslice) {
- if (weaponactive == -1) {
+ if (!hasWeapon()) {
emit_sound_at(clawslicesound, victim->coords, 128.);
victim->spurt = 1;
victim->DoBloodBig(2 / victim->armorhead, 175);
if (animCurrent == crouchdrawrightanim) {
animTarget = getCrouch();
}
- if (weaponactive == -1) {
+ if (!hasWeapon()) {
weaponactive = 0;
+ emit_sound_at(knifedrawsound, coords, 128.);
} else if (weaponactive == 0) {
weaponactive = -1;
if (num_weapons == 2) {
weaponids[0] = weaponids[1];
weaponids[1] = buffer;
}
- }
-
- if (weaponactive == -1) {
emit_sound_at(knifesheathesound, coords, 128.);
}
- if (weaponactive != -1) {
- emit_sound_at(knifedrawsound, coords, 128.);
- }
}
if (animCurrent == rollanim) {
animTarget = getCrouch();
animTarget = getIdle();
lastfeint = 0;
}
- if (animCurrent == blockhighleftanim && aitype != playercontrolled) {
+ if (animCurrent == blockhighleftanim && !isPlayerControlled()) {
animTarget = blockhighleftstrikeanim;
}
if (animCurrent == knifeslashstartanim || animCurrent == knifethrowanim || animCurrent == swordslashanim || animCurrent == staffhitanim || animCurrent == staffgroundsmashanim || animCurrent == staffspinhitanim) {
targetoffset = 0;
}
- if (num_weapons == 1 && weaponactive != -1) {
+ if (num_weapons == 1 && hasWeapon()) {
weaponstuck = -1;
}
frameTarget = 0;
}
}
- if (weaponactive == -1 && num_weapons > 0) {
+ if (!hasWeapon() && num_weapons > 0) {
if (weapons[weaponids[0]].getType() == staff) {
weaponactive = 0;
}
deathbleeding = 0;
}
if (bloodloss > damagetolerance && Animation::animations[animTarget].attack == neutral) {
- if (weaponactive != -1) {
+ if (hasWeapon()) {
weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale);
weapons[weaponids[0]].velocity.x += .01;
num_weapons--;
RagDoll(0);
- if (weaponactive != -1) {
+ if (hasWeapon()) {
weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale);
weapons[weaponids[0]].velocity.x += .01;
num_weapons--;
if (permanentdamage > damagetolerance && dead != 2) {
DoBlood(1, 255);
- if (weaponactive != -1) {
+ if (hasWeapon()) {
weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale);
weapons[weaponids[0]].velocity.x += .01;
num_weapons--;
if (Tutorial::active && id != 0) {
play = 0;
}
- if (play && aitype != playercontrolled) {
+ if (play && !isPlayerControlled()) {
int whichsound = -1;
if (speechdelay <= 0) {
unsigned int i = abs(Random() % 4);
}
}
- if (weaponactive != -1) {
+ if (hasWeapon()) {
if (weapons[weaponids[weaponactive]].getType() != staff) {
righthandmorphstart = 1;
righthandmorphend = 1;
void Person::doAI()
{
- if (aitype != playercontrolled && !Dialog::inDialog()) {
+ if (!isPlayerControlled() && !Dialog::inDialog()) {
jumpclimb = 0;
//disable movement in editor
if (Game::editorenabled) {
lastseentime = 12;
if (!Person::players[0]->dead && ((!Tutorial::active || cananger) && hostile)) {
- if (ally < 0 || weaponactive != -1 || lastchecktime <= 0) {
+ if (ally < 0 || hasWeapon() || lastchecktime <= 0) {
aitype = attacktypecutoff;
lastseentime = 1;
}
if (isIdle()) {
crouchkeydown = 1;
}
- if (Person::players[0]->animTarget != rabbitkickanim && Person::players[0]->weaponactive != -1) {
+ if (Person::players[0]->animTarget != rabbitkickanim && Person::players[0]->hasWeapon()) {
if (weapons[Person::players[0]->weaponids[0]].getType() == knife) {
if (isIdle() || isCrouch() || isRun() || isFlip()) {
if (abs(Random() % 2) == 0) {
animTarget != backhandspringanim &&
animTarget != dodgebackanim) {
//draw weapon
- if (weaponactive == -1 && num_weapons > 0) {
+ if (!hasWeapon() && num_weapons > 0) {
drawkeydown = Random() % 2;
} else {
drawkeydown = 0;
lookyaw = targetyaw;
aiupdatedelay = .2 + fabs((float)(Random() % 100) / 1000);
- if (distsq(&coords, &Person::players[0]->coords) > 5 && (Person::players[0]->weaponactive == -1 || weaponactive != -1)) {
+ if (distsq(&coords, &Person::players[0]->coords) > 5 && (!Person::players[0]->hasWeapon() || hasWeapon())) {
forwardkeydown = 1;
} else if ((distsq(&coords, &Person::players[0]->coords) > 16 ||
distsq(&coords, &Person::players[0]->coords) < 9) &&
- Person::players[0]->weaponactive != -1) {
+ Person::players[0]->hasWeapon()) {
forwardkeydown = 1;
} else if (Random() % 6 == 0 || (creature == wolftype && Random() % 3 == 0)) {
forwardkeydown = 1;
targetyaw += 90 * (whichdirection * 2 - 1);
}
//attack!!!
- if (Random() % 2 == 0 || weaponactive != -1 || creature == wolftype) {
+ if (Random() % 2 == 0 || hasWeapon() || creature == wolftype) {
attackkeydown = 1;
} else {
attackkeydown = 0;
}
//TODO: wat
- if (aitype != playercontrolled &&
+ if (!isPlayerControlled() &&
(isIdle() ||
isCrouch() ||
isRun())) {
Person::players[j]->lastattack3 == Person::players[j]->animTarget &&
(Random() % 2 == 0 || difficulty == 2) ||
(isIdle() || isRun()) &&
- Person::players[j]->weaponactive != -1 ||
+ Person::players[j]->hasWeapon() ||
Person::players[j]->animTarget == swordslashanim &&
- weaponactive != -1 ||
+ hasWeapon() ||
Person::players[j]->animTarget == staffhitanim ||
Person::players[j]->animTarget == staffspinhitanim)) {
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 4 &&
Person::players[j]->animTarget == knifeslashstartanim ||
Person::players[j]->animTarget == swordslashanim &&
(distsq(&Person::players[j]->coords, &coords) < 2 ||
- weaponactive != -1))) {
+ hasWeapon()))) {
if (target >= 0) {
target = -1;
} else {
bool Person::catchKnife()
{
return
- ((PersonType::types[creature].knifeCatchingType == 0) && (Random() % 2 != 0) && (weaponactive == -1) && (aitype == attacktypecutoff)) ||
- ((PersonType::types[creature].knifeCatchingType == 1) && (Random() % 3 != 0) && (weaponactive == -1) && (isIdle() || isRun() || animTarget == walkanim));
+ ((PersonType::types[creature].knifeCatchingType == 0) && (Random() % 2 != 0) && (!hasWeapon()) && (aitype == attacktypecutoff)) ||
+ ((PersonType::types[creature].knifeCatchingType == 1) && (Random() % 3 != 0) && (!hasWeapon()) && (isIdle() || isRun() || animTarget == walkanim));
}