}
pause = 0;
- if (distsqflat(&Person::players[0]->coords, &coords) < 30 &&
- Person::players[0]->coords.y > coords.y + 2 &&
- !Person::players[0]->onterrain) {
+ if (distsqflat(&victim->coords, &coords) < 30 &&
+ victim->coords.y > coords.y + 2 &&
+ !victim->onterrain) {
pause = 1;
}
if ((!Tutorial::active || cananger) &&
hostile &&
!isPlayerFriend() &&
- !Person::players[0]->dead &&
- distsq(&coords, &Person::players[0]->coords) < 400 &&
+ !victim->dead &&
+ distsq(&coords, &victim->coords) < 400 &&
occluded < 25) {
- if (distsq(&coords, &Person::players[0]->coords) < 12 &&
- Animation::animations[Person::players[0]->animTarget].height != lowheight &&
+ if (distsq(&coords, &victim->coords) < 12 &&
+ Animation::animations[victim->animTarget].height != lowheight &&
!Game::editorenabled &&
- (Person::players[0]->coords.y < coords.y + 5 || Person::players[0]->onterrain)) {
+ (victim->coords.y < coords.y + 5 || victim->onterrain)) {
aitype = attacktypecutoff;
}
- if (distsq(&coords, &Person::players[0]->coords) < 30 &&
- Animation::animations[Person::players[0]->animTarget].height == highheight &&
+ if (distsq(&coords, &victim->coords) < 30 &&
+ Animation::animations[victim->animTarget].height == highheight &&
!Game::editorenabled) {
aitype = attacktypecutoff;
}
if (howactive < typesleeping &&
((!Tutorial::active || cananger) && hostile) &&
!isPlayerFriend() &&
- !Person::players[0]->dead &&
- distsq(&coords, &Person::players[0]->coords) < 400 &&
+ !victim->dead &&
+ distsq(&coords, &victim->coords) < 400 &&
occluded < 25) {
- if (distsq(&coords, &Person::players[0]->coords) < 12 &&
- Animation::animations[Person::players[0]->animTarget].height != lowheight && !Game::editorenabled) {
+ if (distsq(&coords, &victim->coords) < 12 &&
+ Animation::animations[victim->animTarget].height != lowheight && !Game::editorenabled) {
aitype = attacktypecutoff;
}
- if (distsq(&coords, &Person::players[0]->coords) < 30 &&
- Animation::animations[Person::players[0]->animTarget].height == highheight && !Game::editorenabled) {
+ if (distsq(&coords, &victim->coords) < 30 &&
+ Animation::animations[victim->animTarget].height == highheight && !Game::editorenabled) {
aitype = attacktypecutoff;
}
}
}
- if (!Person::players[0]->dead &&
+ if (!victim->dead &&
!isPlayerFriend() &&
losupdatedelay < 0 &&
!Game::editorenabled &&
occluded < 2 &&
((!Tutorial::active || cananger) && hostile)) {
losupdatedelay = .2;
- if (distsq(&coords, &Person::players[0]->coords) < 4 && Animation::animations[animTarget].height != lowheight) {
+ if (distsq(&coords, &victim->coords) < 4 && Animation::animations[animTarget].height != lowheight) {
aitype = attacktypecutoff;
lastseentime = 1;
}
if (abs(Random() % 2) || Animation::animations[animTarget].height != lowheight) {
//TODO: factor out canSeePlayer()
- if (distsq(&coords, &Person::players[0]->coords) < 400) {
- if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0) {
+ if (distsq(&coords, &victim->coords) < 400) {
+ if (normaldotproduct(facing, victim->coords - coords) > 0) {
if ((Object::checkcollide(
DoRotation(jointPos(head), 0, yaw, 0) *
scale +
coords,
- DoRotation(Person::players[0]->jointPos(head), 0, Person::players[0]->yaw, 0) *
- Person::players[0]->scale +
- Person::players[0]->coords) == -1) ||
- (Person::players[0]->animTarget == hanganim && normaldotproduct(Person::players[0]->facing, coords - Person::players[0]->coords) < 0)) {
+ DoRotation(victim->jointPos(head), 0, victim->yaw, 0) *
+ victim->scale +
+ victim->coords) == -1) ||
+ (victim->animTarget == hanganim && normaldotproduct(victim->facing, coords - victim->coords) < 0)) {
/* //TODO: changed j to 0 on a whim, make sure this is correct
(Person::players[j]->animTarget==hanganim&&normaldotproduct(
Person::players[j]->facing,coords-Person::players[j]->coords)<0)
} else {
ally = 0;
}
- lastseen = Person::players[0]->coords;
+ lastseen = victim->coords;
lastseentime = 12;
}
lastseentime = 12;
- if (!Person::players[0]->dead && !isPlayerFriend() && ((!Tutorial::active || cananger) && hostile)) {
+ if (!victim->dead && !isPlayerFriend() && ((!Tutorial::active || cananger) && hostile)) {
if (ally < 0 || hasWeapon() || lastchecktime <= 0) {
aitype = attacktypecutoff;
lastseentime = 1;
}
}
- if (!Person::players[0]->dead) {
+ if (!victim->dead) {
if (ally >= 0) {
if (weapons[ally].owner != -1 ||
distsq(&coords, &weapons[ally].position) > 16) {
aiupdatedelay -= multiplier;
//dodge or reverse rabbit kicks, knife throws, flips
if (damage < damagetolerance * 2 / 3) {
- if ((Person::players[0]->animTarget == rabbitkickanim ||
- Person::players[0]->animTarget == knifethrowanim ||
- (Person::players[0]->isFlip() &&
- normaldotproduct(Person::players[0]->facing, Person::players[0]->coords - coords) < 0)) &&
- !Person::players[0]->skeleton.free &&
+ if ((victim->animTarget == rabbitkickanim ||
+ victim->animTarget == knifethrowanim ||
+ (victim->isFlip() &&
+ normaldotproduct(victim->facing, victim->coords - coords) < 0)) &&
+ !victim->skeleton.free &&
(aiupdatedelay < .1)) {
attackkeydown = 0;
if (isIdle()) {
crouchkeydown = 1;
}
- if (Person::players[0]->animTarget != rabbitkickanim && Person::players[0]->hasWeapon()) {
- if (weapons[Person::players[0]->weaponids[0]].getType() == knife) {
+ if (victim->animTarget != rabbitkickanim && victim->hasWeapon()) {
+ if (weapons[victim->weaponids[0]].getType() == knife) {
if (isIdle() || isCrouch() || isRun() || isFlip()) {
if (abs(Random() % 2) == 0) {
setTargetAnimation(backhandspringanim);
}
}
//get confused by flips
- if (Person::players[0]->isFlip() &&
- !Person::players[0]->skeleton.free &&
- Person::players[0]->animTarget != walljumprightkickanim &&
- Person::players[0]->animTarget != walljumpleftkickanim) {
- if (distsq(&Person::players[0]->coords, &coords) < 25) {
+ if (victim->isFlip() &&
+ !victim->skeleton.free &&
+ victim->animTarget != walljumprightkickanim &&
+ victim->animTarget != walljumpleftkickanim) {
+ if (distsq(&victim->coords, &coords) < 25) {
if ((1 - damage / damagetolerance) > .5) {
stunned = 1;
}
if (damage < damagetolerance / 2) {
if (Animation::animations[animTarget].height != highheight) {
if (damage < damagetolerance * .5 &&
- ((Person::players[0]->animTarget == walljumprightkickanim ||
- Person::players[0]->animTarget == walljumpleftkickanim) &&
+ ((victim->animTarget == walljumprightkickanim ||
+ victim->animTarget == walljumpleftkickanim) &&
((aiupdatedelay < .15 &&
difficulty == 2) ||
(aiupdatedelay < .08 &&
}
}
//lose sight of player in the air (?)
- if (Person::players[0]->coords.y > coords.y + 5 &&
- Animation::animations[Person::players[0]->animTarget].height != highheight &&
- !Person::players[0]->onterrain) {
+ if (victim->coords.y > coords.y + 5 &&
+ Animation::animations[victim->animTarget].height != highheight &&
+ !victim->onterrain) {
aitype = pathfindtype;
finalfinaltarget = waypoints[waypoint];
finalpathfindpoint = -1;
}
rabbitkickenabled = Random() % 2;
//chase player
- XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity;
- XYZ targetpoint = Person::players[0]->coords;
+ XYZ rotatetarget = victim->coords + victim->velocity;
+ XYZ targetpoint = victim->coords;
float vellength = findLength(&velocity);
if (vellength != 0 &&
- distsq(&Person::players[0]->coords, &coords) < distsq(&rotatetarget, &coords)) {
- targetpoint += Person::players[0]->velocity *
- findDistance(&Person::players[0]->coords, &coords) / vellength;
+ distsq(&victim->coords, &coords) < distsq(&rotatetarget, &coords)) {
+ targetpoint += victim->velocity *
+ findDistance(&victim->coords, &coords) / vellength;
}
targetyaw = roughDirectionTo(coords, targetpoint);
lookyaw = targetyaw;
aiupdatedelay = .2 + fabs((float)(Random() % 100) / 1000);
- if (distsq(&coords, &Person::players[0]->coords) > 5 && (!Person::players[0]->hasWeapon() || hasWeapon())) {
+ if (distsq(&coords, &victim->coords) > 5 && (!victim->hasWeapon() || hasWeapon())) {
forwardkeydown = 1;
- } else if ((distsq(&coords, &Person::players[0]->coords) > 16 ||
- distsq(&coords, &Person::players[0]->coords) < 9) &&
- Person::players[0]->hasWeapon()) {
+ } else if ((distsq(&coords, &victim->coords) > 16 ||
+ distsq(&coords, &victim->coords) < 9) &&
+ victim->hasWeapon()) {
forwardkeydown = 1;
} else if (Random() % 6 == 0 || (creature == wolftype && Random() % 3 == 0)) {
forwardkeydown = 1;
forwardkeydown = 0;
}
//chill out around the corpse
- if (Person::players[0]->dead) {
+ if (victim->dead) {
forwardkeydown = 0;
if (Random() % 10 == 0) {
forwardkeydown = 1;
} else {
attackkeydown = 0;
}
- if (isRun() && Random() % 6 && distsq(&coords, &Person::players[0]->coords) > 7) {
+ if (isRun() && Random() % 6 && distsq(&coords, &victim->coords) > 7) {
attackkeydown = 0;
}
jumpkeydown = 0;
}
if (collided > .8 && jumppower >= 5 ||
- distsq(&coords, &Person::players[0]->coords) > 400 &&
+ distsq(&coords, &victim->coords) > 400 &&
onterrain &&
creature == rabbittype) {
jumpkeydown = 1;
}
//TODO: why are we controlling the human?
- if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0) {
- Person::players[0]->jumpkeydown = 0;
+ if (normaldotproduct(facing, victim->coords - coords) > 0) {
+ victim->jumpkeydown = 0;
}
- if (Person::players[0]->animTarget == jumpdownanim &&
- distsq(&Person::players[0]->coords, &coords) < 40) {
+ if (victim->animTarget == jumpdownanim &&
+ distsq(&victim->coords, &coords) < 40) {
crouchkeydown = 1;
}
if (jumpkeydown) {
}
XYZ facing = coords;
- XYZ flatfacing = Person::players[0]->coords;
+ XYZ flatfacing = victim->coords;
facing.y += jointPos(head).y * scale;
- flatfacing.y += Person::players[0]->jointPos(head).y * Person::players[0]->scale;
+ flatfacing.y += victim->jointPos(head).y * victim->scale;
if (occluded >= 2) {
if (-1 != Object::checkcollide(facing, flatfacing)) {
if (!pause) {
weaponstuck == -1)) {
aitype = searchtype;
lastchecktime = 12;
- lastseen = Person::players[0]->coords;
+ lastseen = victim->coords;
lastseentime = 12;
}
} else {
}
}
}
- if (Animation::animations[Person::players[0]->animTarget].height == highheight &&
+ if (Animation::animations[victim->animTarget].height == highheight &&
(aitype == attacktypecutoff ||
aitype == searchtype)) {
- if (Person::players[0]->coords.y > terrain.getHeight(Person::players[0]->coords.x, Person::players[0]->coords.z) + 10) {
- XYZ test = Person::players[0]->coords;
+ if (victim->coords.y > terrain.getHeight(victim->coords.x, victim->coords.z) + 10) {
+ XYZ test = victim->coords;
test.y -= 40;
- if (-1 == Object::checkcollide(Person::players[0]->coords, test)) {
+ if (-1 == Object::checkcollide(victim->coords, test)) {
stunned = 1;
}
}