1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 09:07:19 +02:00

Make certain AI Behviours and opcodes use sprint

This commit is contained in:
Daniel Evans 2015-05-09 04:40:41 +01:00
parent 279407b254
commit c1c2d7341f
4 changed files with 11 additions and 7 deletions

View File

@ -141,9 +141,10 @@ namespace Activities {
DECL_ACTIVITY( GoTo ) DECL_ACTIVITY( GoTo )
glm::vec3 target; glm::vec3 target;
bool sprint;
GoTo( const glm::vec3& target ) GoTo( const glm::vec3& target, bool _sprint = false )
: target( target ) {} : target( target ), sprint(_sprint) {}
bool update(CharacterObject* character, CharacterController* controller); bool update(CharacterObject* character, CharacterController* controller);
}; };

View File

@ -60,7 +60,7 @@ private:
VehicleObject* currentVehicle; VehicleObject* currentVehicle;
size_t currentSeat; size_t currentSeat;
void createActor(const glm::vec2& size = glm::vec2(0.7f, 0.8f)); void createActor(const glm::vec2& size = glm::vec2(0.45f, 1.2f));
void destroyActor(); void destroyActor();
// Incredibly hacky "move in this direction". // Incredibly hacky "move in this direction".

View File

@ -207,6 +207,7 @@ bool Activities::GoTo::update(CharacterObject *character, CharacterController *c
// Ignore vertical axis for the sake of simplicity. // Ignore vertical axis for the sake of simplicity.
if( glm::length(glm::vec2(targetDirection)) < 0.1f ) { if( glm::length(glm::vec2(targetDirection)) < 0.1f ) {
character->setPosition(glm::vec3(glm::vec2(target), cpos.z)); character->setPosition(glm::vec3(glm::vec2(target), cpos.z));
character->controller->setRunning(false);
return true; return true;
} }
@ -214,6 +215,7 @@ bool Activities::GoTo::update(CharacterObject *character, CharacterController *c
character->rotation = r; character->rotation = r;
controller->setRawMovement({1.f, 0.f, 0.f}); controller->setRawMovement({1.f, 0.f, 0.f});
controller->setRunning(sprint);
return false; return false;
} }
@ -315,6 +317,7 @@ bool Activities::EnterVehicle::update(CharacterObject *character, CharacterContr
entering = true; entering = true;
// Warp character to vehicle orientation // Warp character to vehicle orientation
character->controller->setRawMovement({0.f, 0.f, 0.f}); character->controller->setRawMovement({0.f, 0.f, 0.f});
character->controller->setRunning(false);
character->rotation = vehicle->getRotation(); character->rotation = vehicle->getRotation();
// Determine if the door open animation should be skipped. // Determine if the door open animation should be skipped.
@ -328,10 +331,10 @@ bool Activities::EnterVehicle::update(CharacterObject *character, CharacterContr
character->playAnimation(anm_open, false); character->playAnimation(anm_open, false);
} }
} }
else if( targetDistance > 15.f ) {
return true; // Give up if the vehicle is too far away.
}
else { else {
if( targetDistance > 5.f ) {
character->controller->setRunning(true);
}
glm::quat r( glm::vec3{ 0.f, 0.f, atan2(targetDirection.y, targetDirection.x) - glm::half_pi<float>() } ); glm::quat r( glm::vec3{ 0.f, 0.f, atan2(targetDirection.y, targetDirection.x) - glm::half_pi<float>() } );
character->rotation = r; character->rotation = r;
character->controller->setRawMovement({1.f, 0.f, 0.f}); character->controller->setRawMovement({1.f, 0.f, 0.f});

View File

@ -717,7 +717,7 @@ void game_character_run_to(const ScriptArguments& args)
glm::vec3 target(args[1].real, args[2].real, 0.f); glm::vec3 target(args[1].real, args[2].real, 0.f);
target = args.getWorld()->getGroundAtPosition(target); target = args.getWorld()->getGroundAtPosition(target);
character->controller->setNextActivity(new Activities::GoTo(target)); character->controller->setNextActivity(new Activities::GoTo(target, true));
} }
bool game_vehicle_flipped(const ScriptArguments& args) bool game_vehicle_flipped(const ScriptArguments& args)