Working on taxi logic

This commit is contained in:
Vladislav Khorev committed 2026-06-09 14:06:43 +03:00
1 parent 77c8471636
commit b94f02bd77
10 files changed
+95 -15

No files matched your search

+39
View File
@@ -26,6 +26,7 @@ namespace ZL {
sol::protected_function darklandsEnterCallback;
sol::protected_function darklandsExitCallback;
sol::protected_function triggerNightEnterCallback;
sol::protected_function callTaxiCallback;
sol::protected_function chatOpenCallbacks[3];
};
@@ -382,6 +383,12 @@ namespace ZL {
this_impl->triggerNightEnterCallback = onEnter.as<sol::protected_function>();
});
api.set_function("set_call_taxi_callback",
[this_impl = impl.get()](sol::object onTaxi) {
if (onTaxi.is<sol::protected_function>())
this_impl->callTaxiCallback = onTaxi.as<sol::protected_function>();
});
api.set_function("set_trigger_zone_enabled",
[game](int index, bool value) {
auto& triggerZones = game->triggerZones;
@@ -392,6 +399,29 @@ namespace ZL {
triggerZones[index].enabled = value;
});
// set_teleport_active(index, active) — activates or deactivates a teleport zone by index.
// Swaps the particle effect texture to match the new state.
api.set_function("set_teleport_active",
[game](int index, bool value) {
auto& zones = game->teleportZones;
if (index < 0 || index >= static_cast<int>(zones.size())) {
std::cerr << "[script] set_teleport_active: index " << index << " out of range\n";
return;
}
zones[index].setActive(value);
});
// is_teleport_active(index) → bool
api.set_function("is_teleport_active",
[game](int index) -> bool {
auto& zones = game->teleportZones;
if (index < 0 || index >= static_cast<int>(zones.size())) {
std::cerr << "[script] is_teleport_active: index " << index << " out of range\n";
return false;
}
return zones[index].active;
});
// npc_set_hp(index, value) — sets an NPC's current HP directly.
api.set_function("npc_set_hp",
@@ -837,6 +867,15 @@ namespace ZL {
}
}
void ScriptEngine::callCallTaxiCallback() {
if (!impl || !impl->callTaxiCallback.valid()) return;
auto result = impl->callTaxiCallback();
if (!result.valid()) {
sol::error err = result;
std::cerr << "[SCRIPT] call_taxi callback error: " << err.what() << "\n";
}
}
void ScriptEngine::callCutsceneCompleteCallback(const std::string& cutsceneId) {
if (!impl) return;
auto it = impl->cutsceneCompleteCallbacks.find(cutsceneId);