From be5fc624393b132863a7d9a97c811bc695b86e5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Sat, 19 Aug 2017 12:55:56 +0200 Subject: [PATCH 01/16] Added methods for hasWeapon and isPlayerControlled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some tests on id == 0 may be replaced by isPlayerControlled as well, but it does not always makes sense (I’d say stuff specific to main player should still test id == 0) --- Source/GameTick.cpp | 82 +++++++++--------- Source/Objects/Person.cpp | 170 +++++++++++++++++--------------------- Source/Objects/Person.hpp | 3 + Source/Tutorial.cpp | 4 +- 4 files changed, 124 insertions(+), 135 deletions(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index c7075da..4ff18e8 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -1643,8 +1643,8 @@ void doJumpReversals() 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) && @@ -1655,8 +1655,8 @@ void doJumpReversals() 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; @@ -1695,8 +1695,8 @@ void doJumpReversals() 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; @@ -1801,7 +1801,7 @@ void doAerialAcrobatics() 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 && @@ -1823,7 +1823,7 @@ void doAerialAcrobatics() 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()) && @@ -1979,7 +1979,7 @@ void doAerialAcrobatics() 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() || @@ -2157,7 +2157,7 @@ void doAttacks() 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 && @@ -2189,7 +2189,7 @@ void doAttacks() 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 @@ -2244,7 +2244,7 @@ void doAttacks() 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) { @@ -2271,7 +2271,7 @@ void doAttacks() 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 && @@ -2657,7 +2657,7 @@ void doAttacks() } } } - if (Person::players[k]->aitype == playercontrolled) { + if (Person::players[k]->isPlayerControlled()) { //rabbit kick if (Person::players[k]->attackkeydown && Person::players[k]->isRun() && @@ -2669,7 +2669,7 @@ void doAttacks() 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)) { @@ -3462,7 +3462,7 @@ void Game::Tick() 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 && @@ -3599,7 +3599,7 @@ void Game::Tick() //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() || @@ -3607,19 +3607,19 @@ void Game::Tick() 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); @@ -3630,11 +3630,11 @@ void Game::Tick() 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.); @@ -3647,7 +3647,7 @@ void Game::Tick() } } 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()) { @@ -3660,14 +3660,14 @@ void Game::Tick() 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.); } @@ -3689,7 +3689,7 @@ void Game::Tick() 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 && @@ -3790,7 +3790,7 @@ void Game::Tick() } } } - 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() || @@ -3815,7 +3815,7 @@ void Game::Tick() 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; @@ -3841,7 +3841,7 @@ void Game::Tick() } } } - 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; @@ -3866,16 +3866,16 @@ void Game::Tick() } //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; } @@ -3886,8 +3886,8 @@ void Game::Tick() 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) { @@ -3903,7 +3903,7 @@ void Game::Tick() } //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 && @@ -4081,7 +4081,7 @@ void Game::Tick() } 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; @@ -4242,7 +4242,7 @@ void Game::Tick() } 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 { @@ -4278,7 +4278,7 @@ void Game::Tick() (((!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; diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 279fb32..d0e8f08 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -596,14 +596,14 @@ int Person::getIdle() 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) { @@ -613,7 +613,7 @@ int Person::getIdle() return swordfightidleanim; } } - if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause) { + if (!isPlayerControlled() && (stunned <= 0) && creature != wolftype) { return fightsidestep; } } @@ -658,7 +658,7 @@ int Person::getCrouch() */ int Person::getRun() { - if (superruntoggle && (weaponactive == -1)) { + if (superruntoggle && (!hasWeapon())) { return PersonType::types[creature].animRunning; } else { return PersonType::types[creature].animRun; @@ -786,7 +786,7 @@ void Person::DoBloodBig(float howmuch, int which) } if (!Tutorial::active || id == 0) { - if (aitype != playercontrolled && howmuch > 0) { + if (!isPlayerControlled() && howmuch > 0) { // play pain sounds int whichsound = -1; @@ -966,7 +966,7 @@ void Person::DoBloodBig(float howmuch, int which) 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; @@ -1175,7 +1175,7 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) 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; @@ -1195,7 +1195,7 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) */ 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; } @@ -1228,7 +1228,7 @@ void Person::Reverse() 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) { @@ -1255,7 +1255,7 @@ void Person::Reverse() 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) { @@ -1281,7 +1281,7 @@ void Person::Reverse() 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) { @@ -1307,7 +1307,7 @@ void Person::Reverse() 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) { @@ -1360,7 +1360,7 @@ void Person::Reverse() 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; @@ -1371,7 +1371,7 @@ void Person::Reverse() 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; @@ -1408,7 +1408,7 @@ void Person::Reverse() } 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; @@ -1493,7 +1493,7 @@ void Person::Reverse() velocity = 0; victim->velocity = 0; - if (aitype != playercontrolled) { + if (!isPlayerControlled()) { feint = 0; if (escapednum < 2) { int chances = ((difficulty == 2) ? 3 : ((difficulty == 1) ? 5 : 10)); @@ -1553,7 +1553,7 @@ void Person::DoDamage(float howmuch) 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; @@ -1596,7 +1596,7 @@ void Person::DoDamage(float howmuch) // play sounds if (!Tutorial::active || id == 0) { - if (speechdelay <= 0 && !dead && aitype != playercontrolled) { + if (speechdelay <= 0 && !dead && !isPlayerControlled()) { int whichsound = -1; if (creature == wolftype) { @@ -1889,7 +1889,7 @@ void Person::RagDoll(bool checkcollision) // 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--; @@ -2047,11 +2047,11 @@ void Person::DoAnimations() } 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()) { @@ -2101,20 +2101,15 @@ void Person::DoAnimations() } } - 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; } @@ -2155,7 +2150,7 @@ void Person::DoAnimations() 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) { @@ -2205,7 +2200,7 @@ void Person::DoAnimations() 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]; @@ -2235,7 +2230,7 @@ void Person::DoAnimations() 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.); @@ -2261,7 +2256,7 @@ void Person::DoAnimations() } } 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) { @@ -2335,8 +2330,9 @@ void Person::DoAnimations() } 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) { @@ -2345,13 +2341,8 @@ void Person::DoAnimations() 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)) { @@ -3017,7 +3008,7 @@ void Person::DoAnimations() 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; @@ -3037,7 +3028,7 @@ void Person::DoAnimations() } 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); @@ -3064,7 +3055,7 @@ void Person::DoAnimations() 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; @@ -3074,7 +3065,7 @@ void Person::DoAnimations() } victim->lowreversaldelay = 0; victim->highreversaldelay = 0; - if (aitype != playercontrolled) { + if (!isPlayerControlled()) { weaponmissdelay = .6; } @@ -3110,7 +3101,7 @@ void Person::DoAnimations() } 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) { @@ -3153,7 +3144,7 @@ void Person::DoAnimations() 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; @@ -3470,7 +3461,7 @@ void Person::DoAnimations() } 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--; @@ -3561,13 +3552,13 @@ void Person::DoAnimations() 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); @@ -3650,13 +3641,13 @@ void Person::DoAnimations() 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); @@ -3673,7 +3664,7 @@ void Person::DoAnimations() } 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); @@ -3729,7 +3720,7 @@ void Person::DoAnimations() 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; @@ -3751,7 +3742,7 @@ void Person::DoAnimations() } 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; @@ -3785,7 +3776,7 @@ void Person::DoAnimations() 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; @@ -3815,19 +3806,19 @@ void Person::DoAnimations() 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); @@ -3925,8 +3916,9 @@ void Person::DoAnimations() 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) { @@ -3935,14 +3927,8 @@ void Person::DoAnimations() 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(); @@ -4296,7 +4282,7 @@ void Person::DoAnimations() 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) { @@ -4518,7 +4504,7 @@ void Person::DoStuff() targetoffset = 0; } - if (num_weapons == 1 && weaponactive != -1) { + if (num_weapons == 1 && hasWeapon()) { weaponstuck = -1; } @@ -4565,7 +4551,7 @@ void Person::DoStuff() frameTarget = 0; } } - if (weaponactive == -1 && num_weapons > 0) { + if (!hasWeapon() && num_weapons > 0) { if (weapons[weaponids[0]].getType() == staff) { weaponactive = 0; } @@ -4677,7 +4663,7 @@ void Person::DoStuff() 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--; @@ -5108,7 +5094,7 @@ void Person::DoStuff() RagDoll(0); - if (weaponactive != -1) { + if (hasWeapon()) { weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale); weapons[weaponids[0]].velocity.x += .01; num_weapons--; @@ -5165,7 +5151,7 @@ void Person::DoStuff() 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--; @@ -5699,7 +5685,7 @@ void Person::DoStuff() 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); @@ -5885,7 +5871,7 @@ void Person::DoStuff() } } - if (weaponactive != -1) { + if (hasWeapon()) { if (weapons[weaponids[weaponactive]].getType() != staff) { righthandmorphstart = 1; righthandmorphend = 1; @@ -7338,7 +7324,7 @@ bool Person::addClothes(const int& clothesId) void Person::doAI() { - if (aitype != playercontrolled && !Dialog::inDialog()) { + if (!isPlayerControlled() && !Dialog::inDialog()) { jumpclimb = 0; //disable movement in editor if (Game::editorenabled) { @@ -8011,7 +7997,7 @@ void Person::doAI() 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; } @@ -8083,7 +8069,7 @@ void Person::doAI() 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) { @@ -8197,7 +8183,7 @@ void Person::doAI() animTarget != backhandspringanim && animTarget != dodgebackanim) { //draw weapon - if (weaponactive == -1 && num_weapons > 0) { + if (!hasWeapon() && num_weapons > 0) { drawkeydown = Random() % 2; } else { drawkeydown = 0; @@ -8216,11 +8202,11 @@ void Person::doAI() 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; @@ -8254,7 +8240,7 @@ void Person::doAI() 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; @@ -8264,7 +8250,7 @@ void Person::doAI() } //TODO: wat - if (aitype != playercontrolled && + if (!isPlayerControlled() && (isIdle() || isCrouch() || isRun())) { @@ -8280,9 +8266,9 @@ void Person::doAI() 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 && @@ -8297,7 +8283,7 @@ void Person::doAI() 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 { @@ -8421,6 +8407,6 @@ void Person::doAI() 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)); } diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index 9492fb7..89d5b40 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -402,6 +402,9 @@ public: void doAI(); bool catchKnife(); + + bool hasWeapon() { return (weaponactive != -1); } + bool isPlayerControlled() { return (aitype == playercontrolled); } }; const int maxplayers = 10; diff --git a/Source/Tutorial.cpp b/Source/Tutorial.cpp index 22ec959..c60ad9b 100644 --- a/Source/Tutorial.cpp +++ b/Source/Tutorial.cpp @@ -302,7 +302,7 @@ void Tutorial::Do(float multiplier) Person::players[1]->num_weapons = 1; Person::players[1]->weaponids[0] = 0; - if (Person::players[0]->weaponactive != -1) { + if (Person::players[0]->hasWeapon()) { weapons[Person::players[0]->weaponids[Person::players[0]->weaponactive]].setType(staff); } else { weapons[0].setType(staff); @@ -508,7 +508,7 @@ void Tutorial::Do(float multiplier) } break; case 41: - if (Person::players[0]->weaponactive == -1 && Person::players[0]->num_weapons > 0) { + if (!Person::players[0]->hasWeapon() && Person::players[0]->num_weapons > 0) { success = 1; } break; -- 2.39.2 From e3db4dc898a65d75d1cf45325ab1e2c9f477eaa3 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sat, 2 Sep 2017 09:45:43 -0400 Subject: [PATCH 02/16] CI: Enable CentOS Continuous Release (CR) repository for oldgcc target With things in flux between CentOS and EPEL while CentOS 7.4 is prepared, the CR repository will ensure dependencies can be found for EPEL. Since EPEL targets Red Hat Enterprise Linux specifically, EPEL for RHEL 7 has already moved onto RHEL 7.4, but CentOS 7.4 hasn't been released yet. --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78b2dfe..728cd03 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ cache: variables: YUMDNF: dnf EXTRA_REPO_INST_COMMAND: /bin/true + EXTRA_REPO_CONFIGURE_COMMAND: /bin/true JPEG_PACKAGE: "pkgconfig(libjpeg)" CMAKE_PACKAGE: "/usr/bin/cmake" DEPENDENCY_PACKAGES: "pkgconfig(openal) pkgconfig(sdl2) pkgconfig(glu) pkgconfig(libpng) pkgconfig(vorbis) pkgconfig(vorbisfile) pkgconfig(ogg)" @@ -15,13 +16,15 @@ variables: before_script: - $EXTRA_REPO_INST_COMMAND + - $EXTRA_REPO_CONFIGURE_COMMAND - $YUMDNF --quiet --assumeyes install $COMMON_PACKAGES build_oldgcc: image: centos:7 variables: YUMDNF: yum - EXTRA_REPO_INST_COMMAND: "yum --quiet --assumeyes install epel-release" + EXTRA_REPO_INST_COMMAND: "yum --quiet --assumeyes install epel-release yum-utils" + EXTRA_REPO_CONFIGURE_COMMAND: "yum-config-manager --enable cr" JPEG_PACKAGE: "libjpeg-devel" CMAKE_PACKAGE: "/usr/bin/cmake3" COMPILER_PACKAGES: "gcc gcc-c++" -- 2.39.2 From f6a6e022ec1a6b41f6283497e41a68b000a37b67 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sat, 2 Sep 2017 10:05:39 -0400 Subject: [PATCH 03/16] CMake: Remove OggVorbis CMake module and use pkg_check_modules We've long since moved from CMake 2.6 and require at least CMake 3.0, which includes support for leveraging pkgconfig modules. Let's use that for the Ogg Vorbis libraries. --- CMake/Modules/COPYING-CMAKE-SCRIPTS | 22 ------- CMake/Modules/FindOggVorbis.cmake | 91 ----------------------------- CMakeLists.txt | 7 +-- 3 files changed, 3 insertions(+), 117 deletions(-) delete mode 100644 CMake/Modules/COPYING-CMAKE-SCRIPTS delete mode 100644 CMake/Modules/FindOggVorbis.cmake diff --git a/CMake/Modules/COPYING-CMAKE-SCRIPTS b/CMake/Modules/COPYING-CMAKE-SCRIPTS deleted file mode 100644 index 4b41776..0000000 --- a/CMake/Modules/COPYING-CMAKE-SCRIPTS +++ /dev/null @@ -1,22 +0,0 @@ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/CMake/Modules/FindOggVorbis.cmake b/CMake/Modules/FindOggVorbis.cmake deleted file mode 100644 index 8f90b9d..0000000 --- a/CMake/Modules/FindOggVorbis.cmake +++ /dev/null @@ -1,91 +0,0 @@ -# - Try to find the OggVorbis libraries -# Once done this will define -# -# OGGVORBIS_FOUND - system has OggVorbis -# OGGVORBIS_VERSION - set either to 1 or 2 -# OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory -# OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis -# OGG_LIBRARY - The Ogg library -# VORBIS_LIBRARY - The Vorbis library -# VORBISFILE_LIBRARY - The VorbisFile library -# VORBISENC_LIBRARY - The VorbisEnc library - -# Copyright (c) 2006, Richard Laerkaeng, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -include (CheckLibraryExists) - -find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) -find_path(OGG_INCLUDE_DIR ogg/ogg.h) - -find_library(OGG_LIBRARY NAMES ogg) -find_library(VORBIS_LIBRARY NAMES vorbis) -find_library(VORBISFILE_LIBRARY NAMES vorbisfile) -find_library(VORBISENC_LIBRARY NAMES vorbisenc) - -mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR - OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY) - - -if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - set(OGGVORBIS_FOUND TRUE) - - set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY}) - - set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES}) - check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) - set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP}) - - if (HAVE_LIBVORBISENC2) - set (OGGVORBIS_VERSION 2) - else (HAVE_LIBVORBISENC2) - set (OGGVORBIS_VERSION 1) - endif (HAVE_LIBVORBISENC2) - -else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - set (OGGVORBIS_VERSION) - set(OGGVORBIS_FOUND FALSE) -endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - - -if (OGGVORBIS_FOUND) - if (NOT OggVorbis_FIND_QUIETLY) - message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}") - endif (NOT OggVorbis_FIND_QUIETLY) -else (OGGVORBIS_FOUND) - if (OggVorbis_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find OggVorbis libraries") - endif (OggVorbis_FIND_REQUIRED) - if (NOT OggVorbis_FIND_QUITELY) - message(STATUS "Could NOT find OggVorbis libraries") - endif (NOT OggVorbis_FIND_QUITELY) -endif (OGGVORBIS_FOUND) - -#check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H) -#check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG) -#check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS) -#check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE) -#check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC) -#check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) - -#if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) -# message(STATUS "Ogg/Vorbis found") -# set (VORBIS_LIBS "-lvorbis") -# set (OGG_LIBS "-logg") -# set (VORBISFILE_LIBS "-lvorbisfile") -# set (VORBISENC_LIBS "-lvorbisenc") -# set (OGGVORBIS_FOUND TRUE) -# if (HAVE_LIBVORBISENC2) -# set (HAVE_VORBIS 2) -# else (HAVE_LIBVORBISENC2) -# set (HAVE_VORBIS 1) -# endif (HAVE_LIBVORBISENC2) -#else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) -# message(STATUS "Ogg/Vorbis not found") -#endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) - - diff --git a/CMakeLists.txt b/CMakeLists.txt index 30616f4..f65500d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,8 +37,6 @@ if(LINUX) option(SYSTEM_INSTALL "Enable system-wide installation, with hardcoded data directory defined with CMAKE_INSTALL_DATADIR" OFF) endif(LINUX) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/Modules/") - ### Version @@ -219,7 +217,8 @@ endif(APPLE) find_package(PNG REQUIRED) find_package(JPEG REQUIRED) -find_package(OggVorbis REQUIRED) + +pkg_check_modules(VORBISFILE vorbisfile REQUIRED) include_directories( ${OPENAL_INCLUDE_DIR} @@ -231,7 +230,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/Source ) -set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${SDL2_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${VORBISFILE_LIBRARY} ${PLATFORM_LIBS}) +set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${SDL2_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${VORBISFILE_LIBRARIES} ${PLATFORM_LIBS}) ### Definitions -- 2.39.2 From 4ecda9ec4241bc59f14807ddef29ee45a2be903b Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 12 Feb 2017 16:03:26 +0100 Subject: [PATCH 04/16] Clothes paths fix: add changes for new mods Used to fix the mods in https://gitlab.com/osslugaru/nonfree-mods --- Misc/list-hardcoded-paths-fixes.txt | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Misc/list-hardcoded-paths-fixes.txt b/Misc/list-hardcoded-paths-fixes.txt index 0949fc2..40d8d86 100644 --- a/Misc/list-hardcoded-paths-fixes.txt +++ b/Misc/list-hardcoded-paths-fixes.txt @@ -1,12 +1,21 @@ :Data:Textures:armor.png Textures/LeatherArmor.png +:Data:Textures:bandage.png Textures/Bandage.png +:Data:Textures:beaten.png Textures/BloodOpal.png +:Data:Textures:belt.png Textures/Belt.png +:Data:Textures:beta.png Textures/BloodWolfDark.png :Data:Textures:bloodapril.png Textures/BloodApril.png +:Data:Textures:BloodApril.png Textures/BloodApril.png :Data:Textures:bloodclover.png Textures/BloodClover.png +:Data:Textures:BloodClover.png Textures/BloodClover.png :Data:Textures:bloodjack.png Textures/BloodJack.png :Data:Textures:bloodtrixie.png Textures/BloodTrixie.png +:Data:Textures:BloodTrixie.png Textures/BloodTrixie.png +:Data:Textures:claireblood.png Textures/BloodFoxLight.png :Data:Textures:clfeng.png Textures/ClFeng.png :Data:Textures:clhuo.png Textures/ClHuo.png :Data:Textures:clshan.png Textures/ClShan.png :Data:Textures:clshui.png Textures/ClShui.png +:Data:Textures:darkarmor.png Textures/LeatherArmor.png :Data:Textures:desertcl.png Textures/DesertCl.png :Data:Textures:earwrap.png Textures/EarWrap.png :Data:Textures:fancypantscamoarcitc.png Textures/FancyPantsCamoArctic.png @@ -18,27 +27,64 @@ :Data:Textures:femaleshirt.png Textures/ShirtFemale.png :Data:Textures:fire.png Textures/Fire.jpg :Data:Textures:footwrap.png Textures/FootWrap.png +:Data:Textures:fox.png Textures/FurFox.png +:Data:Textures:foxmimablood.png Textures/BloodFoxHeavy.png +:Data:Textures:foxpants.png Textures/FoxPants.png :Data:Textures:gibottom.png Textures/GiBottom.png :Data:Textures:gi.png Textures/Gi.png :Data:Textures:giteared.png Textures/GiTeared.png :Data:Textures:gitop.png Textures/GiTop.png +:Data:Textures:goggles.png Textures/Goggles.png +:Data:Textures:Goggles.png Textures/Goggles.png :Data:Textures:headband.png Textures/HeadBand.png :Data:Textures:headban.png Textures/HeadBand.png +:Data:Textures:ironarmor.png Textures/IronArmor.png +:Data:Textures:Ironarmor.png Textures/IronArmor.png +:Data:Textures:ironpants.png Textures/IronPants.png +:Data:Textures:Ironpants.png Textures/IronPants.png +:Data:Textures:ironwristleft.png Textures/IronWristLeft.png +:Data:Textures:Ironwristleft.png Textures/IronWristLeft.png +:Data:Textures:ironwrist left.png Textures/IronWristLeft.png +:Data:Textures:ironwristright.png Textures/IronWristRight.png +:Data:Textures:Ironwristright.png Textures/IronWristRight.png :Data:Textures:leatherarmor.png Textures/LeatherArmor.png +:Data:Textures:leatherarmor2.png Textures/LeatherArmor2.png +:Data:Textures:leatherarmor3.png Textures/LeatherArmor3.png :Data:Textures:leatheraromr.png Textures/LeatherArmor.png :Data:Textures:leatherpants.png Textures/LeatherPants.png +:Data:Textures:leatherpants2.png Textures/LeatherPants2.png +:Data:Textures:leatherpants3.png Textures/LeatherPants3.png :Data:Textures:leatherwrapright.png Textures/LeatherWristRight.png :Data:Textures:leatherwristleft.png Textures/LeatherWristLeft.png +:Data:Textures:leatherwristleft2.png Textures/LeatherWristLeft2.png +:Data:Textures:Leatherwristleft2.png Textures/LeatherWristLeft2.png +:Data:Textures:leatherwristleft3.png Textures/LeatherWristLeft3.png :Data:Textures:leatherwristlet.png Textures/LeatherWristLeft.png :Data:Textures:leatherwristright.png Textures/LeatherWristRight.png +:Data:Textures:leatherwristright2.png Textures/LeatherWristRight2.png +:Data:Textures:Leatherwristright2.png Textures/LeatherWristRight2.png +:Data:Textures:leatherwristright3.png Textures/LeatherWristRight3.png :Data:Textures:lognsleeve.png Textures/LongSleeve.png :Data:Textures:longsleeve .png Textures/LongSleeve.png :Data:Textures:longsleeve.png Textures/LongSleeve.png :Data:Textures:lonsleeve.png Textures/LongSleeve.png +:Data:Textures:longsleeveltbl.png Textures/LongSleeveLightBlood.png +:Data:Textures:longsleevemedbl.png Textures/LongSleeveMediumBlood.png +:Data:Textures:longsleevehvybl.png Textures/LongSleeveHeavyBlood.png +:Data:Textures:longsleeveveryhvybl.png Textures/LongSleeveVeryHeavyBlood.png +:Data:Textures:longsleeveTblood.png Textures/LongSleeveTBlood.png +:Data:Textures:longsleeveTblood2.png Textures/LongSleeveTBlood2.png +:Data:Textures:longsleeveTblood3.png Textures/LongSleeveTBlood3.png +:Data:Textures:longsleeveTblood4.png Textures/LongSleeveTBlood4.png :Data:Textures:mask.png Textures/Mask.png +:Data:Textures:oakeyblood.png Textures/BloodOakey.png :Data:Textures:pants.png Textures/Pants.png +:Data:Textures:scar.png Textures/Scar.png :Data:Textures:shirtfemale.png Textures/ShirtFemale.png :Data:Textures:shirt.png Textures/Shirt.png :Data:Textures:shirts.png Textures/Shirt.png :Data:Textures:shrit.png Textures/Shirt.png +:Data:Textures:sick.png Textures/Sick.png +:Data:Textures:sick2.png Textures/Sick2.png +:Data:Textures:vest.png Textures/Vest.png :Data:Textures:world.png Textures/World.png -- 2.39.2 From 8f8250f231122f66e75fc83506dd51dbce948dd0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 6 Sep 2017 14:11:30 +0200 Subject: [PATCH 05/16] OpenAL: Fix dispose logic on Linux We no longer know what were the problems Ryan refers to, but the code seems to work just fine with recent OpenAL and solves this error: AL lib: (EE) alc_cleanup: 1 device not closed Might help with #98. --- Source/GameInitDispose.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index a1e9603..85be118 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -88,16 +88,11 @@ void Dispose() OPENAL_StopSound(OPENAL_ALL); -// this is causing problems on Linux, but we'll force an _exit() a little -// later in the shutdown process. --ryan. -#if !PLATFORM_LINUX - for (int i = 0; i < sounds_count; ++i) { OPENAL_Sample_Free(samp[i]); } OPENAL_Close(); -#endif } void Game::newGame() -- 2.39.2 From a8e0e96af3222c42663b3c60158caed20ac46829 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 6 Sep 2017 14:31:42 +0200 Subject: [PATCH 06/16] Fix unused-result warning for chdir Fixes this warning: Source/main.cpp: In function 'void chdirToAppPath(const char*)': Source/main.cpp:581:14: warning: ignoring return value of 'int chdir(const char*)', declared with attribute warn_unused_result [-Wunused-result] chdir(dir); ~~~~~^~~~~ --- Source/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/main.cpp b/Source/main.cpp index e0270b6..cacfabd 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -579,7 +579,10 @@ static inline void chdirToAppPath(const char* argv0) *ptr = '\0'; } #endif - chdir(dir); + errno = 0; + if (chdir(dir) != 0) { + printf("Error changing dir to '%s' (%s).\n", dir, strerror(errno)); + } free(dir); } } -- 2.39.2 From 4dfbee7192000c0047a73d48fb10a33d39261d89 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 10 Dec 2017 21:05:13 +0000 Subject: [PATCH 07/16] In case the resolution settings in the config file have wrong values, the main window is not appearing, forcing here minimum decent values. --- Source/Globals.cpp | 2 ++ Source/User/Settings.cpp | 20 ++++++++++---------- Source/User/Settings.hpp | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Source/Globals.cpp b/Source/Globals.cpp index 3a4d544..41d81cb 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -46,6 +46,8 @@ int difficulty = 0; float multiplier = 0; float realmultiplier = 0; float screenwidth = 0, screenheight = 0; +float minscreenwidth = 640, minscreenheight = 480; +float maxscreenwidth = 3000, maxscreenheight = 3000; bool fullscreen = 0; float viewdistance = 0; XYZ viewer; diff --git a/Source/User/Settings.cpp b/Source/User/Settings.cpp index fedc77e..4890f45 100644 --- a/Source/User/Settings.cpp +++ b/Source/User/Settings.cpp @@ -76,16 +76,10 @@ void SaveSettings() if (newdetail > 2) { newdetail = 2; } - if (newscreenwidth > 3000) { + if (newscreenwidth < minscreenwidth || newscreenwidth > maxscreenwidth) { newscreenwidth = screenwidth; } - if (newscreenwidth < 0) { - newscreenwidth = screenwidth; - } - if (newscreenheight > 3000) { - newscreenheight = screenheight; - } - if (newscreenheight < 0) { + if (newscreenheight < minscreenheight || newscreenheight > maxscreenheight) { newscreenheight = screenheight; } errno = 0; @@ -207,8 +201,14 @@ bool LoadSettings() if (!strncmp(setting, "Screenwidth", 11)) { ipstream >> kContextWidth; + if (kContextWidth < (int)minscreenwidth || kContextWidth > (int)maxscreenwidth) { + kContextWidth = (int)minscreenwidth; + } } else if (!strncmp(setting, "Screenheight", 12)) { ipstream >> kContextHeight; + if (kContextHeight < (int)minscreenheight || kContextHeight > (int)maxscreenheight) { + kContextHeight = (int)minscreenheight; + } } else if (!strncmp(setting, "Fullscreen", 10)) { ipstream >> fullscreen; } else if (!strncmp(setting, "Mouse sensitivity", 17)) { @@ -316,10 +316,10 @@ bool LoadSettings() if (detail < 0) { detail = 0; } - if (screenwidth < 0) { + if (screenwidth < minscreenwidth || screenwidth > maxscreenwidth) { screenwidth = 1024; } - if (screenheight < 0) { + if (screenheight < minscreenheight || screenheight > maxscreenheight) { screenheight = 768; } diff --git a/Source/User/Settings.hpp b/Source/User/Settings.hpp index e07d895..254250a 100644 --- a/Source/User/Settings.hpp +++ b/Source/User/Settings.hpp @@ -51,6 +51,8 @@ extern int kContextWidth; extern int kContextHeight; extern float screenwidth, screenheight; extern bool fullscreen; +extern float minscreenwidth, minscreenheight; +extern float maxscreenwidth, maxscreenheight; void DefaultSettings(); void SaveSettings(); -- 2.39.2 From d320bd1b418c85ec4b1edf967b50426f0f553322 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 19 Feb 2018 13:24:32 +0100 Subject: [PATCH 08/16] Object size selector with better keys --- Source/GameTick.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 4ff18e8..1a22117 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -1585,7 +1585,7 @@ void Game::ProcessDevInput() } /* Decrease size for next object */ - if (Input::isKeyDown(SDL_SCANCODE_DOWN) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) { + if (Input::isKeyDown(SDL_SCANCODE_DOWN) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) { editorsize -= multiplier; if (editorsize < .1) { editorsize = .1; @@ -1593,7 +1593,7 @@ void Game::ProcessDevInput() } /* Increase size for next object */ - if (Input::isKeyDown(SDL_SCANCODE_UP) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) { + if (Input::isKeyDown(SDL_SCANCODE_UP) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) { editorsize += multiplier; } -- 2.39.2 From 29b23632dbddbb74ca9c74e3229c5e4729fe3622 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 19 Feb 2018 16:46:20 +0100 Subject: [PATCH 09/16] New non-atacking player --- Source/GameTick.cpp | 3 +++ Source/Objects/Person.cpp | 3 ++- Source/Objects/Person.hpp | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 1a22117..ed1aed9 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -1472,6 +1472,9 @@ void Game::ProcessDevInput() Person::players.back()->power = Person::players[0]->power; Person::players.back()->speedmult = Person::players[0]->speedmult; + if (Input::isKeyDown(SDL_SCANCODE_RSHIFT)) + Person::players.back()->isplayerfriend = true; + Person::players.back()->loaded = true; } diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index d0e8f08..8022c0f 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -169,6 +169,7 @@ Person::Person() victim(nullptr) , hasvictim(false) + , isplayerfriend(false) , updatedelay(0) @@ -7324,7 +7325,7 @@ bool Person::addClothes(const int& clothesId) void Person::doAI() { - if (!isPlayerControlled() && !Dialog::inDialog()) { + if (!isPlayerControlled() && !isPlayerFriend() && !Dialog::inDialog()) { jumpclimb = 0; //disable movement in editor if (Game::editorenabled) { diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index 89d5b40..22c76eb 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -157,6 +157,7 @@ public: std::shared_ptr victim; bool hasvictim; + bool isplayerfriend; float updatedelay; float normalsupdatedelay; @@ -405,6 +406,7 @@ public: bool hasWeapon() { return (weaponactive != -1); } bool isPlayerControlled() { return (aitype == playercontrolled); } + bool isPlayerFriend() { return isplayerfriend; } }; const int maxplayers = 10; -- 2.39.2 From b156744d80db4f6ff49391edb09e919fb30f8a9b Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 20 Feb 2018 11:31:24 +0100 Subject: [PATCH 10/16] Player friend looks at the player --- Source/Objects/Person.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 8022c0f..2a4d4ae 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -7325,7 +7325,7 @@ bool Person::addClothes(const int& clothesId) void Person::doAI() { - if (!isPlayerControlled() && !isPlayerFriend() && !Dialog::inDialog()) { + if (!isPlayerControlled() && !Dialog::inDialog()) { jumpclimb = 0; //disable movement in editor if (Game::editorenabled) { @@ -7488,6 +7488,7 @@ void Person::doAI() if ((!Tutorial::active || cananger) && hostile && + !isPlayerFriend() && !Person::players[0]->dead && distsq(&coords, &Person::players[0]->coords) < 400 && occluded < 25) { @@ -7605,7 +7606,7 @@ void Person::doAI() //hearing sounds if (!Game::editorenabled) { if (howactive <= typesleeping) { - if (numenvsounds > 0 && (!Tutorial::active || cananger) && hostile) { + if (numenvsounds > 0 && (!Tutorial::active || cananger) && !isPlayerFriend() && hostile) { for (int j = 0; j < numenvsounds; j++) { float vol = howactive == typesleeping ? envsoundvol[j] - 14 : envsoundvol[j]; if (vol > 0 && distsq(&coords, &envsound[j]) < 2 * (vol + vol * (creature == rabbittype) * 3)) { @@ -7625,6 +7626,7 @@ void Person::doAI() if (howactive < typesleeping && ((!Tutorial::active || cananger) && hostile) && + !isPlayerFriend() && !Person::players[0]->dead && distsq(&coords, &Person::players[0]->coords) < 400 && occluded < 25) { @@ -7803,7 +7805,7 @@ void Person::doAI() jumpkeydown = 1; } - if (numenvsounds > 0 && ((!Tutorial::active || cananger) && hostile)) { + if (numenvsounds > 0 && ((!Tutorial::active || cananger) && !isPlayerFriend() && hostile)) { for (int k = 0; k < numenvsounds; k++) { if (distsq(&coords, &envsound[k]) < 2 * (envsoundvol[k] + envsoundvol[k] * (creature == rabbittype) * 3)) { aitype = attacktypecutoff; @@ -7812,6 +7814,7 @@ void Person::doAI() } if (!Person::players[0]->dead && + !isPlayerFriend() && losupdatedelay < 0 && !Game::editorenabled && occluded < 2 && @@ -7997,7 +8000,7 @@ void Person::doAI() lastseentime = 12; - if (!Person::players[0]->dead && ((!Tutorial::active || cananger) && hostile)) { + if (!Person::players[0]->dead && !isPlayerFriend() && ((!Tutorial::active || cananger) && hostile)) { if (ally < 0 || hasWeapon() || lastchecktime <= 0) { aitype = attacktypecutoff; lastseentime = 1; @@ -8390,6 +8393,9 @@ void Person::doAI() } else if (howactive >= typesleeping) { targetheadyaw = targetyaw; targetheadpitch = 0; + } else if (isPlayerFriend()) { + targetheadyaw = 180 - roughDirectionTo(coords, Person::players[0]->coords); + targetheadpitch = pitchTo(coords, Person::players[0]->coords); } else { if (interestdelay <= 0) { interestdelay = .7 + (float)(abs(Random() % 100)) / 100; -- 2.39.2 From 741d22aa77b9d20c67ccda3285235c71f988cfe6 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 20 Feb 2018 16:53:52 +0100 Subject: [PATCH 11/16] Friends always follow the player --- Source/Objects/Person.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 2a4d4ae..52c8fc4 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -8362,6 +8362,7 @@ void Person::doAI() } } } + //stunned if (aitype == passivetype && !(numwaypoints > 1) || stunned > 0 || @@ -8380,6 +8381,27 @@ void Person::doAI() throwkeydown = 0; } + // friends follow player + if (stunned < 1 && + isPlayerFriend() && + !Person::players[0]->dead && + distsq(&coords, &Person::players[0]->coords) > 5) { + XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity; + XYZ targetpoint = Person::players[0]->coords; + velocity = (targetpoint - coords); + velocity.y += 2; + 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; + } + targetyaw = roughDirectionTo(coords, targetpoint); + lookyaw = targetyaw; + forwardkeydown = 1; + aitype = searchtype; + } + XYZ facing; facing = 0; facing.z = -1; -- 2.39.2 From e069918736630bf740df60442891b66f93b564e9 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 21 Feb 2018 16:14:29 +0100 Subject: [PATCH 12/16] Friends help player with its enemies --- Source/GameTick.cpp | 19 ++++++++++++++++- Source/Objects/Person.cpp | 43 ++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index ed1aed9..c627e51 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -2193,7 +2193,23 @@ void doAttacks() } if (Person::players[k]->animTarget != rabbitrunninganim && Person::players[k]->animTarget != wolfrunninganim) { if (!Person::players[k]->isPlayerControlled()) { - Person::players[k]->victim = Person::players[0]; + if (Person::players[k]->isPlayerFriend()) { + bool found = false; + for (unsigned k2 = 1; k2 < Person::players.size(); k2++) { + if (k != k2 && + !Person::players[k2]->dead && + Person::players[k2]->aitype == attacktypecutoff) { + Person::players[k]->victim = Person::players[k2]; + found = true; + break; + } + } + if (!found) { + Person::players[k]->attackkeydown = 0; + } + } else { + Person::players[k]->victim = Person::players[0]; + } } //attack key pressed if (Person::players[k]->attackkeydown) { @@ -4487,6 +4503,7 @@ void Game::TickOnceAfter() Person::players[i]->aitype == gethelptype || Person::players[i]->aitype == searchtype) && !Person::players[i]->dead && + !Person::players[i]->isPlayerFriend() && (Person::players[i]->animTarget != sneakattackedanim && Person::players[i]->animTarget != knifesneakattackedanim && Person::players[i]->animTarget != swordsneakattackedanim)) { diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 52c8fc4..daba275 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -8381,25 +8381,30 @@ void Person::doAI() throwkeydown = 0; } - // friends follow player - if (stunned < 1 && - isPlayerFriend() && - !Person::players[0]->dead && - distsq(&coords, &Person::players[0]->coords) > 5) { - XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity; - XYZ targetpoint = Person::players[0]->coords; - velocity = (targetpoint - coords); - velocity.y += 2; - 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; - } - targetyaw = roughDirectionTo(coords, targetpoint); - lookyaw = targetyaw; - forwardkeydown = 1; - aitype = searchtype; + if (stunned < 1 && isPlayerFriend()) { + // friends follow player + if (!Person::players[0]->dead && + distsq(&coords, &Person::players[0]->coords) > 5) { + XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity; + XYZ targetpoint = Person::players[0]->coords; + velocity = (targetpoint - coords); + velocity.y += 2; + 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; + } + targetyaw = roughDirectionTo(coords, targetpoint); + lookyaw = targetyaw; + forwardkeydown = 1; + aitype = pathfindtype; + } + + // friends help player with its enemies + if (Game::musictype == stream_fighttheme) { + aitype = attacktypecutoff; + } } XYZ facing; -- 2.39.2 From d67f3dc0e14c195e650e732e8477c1ac4085e9de Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 21 Feb 2018 16:33:44 +0100 Subject: [PATCH 13/16] Use victim to attack, not player 0 --- Source/Objects/Person.cpp | 134 +++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index daba275..5a735c3 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -7333,9 +7333,9 @@ void Person::doAI() } 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; } @@ -7489,17 +7489,17 @@ void Person::doAI() 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; } @@ -7627,15 +7627,15 @@ void Person::doAI() 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; } @@ -7813,29 +7813,29 @@ void Person::doAI() } } - 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) @@ -7896,7 +7896,7 @@ void Person::doAI() } else { ally = 0; } - lastseen = Person::players[0]->coords; + lastseen = victim->coords; lastseentime = 12; } @@ -8000,13 +8000,13 @@ void Person::doAI() 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) { @@ -8063,18 +8063,18 @@ void Person::doAI() 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); @@ -8094,11 +8094,11 @@ void Person::doAI() } } //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; } @@ -8127,8 +8127,8 @@ void Person::doAI() 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 && @@ -8167,9 +8167,9 @@ void Person::doAI() } } //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; @@ -8194,23 +8194,23 @@ void Person::doAI() } 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; @@ -8218,7 +8218,7 @@ void Person::doAI() forwardkeydown = 0; } //chill out around the corpse - if (Person::players[0]->dead) { + if (victim->dead) { forwardkeydown = 0; if (Random() % 10 == 0) { forwardkeydown = 1; @@ -8249,7 +8249,7 @@ void Person::doAI() } 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; } @@ -8305,17 +8305,17 @@ void Person::doAI() 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) { @@ -8329,9 +8329,9 @@ void Person::doAI() } 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) { @@ -8342,7 +8342,7 @@ void Person::doAI() weaponstuck == -1)) { aitype = searchtype; lastchecktime = 12; - lastseen = Person::players[0]->coords; + lastseen = victim->coords; lastseentime = 12; } } else { @@ -8351,13 +8351,13 @@ void Person::doAI() } } } - 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; } } -- 2.39.2 From a99778b1da1ea16a6a87a00461cd2c4e36ab13a3 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 21 Feb 2018 16:39:37 +0100 Subject: [PATCH 14/16] Pass killeveryone maps when friends are alive --- Source/GameTick.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index c627e51..dbd6f0e 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -4654,7 +4654,7 @@ void Game::TickOnceAfter() } alldead = true; for (unsigned i = 1; i < Person::players.size(); i++) { - if (!Person::players[i]->dead && Person::players[i]->howactive < typedead1) { + if (!Person::players[i]->dead && Person::players[i]->howactive < typedead1 && !Person::players[i]->isPlayerFriend()) { alldead = false; break; } -- 2.39.2 From 43b29d6c2092964efbba5ee4d5f4a559d86bc508 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Thu, 22 Feb 2018 16:29:43 +0100 Subject: [PATCH 15/16] Friends don't abandon player when enemies flee --- Source/GameTick.cpp | 2 ++ Source/Objects/Person.cpp | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index dbd6f0e..f96dbd4 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -2200,11 +2200,13 @@ void doAttacks() !Person::players[k2]->dead && Person::players[k2]->aitype == attacktypecutoff) { Person::players[k]->victim = Person::players[k2]; + Person::players[k]->hasvictim = true; found = true; break; } } if (!found) { + Person::players[k]->hasvictim = false; Person::players[k]->attackkeydown = 0; } } else { diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 5a735c3..b140307 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -7339,6 +7339,10 @@ void Person::doAI() pause = 1; } + if (isPlayerFriend() && aitype == pathfindtype) { + aitype = passivetype; + } + //pathfinding if (aitype == pathfindtype) { if (finalpathfindpoint == -1) { @@ -8382,8 +8386,16 @@ void Person::doAI() } if (stunned < 1 && isPlayerFriend()) { + // friends help player with its enemies + if (Game::musictype == stream_fighttheme && hasvictim) { + aitype = attacktypecutoff; + } else { + aitype = pathfindtype; + } + // friends follow player if (!Person::players[0]->dead && + aitype == pathfindtype && distsq(&coords, &Person::players[0]->coords) > 5) { XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity; XYZ targetpoint = Person::players[0]->coords; @@ -8398,12 +8410,6 @@ void Person::doAI() targetyaw = roughDirectionTo(coords, targetpoint); lookyaw = targetyaw; forwardkeydown = 1; - aitype = pathfindtype; - } - - // friends help player with its enemies - if (Game::musictype == stream_fighttheme) { - aitype = attacktypecutoff; } } -- 2.39.2 From c5a14dfbeaae2f6085b69a7f93e7d6d91b7349d3 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Thu, 22 Feb 2018 16:57:17 +0100 Subject: [PATCH 16/16] Friends fight with true enemies, before they attacked player but hurting enemies --- Source/GameTick.cpp | 4 +++- Source/Objects/Person.hpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index f96dbd4..285c80c 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -2270,7 +2270,9 @@ void doAttacks() Person::players[k]->hasvictim = 0; if (Person::players.size() > 1) { for (unsigned i = 0; i < Person::players.size(); i++) { - if (i == k || !(k == 0 || i == 0)) { + if (i == k || + (Person::players[k]->isPlayerTeam() && Person::players[i]->isPlayerTeam()) || + !(Person::players[k]->isPlayerTeam() || Person::players[i]->isPlayerTeam())) { continue; } if (!Person::players[k]->hasvictim) { diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index 22c76eb..3c415a5 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -407,6 +407,7 @@ public: bool hasWeapon() { return (weaponactive != -1); } bool isPlayerControlled() { return (aitype == playercontrolled); } bool isPlayerFriend() { return isplayerfriend; } + bool isPlayerTeam() { return isPlayerControlled() || isPlayerFriend(); } }; const int maxplayers = 10; -- 2.39.2