#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; // 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) {} };