Working on fixing scripting bugs'

This commit is contained in:
Vladislav Khorev committed 2026-07-10 17:00:10 +03:00
1 parent 7dadfd8ed8
commit 8e745ce0cd
8 files changed
+119 -71

No files matched your search

+18
View File
@@ -128,11 +128,29 @@ namespace ZL {
npcs[index]->state.targetFacingAngle = rad;
});
api.set_function("player_rotate_to",
[loc](float angle) {
const float rad = angle * static_cast<float>(M_PI) / 180.f;
std::cout << "[script] player_rotate_to: angle " << angle << " degrees (" << rad << " radians)" << std::endl;
loc->player->state.targetFacingAngle = rad;
});
api.set_function("player_stop_and_rotate_to_npc",
[loc](int index) {
loc->player->stopAndRotateToTarget(index);
});
api.set_function("npc_stop_and_rotate_to_player",
[loc](int index) {
auto& npcs = loc->npcs;
if (index < 0 || index >= static_cast<int>(npcs.size())) {
std::cerr << "[script] npc_stop_and_rotate_to_player: index " << index
<< " out of range (0.." << npcs.size() - 1 << ")\n";
return;
}
npcs[index]->stopAndRotateToTarget(CharacterState::kPlayerIndex);
});
api.set_function("player_walk_to",
[loc, this_impl = impl.get()](float x, float y, float z, sol::object on_arrived) {