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

+1 -4
View File
@@ -368,10 +368,7 @@ namespace ZL
if (currentLocation)
{
if (currentLocation->teleportZones.size() > 0)
{
currentLocation->teleportZones[0].active = true;
}
currentLocation->scriptEngine.callCallTaxiCallback();
}
};
+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);
+1
View File
@@ -49,6 +49,7 @@ public:
void callCutsceneCompleteCallback(const std::string& cutsceneId);
void callChatOpenCallback(int chatIndex);
void callCallTaxiCallback();
private:
struct Impl;
+9
View File
@@ -6,6 +6,8 @@ namespace ZL {
void TeleportZone::initSparks(std::shared_ptr<Texture> activeTex, std::shared_ptr<Texture> inactiveTex)
{
activeTexture = activeTex;
inactiveTexture = inactiveTex;
sparks = std::make_unique<SparkEmitter>();
std::vector<Vector3f> emitPoints;
emitPoints.push_back(Vector3f{ position.x(), position.y(), position.z() });
@@ -25,6 +27,13 @@ void TeleportZone::initSparks(std::shared_ptr<Texture> activeTex, std::shared_pt
sparks->markConfigured();
}
void TeleportZone::setActive(bool isActive)
{
active = isActive;
if (sparks && activeTexture && inactiveTexture)
sparks->setTexture(isActive ? activeTexture : inactiveTexture);
}
void TeleportZone::update(float deltaMs)
{
if (sparks) sparks->update(deltaMs);
+3
View File
@@ -17,8 +17,11 @@ struct TeleportZone {
Eigen::Vector3f destinationPosition = Eigen::Vector3f::Zero();
float destinationRotationY = 0.0f;
std::unique_ptr<SparkEmitter> sparks;
std::shared_ptr<Texture> activeTexture;
std::shared_ptr<Texture> inactiveTexture;
void initSparks(std::shared_ptr<Texture> activeTex, std::shared_ptr<Texture> inactiveTex);
void setActive(bool isActive);
void update(float deltaMs);
void prepareForDraw(const Eigen::Matrix4f& viewMatrix);
void draw(Renderer& renderer, float zoom, int width, int height);