X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects%2FPerson.cpp;h=8898cac60bba81fce30ded86d76c38b5dc9c3ea4;hb=265236f7b4d05d576a4a6fd81823abff5f3f757b;hp=e9ccbbf9b6ea753b11aef0a8a54a572991e6919e;hpb=ce51a88a16d2e7af222929546d250eba4acb299d;p=lugaru.git diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index e9ccbbf..8898cac 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -72,7 +72,7 @@ extern float envsoundlife[30]; extern XYZ windvector; -std::vector> Person::players(1, std::shared_ptr(new Person())); +std::vector> Person::players; Person::Person() : whichpatchx(0) @@ -336,16 +336,13 @@ Person::Person() , neckspurtdelay(0) , neckspurtparticledelay(0) , neckspurtamount(0) - , - whichskin(0) + , whichskin(0) , rabbitkickragdoll(false) - , - tempanimation() - , + , tempanimation("Tempanim", lowheight, neutral) - jumpclimb(false) + , jumpclimb(false) { damagetolerance = PersonType::types[creature].defaultDamageTolerance; setProportions(1, 1, 1, 1); @@ -444,12 +441,12 @@ void Person::changeCreatureType(person_type type) { creature = type; whichskin = 0; - skeletonLoad(type == rabbittype); + skeletonLoad(); scale = PersonType::types[creature].defaultScale; damagetolerance = PersonType::types[creature].defaultDamageTolerance; } -void Person::skeletonLoad(bool clothes) +void Person::skeletonLoad() { skeleton.id = id; skeleton.Load( @@ -465,7 +462,7 @@ void Person::skeletonLoad(bool clothes) PersonType::types[creature].modelFileNames[6], PersonType::types[creature].lowModelFileName, PersonType::types[creature].modelClothesFileName, - clothes); + PersonType::types[creature].clothes); skeleton.drawmodel.textureptr.load(PersonType::types[creature].skins[whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize); } @@ -2093,8 +2090,7 @@ void Person::DoAnimations() if (victim->aitype == gethelptype) { victim->DoDamage(victim->damagetolerance - victim->damage); } - //victim->DoDamage(30); - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { DoBloodBig(0, 255); emit_sound_at(clawslicesound, victim->coords); victim->spurt = 1; @@ -2449,17 +2445,17 @@ void Person::DoAnimations() if (id == 0) { camerashake += .4; } - if (Random() % 2 || creature == wolftype) { + if (Random() % 2 || PersonType::types[creature].hasClaws) { victim->spurt = 1; DoBlood(.2, 250); - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { DoBloodBig(0, 250); } } if (!Tutorial::active) { emit_sound_at(heavyimpactsound, victim->coords, 128.); } - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { emit_sound_at(clawslicesound, victim->coords, 128.); victim->spurt = 1; victim->DoBloodBig(2 / victim->armorhead, 175); @@ -2487,14 +2483,14 @@ void Person::DoAnimations() if (id == 0) { camerashake += .4; } - if (Random() % 2 || creature == wolftype) { + if (Random() % 2 || PersonType::types[creature].hasClaws) { victim->spurt = 1; - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { DoBloodBig(0, 235); } } emit_sound_at(whooshhitsound, victim->coords); - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { emit_sound_at(clawslicesound, victim->coords, 128.); victim->spurt = 1; victim->DoBloodBig(2, 175); @@ -2527,7 +2523,7 @@ void Person::DoAnimations() if (!Tutorial::active) { emit_sound_at(heavyimpactsound, victim->coords, 160.); } - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { emit_sound_at(clawslicesound, victim->coords, 128.); victim->spurt = 1; victim->DoBloodBig(2 / victim->armorhead, 175); @@ -2564,7 +2560,7 @@ void Person::DoAnimations() if (!Tutorial::active) { emit_sound_at(heavyimpactsound, victim->coords, 160.); } - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { emit_sound_at(clawslicesound, victim->coords, 128.); victim->spurt = 1; victim->DoBloodBig(2 / victim->armorhead, 175); @@ -3205,7 +3201,7 @@ void Person::DoAnimations() if (id == 0) { camerashake += .4; } - if (Random() % 2 || creature == wolftype) { + if (Random() % 2 || PersonType::types[creature].hasClaws) { victim->spurt = 1; } emit_sound_at(staffheadsound, victim->coords); @@ -3240,7 +3236,7 @@ void Person::DoAnimations() if (id == 0) { camerashake += .4; } - if (Random() % 2 || creature == wolftype) { + if (Random() % 2 || PersonType::types[creature].hasClaws) { victim->spurt = 1; } emit_sound_at(staffheadsound, victim->coords); @@ -3275,7 +3271,7 @@ void Person::DoAnimations() if (id == 0) { camerashake += .4; } - if (Random() % 2 || creature == wolftype) { + if (Random() % 2 || PersonType::types[creature].hasClaws) { victim->spurt = 1; } emit_sound_at(staffbodysound, victim->coords); @@ -3348,7 +3344,7 @@ void Person::DoAnimations() if (victim->howactive == typesleeping) { victim->DoDamage(damagemult * 150 / victim->protectionhead); } - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { emit_sound_at(clawslicesound, victim->coords, 128.); victim->spurt = 1; victim->DoBloodBig(2 / victim->armorhead, 175); @@ -3370,7 +3366,7 @@ void Person::DoAnimations() } victim->Puff(abdomen); victim->DoDamage(damagemult * 30 / victim->protectionhigh); - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { emit_sound_at(clawslicesound, victim->coords, 128.); victim->spurt = 1; victim->DoBloodBig(2 / victim->armorhigh, 170); @@ -3453,7 +3449,7 @@ void Person::DoAnimations() if (!Tutorial::active) { emit_sound_at(heavyimpactsound, victim->coords, 128.); } - if (creature == wolftype) { + if (PersonType::types[creature].hasClaws) { emit_sound_at(clawslicesound, victim->coords, 128); victim->spurt = 1; victim->DoBloodBig(2 / victim->armorhigh, 170); @@ -3565,17 +3561,17 @@ void Person::DoAnimations() award_bonus(id, Reversal); bool doslice; - doslice = 0; - if (weaponactive != -1 || creature == wolftype) { - doslice = 1; - } - if (creature == rabbittype && weaponactive != -1) { - if (weapons[weaponids[0]].getType() == staff) { - doslice = 0; - } + if (weaponactive == -1) { + doslice = PersonType::types[creature].hasClaws; + } else { + doslice = (weapons[weaponids[0]].getType() != staff); } if (doslice) { - if (weaponactive != -1) { + if (weaponactive == -1) { + emit_sound_at(clawslicesound, victim->coords, 128.); + victim->spurt = 1; + victim->DoBloodBig(2 / victim->armorhigh, 175); + } else { victim->DoBloodBig(2 / victim->armorhigh, 225); emit_sound_at(knifeslicesound, victim->coords); if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) { @@ -3583,11 +3579,6 @@ void Person::DoAnimations() } weapons[weaponids[weaponactive]].blooddrip += 3; } - if (weaponactive == -1 && creature == wolftype) { - emit_sound_at(clawslicesound, victim->coords, 128.); - victim->spurt = 1; - victim->DoBloodBig(2 / victim->armorhigh, 175); - } } } @@ -3659,17 +3650,17 @@ void Person::DoAnimations() victim->damage = victim->damagetolerance; victim->permanentdamage = victim->damagetolerance - 1; bool doslice; - doslice = 0; - if (weaponactive != -1 || creature == wolftype) { - doslice = 1; - } - if (creature == rabbittype && weaponactive != -1) { - if (weapons[weaponids[0]].getType() == staff) { - doslice = 0; - } + if (weaponactive == -1) { + doslice = PersonType::types[creature].hasClaws; + } else { + doslice = (weapons[weaponids[0]].getType() != staff); } if (doslice) { - if (weaponactive != -1) { + if (weaponactive == -1) { + emit_sound_at(clawslicesound, victim->coords, 128.); + victim->spurt = 1; + victim->DoBloodBig(2, 175); + } else { victim->DoBloodBig(200, 225); emit_sound_at(knifeslicesound, victim->coords); if (bloodtoggle) { @@ -3677,12 +3668,6 @@ void Person::DoAnimations() } weapons[weaponids[weaponactive]].blooddrip += 5; } - - if (creature == wolftype && weaponactive == -1) { - emit_sound_at(clawslicesound, victim->coords, 128.); - victim->spurt = 1; - victim->DoBloodBig(2, 175); - } } award_bonus(id, spinecrusher); } @@ -3836,17 +3821,17 @@ void Person::DoAnimations() } } bool doslice; - doslice = 0; - if (weaponactive != -1 || creature == wolftype) { - doslice = 1; - } - if (creature == rabbittype && weaponactive != -1) { - if (weapons[weaponids[0]].getType() == staff) { - doslice = 0; - } + if (weaponactive == -1) { + doslice = PersonType::types[creature].hasClaws; + } else { + doslice = (weapons[weaponids[0]].getType() != staff); } if (doslice) { - if (weaponactive != -1) { + if (weaponactive == -1) { + emit_sound_at(clawslicesound, victim->coords, 128.); + victim->spurt = 1; + victim->DoBloodBig(2 / victim->armorhead, 175); + } else { victim->DoBloodBig(2 / victim->armorhead, 225); emit_sound_at(knifeslicesound, victim->coords); if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) { @@ -3854,11 +3839,6 @@ void Person::DoAnimations() } weapons[weaponids[weaponactive]].blooddrip += 3; } - if (weaponactive == -1 && creature == wolftype) { - emit_sound_at(clawslicesound, victim->coords, 128.); - victim->spurt = 1; - victim->DoBloodBig(2 / victim->armorhead, 175); - } } award_bonus(id, Reversal); @@ -6029,19 +6009,10 @@ void Person::DoStuff() } else if (isRun()) { velocity += facing * multiplier * speed * 700 * scale; velspeed = findLength(&velocity); - if (creature == rabbittype) { - if (velspeed > speed * 55 * scale) { - velocity /= velspeed; - velspeed = speed * 55 * scale; - velocity *= velspeed; - } - } - if (creature == wolftype) { - if (velspeed > speed * 75 * scale) { - velocity /= velspeed; - velspeed = speed * 75 * scale; - velocity *= velspeed; - } + if (velspeed > speed * PersonType::types[creature].maxRunSpeed * scale) { + velocity /= velspeed; + velspeed = speed * PersonType::types[creature].maxRunSpeed * scale; + velocity *= velspeed; } velocity.y += gravity * multiplier * 20; ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z)); @@ -8446,3 +8417,10 @@ 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)); +}