|
|
|
|
#pragma region License
|
|
|
|
|
/*
|
|
|
|
|
License (OLC-3)
|
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
|
are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
1. Redistributions or derivations of source code must retain the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
|
|
|
|
|
|
2. Redistributions or derivative works in binary form must reproduce the above
|
|
|
|
|
copyright notice. This list of conditions and the following disclaimer must be
|
|
|
|
|
reproduced in the documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
3. Neither the name of the copyright holder nor the names of its contributors may
|
|
|
|
|
be used to endorse or promote products derived from this software without specific
|
|
|
|
|
prior written permission.
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
|
|
|
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
|
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
Portions of this software are copyright <EFBFBD> 2024 The FreeType
|
|
|
|
|
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
|
|
|
|
All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
|
|
#include "MonsterStrategyHelpers.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "AdventuresInLestoria.h"
|
|
|
|
|
#include "SoundEffect.h"
|
|
|
|
|
#include "BulletTypes.h"
|
|
|
|
|
|
|
|
|
|
using A=Attribute;
|
|
|
|
|
|
|
|
|
|
INCLUDE_game
|
|
|
|
|
|
|
|
|
|
void Monster::STRATEGY::PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string strategy){
|
|
|
|
|
enum PhaseName{
|
|
|
|
|
INIT,
|
|
|
|
|
MOVE,
|
|
|
|
|
WINDUP,
|
|
|
|
|
RECOVERY,
|
|
|
|
|
LEAP,
|
|
|
|
|
PREPARE_WHIRLWIND,
|
|
|
|
|
WHIRLWIND,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
switch(m.phase){
|
|
|
|
|
case INIT:{
|
|
|
|
|
m.F(A::CHASE_TIMER)=ConfigFloat("Ability Choose Timer");
|
|
|
|
|
m.phase=MOVE;
|
|
|
|
|
}break;
|
|
|
|
|
case MOVE:{
|
|
|
|
|
float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos());
|
|
|
|
|
|
|
|
|
|
m.F(A::CHASE_TIMER)-=fElapsedTime;
|
|
|
|
|
if(m.F(A::CHASE_TIMER)<=0.f){
|
|
|
|
|
m.I(A::ABILITY_COUNT)++;
|
|
|
|
|
m.F(A::CHASE_TIMER)=ConfigFloat("Ability Choose Timer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m.I(A::ABILITY_COUNT)>0){
|
|
|
|
|
float roll{util::random_range(0.f,100.f)};
|
|
|
|
|
float distanceToPlayer{util::distance(m.GetPos(),game->GetPlayer()->GetPos())};
|
|
|
|
|
std::pair<float,float>jumpAttackRollRange{0.f,ConfigFloat("Jump Attack Chance")};
|
|
|
|
|
std::pair<float,float>whirlwindAttackRollRange{jumpAttackRollRange.second,jumpAttackRollRange.second+ConfigFloat("Whirlwind Attack Chance")};
|
|
|
|
|
|
|
|
|
|
if(roll<jumpAttackRollRange.second&&distanceToPlayer>=ConfigFloatArr("Jump Attack Ranges",0)/100.f*24.f&&distanceToPlayer<=ConfigFloatArr("Jump Attack Ranges",1)/100.f*24.f){
|
|
|
|
|
m.phase=LEAP;
|
|
|
|
|
m.V(A::JUMP_TARGET_POS)=game->GetPlayer()->GetPos();
|
|
|
|
|
m.I(A::ABILITY_COUNT)--;
|
|
|
|
|
const float impactArea{ConfigFloat("Jump Attack Impact Area")};
|
|
|
|
|
m.SetStrategyDrawFunction([impactArea](AiL*game,Monster&monster,const std::string&strategy){
|
|
|
|
|
game->view.DrawRotatedDecal(monster.V(A::JUMP_TARGET_POS),GFX["range_indicator.png"].Decal(),0.f,GFX["range_indicator.png"].Sprite()->Size()/2.f,vf2d{1,1}*(impactArea/100.f),{255,0,0,96});
|
|
|
|
|
});
|
|
|
|
|
m.F(A::JUMP_MOVE_TO_TARGET_TIMER)=0.f;
|
|
|
|
|
m.V(A::PREV_POS)=m.GetPos();
|
|
|
|
|
m.PerformAnimation("LEAPING",m.V(A::JUMP_TARGET_POS));
|
|
|
|
|
break;
|
|
|
|
|
}else
|
|
|
|
|
if(roll>=whirlwindAttackRollRange.first&&roll<whirlwindAttackRollRange.second
|
|
|
|
|
&&distanceToPlayer>=ConfigFloatArr("Whirlwind Attack Ranges",0)/100.f*24.f&&distanceToPlayer<=ConfigFloatArr("Whirlwind Attack Ranges",1)/100.f*24.f){
|
|
|
|
|
m.phase=PREPARE_WHIRLWIND;
|
|
|
|
|
m.I(A::ABILITY_COUNT)--;
|
|
|
|
|
vf2d aimingTarget{game->GetPlayer()->GetPos()};
|
|
|
|
|
if(aimingTarget==m.GetPos()){ //Handle edge case.
|
|
|
|
|
aimingTarget=m.GetPos()+vf2d{1.f,util::random(2*PI)}.cart();
|
|
|
|
|
}
|
|
|
|
|
m.V(A::PATH_DIR)=util::pointTo(m.GetPos(),aimingTarget);
|
|
|
|
|
m.PerformAnimation("SPIN",m.V(A::LOCKON_POS));
|
|
|
|
|
m.F(A::CASTING_TIMER)=ConfigFloat("Whirlwind Chargeup Time");
|
|
|
|
|
m.AddBuff(BuffType::SPEEDBOOST,ConfigFloat("Whirlwind Spin Time"),ConfigFloat("Whirlwind Bonus Movespd")/100.f);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NormalBehavior:
|
|
|
|
|
if(distToPlayer>ConfigFloat("Attack Spacing")/100.f*24){
|
|
|
|
|
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
|
|
|
|
}else{
|
|
|
|
|
m.phase=WINDUP;
|
|
|
|
|
m.F(A::CASTING_TIMER)=ConfigFloat("Slash Windup Time");
|
|
|
|
|
m.PerformAnimation("SLASH",m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos()));
|
|
|
|
|
}
|
|
|
|
|
}break;
|
|
|
|
|
case WINDUP:{
|
|
|
|
|
m.F(A::CASTING_TIMER)-=fElapsedTime;
|
|
|
|
|
if(m.F(A::CASTING_TIMER)<=0){
|
|
|
|
|
m.phase=RECOVERY;
|
|
|
|
|
vf2d slashTarget=game->GetPlayer()->GetPos();
|
|
|
|
|
m.PerformAnimation("SLASHING",m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos()));
|
|
|
|
|
CreateBullet(DaggerSlash)(m,ConfigString("Dagger Slash Image"),ConfigFloat("Dagger Hit Radius"),m.GetAttack(),ConfigFloat("Dagger Slash Knockback"),m.OnUpperLevel(),m.GetFacingDirectionToTarget(slashTarget),ConfigFloat("Dagger Frame Duration"),ConfigFloat("Dagger Slash Distance"))EndBullet;
|
|
|
|
|
m.F(A::CASTING_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration();
|
|
|
|
|
m.F(A::RECOVERY_TIME)=ConfigFloat("Attack Recovery Time");
|
|
|
|
|
}
|
|
|
|
|
}break;
|
|
|
|
|
case RECOVERY:{
|
|
|
|
|
m.F(A::CASTING_TIMER)-=fElapsedTime;
|
|
|
|
|
m.F(A::RECOVERY_TIME)-=fElapsedTime;
|
|
|
|
|
if(m.F(A::CASTING_TIMER)<=0){m.PerformIdleAnimation(m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos()));}
|
|
|
|
|
if(m.F(A::RECOVERY_TIME)<=0)m.phase=MOVE;
|
|
|
|
|
}break;
|
|
|
|
|
case LEAP:{
|
|
|
|
|
m.F(A::JUMP_MOVE_TO_TARGET_TIMER)+=fElapsedTime;
|
|
|
|
|
const float halfJumpTime{ConfigFloat("Jump Attack Duration")/2.f};
|
|
|
|
|
if(m.F(A::JUMP_MOVE_TO_TARGET_TIMER)<halfJumpTime)m.SetZ(util::smoothstep(0,ConfigFloat("Jump Attack Height"),m.F(A::JUMP_MOVE_TO_TARGET_TIMER)/halfJumpTime));
|
|
|
|
|
else m.SetZ(util::smoothstep(ConfigFloat("Jump Attack Height"),0,(m.F(A::JUMP_MOVE_TO_TARGET_TIMER)-halfJumpTime)/halfJumpTime));
|
|
|
|
|
m.SetPos(m.V(A::PREV_POS).lerp(m.V(A::JUMP_TARGET_POS),m.F(A::JUMP_MOVE_TO_TARGET_TIMER)/ConfigFloat("Jump Attack Duration")));
|
|
|
|
|
if(m.F(A::JUMP_MOVE_TO_TARGET_TIMER)>=ConfigFloat("Jump Attack Duration")){
|
|
|
|
|
SoundEffect::PlaySFX("Leap Land",m.GetPos());
|
|
|
|
|
game->Hurt(m.GetPos(),ConfigFloat("Jump Attack Impact Area")/100.f*24.f,m.GetAttack(),m.OnUpperLevel(),m.GetZ(),HurtType::PLAYER);
|
|
|
|
|
game->ProximityKnockback(m.GetPos(),ConfigFloat("Jump Attack Impact Area")/100.f*24.f,ConfigFloat("Jump Attack Knockback Amount"),HurtType::MONSTER|HurtType::PLAYER);
|
|
|
|
|
m.SetZ(0.f);
|
|
|
|
|
m.SetPos(m.V(A::JUMP_TARGET_POS));
|
|
|
|
|
m.phase=MOVE;
|
|
|
|
|
m.PerformIdleAnimation();
|
|
|
|
|
m.SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
|
|
|
|
}
|
|
|
|
|
}break;
|
|
|
|
|
case PREPARE_WHIRLWIND:{
|
|
|
|
|
m.F(A::CASTING_TIMER)-=fElapsedTime;
|
|
|
|
|
if(m.F(A::CASTING_TIMER)<=0.f){
|
|
|
|
|
m.phase=WHIRLWIND;
|
|
|
|
|
m.F(A::CHASE_TIMER)=0.f;
|
|
|
|
|
m.PerformAnimation("SPINNING");
|
|
|
|
|
}
|
|
|
|
|
}break;
|
|
|
|
|
case WHIRLWIND:{
|
|
|
|
|
m.F(A::CHASE_TIMER)+=fElapsedTime;
|
|
|
|
|
if(m.F(A::CHASE_TIMER)>=ConfigFloat("Whirlwind Spin Time")){
|
|
|
|
|
m.phase=MOVE;
|
|
|
|
|
m.PerformIdleAnimation();
|
|
|
|
|
}
|
|
|
|
|
m.MoveForward(m.V(A::PATH_DIR),fElapsedTime);
|
|
|
|
|
const HurtList hurtTargets{game->Hurt(m.GetPos(),ConfigFloat("Whirlwind Radius")/100.f*24.f,m.GetAttack(),m.OnUpperLevel(),m.GetZ(),HurtType::PLAYER)};
|
|
|
|
|
for(auto&[target,isHurt]:hurtTargets){
|
|
|
|
|
if(std::holds_alternative<Player*>(target)){
|
|
|
|
|
(std::get<Player*>(target))->ApplyIframes(0.5f);
|
|
|
|
|
}else ERR("WARNING! Somehow ended up with a non-player entity for whirlwind damage check! THIS SHOULD NOT BE HAPPENING!")
|
|
|
|
|
}
|
|
|
|
|
game->ProximityKnockback(m.GetPos(),ConfigFloat("Whirlwind Radius")/100.f*24.f,ConfigFloat("Whirlwind Knockback Amount"),HurtType::MONSTER|HurtType::PLAYER);
|
|
|
|
|
}break;
|
|
|
|
|
}
|
|
|
|
|
}
|