mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
A script base whose original requires the shared Lua AI: StartLuaAI from OnStartup with the Set table; proximity, hits, timers, deaths and notifications go to the machine, arrivals come from the movement AI finishing a GoTo or follow, and the tether is checked every frame. Moves, skills, immunity and health go through the movement AI, skill and destroyable components. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.5 KiB
C++
34 lines
1.5 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;
|
|
// 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) {}
|
|
};
|