1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-09 20:32:43 +01:00

Script: 00FD (Is Player in Vehicle Near Character)

This commit is contained in:
Jannik Vogel 2016-06-11 13:31:02 +02:00
parent bac779b53d
commit 88e205df7f

View File

@ -335,6 +335,31 @@ bool game_player_stopped_near_point_on_foot_3d(const ScriptArguments& args)
return false;
}
bool game_is_player_in_vehicle_near_character(const ScriptArguments& args)
{
auto player = static_cast<CharacterObject*>(args.getPlayerCharacter(0));
auto character = static_cast<CharacterObject*>(args.getObject<CharacterObject>(1));
glm::vec3 size(args[2].real, args[3].real, args[4].real);
bool drawSphere = !!args[5].integerValue();
auto center = character->getPosition();
auto vehicle = player->getCurrentVehicle();
if(vehicle) {
auto distance = center - player->getPosition();
distance /= size;
if (glm::length(distance) < 1.f) {
return true;
}
}
if (drawSphere) {
args.getWorld()->drawAreaIndicator(AreaIndicatorInfo::Cylinder, center, size); //FIXME!
}
return false;
}
bool game_character_near_point_in_vehicle(const ScriptArguments& args)
{
auto character = static_cast<CharacterObject*>(args.getObject<CharacterObject>(0));
@ -1283,6 +1308,8 @@ ObjectModule::ObjectModule()
bindFunction(0x00F7, game_player_near_point_in_vehicle_3D, 8, "Is Player near point in car" );
bindFunction(0x00F9, game_player_stopped_near_point_on_foot_3d, 8, "Detect player stopped on foot area 3d" );
bindFunction(0x00FD, game_is_player_in_vehicle_near_character, 6, "Is Player in Vehicle Near Character");
bindFunction(0x0100, game_character_near_point_in_vehicle, 8, "Is Character near point in car" );
bindFunction(0x0108, game_destroy_object<InstanceObject>, 1, "Destroy Object" );