feat: implement ronin script

This commit is contained in:
David Markowitz
2026-06-21 20:57:09 -07:00
parent 5fa158298b
commit 30479a0ef0
11 changed files with 112 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
set(DSCRIPTS_SOURCES_02_SERVER_ENEMY_FV
"DragonRonin.cpp"
"FvMaelstromCavalry.cpp"
"FvMaelstromDragon.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,6 @@
#include "DragonRonin.h"
void DragonRonin::OnStartup(Entity* self) {
self->SetVar<float>(u"suicideTimer", 40);
CountdownDestroyAI::OnStartup(self);
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include "CountdownDestroyAI.h"
class DragonRonin : public CountdownDestroyAI {
public:
void OnStartup(Entity* self) override;
};

View File

@@ -1,6 +1,7 @@
set(DSCRIPTS_SOURCES_02_SERVER_ENEMY_GENERAL
"BaseEnemyMech.cpp"
"BaseEnemyApe.cpp"
"CountdownDestroyAI.cpp"
"GfApeSmashingQB.cpp"
"TreasureChestDragonServer.cpp"
"EnemyNjBuff.cpp"

View File

@@ -0,0 +1,50 @@
#include "CountdownDestroyAI.h"
#include "BaseCombatAIComponent.h"
#include "ScriptComponent.h"
void CountdownDestroyAI::OnStartup(Entity* self) {
CountdownStartup(*self);
auto* scriptComp = self->GetComponent<ScriptComponent>();
if (scriptComp) scriptComp->RegisterMsg(this, &CountdownDestroyAI::OnNotifyCombatAIStateChange);
}
void CountdownDestroyAI::CountdownStartup(Entity& self) {
auto suicideTimer = self.GetVar<float>(u"suicideTimer");
if (suicideTimer == 0.0f) suicideTimer = 60;
self.AddTimer("Dead", suicideTimer);
}
void CountdownDestroyAI::OnHit(Entity* self, Entity* attacker) {
if (!self->GetVar<bool>(u"ShouldBeDead")) return;
self->CancelTimer("IsBeingAttacked");
self->AddTimer("Dead", 5.0f);
}
void CountdownDestroyAI::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "Dead") {
self->SetVar<bool>(u"ShouldBeDead", true);
if (self->GetVar<bool>(u"Busy")) {
self->AddTimer("IsBeingAttacked", 5.0f);
} else {
self->Smash();
}
} else if (timerName == "IsBeingAttacked") {
self->Smash();
}
}
bool CountdownDestroyAI::OnNotifyCombatAIStateChange(Entity& self, GameMessages::NotifyCombatAIStateChange& notifyMsg) {
const auto curState = notifyMsg.newState;
if (curState == AiState::dead) return true;
if (curState == AiState::aggro) {
self.SetVar(u"Busy", true);
} else {
self.SetVar(u"Busy", false);
if (self.GetVar<bool>(u"ShouldBeDead")) {
self.Smash();
}
}
return true;
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "CppScripts.h"
#include "GameMessages.h"
class CountdownDestroyAI : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void CountdownStartup(Entity& self);
void OnHit(Entity* self, Entity* attacker) override;
void OnTimerDone(Entity* self, std::string timerName) override;
bool OnNotifyCombatAIStateChange(Entity& self, GameMessages::NotifyCombatAIStateChange& msg);
};

View File

@@ -137,7 +137,9 @@
#include "FvFlyingCreviceDragon.h"
#include "FvDragonInstanceServer.h"
#include "FvMaelstromDragon.h"
#include "DragonRonin.h"
#include "FvDragonSmashingGolemQb.h"
#include "CountdownDestroyAI.h"
#include "TreasureChestDragonServer.h"
#include "InstanceExitTransferPlayerToLastNonInstance.h"
#include "FvFreeGfNinjas.h"
@@ -492,7 +494,9 @@ namespace {
{"scripts\\02_server\\Map\\FV\\L_FV_HORSEMEN_TRIGGER.lua", []() {return new FvHorsemenTrigger();}},
{"scripts\\ai\\FV\\L_FV_FLYING_CREVICE_DRAGON.lua", []() {return new FvFlyingCreviceDragon();}},
{"scripts\\ai\\FV\\Dragon_Instance\\L_FV_DRAGON_INSTANCE_SERVER.lua", []() {return new FvDragonInstanceServer();}},
{"scripts\\02_server\\Enemy\\FV\\L_FV_DRAGON_RONIN.lua", []() {return new DragonRonin();}},
{"scripts\\02_server\\Enemy\\FV\\L_FV_MAELSTROM_DRAGON.lua", []() {return new FvMaelstromDragon();}},
{"scripts\\02_server\\Enemy\\General\\L_COUNTDOWN_DESTROY_AI.lua", []() {return new CountdownDestroyAI();}},
{"scripts\\ai\\FV\\L_FV_DRAGON_SMASHING_GOLEM_QB.lua", []() {return new FvDragonSmashingGolemQb();}},
{"scripts\\02_server\\Enemy\\General\\L_TREASURE_CHEST_DRAGON_SERVER.lua", []() {return new TreasureChestDragonServer();}},
{"scripts\\ai\\GENERAL\\L_INSTANCE_EXIT_TRANSFER_PLAYER_TO_LAST_NON_INSTANCE.lua", []() {return new InstanceExitTransferPlayerToLastNonInstance();}},