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:
parent
279407b254
commit
c1c2d7341f
@ -141,9 +141,10 @@ namespace Activities {
|
||||
DECL_ACTIVITY( GoTo )
|
||||
|
||||
glm::vec3 target;
|
||||
bool sprint;
|
||||
|
||||
GoTo( const glm::vec3& target )
|
||||
: target( target ) {}
|
||||
GoTo( const glm::vec3& target, bool _sprint = false )
|
||||
: target( target ), sprint(_sprint) {}
|
||||
|
||||
bool update(CharacterObject* character, CharacterController* controller);
|
||||
};
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
VehicleObject* currentVehicle;
|
||||
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();
|
||||
|
||||
// Incredibly hacky "move in this direction".
|
||||
|
@ -207,6 +207,7 @@ bool Activities::GoTo::update(CharacterObject *character, CharacterController *c
|
||||
// Ignore vertical axis for the sake of simplicity.
|
||||
if( glm::length(glm::vec2(targetDirection)) < 0.1f ) {
|
||||
character->setPosition(glm::vec3(glm::vec2(target), cpos.z));
|
||||
character->controller->setRunning(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -214,6 +215,7 @@ bool Activities::GoTo::update(CharacterObject *character, CharacterController *c
|
||||
character->rotation = r;
|
||||
|
||||
controller->setRawMovement({1.f, 0.f, 0.f});
|
||||
controller->setRunning(sprint);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -315,6 +317,7 @@ bool Activities::EnterVehicle::update(CharacterObject *character, CharacterContr
|
||||
entering = true;
|
||||
// Warp character to vehicle orientation
|
||||
character->controller->setRawMovement({0.f, 0.f, 0.f});
|
||||
character->controller->setRunning(false);
|
||||
character->rotation = vehicle->getRotation();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
else if( targetDistance > 15.f ) {
|
||||
return true; // Give up if the vehicle is too far away.
|
||||
}
|
||||
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>() } );
|
||||
character->rotation = r;
|
||||
character->controller->setRawMovement({1.f, 0.f, 0.f});
|
||||
|
@ -717,7 +717,7 @@ void game_character_run_to(const ScriptArguments& args)
|
||||
glm::vec3 target(args[1].real, args[2].real, 0.f);
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user