From d432966e3ef7d940e52917eb0fbe55aa64e5f875 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 26 Sep 2024 23:16:46 -0700 Subject: [PATCH] Worked on Pirate Captain base AI. (Mounted Parrot AI still needs implemented). --- Adventures in Lestoria/Monster.cpp | 3 +- Adventures in Lestoria/Monster.h | 2 +- Adventures in Lestoria/Pirate_Captain.cpp | 48 ++++++++++++++++++- Adventures in Lestoria/TODO.txt | 2 +- .../assets/config/MonsterStrategies.txt | 20 +++++++- .../assets/config/Monsters.txt | 7 ++- 6 files changed, 75 insertions(+), 7 deletions(-) diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index e966efe7..57f971d4 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -1411,8 +1411,9 @@ const bool Monster::_DealTrueDamage(const uint32_t damageAmt,HurtFlag::HurtFlag return _Hurt(damageAmt,OnUpperLevel(),GetZ(),TrueDamageFlag::IGNORE_DAMAGE_RULES,hurtFlags); } -void Monster::Heal(const int healAmt){ +void Monster::Heal(const int healAmt,const bool displayDamageNumber){ hp=std::clamp(hp+healAmt,0,int(GetMaxHealth())); + if(displayDamageNumber)DAMAGENUMBER_LIST.emplace_back(std::make_shared(GetPos(),healAmt,false,DamageNumberType::HEALTH_GAIN); } const float Monster::GetModdedStatBonuses(std::string_view stat)const{ diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h index 08d3f405..607a8f10 100644 --- a/Adventures in Lestoria/Monster.h +++ b/Adventures in Lestoria/Monster.h @@ -203,7 +203,7 @@ public: const bool ReachedTargetPos(const float maxDistanceFromTarget=4.f)const; const float GetHealthRatio()const; const bool _DealTrueDamage(const uint32_t damageAmt,HurtFlag::HurtFlag hurtFlags=HurtFlag::NONE); - void Heal(const int healAmt); + void Heal(const int healAmt,const bool displayDamageNumber=false); const float GetModdedStatBonuses(std::string_view stat)const; //The collision rectangle is only used currently for determining the safe spots for the stone golem boss fight. const std::optional>&GetRectangleCollision()const; diff --git a/Adventures in Lestoria/Pirate_Captain.cpp b/Adventures in Lestoria/Pirate_Captain.cpp index b20a71f4..074c1d8a 100644 --- a/Adventures in Lestoria/Pirate_Captain.cpp +++ b/Adventures in Lestoria/Pirate_Captain.cpp @@ -50,15 +50,61 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string enum PhaseName{ INIT, MOVE, + PREPARE_SHOOT, + SHOOT_RELOAD, + DRINK_RUM, }; switch(m.phase){ case INIT:{ - m.F(A::TARGET_TIMER)= + m.F(A::TARGET_TIMER)=ConfigFloat("Shooting Frequency"); m.phase=MOVE; }break; case MOVE:{ + m.F(A::TARGET_TIMER)-=fElapsedTime; GOBLIN_DAGGER(m,fElapsedTime,"Goblin Dagger"); + + if(m.F(A::TARGET_TIMER)<=0.f){ + const float diceRoll{util::random(100)}; + if(diceRoll<=ConfigFloat("Shooting Chance")){ + const float distToPlayer{util::distance(game->GetPlayer()->GetPos(),m.GetPos())}; + if(distToPlayer<=ConfigFloat("Shoot Max Range")/100.f*24){ + m.F(A::SHOOT_TIMER)=ConfigFloat("Shooting Delay"); + m.phase=PREPARE_SHOOT; + m.PerformAnimation("SHOOT",game->GetPlayer()->GetPos()); + m.V(A::LOCKON_POS)=game->GetPlayer()->GetPos(); + } + } + m.F(A::TARGET_TIMER)=ConfigFloat("Shooting Frequency"); + }else + if(m.GetHealth()