Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #161 gates do not open #727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 53 additions & 19 deletions rwengine/src/script/modules/GTA3ModuleImpl.inl
Original file line number Diff line number Diff line change
Expand Up @@ -7192,18 +7192,32 @@
@arg arg9
*/
bool opcode_02b3(const ScriptArguments& args, const ScriptPlayer player, const ScriptFloat arg2, const ScriptFloat arg3, const ScriptFloat arg4, const ScriptFloat arg5, const ScriptFloat arg6, const ScriptFloat arg7, const ScriptFloat arg8, const ScriptInt arg9) {
RW_UNIMPLEMENTED_OPCODE(0x02b3);
RW_UNUSED(player);
RW_UNUSED(arg2);
RW_UNUSED(arg3);
RW_UNUSED(arg4);
RW_UNUSED(arg5);
RW_UNUSED(arg6);
RW_UNUSED(arg7);
RW_UNUSED(arg8);
RW_UNUSED(arg9);
RW_UNUSED(args);
return false;
bool inArea;

Check warning on line 7196 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L7196

Added line #L7196 was not covered by tests

if (arg9) {

Check warning on line 7198 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L7198

Added line #L7198 was not covered by tests
RW_UNIMPLEMENTED("02B3: in_cube sphere");
inArea = false;
} else {
const glm::vec3& p = player.get()->getCharacter()->getPosition();

Check warning on line 7202 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L7200-L7202

Added lines #L7200 - L7202 were not covered by tests

float angle = std::atan2(arg3 - arg6, arg5 - arg2);
float x = arg8 * std::cos(angle);
float y = arg8 * std::sin(angle);

Check warning on line 7206 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L7204-L7206

Added lines #L7204 - L7206 were not covered by tests

glm::vec2 AB = glm::vec2(arg2 - (arg2 - x), arg3 - (arg3 - y));
glm::vec2 AM = glm::vec2(arg2 - p.x, arg3 - p.y);
glm::vec2 BC = glm::vec2((arg2 - x) - (arg5 - x), (arg3 - y) - (arg6 - y));
glm::vec2 BM = glm::vec2(arg2 - p.x, arg3 - p.y);
float dotABAM = glm::dot(AB, AM);
float dotBCBM = glm::dot(BC, BM);

Check warning on line 7213 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L7208-L7213

Added lines #L7208 - L7213 were not covered by tests

inArea = (p.z >= arg4 && p.z <= arg7 &&
0 < dotABAM && dotABAM < glm::dot(AB, AB) &&
0 < dotBCBM && dotBCBM < glm::dot(BC, BC));
}

Check warning on line 7218 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L7215-L7218

Added lines #L7215 - L7218 were not covered by tests

return inArea;

Check warning on line 7220 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L7220

Added line #L7220 was not covered by tests
}

/**
Expand Down Expand Up @@ -9317,15 +9331,35 @@
@arg arg8 Boolean true/false
*/
bool opcode_034e(const ScriptArguments& args, const ScriptObject object, ScriptVec3 coord, const ScriptFloat arg5, const ScriptFloat arg6, const ScriptFloat arg7, const ScriptBoolean arg8) {
RW_UNIMPLEMENTED_OPCODE(0x034e);
RW_UNUSED(object);
RW_UNUSED(coord);
RW_UNUSED(arg5);
RW_UNUSED(arg6);
RW_UNUSED(arg7);
RW_UNUSED(arg8);
RW_UNUSED(args);
return true;
const glm::vec3& curPos = object.m_object->getPosition();
glm::vec3 newPos;

Check warning on line 9336 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9335-L9336

Added lines #L9335 - L9336 were not covered by tests

if (curPos == coord) {
return true;

Check warning on line 9339 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9338-L9339

Added lines #L9338 - L9339 were not covered by tests
}

newPos.x = (curPos.x < coord.x ? curPos.x + arg5 : curPos.x - arg5);
newPos.y = (curPos.y < coord.y ? curPos.y + arg6 : curPos.y - arg6);
newPos.z = (curPos.z < coord.z ? curPos.z + arg7 : curPos.z - arg7);

Check warning on line 9344 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9342-L9344

Added lines #L9342 - L9344 were not covered by tests

if (arg8) {
for (const auto& obj : args.getWorld()->pedestrianPool.objects) {
if (glm::distance(newPos, obj.second->getPosition()) <= 2.1f) {
return true;

Check warning on line 9349 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9346-L9349

Added lines #L9346 - L9349 were not covered by tests
}
}

Check warning on line 9351 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9351

Added line #L9351 was not covered by tests

for (const auto& obj : args.getWorld()->vehiclePool.objects) {
if (glm::distance(newPos, obj.second->getPosition()) <= 3.61f) {
return true;

Check warning on line 9355 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9353-L9355

Added lines #L9353 - L9355 were not covered by tests
}
}
}

Check warning on line 9358 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9357-L9358

Added lines #L9357 - L9358 were not covered by tests

object.m_object->setPosition(newPos);

Check warning on line 9360 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9360

Added line #L9360 was not covered by tests

return (newPos == coord);

Check warning on line 9362 in rwengine/src/script/modules/GTA3ModuleImpl.inl

View check run for this annotation

Codecov / codecov/patch

rwengine/src/script/modules/GTA3ModuleImpl.inl#L9362

Added line #L9362 was not covered by tests
}

/**
Expand Down