|
|
#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> 2023 The FreeType
|
|
|
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
|
|
All rights reserved.
|
|
|
*/
|
|
|
#pragma endregion
|
|
|
|
|
|
#include "Monster.h"
|
|
|
#include "AdventuresInLestoria.h"
|
|
|
#include "MonsterStrategyHelpers.h"
|
|
|
#include "util.h"
|
|
|
#include "BulletTypes.h"
|
|
|
#include "SoundEffect.h"
|
|
|
|
|
|
INCLUDE_game
|
|
|
INCLUDE_BULLET_LIST
|
|
|
INCLUDE_GFX
|
|
|
INCLUDE_MONSTER_LIST
|
|
|
INCLUDE_MONSTER_DATA
|
|
|
|
|
|
using A=Attribute;
|
|
|
|
|
|
void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy){
|
|
|
switch(m.phase){
|
|
|
case 0:{
|
|
|
m.phase=ConfigInt("StartPhase");
|
|
|
m.overlaySprite=ConfigString("Overlay Sprite");
|
|
|
m.overlaySpriteTransparency=0U;
|
|
|
}break;
|
|
|
case 1:{ //Run bear strategy in phase 1.
|
|
|
|
|
|
auto TransitionToPhase2=[&](){
|
|
|
m.phase=2;
|
|
|
m.PerformOtherAnimation(1);
|
|
|
m.AddBuff(BARRIER_DAMAGE_REDUCTION,INFINITE,ConfigFloat("Phase 2.Barrier Damage Reduction")/100.f);
|
|
|
m.I(A::PHASE_REPEAT_COUNT)=ConfigInt("Phase 2.Wisp Pattern Spawn Count");
|
|
|
SoundEffect::PlaySFX("Ursule Phase Transition",SoundEffect::CENTERED);
|
|
|
};
|
|
|
|
|
|
if(m.GetRemainingHPPct()<=ConfigFloat("Phase 2.Change")/100.f){
|
|
|
//before moving to Phase 2, we need to make sure we're in Phase 0 of the bear AI.
|
|
|
if(m.overlaySpriteTransparency<210U){
|
|
|
if(m.I(A::PHASE)!=0.f)goto bear;
|
|
|
else{
|
|
|
if(m.F(A::RUN_AWAY_TIMER)==0.f)m.F(A::RUN_AWAY_TIMER)=ConfigFloat("Phase 1.Fur Change Color Time");
|
|
|
else{
|
|
|
m.F(A::RUN_AWAY_TIMER)=std::max(0.f,m.F(A::RUN_AWAY_TIMER)-fElapsedTime);
|
|
|
if(m.F(A::RUN_AWAY_TIMER)==0.f)m.overlaySpriteTransparency=210U;
|
|
|
}
|
|
|
m.overlaySpriteTransparency=util::lerp(0U,210U,1-(m.F(A::RUN_AWAY_TIMER)/ConfigFloat("Phase 1.Fur Change Color Time")));
|
|
|
}
|
|
|
break;
|
|
|
}else{
|
|
|
//We also need to move to the center of the map.
|
|
|
if(m.F(A::RUN_AWAY_TIMER)==0.f)m.F(A::RUN_AWAY_TIMER)=ConfigFloat("Phase 1.Run to Center Time");
|
|
|
else{
|
|
|
m.F(A::RUN_AWAY_TIMER)=std::max(0.f,m.F(A::RUN_AWAY_TIMER)-fElapsedTime);
|
|
|
if(m.F(A::RUN_AWAY_TIMER)==0.f){
|
|
|
TransitionToPhase2();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
vf2d mapCenter=game->GetCurrentMap().MapData.MapSize*vf2d{float(game->GetCurrentMap().MapData.tilewidth),float(game->GetCurrentMap().MapData.tileheight)}/2.0f;
|
|
|
float distToCenter=geom2d::line<float>(m.GetPos(),mapCenter).length();
|
|
|
if(distToCenter>4.0f){
|
|
|
m.targetAcquireTimer=20.f;
|
|
|
m.target=mapCenter;
|
|
|
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
|
|
break;
|
|
|
}else{ //Now we're finally good for phase 2.
|
|
|
TransitionToPhase2();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
bear:
|
|
|
BEAR(m,fElapsedTime,"Bear");
|
|
|
}break;
|
|
|
case 2:{
|
|
|
m.PerformOtherAnimation(2);
|
|
|
m.F(A::SHOOT_TIMER)=std::max(0.f,m.F(A::SHOOT_TIMER)-fElapsedTime);
|
|
|
|
|
|
if(m.I(A::PHASE_REPEAT_COUNT)>0){
|
|
|
if(m.F(A::SHOOT_TIMER)==0.f){
|
|
|
uint8_t wispPatternCount=ConfigInt("Wisp Pattern Count");
|
|
|
|
|
|
uint8_t wispPattern=util::random()%wispPatternCount;
|
|
|
|
|
|
if(ConfigString("Phase 2.Wisp Pattern Random Selection")=="Bag"){
|
|
|
if(m.VEC(A::WISP_PATTERN_LIST).size()==0){
|
|
|
for(uint8_t numb=0;numb<wispPatternCount;numb++){ //Numbers are randomly inserted into the list.
|
|
|
m.VEC(A::WISP_PATTERN_LIST).insert(m.VEC(A::WISP_PATTERN_LIST).begin()+(util::random()%(m.VEC(A::WISP_PATTERN_LIST).size()+1)),numb);
|
|
|
}
|
|
|
}
|
|
|
wispPattern=std::any_cast<uint8_t>(m.VEC(A::WISP_PATTERN_LIST).back());
|
|
|
m.VEC(A::WISP_PATTERN_LIST).pop_back();
|
|
|
}
|
|
|
|
|
|
m.F(A::SHOOT_TIMER)=ConfigFloat("Phase 2.Wisp Pattern Spawn Wait Time");
|
|
|
|
|
|
vi2d wispSize={ConfigIntArr("Phase 2.Wisp Size",0),ConfigIntArr("Phase 2.Wisp Size",1)};
|
|
|
|
|
|
float rowWidth=ConfigString(std::format("Wisp Pattern {}.Row[0]",wispPattern)).length()*wispSize.x; // Width of a wisp set in pixels.
|
|
|
float mapWidth=game->GetCurrentMap().MapData.MapSize.x*float(game->GetCurrentMap().MapData.tilewidth);
|
|
|
int rowCount=Config(std::format("Wisp Pattern {}",wispPattern)).GetKeys().size();
|
|
|
for(float x=0;x<mapWidth;x+=wispSize.x){
|
|
|
for(int y=0;y<rowCount;y++){
|
|
|
std::string_view row=ConfigString(std::format("Wisp Pattern {}.Row[{}]",wispPattern,y));
|
|
|
if(row[int(x/wispSize.x)%row.length()]!='.'){
|
|
|
float ySpawn=ConfigInt("Phase 2.Wisp Pattern Spawn Y")+y*wispSize.y;
|
|
|
BULLET_LIST.push_back(std::make_unique<Wisp>(vf2d{x,ySpawn},vf2d{0,ConfigFloat("Phase 2.Wisp Speed")},wispSize.x/2,m.GetAttack(),m.OnUpperLevel(),false,ConfigPixel("Phase 2.Wisp Color")));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
m.I(A::PHASE_REPEAT_COUNT)--;
|
|
|
}
|
|
|
}else{
|
|
|
if(m.F(A::RECOVERY_TIME)==0.f){
|
|
|
if(ConfigFloat("Phase 2.Wisp Count Phase Change Wait")==0.f)m.phase=3;
|
|
|
m.F(A::RECOVERY_TIME)=ConfigFloat("Phase 2.Wisp Count Phase Change Wait");
|
|
|
}else{
|
|
|
m.F(A::RECOVERY_TIME)-=fElapsedTime;
|
|
|
if(m.F(A::RECOVERY_TIME)<=0.f){
|
|
|
m.phase=3;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}break;
|
|
|
case 3:{
|
|
|
std::cout<<"Phase 3"<<std::endl;
|
|
|
}break;
|
|
|
default:{
|
|
|
ERR(std::format("WARNING! Unknown phase {} for {} reached!",m.phase,m.GetName()));
|
|
|
}
|
|
|
}
|
|
|
} |