X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=ed1aed93a4c4ed8ff8a0652efbf8234c5120a20d;hb=29b23632dbddbb74ca9c74e3229c5e4729fe3622;hp=82b75e54eb693d47db5ced0fc44bb3b01ca0d632;hpb=5ab55c3eea543a30fe979f623d4a984935e2a0fb;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 82b75e5..ed1aed9 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -148,27 +148,6 @@ float musicvolume[4] = {}; float oldmusicvolume[4] = {}; int musicselected = 0; -const char* rabbitskin[] = { - "Textures/Fur3.jpg", - "Textures/Fur.jpg", - "Textures/Fur2.jpg", - "Textures/Lynx.jpg", - "Textures/Otter.jpg", - "Textures/Opal.jpg", - "Textures/Sable.jpg", - "Textures/Chocolate.jpg", - "Textures/BW2.jpg", - "Textures/WB2.jpg" -}; - -const char* wolfskin[] = { - "Textures/Wolf.jpg", - "Textures/DarkWolf.jpg", - "Textures/SnowWolf.jpg" -}; - -const char** creatureskin[] = { rabbitskin, wolfskin }; - #define STATIC_ASSERT(x) extern int s_a_dummy[2 * (!!(x)) - 1]; STATIC_ASSERT(rabbittype == 0 && wolftype == 1) @@ -861,13 +840,11 @@ bool Game::LoadLevel(const std::string& name, bool tutorial) } else { Person::players[i]->damagetolerance = 200; } - } - Game::LoadingScreen(); + Game::LoadingScreen(); - Person::players[i]->tempanimation = Animation("Tempanim", lowheight, neutral); + Person::players[i]->tempanimation = Animation("Tempanim", lowheight, neutral); - if (i == 0) { Person::players[i]->headmorphness = 0; Person::players[i]->targetheadmorphness = 1; Person::players[i]->headmorphstart = 0; @@ -1045,50 +1022,56 @@ void Game::ProcessInput() /* Devtools */ if (devtools && !mainmenu) { - ProcessDevInput(); + /* Console */ + if (Input::isKeyPressed(consolekey)) { + console = !console; + if (console) { + OPENAL_SetFrequency(OPENAL_ALL); + } else { + freeze = 0; + waiting = false; + } + } + + /* Other devtools, disabled when the console is shown */ + if (!console) { + ProcessDevInput(); + } } } void Game::ProcessDevInput() { - if (!devtools || mainmenu) { + if (!devtools || mainmenu || console) { return; } - /* Console */ - if (Input::isKeyPressed(consolekey)) { - console = !console; - if (console) { - OPENAL_SetFrequency(OPENAL_ALL); - } else { - freeze = 0; - waiting = false; - } - } - if (Input::isKeyDown(SDL_SCANCODE_LALT)) { /* Enable editor */ if (Input::isKeyPressed(SDL_SCANCODE_M) && !Input::isKeyDown(SDL_SCANCODE_LSHIFT)) { editorenabled = !editorenabled; if (editorenabled) { Person::players[0]->damagetolerance = 100000; + Person::players[0]->damage = 0; + Person::players[0]->permanentdamage = 0; + Person::players[0]->superpermanentdamage = 0; + Person::players[0]->burnt = 0; + Person::players[0]->bloodloss = 0; + Person::players[0]->deathbleeding = 0; } else { Person::players[0]->damagetolerance = 200; } - Person::players[0]->damage = 0; // these lines were in both if and else, but I think they would better fit in the if - Person::players[0]->permanentdamage = 0; - Person::players[0]->superpermanentdamage = 0; - Person::players[0]->bloodloss = 0; - Person::players[0]->deathbleeding = 0; } /* Nullify damage and give 200000 health */ if (Input::isKeyPressed(SDL_SCANCODE_H)) { Person::players[0]->damagetolerance = 200000; Person::players[0]->damage = 0; - Person::players[0]->burnt = 0; Person::players[0]->permanentdamage = 0; Person::players[0]->superpermanentdamage = 0; + Person::players[0]->burnt = 0; + Person::players[0]->bloodloss = 0; + Person::players[0]->deathbleeding = 0; } /* Change environment */ @@ -1213,7 +1196,7 @@ void Game::ProcessDevInput() } Person::players[closest]->skeleton.drawmodel.textureptr.load( - creatureskin[Person::players[closest]->creature][Person::players[closest]->whichskin], 1, + PersonType::types[Person::players[closest]->creature].skins[Person::players[closest]->whichskin], 1, &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize); } @@ -1227,24 +1210,9 @@ void Game::ProcessDevInput() closest = findClosestPlayer(); } - // FIXME: Those proportions are buggy if (closest >= 0) { - if (Person::players[closest]->creature == rabbittype) { - Person::players[closest]->creature = wolftype; - Person::players[closest]->whichskin = 0; - Person::players[closest]->skeletonLoad(); - Person::players[closest]->scale = .23 * 5 * Person::players[0]->scale; - - Person::players[closest]->damagetolerance = 300; - } else { - Person::players[closest]->creature = rabbittype; - Person::players[closest]->whichskin = 0; - Person::players[closest]->skeletonLoad(true); - - Person::players[closest]->scale = .2 * 5 * Person::players[0]->scale; - - Person::players[closest]->damagetolerance = 200; - } + person_type nextType = static_cast((Person::players[closest]->creature + 1) % PersonType::types.size()); + Person::players[closest]->changeCreatureType(nextType); } } @@ -1464,7 +1432,7 @@ void Game::ProcessDevInput() Person::players.back()->howactive = editoractive; Person::players.back()->whichskin = (int)(abs(Random() % 3)); - Person::players.back()->skeletonLoad(true); + Person::players.back()->skeletonLoad(); Person::players.back()->skeleton.drawmodelclothes.textureptr.load("Textures/Belt.png", 1); Person::players.back()->speed = 1 + (float)(Random() % 100) / 1000; @@ -1478,8 +1446,6 @@ void Game::ProcessDevInput() Person::players.back()->setProportions(1, 1, 1, 1); - Person::players.back()->tempanimation = Animation("Tempanim", lowheight, neutral); - Person::players.back()->damagetolerance = 200; Person::players.back()->protectionhead = Person::players[0]->protectionhead; @@ -1506,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; } @@ -1619,7 +1588,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; @@ -1627,7 +1596,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; } @@ -1677,8 +1646,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) && @@ -1689,8 +1658,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; @@ -1729,8 +1698,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; @@ -1835,7 +1804,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 && @@ -1857,7 +1826,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()) && @@ -2013,7 +1982,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() || @@ -2191,7 +2160,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 && @@ -2223,7 +2192,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 @@ -2278,7 +2247,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) { @@ -2305,7 +2274,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 && @@ -2691,7 +2660,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() && @@ -2703,7 +2672,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)) { @@ -3496,7 +3465,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 && @@ -3633,7 +3602,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() || @@ -3641,19 +3610,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); @@ -3664,11 +3633,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.); @@ -3681,7 +3650,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()) { @@ -3694,14 +3663,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.); } @@ -3723,7 +3692,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 && @@ -3824,7 +3793,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() || @@ -3849,7 +3818,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; @@ -3875,7 +3844,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; @@ -3900,16 +3869,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; } @@ -3920,8 +3889,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) { @@ -3937,7 +3906,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 && @@ -4115,7 +4084,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; @@ -4276,7 +4245,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 { @@ -4312,7 +4281,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;