Files
DarkflameServer/dScripts/ai/LuaAI/LuaAIScript.h
Aaron Kimbrell 06e9778076 feat(ai): shared Lua AI waypoint paths and template timers
Port o_WayPointEvents and the waypoint parts of o_mis, o_StateCreate and
o_onEvent: Set.WayPointSet / attached_path / groupID, the WayPointEvent
state and its actions, SavedWP and the last point detaching the path, the
startpath fire event and SetStoreTimmer / CancelTemplateTimers. The
binding reports MovementAIComponent waypoints as arrivals without
actions, since the movement AI already runs the waypoint commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 23:42:38 -06:00

38 lines
1.8 KiB
C++

#pragma once
// The base for a script whose original requires the shared Lua AI (State, o_StateCreate, o_mis, o_Main) and runs
// loadOnce, getVarables, CreateStates and oStart: call StartLuaAI from OnStartup with its Set table. It handles the
// messages o_onEvent and the states do; a script with its own onTimerDone or onDie in the original overrides
// OnLuaTimerDone or OnLuaDie (the states still get theirs first), one with its own onNotifyObject overrides
// OnNotifyObject.
#include "CppScripts.h"
#include "LuaAIMachine.h"
class LuaAIScript : public CppScripts::Script {
public:
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
void OnHit(Entity* self, Entity* attacker) override;
void OnTimerDone(Entity* self, std::string timerName) final;
void OnDie(Entity* self, Entity* killer) final;
void OnUpdate(Entity* self) override;
// The waypoints of its path: the global onArrived (o_WayPointEvents)
void OnWaypointReached(Entity* self, uint32_t waypointIndex) override;
// o_onEvent onFireEvent: startpath
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override;
// o_onEvent onNotifyObject: GoHome
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
// The machine running on this entity, or nullptr
static LuaAI::Machine* GetMachine(const Entity* self);
protected:
// loadOnce, getVarables, CreateStates and oStart
static void StartLuaAI(Entity* self, const LuaAI::Settings& settings);
// The global onTimerDone: o_onEvent's unless the original has its own
virtual void OnLuaTimerDone(Entity* self, const std::string& timerName);
// The global onDie: o_main's does nothing
virtual void OnLuaDie(Entity* self, Entity* killer) {}
};