From debc23bfa33f5d448350f65d837ebeef3e5c6d79 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 5 Nov 2024 23:22:44 -0800 Subject: [PATCH] Additional AI setup. --- Adventures in Lestoria/Monster.cpp | 2 -- Adventures in Lestoria/Monster.h | 4 +++- Adventures in Lestoria/OctopusArm.cpp | 20 +++++++++++++++++++ .../assets/config/MonsterStrategies.txt | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index 543831ac..a0dbbb1b 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -1259,8 +1259,6 @@ const float Monster::GetCollisionDamage()const{ else return MONSTER_DATA[name].GetCollisionDmg(); } -//Sets the strategy death function that runs when a monster dies. -// The function should return false to indicate the event is over. If the event should keep running, return true. void Monster::SetStrategyDeathFunction(std::functionfunc){ strategyDeathFunc=func; } diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h index a76c5c9d..7dff52a3 100644 --- a/Adventures in Lestoria/Monster.h +++ b/Adventures in Lestoria/Monster.h @@ -289,7 +289,9 @@ private: NPCData npcData; float lastPathfindingCooldown=0.f; std::functionstrategyDeathFunc{}; - void SetStrategyDeathFunction(std::functionfunc); +//Sets the strategy death function that runs when a monster dies. +// The function should return false to indicate the event is over. If the event should keep running, return true. + void SetStrategyDeathFunction(std::functionfunc); //If you are trying to change a Get() stat, use the STAT_UP buff (and the optional argument) to supply an attribute you want to apply. const ItemAttribute&GetBonusStat(std::string_view attr)const; //Returns false if the monster could not be moved to the requested location due to collision. diff --git a/Adventures in Lestoria/OctopusArm.cpp b/Adventures in Lestoria/OctopusArm.cpp index a3a17bfb..b9d2dc4c 100644 --- a/Adventures in Lestoria/OctopusArm.cpp +++ b/Adventures in Lestoria/OctopusArm.cpp @@ -46,6 +46,8 @@ All rights reserved. using A=Attribute; INCLUDE_game +INCLUDE_MONSTER_LIST +INCLUDE_MONSTER_DATA void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string strategy){ enum PhaseName{ @@ -73,6 +75,24 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str m.PerformAnimation("RISE",game->GetPlayer()->GetPos()); m.F(A::CASTING_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration(); SETPHASE(RISE_ANIMATION); + m.SetStrategyDeathFunction([bossDamageOnDeath=ConfigInt("Boss Damage On Death")](GameEvent&event,Monster&m,const StrategyName&strategyName){ + const std::string GIANT_OCTOPUS_NAME{"Giant Octopus"}; + const std::string OCTOPUS_ARM_NAME{"Octopus Arm"}; + + if(!MONSTER_DATA.count(GIANT_OCTOPUS_NAME))ERR("WARNING! Octopus" + + auto boss{std::find_if(MONSTER_LIST.begin(),MONSTER_LIST.end(),[&GIANT_OCTOPUS_NAME](const std::shared_ptr&m){ + return m->GetName()==GIANT_OCTOPUS_NAME; + })}; + if(boss!=MONSTER_LIST.end()){ + Monster&bossMonster{**boss}; + bossMonster.Hurt(bossDamageOnDeath,m.OnUpperLevel(),m.GetZ()); + } + std::for_each(MONSTER_LIST.begin(),MONSTER_LIST.end(),[&OCTOPUS_ARM_NAME](const std::shared_ptr&m){ + if(m->GetName()==OCTOPUS_ARM_NAME) + }); + return false; + }); }break; case RISE_ANIMATION:{ m.F(A::CASTING_TIMER)-=fElapsedTime; diff --git a/Adventures in Lestoria/assets/config/MonsterStrategies.txt b/Adventures in Lestoria/assets/config/MonsterStrategies.txt index 4ecf95ae..07914560 100644 --- a/Adventures in Lestoria/assets/config/MonsterStrategies.txt +++ b/Adventures in Lestoria/assets/config/MonsterStrategies.txt @@ -1213,6 +1213,8 @@ MonsterStrategy Attack Knockback = 50 + Boss Damage On Death = 6000hp + # Amount of time the spreading aftershock effect appears for. Attack Effect Time = 0.4s }