diff --git a/Adventures in Lestoria/Crab.cpp b/Adventures in Lestoria/Crab.cpp index 2e55f314..42ad80b5 100644 --- a/Adventures in Lestoria/Crab.cpp +++ b/Adventures in Lestoria/Crab.cpp @@ -47,5 +47,72 @@ using A=Attribute; INCLUDE_game void Monster::STRATEGY::CRAB(Monster&m,float fElapsedTime,std::string strategy){ + enum PhaseName{ + INIT, + MOVE, + PREPARE_CHARGE, + CHARGE, + }; + switch(PHASE()){ + case INIT:{ + m.B(A::RANDOM_DIRECTION)=util::random()%2; + m.F(A::RANDOM_RANGE)=util::random_range(ConfigPixelsArr("Random Direction Range",0),ConfigPixelsArr("Random Direction Range",1)); + SETPHASE(MOVE); + }break; + case MOVE:{ + m.F(A::ATTACK_COOLDOWN)+=fElapsedTime; + m.F(A::LAST_JUMP_TIMER)+=fElapsedTime; + + float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos()); + + const bool outsideMaxShootingRange=distToPlayer>=ConfigPixelsArr("Stand Still and Shoot Range",1); + + if(m.F(A::LAST_JUMP_TIMER)>=ConfigFloat("Stop Check Interval")){ + if(util::random(100)<=ConfigFloat("Stop Percent")){ + SETPHASE(PREPARE_CHARGE); + m.PerformAnimation("CHARGEUP",m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos())); + m.F(A::CASTING_TIMER)=ConfigFloat("Charge Wait Time"); + m.target=game->GetPlayer()->GetPos()+util::distance(m.GetPos(),game->GetPlayer()->GetPos())*util::pointTo(m.GetPos(),game->GetPlayer()->GetPos()); + }else + if(util::random(100)<=ConfigFloat("Change Direction Chance"))m.B(A::RANDOM_DIRECTION)=!m.B(A::RANDOM_DIRECTION); + m.F(A::LAST_JUMP_TIMER)=0.f; + }else + if(outsideMaxShootingRange){ + m.target=game->GetPlayer()->GetPos(); + RUN_TOWARDS(m,fElapsedTime,"Run Towards"); + }else + if(distToPlayer(m.GetPos(),game->GetPlayer()->GetPos()).upoint(-1); + RUN_TOWARDS(m,fElapsedTime,"Run Towards"); + }else + if(distToPlayer>=ConfigPixelsArr("Random Direction Range",0)&&distToPlayerGetPlayer()->GetPos(),m.GetPos()); + float targetDir=m.B(A::RANDOM_DIRECTION)==CW?dirFromPlayer+PI/4:dirFromPlayer-PI/4; + m.target=game->GetPlayer()->GetPos()+vf2d{m.F(A::RANDOM_RANGE),targetDir}.cart(); + RUN_TOWARDS(m,fElapsedTime,"Run Towards"); + m.F(A::CHASE_TIMER)=1.f; + } + }break; + case PREPARE_CHARGE:{ + m.F(A::CASTING_TIMER)-=fElapsedTime; + if(m.F(A::CASTING_TIMER)<=0.f){ + SETPHASE(CHARGE); + m.F(A::CHASE_TIMER)=ConfigFloat("Charge Max Time"); + m.PerformAnimation("PINCER"); + } + }break; + case CHARGE:{ + m.F(A::CHASE_TIMER)-=fElapsedTime; + RUN_TOWARDS(m,fElapsedTime,"Run Towards"); + if(m.F(A::CHASE_TIMER)<=0.f||m.ReachedTargetPos()){ + SETPHASE(MOVE); + m.B(A::RANDOM_DIRECTION)=util::random()%2; + m.F(A::RANDOM_RANGE)=util::random_range(ConfigPixelsArr("Random Direction Range",0),ConfigPixelsArr("Random Direction Range",1)); + } + }break; + } } \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index a4adcab3..35b423f2 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 11674 +#define VERSION_BUILD 11683 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/Campaigns/3_1.tmx b/Adventures in Lestoria/assets/Campaigns/3_1.tmx index 071d466c..08825543 100644 --- a/Adventures in Lestoria/assets/Campaigns/3_1.tmx +++ b/Adventures in Lestoria/assets/Campaigns/3_1.tmx @@ -1,5 +1,5 @@ - + @@ -1243,27 +1243,17 @@ - + - + - - - - - - - - - - - + diff --git a/Adventures in Lestoria/assets/config/MonsterStrategies.txt b/Adventures in Lestoria/assets/config/MonsterStrategies.txt index 75144b2f..b5601763 100644 --- a/Adventures in Lestoria/assets/config/MonsterStrategies.txt +++ b/Adventures in Lestoria/assets/config/MonsterStrategies.txt @@ -1156,6 +1156,21 @@ MonsterStrategy } Crab { + # When the monster will attempt to run away from target. + Run Away Range = 400 + # Chooses a random direction within the confines of this range, stays within it. + Random Direction Range = 400,600 + # Does not move and shoots from anywhere in these ranges. + Stand Still and Shoot Range = 600,600 + # Anything outside the max "Stand Still and Shoot Range" will cause the monster to move towards the target instead. + + # How often to check for a charge stop. + Stop Check Interval = 1s + # Percentage chance to perform charge each stop. + Stop Percent = 20% + Change Direction Chance = 10% + Charge Wait Time = 0.3s + Charge Max Time = 3s } } \ No newline at end of file diff --git a/Adventures in Lestoria/assets/config/Monsters.txt b/Adventures in Lestoria/assets/config/Monsters.txt index 14ba11bd..c8a2637a 100644 --- a/Adventures in Lestoria/assets/config/Monsters.txt +++ b/Adventures in Lestoria/assets/config/Monsters.txt @@ -1537,6 +1537,7 @@ Monsters WALK = 2, 0.15, Repeat PINCER = 3, 0.3, Repeat DEATH = 2, 0.15, OneShot + CHARGEUP = 1, 0.1, OneShot } # Drop Item Name, Drop Percentage(0-100%), Drop Min Quantity, Drop Max Quantity diff --git a/Adventures in Lestoria/assets/gamepack.pak b/Adventures in Lestoria/assets/gamepack.pak index 32c32272..bb7cd57d 100644 Binary files a/Adventures in Lestoria/assets/gamepack.pak and b/Adventures in Lestoria/assets/gamepack.pak differ diff --git a/Adventures in Lestoria/assets/maps/Monster_Presets.tmx b/Adventures in Lestoria/assets/maps/Monster_Presets.tmx index a844401a..c7171b7a 100644 --- a/Adventures in Lestoria/assets/maps/Monster_Presets.tmx +++ b/Adventures in Lestoria/assets/maps/Monster_Presets.tmx @@ -32,7 +32,7 @@ - + diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 52d3d5b2..65e6186b 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ