In-progress changes to refactoring monster strategies and reading from configs with string views.
This commit is contained in:
parent
d384478792
commit
0fea687304
@ -57,7 +57,7 @@ class ItemAttribute{
|
||||
std::string modifies="";
|
||||
std::optional<std::variant<Player*,Monster*>>target;
|
||||
public:
|
||||
inline static safemap<std::string,ItemAttribute>attributes;
|
||||
inline static safemap<std::string_view,ItemAttribute>attributes;
|
||||
ItemAttribute(std::string_view originalName,std::string_view name,bool isPct,bool showDecimal,std::string_view modifies=""sv);
|
||||
static ItemAttribute&Get(const std::string_view name,const std::optional<std::variant<Player*,Monster*>>target={});
|
||||
const std::string_view Name()const;
|
||||
|
||||
@ -226,7 +226,7 @@ void Audio::BGM::SetFadeTime(const float fadeTime){
|
||||
this->fadeTime=fadeTime;
|
||||
}
|
||||
|
||||
void Audio::BGM::AddEventVolumes(const Event&eventName,const VolumeList&volumes){
|
||||
void Audio::BGM::AddEventVolumes(const std::string_view eventName,const VolumeList&volumes){
|
||||
eventVolumes.AddEventInfo(eventName,volumes);
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ const VolumeList&Audio::EventData::GetVolumes(const Event&event)const{
|
||||
return eventInfo.at("Default Volume");
|
||||
}
|
||||
|
||||
void Audio::EventData::AddEventInfo(const Event&eventName,const VolumeList&volumes){
|
||||
void Audio::EventData::AddEventInfo(const std::string_view eventName,const VolumeList&volumes){
|
||||
eventInfo[eventName]=volumes;
|
||||
}
|
||||
|
||||
|
||||
@ -99,10 +99,10 @@ private:
|
||||
};
|
||||
class EventData{
|
||||
public:
|
||||
void AddEventInfo(const Event&eventName,const VolumeList&volumes);
|
||||
void AddEventInfo(const std::string_view eventName,const VolumeList&volumes);
|
||||
const VolumeList&GetVolumes(const Event&event)const;
|
||||
private:
|
||||
std::map<Event,VolumeList>eventInfo;
|
||||
std::map<std::string_view,VolumeList>eventInfo;
|
||||
};
|
||||
static float bgmVol;
|
||||
static float sfxVol;
|
||||
@ -116,7 +116,7 @@ private:
|
||||
void SetName(std::string_view name);
|
||||
void SetFileName(std::string_view name);
|
||||
void AddChannel(const ChannelName&name);
|
||||
void AddEventVolumes(const Event&eventName,const VolumeList&volumes);
|
||||
void AddEventVolumes(const std::string_view eventName,const VolumeList&volumes);
|
||||
void SetFadeTime(const float fadeTime);
|
||||
const ChannelID&GetChannelID(const int index);
|
||||
const ChannelIDList&GetChannelIDs()const;
|
||||
@ -136,8 +136,8 @@ private:
|
||||
private:
|
||||
MiniAudio audioEngine;
|
||||
SongName currentBGM="";
|
||||
safemap<SongName,BGM>bgm;
|
||||
std::set<Event>events;
|
||||
safemap<std::string_view,BGM>bgm;
|
||||
std::set<std::string_view>events;
|
||||
static float defaultFadeTime;
|
||||
Event currentAudioEvent="Default Volume";
|
||||
std::vector<float>prevVolumes;
|
||||
|
||||
@ -51,7 +51,7 @@ INCLUDE_MONSTER_DATA
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::BEAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(BEAR)
|
||||
switch(PHASE()){
|
||||
case 0:{
|
||||
float distToPlayer=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).length();
|
||||
@ -69,7 +69,7 @@ void Monster::STRATEGY::BEAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
m.RotateTowardsPos(m.GetPos()+m.V(A::LOCKON_POS).cart());
|
||||
}else{
|
||||
m.target=game->GetPlayer()->GetPos();
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}
|
||||
}break;
|
||||
case 1:{
|
||||
@ -108,4 +108,4 @@ void Monster::STRATEGY::BEAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -62,14 +62,14 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos());
|
||||
if(m.canMove&&distToPlayer>=ConfigInt("Closein Range")/100.f*24){
|
||||
m.RemoveBuff(BuffType::SELF_INFLICTED_SLOWDOWN);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(m.HasLineOfSight(game->GetPlayer()->GetPos())&&m.canMove&&distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
|
||||
m.RemoveBuff(BuffType::SELF_INFLICTED_SLOWDOWN);
|
||||
m.AddBuff(BuffType::SELF_INFLICTED_SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f);
|
||||
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(-100);
|
||||
if(m.attackedByPlayer)goto ScratchPhaseTransition;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
|
||||
}else{
|
||||
ScratchPhaseTransition:
|
||||
@ -110,7 +110,7 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
if(m.F(A::TARGET_TIMER)<=0||m.bumpedIntoTerrain||distToTarget<12.f){
|
||||
TransitionToRecoveryPhase();
|
||||
}else{
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
//m.PerformShootAnimation();
|
||||
if(!m.canMove)TransitionToRecoveryPhase();
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ All rights reserved.
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::BREAKING_PILLAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(BREAKING_PILLAR)
|
||||
enum Phase{
|
||||
INITIALIZE,
|
||||
RUN,
|
||||
@ -62,7 +62,7 @@ void Monster::STRATEGY::BREAKING_PILLAR(Monster&m,float fElapsedTime,std::string
|
||||
m.F(A::SHAKE_TIMER)=0.2f;
|
||||
SETPHASE(RUN);
|
||||
|
||||
m.SetStrategyDeathFunction([&](GameEvent&deathEvent,Monster&m,const std::string&strategy){
|
||||
m.SetStrategyDeathFunction([&](GameEvent&deathEvent,Monster&m,const StrategyName strategy){
|
||||
m.lifetime=0.01f;
|
||||
m.B(A::MARKED_DEAD)=true;
|
||||
const float bulletAngRandomOffset{util::random(PI/2)};
|
||||
@ -92,4 +92,4 @@ void Monster::STRATEGY::BREAKING_PILLAR(Monster&m,float fElapsedTime,std::string
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -57,7 +57,7 @@ enum Class{
|
||||
|
||||
namespace classutils{//Classes have bit-wise operator capabilities.
|
||||
inline std::unordered_map<Class,std::string>classList;
|
||||
static inline Class StringToClass(std::string className){
|
||||
static inline Class StringToClass(const std::string&className){
|
||||
const std::vector<std::string>&classList=DATA["class_list"].GetValues();
|
||||
auto it=std::find(classList.begin(),classList.end(),className);
|
||||
if(it==classList.end())ERR(std::format("WARNING! Class {} does not exist!",className));
|
||||
|
||||
@ -42,11 +42,9 @@ All rights reserved.
|
||||
#include "SoundEffect.h"
|
||||
#include "BulletTypes.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::CRAB(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(CRAB)
|
||||
enum PhaseName{
|
||||
INIT,
|
||||
MOVE,
|
||||
@ -80,11 +78,11 @@ void Monster::STRATEGY::CRAB(Monster&m,float fElapsedTime,std::string strategy){
|
||||
}else
|
||||
if(outsideMaxShootingRange){
|
||||
m.target=game->GetPlayer()->GetPos();
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(distToPlayer<ConfigPixels("Run Away Range")){
|
||||
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).upoint(-1);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(distToPlayer>=ConfigPixelsArr("Random Direction Range",0)&&distToPlayer<ConfigPixelsArr("Random Direction Range",1)){
|
||||
#define CW true
|
||||
@ -93,7 +91,7 @@ void Monster::STRATEGY::CRAB(Monster&m,float fElapsedTime,std::string strategy){
|
||||
float dirFromPlayer=util::angleTo(game->GetPlayer()->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.RunStrategy(RUN_TOWARDS);
|
||||
m.F(A::CHASE_TIMER)=1.f;
|
||||
}
|
||||
}break;
|
||||
@ -107,7 +105,7 @@ void Monster::STRATEGY::CRAB(Monster&m,float fElapsedTime,std::string strategy){
|
||||
}break;
|
||||
case CHARGE:{
|
||||
m.F(A::CHASE_TIMER)-=fElapsedTime;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
if(m.F(A::CHASE_TIMER)<=0.f||m.ReachedTargetPos()){
|
||||
SETPHASE(MOVE);
|
||||
m.B(A::RANDOM_DIRECTION)=util::random()%2;
|
||||
@ -115,4 +113,4 @@ void Monster::STRATEGY::CRAB(Monster&m,float fElapsedTime,std::string strategy){
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -53,7 +53,6 @@ using MonsterSpawnerID=int;
|
||||
#define INCLUDE_BULLET_LIST extern std::vector<std::unique_ptr<IBullet>>BULLET_LIST;
|
||||
#define INCLUDE_EMITTER_LIST extern std::vector<std::unique_ptr<IEmitter>>EMITTER_LIST;
|
||||
#define INCLUDE_DATA extern utils::datafile DATA;
|
||||
#define INCLUDE_STRATEGY_DATA extern safemap<std::string,std::function<void(Monster&,float,std::string)>>STRATEGY_DATA;
|
||||
#define INCLUDE_TILE_ANIMATION_DATA extern std::map<int,std::vector<std::pair<int,float>>>TILE_ANIMATION_DATA;
|
||||
#define INCLUDE_GFX extern safemap<std::string,Renderable>GFX;
|
||||
#define INCLUDE_ITEM_DATA extern safemap<std::string,ItemInfo>ITEM_DATA;
|
||||
|
||||
@ -38,4 +38,6 @@ All rights reserved.
|
||||
|
||||
#include "Monster.h"
|
||||
|
||||
void Monster::STRATEGY::DONOTHING(Monster&m,float fElapsedTime,std::string strategy){}
|
||||
DEFINE_STRATEGY(DONOTHING)
|
||||
|
||||
END_STRATEGY
|
||||
@ -44,7 +44,7 @@ INCLUDE_game
|
||||
INCLUDE_DATA
|
||||
|
||||
float EnvironmentalAudio::ACTIVATION_RANGE;
|
||||
std::map<EnvironmentalAudioSoundName,EnvironmentalAudioData>EnvironmentalAudio::SOUND_DATA;
|
||||
std::map<std::string_view,EnvironmentalAudioData>EnvironmentalAudio::SOUND_DATA;
|
||||
|
||||
void EnvironmentalAudio::Initialize(){
|
||||
ACTIVATION_RANGE="Audio.Environmental Audio Activation Range"_F;
|
||||
|
||||
@ -54,7 +54,7 @@ class EnvironmentalAudio{
|
||||
static float ACTIVATION_RANGE;
|
||||
bool activated=false;
|
||||
size_t soundInstance=std::numeric_limits<size_t>::max();
|
||||
static std::map<EnvironmentalAudioSoundName,EnvironmentalAudioData>SOUND_DATA;
|
||||
static std::map<std::string_view,EnvironmentalAudioData>SOUND_DATA;
|
||||
public:
|
||||
static void Initialize();
|
||||
EnvironmentalAudio();
|
||||
|
||||
@ -46,9 +46,7 @@ All rights reserved.
|
||||
INCLUDE_game
|
||||
INCLUDE_BULLET_LIST
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::FROG(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(FROG)
|
||||
m.F(A::LOCKON_WAITTIME)=std::max(0.0f,m.F(A::LOCKON_WAITTIME)-fElapsedTime);
|
||||
phase:
|
||||
switch(PHASE()){
|
||||
@ -62,7 +60,7 @@ void Monster::STRATEGY::FROG(Monster&m,float fElapsedTime,std::string strategy){
|
||||
goto phase;
|
||||
}
|
||||
m.RotateTowardsPos(m.target);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
m.PerformJumpAnimation();
|
||||
}break;
|
||||
case 1:{
|
||||
@ -91,4 +89,4 @@ void Monster::STRATEGY::FROG(Monster&m,float fElapsedTime,std::string strategy){
|
||||
ERR(std::format("Unhandled phase {} for {} strategy!",PHASE(),strategy));
|
||||
}
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -43,13 +43,11 @@ All rights reserved.
|
||||
#include "BulletTypes.h"
|
||||
#include <ranges>
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_MONSTER_LIST
|
||||
INCLUDE_BULLET_LIST
|
||||
|
||||
void Monster::STRATEGY::GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(GHOST_OF_PIRATE_CAPTAIN)
|
||||
enum PhaseName{
|
||||
INIT,
|
||||
NORMAL,
|
||||
@ -110,7 +108,7 @@ void Monster::STRATEGY::GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std
|
||||
SHRAPNEL_SHOT,
|
||||
};
|
||||
case INIT:{
|
||||
m.SetStrategyDeathFunction([](GameEvent&ev,Monster&m,const std::string&strategy){
|
||||
m.SetStrategyDeathFunction([](GameEvent&ev,Monster&m,const StrategyName strategy){
|
||||
for(std::shared_ptr<Monster>&m:MONSTER_LIST){
|
||||
if(m->IsAlive())m->_DealTrueDamage(m->GetHealth(),HurtFlag::NONE);
|
||||
}
|
||||
@ -312,11 +310,11 @@ void Monster::STRATEGY::GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std
|
||||
}
|
||||
}break;
|
||||
case FINAL:{
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
m.target=ConfigVec("Final Standing Spot");
|
||||
m.PerformAnimation("SLASH",Direction::SOUTH);
|
||||
m.SetStrategyOnHitFunction({});
|
||||
m.SetStrategyDeathFunction([](GameEvent&event,Monster&m,const std::string&strategyName){
|
||||
m.SetStrategyDeathFunction([](GameEvent&event,Monster&m,const StrategyName strategyName){
|
||||
for(std::unique_ptr<IBullet>&bullet:BULLET_LIST|std::views::filter([](std::unique_ptr<IBullet>&bullet){return !bullet->friendly;}))bullet->lifetime=0.f;
|
||||
const std::string_view PIRATES_TREASURE{"Pirate's Treasure"};
|
||||
for(std::shared_ptr<Monster>&treasure:MONSTER_LIST
|
||||
@ -371,4 +369,4 @@ void Monster::STRATEGY::GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -46,7 +46,7 @@ using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::GIANT_CRAB(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(GIANT_CRAB)
|
||||
enum PhaseName{
|
||||
PREPARE_CHARGE,
|
||||
CHARGE,
|
||||
@ -78,7 +78,7 @@ void Monster::STRATEGY::GIANT_CRAB(Monster&m,float fElapsedTime,std::string stra
|
||||
}
|
||||
}
|
||||
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -47,7 +47,7 @@ using A=Attribute;
|
||||
INCLUDE_game
|
||||
INCLUDE_MONSTER_LIST
|
||||
|
||||
void Monster::STRATEGY::GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(GIANT_OCTOPUS)
|
||||
enum PhaseName{
|
||||
INIT,
|
||||
IDENTIFY_ARMS,
|
||||
@ -71,7 +71,7 @@ void Monster::STRATEGY::GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string s
|
||||
case INIT:{
|
||||
m.F(A::BREAK_TIME)=0.5f;
|
||||
m.AddBuff(BuffType::DAMAGE_REDUCTION,INFINITE,ConfigFloat("Permanent Resistance Buff")/100.f);
|
||||
m.SetStrategyDeathFunction([](GameEvent&event,Monster&m,const std::string&strategy){
|
||||
m.SetStrategyDeathFunction([](GameEvent&event,Monster&m,const StrategyName strategy){
|
||||
std::string takoyakiImgDir{"item_img_directory"_S+"Takoyaki.png"};
|
||||
if(!GFX.count(takoyakiImgDir))ERR(std::format("WARNING! Could not find item image {}",takoyakiImgDir));
|
||||
game->AddEffect(std::make_unique<Effect>(m.GetPos(),INFINITE,"item_img_directory"_S+"Takoyaki.png",m.OnUpperLevel(),1.f,0.f,vf2d{4.f,4.f},vf2d{},WHITE));
|
||||
@ -131,7 +131,7 @@ void Monster::STRATEGY::GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string s
|
||||
randomArm.lock()->GetFloat(A::RECOVERY_TIME)=randomArm.lock()->GetCurrentAnimation().GetTotalAnimationDuration();
|
||||
randomArm.lock()->SetCollisionRadius(0.f);
|
||||
randomArm.lock()->V(A::JUMP_TARGET_POS)=randomLoc;
|
||||
randomArm.lock()->SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
||||
randomArm.lock()->SetStrategyDrawFunction([]STRATEGY_FUNC{});
|
||||
}
|
||||
m.F(A::CASTING_TIMER)=util::random_range(ConfigFloatArr("Arm Move Timer",0),ConfigFloatArr("Arm Move Timer",1));
|
||||
}
|
||||
@ -176,4 +176,4 @@ void Monster::STRATEGY::GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string s
|
||||
}break;
|
||||
case DEAD:{}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -47,7 +47,7 @@ INCLUDE_game
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::GOBLIN_BOAR_RIDER(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(GOBLIN_BOAR_RIDER)
|
||||
//We have access to GOBLIN_BOW_MOUNTED_X and GOBLIN_BOW_ATTACK_X
|
||||
if(!m.B(A::INITIALIZED_MOUNTED_MONSTER)){
|
||||
m.B(A::INITIALIZED_MOUNTED_MONSTER)=true;
|
||||
@ -64,7 +64,7 @@ void Monster::STRATEGY::GOBLIN_BOAR_RIDER(Monster&m,float fElapsedTime,std::stri
|
||||
m.deathData.emplace_back(ConfigString("Spawned Monster"),1U);
|
||||
}
|
||||
|
||||
BOAR(m,fElapsedTime,"Boar");
|
||||
m.RunStrategy(BOAR);
|
||||
|
||||
m.F(A::ATTACK_COOLDOWN)+=fElapsedTime;
|
||||
if(m.F(A::SHOOT_TIMER)>0.f){
|
||||
@ -85,4 +85,4 @@ void Monster::STRATEGY::GOBLIN_BOAR_RIDER(Monster&m,float fElapsedTime,std::stri
|
||||
m.F(A::SHOOT_TIMER)=ConfigFloat("Attack Windup Time");
|
||||
m.mounted_animation.value().ChangeState(m.internal_mounted_animState,std::format("GOBLIN_BOW_ATTACK_{}",int(m.GetFacingDirection())));
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -54,7 +54,7 @@ using A=Attribute;
|
||||
Tries to keeps his distance on a 600 radius. Throws bombs even while moving.
|
||||
*/
|
||||
|
||||
void Monster::STRATEGY::GOBLIN_BOMB(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(GOBLIN_BOMB)
|
||||
enum PhaseName{
|
||||
INITIALIZE,
|
||||
RUN,
|
||||
@ -79,8 +79,7 @@ void Monster::STRATEGY::GOBLIN_BOMB(Monster&m,float fElapsedTime,std::string str
|
||||
m.F(A::SHOOT_TIMER)=0.f;
|
||||
}
|
||||
if(m.F(A::SHOOT_ANIMATION_TIME)<0.f)m.B(A::IGNORE_DEFAULT_ANIMATIONS)=false;
|
||||
RUN_AWAY(m,fElapsedTime,"Run Away");
|
||||
m.RunStrategy(RUN_AWAY);
|
||||
}break;
|
||||
}
|
||||
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -54,9 +54,8 @@ before shooting takes 1 second.
|
||||
INCLUDE_game
|
||||
INCLUDE_ANIMATION_DATA
|
||||
INCLUDE_BULLET_LIST
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(GOBLIN_BOW)
|
||||
#pragma region Phase, Animation, and Helper function setup
|
||||
enum PhaseName{
|
||||
INITIALIZE_PERCEPTION,
|
||||
@ -87,14 +86,14 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
|
||||
|
||||
if(outsideMaxShootingRange){
|
||||
m.target=game->GetPlayer()->GetPos();
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(m.F(A::ATTACK_COOLDOWN)>=ConfigFloat("Attack Reload Time")){
|
||||
PrepareToShoot();
|
||||
}else
|
||||
if(distToPlayer<ConfigPixels("Run Away Range")){
|
||||
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).upoint(-1);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(distToPlayer>=ConfigPixelsArr("Random Direction Range",0)&&distToPlayer<ConfigPixelsArr("Random Direction Range",1)){
|
||||
#define CW true
|
||||
@ -103,7 +102,7 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
|
||||
float dirFromPlayer=util::angleTo(game->GetPlayer()->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.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(m.F(A::ATTACK_COOLDOWN)>=ConfigFloat("Attack Reload Time")/2.f){ //Only the stand still and shoot range remains, which is twice as fast...
|
||||
PrepareToShoot();
|
||||
@ -134,4 +133,4 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
|
||||
m.F(A::RANDOM_RANGE)=util::random_range(ConfigPixelsArr("Random Direction Range",0),ConfigPixelsArr("Random Direction Range",1));
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -52,9 +52,8 @@ and either slashes with the dagger or stabs with it.
|
||||
INCLUDE_game
|
||||
INCLUDE_ANIMATION_DATA
|
||||
INCLUDE_BULLET_LIST
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(GOBLIN_DAGGER)
|
||||
enum PhaseName{
|
||||
MOVE,
|
||||
WINDUP,
|
||||
@ -70,7 +69,7 @@ void Monster::STRATEGY::GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string s
|
||||
case MOVE:{
|
||||
float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos());
|
||||
if(distToPlayer>ConfigFloat("Attack Spacing")/100.f*24){
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else{
|
||||
SETPHASE(WINDUP);
|
||||
m.I(A::ATTACK_TYPE)=util::random()%2; //Choose randomly between stab or slash.
|
||||
@ -116,4 +115,4 @@ void Monster::STRATEGY::GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string s
|
||||
if(m.F(A::RECOVERY_TIME)<=0)SETPHASE(MOVE);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -51,7 +51,7 @@ using A=Attribute;
|
||||
* Attack Strategie: Fly circles at the edge of the Players Screen. every 8 seconds charge on players location to the other corner of the screen.
|
||||
* */
|
||||
|
||||
void Monster::STRATEGY::HAWK(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(HAWK)
|
||||
enum PhaseName{
|
||||
INITIALIZE,
|
||||
FLYING,
|
||||
@ -81,7 +81,7 @@ void Monster::STRATEGY::HAWK(Monster&m,float fElapsedTime,std::string strategy){
|
||||
float dirToPlayer{util::pointTo(game->GetPlayer()->GetPos(),m.GetPos()).polar().y};
|
||||
dirToPlayer+=m.B(A::RANDOM_DIRECTION)?0.25*PI:-0.25*PI;
|
||||
m.target=game->GetPlayer()->GetPos()+vf2d{ConfigFloat("Flight Distance"),dirToPlayer}.cart();
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}
|
||||
}break;
|
||||
case PREPARE_CHARGE:{
|
||||
@ -99,7 +99,7 @@ void Monster::STRATEGY::HAWK(Monster&m,float fElapsedTime,std::string strategy){
|
||||
m.B(A::IGNORE_DEFAULT_ANIMATIONS)=true;
|
||||
if(m.F(A::FLYING_HEIGHT)>-ConfigFloat("Flight Oscillation Amount"))m.F(A::FLYING_HEIGHT)=std::max(-ConfigFloat("Flight Oscillation Amount"),m.F(A::FLYING_HEIGHT)-ConfigFloat("Attack Z Speed")*fElapsedTime);
|
||||
m.targetAcquireTimer=1.f;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
float distToTarget=geom2d::line<float>(m.GetPos(),m.target).length();
|
||||
if(distToTarget<12.f){
|
||||
m.F(A::TARGET_FLYING_HEIGHT)=ConfigFloat("Flight Height")-ConfigFloat("Flight Height Variance")+util::random_range(0,ConfigFloat("Flight Height Variance")*2);
|
||||
@ -110,4 +110,4 @@ void Monster::STRATEGY::HAWK(Monster&m,float fElapsedTime,std::string strategy){
|
||||
m.B(A::IGNORE_DEFAULT_ANIMATIONS)=false;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -61,11 +61,11 @@ const std::string Item::BLANK_ITEM_NAME="";
|
||||
safemap<std::string,ItemInfo>ITEM_DATA;
|
||||
safemap<std::string,IT>ITEM_CONVERSIONS;
|
||||
safemap<std::string,ItemScript>ITEM_SCRIPTS;
|
||||
safemap<std::string,std::set<std::string>>ITEM_CATEGORIES;
|
||||
safemap<std::string_view,std::set<std::string>>ITEM_CATEGORIES;
|
||||
std::shared_ptr<Item>Item::BLANK=std::make_shared<Item>();
|
||||
std::multimap<IT,std::shared_ptr<Item>>Inventory::_inventory;
|
||||
std::vector<std::shared_ptr<Item>>Inventory::blacksmithInventory;
|
||||
std::map<ITCategory,std::vector<std::shared_ptr<Item>>>Inventory::sortedInv;
|
||||
std::map<std::string_view,std::vector<std::shared_ptr<Item>>>Inventory::sortedInv;
|
||||
std::array<std::pair<IT,int>,3U>Inventory::loadoutItemsUsed;
|
||||
std::vector<ItemOverlay>ItemOverlay::items;
|
||||
std::map<std::string,ItemSet>ItemSet::sets;
|
||||
@ -135,8 +135,8 @@ void ItemInfo::InitializeItems(){
|
||||
auto ReadItems=[&](datafile&data){
|
||||
for(auto&[key,value]:data.GetKeys()){
|
||||
if(key=="")ERR("Failed to read an item block ,no name specified!");
|
||||
std::string imgPath="assets/"+"item_img_directory"_S+key+".png";
|
||||
Renderable&img=GFX["item_img_directory"_S+key+".png"];
|
||||
std::string imgPath="assets/"sv+"item_img_directory"_SV+key+".png"sv;
|
||||
Renderable&img=GFX["item_img_directory"_S+key+".png"sv];
|
||||
game->LoadResource(img,imgPath);
|
||||
|
||||
std::string scriptName="",description="",category="";
|
||||
@ -437,20 +437,20 @@ void ItemInfo::InitializeItems(){
|
||||
ItemProps::ItemProps(utils::datafile*scriptProps,utils::datafile*customProps)
|
||||
:scriptProps(scriptProps),customProps(customProps){}
|
||||
|
||||
int ItemProps::GetInt(const std::string&prop,size_t index)const{
|
||||
int ItemProps::GetInt(std::string_view prop,size_t index)const{
|
||||
if(customProps->HasProperty(prop)) return (*customProps)[prop].GetInt(index);
|
||||
else return (*scriptProps)[prop].GetInt(index);
|
||||
};
|
||||
float ItemProps::GetFloat(const std::string&prop,size_t index)const{
|
||||
float ItemProps::GetFloat(std::string_view prop,size_t index)const{
|
||||
if(customProps->HasProperty(prop)) return float((*customProps)[prop].GetReal(index));
|
||||
else return float((*scriptProps)[prop].GetReal(index));
|
||||
};
|
||||
std::string ItemProps::GetString(const std::string&prop,size_t index)const{
|
||||
std::string ItemProps::GetString(std::string_view prop,size_t index)const{
|
||||
if(customProps->HasProperty(prop)) return (*customProps)[prop].GetString(index);
|
||||
else return (*scriptProps)[prop].GetString(index);
|
||||
};
|
||||
|
||||
const uint32_t ItemProps::PropCount(const std::string&prop)const{
|
||||
const uint32_t ItemProps::PropCount(std::string_view prop)const{
|
||||
if(customProps->HasProperty(prop)) return (*customProps)[prop].GetValueCount();
|
||||
else return uint32_t((*scriptProps)[prop].GetValueCount());
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ private:
|
||||
static std::map<EquipSlot,std::weak_ptr<Item>>equipment;
|
||||
static std::array<std::pair<IT,int>,3U>loadoutItemsUsed;
|
||||
//Only contains "1" of every item, as this is a map to index items and not the actual storage of items!
|
||||
static std::map<ITCategory,std::vector<std::shared_ptr<Item>>>sortedInv;
|
||||
static std::map<std::string_view,std::vector<std::shared_ptr<Item>>>sortedInv;
|
||||
};
|
||||
|
||||
class ItemProps{
|
||||
@ -345,10 +345,10 @@ class ItemProps{
|
||||
utils::datafile*customProps;
|
||||
public:
|
||||
ItemProps(utils::datafile*scriptProps,utils::datafile*customProps);
|
||||
int GetInt(const std::string&prop,size_t index=0)const;
|
||||
float GetFloat(const std::string&prop,size_t index=0)const;
|
||||
std::string GetString(const std::string&prop,size_t index=0)const;
|
||||
const uint32_t PropCount(const std::string&prop)const;
|
||||
int GetInt(std::string_view prop,size_t index=0)const;
|
||||
float GetFloat(std::string_view prop,size_t index=0)const;
|
||||
std::string GetString(std::string_view prop,size_t index=0)const;
|
||||
const uint32_t PropCount(std::string_view prop)const;
|
||||
};
|
||||
|
||||
class ItemInfo{
|
||||
|
||||
@ -163,18 +163,18 @@ void ItemEnchantInfo::Initialize(){
|
||||
|
||||
using enum ItemEnchantCategory;
|
||||
if(enchantCategory==CLASS){
|
||||
Class itemEnchantClass{classutils::StringToClass(key)};
|
||||
Class itemEnchantClass{classutils::StringToClass(std::string{key})};
|
||||
datafile&classEnchantData{enchantData[key]};
|
||||
for(const auto&[key,size]:classEnchantData){
|
||||
ItemEnchantInfo newEnchant{MakeEnchant(key,classEnchantData[key])};
|
||||
newEnchant.abilityClass=itemEnchantClass;
|
||||
const auto&result{ENCHANT_LIST.insert({key,newEnchant})};
|
||||
const auto&result{ENCHANT_LIST.insert({std::string{key},newEnchant})};
|
||||
const bool InsertFailed{!result.second};
|
||||
if(InsertFailed)ERR(std::format("WARNING! Enchant {} already existed in Enchant List! Duplicates are not allowed!",key));
|
||||
}
|
||||
}else{
|
||||
ItemEnchantInfo newEnchant{MakeEnchant(key,enchantData[key])};
|
||||
const auto&result{ENCHANT_LIST.insert({key,newEnchant})};
|
||||
const auto&result{ENCHANT_LIST.insert({std::string{key},newEnchant})};
|
||||
const bool InsertFailed{!result.second};
|
||||
if(InsertFailed)ERR(std::format("WARNING! Enchant {} already existed in Enchantment List! Duplicates are not allowed!",key));
|
||||
}
|
||||
@ -285,7 +285,7 @@ const ItemEnchant ItemEnchant::RollRandomEnchant(const std::optional<ItemEnchant
|
||||
return false;
|
||||
};
|
||||
|
||||
for(;;){
|
||||
while(true){
|
||||
ItemEnchantInfo&randomEnchant{remainingAvailableEnchants[util::random()%remainingAvailableEnchants.size()]};
|
||||
ItemEnchant newEnchant{randomEnchant.Name()};
|
||||
if(!previousEnchant||
|
||||
|
||||
@ -107,7 +107,7 @@ private:
|
||||
std::optional<EnchantAbilitySlot>abilitySlot;
|
||||
ItemAttributable minStatModifiers;
|
||||
ItemAttributable maxStatModifiers;
|
||||
std::unordered_map<std::string,float>config;
|
||||
std::unordered_map<std::string_view,float>config;
|
||||
static std::unordered_map<std::string,ItemEnchantInfo>ENCHANT_LIST;
|
||||
static std::unordered_map<ItemEnchantCategory,ItemEnchantCategoryData>ENCHANT_CATEGORIES;
|
||||
AbilityDescriptionModifiers modifiers;
|
||||
|
||||
@ -45,12 +45,10 @@ All rights reserved.
|
||||
INCLUDE_game
|
||||
INCLUDE_MONSTER_LIST
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::MAJOR_HAWK(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(MAJOR_HAWK)
|
||||
//Runs the Hawk strategy and has an aggressive mode when the amount of this monster falls below an amount.
|
||||
const int majorHawkCount=std::accumulate(MONSTER_LIST.begin(),MONSTER_LIST.end(),0,[&](const int&acc,const std::shared_ptr<Monster>&monster){return std::move(acc)+((monster->IsAlive()&&monster->GetName()==ConfigString("Aggressive Name Check"))?1:0);});
|
||||
|
||||
if(majorHawkCount<=ConfigInt("Aggressive Hawk Count"))HAWK(m,fElapsedTime,"Major Hawk");
|
||||
else HAWK(m,fElapsedTime,"Hawk"); //Use normal hawk behaviors when there are too many Major Hawks.
|
||||
}
|
||||
else m.RunStrategy(HAWK); //Use normal hawk behaviors when there are too many Major Hawks.
|
||||
END_STRATEGY
|
||||
@ -58,8 +58,8 @@ std::vector<Menu*>Menu::stack;
|
||||
std::map<MenuType,Menu*>Menu::menus;
|
||||
std::string Menu::themeSelection="BlueDefault";
|
||||
safeunorderedmap<std::string,Theme>Menu::themes;
|
||||
safemap<ITCategory,std::vector<std::weak_ptr<MenuComponent>>>Menu::inventoryListeners;
|
||||
safemap<ITCategory,std::vector<std::weak_ptr<MenuComponent>>>Menu::merchantInventoryListeners;
|
||||
safemap<std::string_view,std::vector<std::weak_ptr<MenuComponent>>>Menu::inventoryListeners;
|
||||
safemap<std::string_view,std::vector<std::weak_ptr<MenuComponent>>>Menu::merchantInventoryListeners;
|
||||
std::vector<std::weak_ptr<MenuComponent>>Menu::equipStatListeners;
|
||||
std::vector<std::weak_ptr<MenuComponent>>Menu::chapterListeners;
|
||||
const vf2d Menu::CENTERED = {-456,-456};
|
||||
|
||||
@ -165,7 +165,7 @@ public:
|
||||
}
|
||||
void Update(AiL*game);
|
||||
void Draw(AiL*game);
|
||||
static void InitializeMenuListenerCategory(const std::string&category);
|
||||
static void InitializeMenuListenerCategory(std::string_view category);
|
||||
static void InitializeMenus();
|
||||
static void LockInListeners();
|
||||
static void OpenMenu(MenuType menu,bool cover=true);
|
||||
|
||||
@ -64,7 +64,6 @@ INCLUDE_game
|
||||
INCLUDE_BULLET_LIST
|
||||
INCLUDE_DATA
|
||||
INCLUDE_GFX
|
||||
INCLUDE_SPAWNER_LIST
|
||||
INCLUDE_SPAWNER_CONTROLLER
|
||||
|
||||
safemap<std::string,std::function<void(Monster&,float,std::string)>>STRATEGY_DATA;
|
||||
@ -444,7 +443,7 @@ void Monster::Update(const float fElapsedTime){
|
||||
}
|
||||
RunStrategy:
|
||||
if(CanMove()){
|
||||
Monster::STRATEGY::RUN_STRATEGY(*this,game->GetElapsedTime());
|
||||
RUN_STRATEGY(GetStrategyName());
|
||||
}
|
||||
}
|
||||
animation.UpdateState(internal_animState,fElapsedTime);
|
||||
@ -1086,11 +1085,11 @@ void Monster::SetZ(float z){
|
||||
this->z=z;
|
||||
}
|
||||
|
||||
void Monster::SetStrategyDrawFunction(std::function<void(AiL*,Monster&,const std::string&)>func){
|
||||
void Monster::SetStrategyDrawFunction(std::function<void(AiL*,Monster&,const StrategyName)>func){
|
||||
strategyDraw=func;
|
||||
}
|
||||
|
||||
void Monster::SetStrategyDrawOverlayFunction(std::function<void(AiL*,Monster&,const std::string&)>func){
|
||||
void Monster::SetStrategyDrawOverlayFunction(std::function<void(AiL*,Monster&,const StrategyName)>func){
|
||||
strategyDrawOverlay=func;
|
||||
}
|
||||
|
||||
@ -1340,11 +1339,11 @@ const float Monster::GetCollisionDamage()const{
|
||||
else return MONSTER_DATA[name].GetCollisionDmg();
|
||||
}
|
||||
|
||||
void Monster::SetStrategyDeathFunction(std::function<bool(GameEvent&event,Monster&monster,const std::string&strategyName)>func){
|
||||
void Monster::SetStrategyDeathFunction(std::function<bool(GameEvent&event,Monster&monster,const StrategyName strategyName)>func){
|
||||
strategyDeathFunc=func;
|
||||
}
|
||||
|
||||
void Monster::SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName&strategyName)>func){
|
||||
void Monster::SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName strategyName)>func){
|
||||
strategyOnHitFunc=func;
|
||||
}
|
||||
|
||||
@ -1741,10 +1740,10 @@ const float Monster::UnconsciousTime()const{
|
||||
const std::vector<MonsterAbilityData>&Monster::GetAbilities()const{
|
||||
return MONSTER_DATA.at(name).GetAbilities();
|
||||
}
|
||||
void Monster::SetPhase(const std::string&strategyName,int phase){
|
||||
void Monster::SetPhase(std::string_view strategyName,int phase){
|
||||
this->phase[strategyName]=phase;
|
||||
}
|
||||
const int Monster::GetPhase(const std::string&strategyName){
|
||||
const int Monster::GetPhase(const std::string_view strategyName){
|
||||
if(!phase.contains(strategyName))phase[strategyName]=0;
|
||||
return this->phase[strategyName];
|
||||
}
|
||||
@ -1800,4 +1799,8 @@ void Monster::PerformSpell(const CastInfo&castData){
|
||||
MonsterAbility::SPELLS.at(castData.name)(castData.name,castData.castPos,*this,GetStrategyName());
|
||||
PerformIdleAnimation();
|
||||
mp-=castData.mpCost;
|
||||
}
|
||||
|
||||
void Monster::RunStrategy(const MonsterStrategy&strategy){
|
||||
monsterStrategies.at(strategy).function(*this,game->GetElapsedTime(),monsterStrategies.at(strategy).name);
|
||||
}
|
||||
@ -81,58 +81,110 @@ class Monster:public IAttributable{
|
||||
friend class DeathSpawnInfo;
|
||||
friend class MonsterTests::MonsterTest;
|
||||
public:
|
||||
enum MonsterStrategy{
|
||||
RUN_TOWARDS,
|
||||
SHOOT_AFAR,
|
||||
TURRET,
|
||||
SLIMEKING,
|
||||
RUN_AWAY,
|
||||
FROG,
|
||||
WOLF,
|
||||
BEAR,
|
||||
URSULE,
|
||||
NPC,
|
||||
BOAR,
|
||||
GOBLIN_DAGGER,
|
||||
GOBLIN_BOW,
|
||||
GOBLIN_BOAR_RIDER,
|
||||
GOBLIN_BOMB,
|
||||
HAWK,
|
||||
STONE_ELEMENTAL,
|
||||
ZEPHY,
|
||||
MAJOR_HAWK,
|
||||
DONOTHING,
|
||||
STONE_GOLEM,
|
||||
BREAKING_PILLAR,
|
||||
PIRATE_MARAUDER,
|
||||
PIRATE_CAPTAIN,
|
||||
SEAGULL,
|
||||
SANDWORM,
|
||||
PIRATE_BUCCANEER,
|
||||
PARROT,
|
||||
CRAB,
|
||||
GIANT_CRAB,
|
||||
GIANT_OCTOPUS,
|
||||
OCTOPUS_ARM,
|
||||
GHOST_OF_PIRATE_CAPTAIN,
|
||||
PIRATES_TREASURE,
|
||||
PIRATES_COIN,
|
||||
SKELETON_BARBARIAN,
|
||||
_RUN_RIGHT,
|
||||
SKELETON_CAPTAIN,
|
||||
SKELETON_CAPTAIN_FLAG,
|
||||
SKELETON_FIRE_MAGE,
|
||||
|
||||
|
||||
END_ENUM //THIS SHOULD ALWAYS BE THE LAST ITEM
|
||||
};
|
||||
struct STRATEGY{
|
||||
static std::string ERR;
|
||||
static int _GetInt(Monster&m,std::string param,std::string strategy,int index=0);
|
||||
static float _GetFloat(Monster&m,std::string param,std::string strategy,int index=0);
|
||||
static Pixel _GetPixel(Monster&m,std::string param,std::string strategy,int index=0);
|
||||
static int _GetInt(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static float _GetFloat(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static Pixel _GetPixel(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
//Converts unit distances to pixels. (Every 100 units = 24 pixels)
|
||||
static float _GetPixels(Monster&m,std::string param,std::string strategy,int index=0);
|
||||
static vf2d _GetVec(Monster&m,std::string param,std::string strategy,int index=0);
|
||||
static const std::string&_GetString(Monster&m,std::string param,std::string strategy,int index=0);
|
||||
static const datafile&_Get(Monster&m,std::string param,std::string strategy);
|
||||
static void RUN_STRATEGY(Monster&m,float fElapsedTime);
|
||||
static void RUN_TOWARDS(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SHOOT_AFAR(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void TURRET(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SLIMEKING(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void RUN_AWAY(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void FROG(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void WOLF(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void BEAR(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void URSULE(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void NPC(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void BOAR(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void GOBLIN_BOW(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void GOBLIN_BOAR_RIDER(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void GOBLIN_BOMB(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void HAWK(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void ZEPHY(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void MAJOR_HAWK(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void DONOTHING(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void STONE_GOLEM(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void BREAKING_PILLAR(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SEAGULL(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SANDWORM(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void PARROT(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void CRAB(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void GIANT_CRAB(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void PIRATES_TREASURE(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void PIRATES_COIN(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SKELETON_BARBARIAN(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void _RUN_RIGHT(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SKELETON_CAPTAIN(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SKELETON_CAPTAIN_FLAG(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static void SKELETON_FIRE_MAGE(Monster&m,float fElapsedTime,std::string strategy);
|
||||
static float _GetPixels(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static olc::vf2d _GetVec(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static const std::string&_GetString(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static const datafile&_Get(Monster&m,std::string_view param,std::string_view strategy);
|
||||
static void RUN_TOWARDS(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SHOOT_AFAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void TURRET(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SLIMEKING(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void RUN_AWAY(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void FROG(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void WOLF(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void BEAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void URSULE(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void NPC(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void BOAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_BOW(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_BOAR_RIDER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_BOMB(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void HAWK(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void ZEPHY(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void MAJOR_HAWK(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void DONOTHING(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void STONE_GOLEM(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void BREAKING_PILLAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SEAGULL(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SANDWORM(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PARROT(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void CRAB(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GIANT_CRAB(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATES_TREASURE(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATES_COIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_BARBARIAN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void _RUN_RIGHT(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_CAPTAIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_CAPTAIN_FLAG(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_FIRE_MAGE(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
};
|
||||
struct StrategyFunction{
|
||||
std::string name;
|
||||
std::function<void(Monster&,float,std::string_view)>function;
|
||||
};
|
||||
void RunStrategy(const MonsterStrategy&strategy);
|
||||
|
||||
private:
|
||||
static safeunorderedmap<MonsterStrategy,StrategyFunction>monsterStrategies;
|
||||
public:
|
||||
Monster()=delete;
|
||||
Monster(vf2d pos,MonsterData data,bool upperLevel=false,bool bossMob=false);
|
||||
@ -220,10 +272,10 @@ public:
|
||||
const std::function<void(Monster&,float,std::string)>&GetStrategy()const;
|
||||
void SetSize(float newSize,bool immediate=true);
|
||||
geom2d::circle<float>BulletCollisionHitbox();
|
||||
void SetStrategyDrawFunction(std::function<void(AiL*game,Monster&monster,const std::string&strategy)>func);
|
||||
void SetStrategyDrawOverlayFunction(std::function<void(AiL*game,Monster&monster,const std::string&strategy)>func);
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDraw=[](AiL*pge,Monster&m,const std::string&strategy){};
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDrawOverlay=[](AiL*pge,Monster&m,const std::string&strategy){};
|
||||
void SetStrategyDrawFunction(std::function<void(AiL*game,Monster&monster,const StrategyName strategy)>func);
|
||||
void SetStrategyDrawOverlayFunction(std::function<void(AiL*game,Monster&monster,const StrategyName strategy)>func);
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDraw=[](AiL*pge,Monster&m,const StrategyName strategy){};
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDrawOverlay=[](AiL*pge,Monster&m,const StrategyName strategy){};
|
||||
const ItemAttributable&GetStats()const;
|
||||
const EventName&GetHurtSound();
|
||||
const EventName&GetDeathSound();
|
||||
@ -287,8 +339,8 @@ public:
|
||||
const bool FaceTarget()const;
|
||||
void ResetCurseOfDeathDamage();
|
||||
void MoveForward(const vf2d&moveForwardVec,const float fElapsedTime); //Moves the monster forward in given cartesian vector direction (will be auto-normalized) applying speeed boosts and other proper movement requirements as if you wanted to move on a frame-by-frame basis.
|
||||
void SetPhase(const std::string&strategyName,int phase);
|
||||
const int GetPhase(const std::string&strategyName);
|
||||
void SetPhase(std::string_view,int phase);
|
||||
const int GetPhase(const std::string_view strategyName);
|
||||
const float GetOriginalCollisionRadius()const;
|
||||
void SetCollisionRadius(const float collisionRadius);
|
||||
const std::string&GetStrategyName()const;
|
||||
@ -354,9 +406,9 @@ private:
|
||||
std::function<void(const HurtDamageInfo damageInfo,Monster&,const std::string&)>strategyOnHitFunc{};
|
||||
//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::function<bool(GameEvent&event,Monster&monster,const StrategyName&strategyName)>func);
|
||||
void SetStrategyDeathFunction(std::function<bool(GameEvent&event,Monster&monster,const StrategyName strategyName)>func);
|
||||
// The function is called immediately after taking damage. Note the damage has already gone through, and the damage data contains the final damage that was received after all damage reductions were applied. It cannot be modified.
|
||||
void SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName&strategyName)>func);
|
||||
void SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName strategyName)>func);
|
||||
//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.
|
||||
|
||||
@ -38,7 +38,7 @@ All rights reserved.
|
||||
|
||||
#include"MonsterAttribute.h"
|
||||
|
||||
using StrategyName=std::string;
|
||||
using StrategyName=std::string_view;
|
||||
|
||||
#pragma once
|
||||
#define ConfigInt(param) Monster::STRATEGY::_GetInt(m,param,strategy)
|
||||
@ -59,4 +59,11 @@ using StrategyName=std::string;
|
||||
#define PHASE() m.GetPhase(strategy)
|
||||
#define SETPHASE(phase) m.SetPhase(strategy,phase)
|
||||
|
||||
#define DEFINE_STRATEGY(strategyName) \
|
||||
void Monster::STRATEGY::strategyName(Monster&m,float fElapsedTime,std::string_view strategy){ \
|
||||
using enum MonsterStrategy;
|
||||
#define END_STRATEGY }
|
||||
|
||||
#define STRATEGY_FUNC (AiL*game,Monster&monster,const StrategyName strategy)
|
||||
|
||||
using A=Attribute;
|
||||
@ -47,12 +47,10 @@ All rights reserved.
|
||||
#include "Tutorial.h"
|
||||
#include "VisualNovel.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_DATA
|
||||
|
||||
void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(NPC)
|
||||
if(PHASE()==0){ //Initialization.
|
||||
if(m.npcData.function.length()>0){
|
||||
m.SetStrategyDrawOverlayFunction([](AiL*game,Monster&m,const std::string&strategy){
|
||||
@ -103,4 +101,4 @@ void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){
|
||||
}else{
|
||||
m.F(A::TARGET_TIMER)=std::max(0.f,m.F(A::TARGET_TIMER)-fElapsedTime);
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -43,13 +43,11 @@ All rights reserved.
|
||||
#include "BulletTypes.h"
|
||||
#include "Arc.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_MONSTER_LIST
|
||||
INCLUDE_MONSTER_DATA
|
||||
|
||||
void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(OCTOPUS_ARM)
|
||||
enum PhaseName{
|
||||
INIT,
|
||||
RISE_ANIMATION,
|
||||
@ -83,7 +81,7 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
|
||||
m.F(A::CASTING_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration();
|
||||
SETPHASE(RISE_ANIMATION);
|
||||
m.SetStrategyDeathFunction([deathFadeTime=ConfigFloat("Death Fade Time"),bossDamageOnDeath=ConfigInt("Boss Damage On Death"),armHealAmtOnDeath=ConfigInt("Arm Heal Amount On Death"),reemergeWaitTime=ConfigFloat("Re-Emerge Wait Time"),delayTimeIncreasePerArm=ConfigFloat("Delay Time Increase Per Arm"),armAttackBuffOnDeath=ConfigFloat("Arm Attack Buff On Death"),bossAttackBuffOnDeath=ConfigFloat("Boss Attack Buff On Death")](GameEvent&event,Monster&m,const StrategyName&strategyName){
|
||||
m.SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
||||
m.SetStrategyDrawFunction([]STRATEGY_FUNC{});
|
||||
const std::string GIANT_OCTOPUS_NAME{"Giant Octopus"};
|
||||
const std::string OCTOPUS_ARM_NAME{"Octopus Arm"};
|
||||
|
||||
@ -105,7 +103,7 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
|
||||
m->SetCollisionRadius(0.f);
|
||||
if(!m->IsDead())m->Heal(armHealAmtOnDeath,true);
|
||||
m->GetFloat(A::RECOVERY_TIME)=reemergeWaitTime+delayTimePerArm;
|
||||
m->SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
||||
m->SetStrategyDrawFunction([]STRATEGY_FUNC{});
|
||||
if(m->HasBuff(BuffType::STAT_UP)){
|
||||
bool found{false};
|
||||
for(Buff&b:m->EditBuffs(BuffType::STAT_UP)){
|
||||
@ -156,7 +154,7 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
|
||||
|
||||
Arc attackArc{GetAttackArc(m)};
|
||||
|
||||
m.SetStrategyDrawFunction([arc=attackArc,&storedArc=m.ANY(A::STORED_ARC),&alphaTimer=m.F(A::ENVIRONMENT_TIMER),attackEffectTime=ConfigFloat("Attack Effect Time")](AiL*game,Monster&monster,const std::string&strategy){
|
||||
m.SetStrategyDrawFunction([arc=attackArc,&storedArc=m.ANY(A::STORED_ARC),&alphaTimer=m.F(A::ENVIRONMENT_TIMER),attackEffectTime=ConfigFloat("Attack Effect Time")]STRATEGY_FUNC{
|
||||
//const float alphaTimer{float(std::fmod(game->GetRunTime(),2.f))}; //Commented out for testing behavior. Should not be using run time...?
|
||||
uint8_t alpha{util::lerp(uint8_t(0),uint8_t(128),alphaTimer)};
|
||||
if(alphaTimer>1.f)alpha=util::lerp(0,128,1-(alphaTimer-1));
|
||||
@ -187,7 +185,7 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
|
||||
}
|
||||
m.F(A::RECOVERY_TIME)=m.GetCurrentAnimation().GetTotalAnimationDuration();
|
||||
m.ANY(A::STORED_ARC)=GetAttackArc(m);
|
||||
m.SetStrategyDrawFunction([&storedArc=m.ANY(A::STORED_ARC),attackEffectTime=ConfigFloat("Attack Effect Time")](AiL*game,Monster&monster,const std::string&strategy){
|
||||
m.SetStrategyDrawFunction([&storedArc=m.ANY(A::STORED_ARC),attackEffectTime=ConfigFloat("Attack Effect Time")]STRATEGY_FUNC{
|
||||
const float alphaTimer{float(std::fmod(game->GetRunTime(),2.f))};
|
||||
if(storedArc.has_value()){
|
||||
const uint8_t effectAlpha{util::lerp(uint8_t(0),uint8_t(255),alphaTimer/attackEffectTime)};
|
||||
@ -205,7 +203,7 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
|
||||
m.GetFloat(A::RECOVERY_TIME)=m.GetCurrentAnimation().GetTotalAnimationDuration()*util::random_range(1.f,2.f);
|
||||
m.SetCollisionRadius(0.f);
|
||||
m.V(A::JUMP_TARGET_POS)=m.GetPos();
|
||||
m.SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
||||
m.SetStrategyDrawFunction([]STRATEGY_FUNC{});
|
||||
}
|
||||
}break;
|
||||
case SUBMERGE:{
|
||||
@ -218,4 +216,4 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,11 +42,9 @@ All rights reserved.
|
||||
#include "SoundEffect.h"
|
||||
#include "BulletTypes.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::PARROT(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(PARROT)
|
||||
enum PhaseName{
|
||||
RUN,
|
||||
FLY_AWAY,
|
||||
@ -55,7 +53,7 @@ void Monster::STRATEGY::PARROT(Monster&m,float fElapsedTime,std::string strategy
|
||||
case RUN:{
|
||||
if(!m.attachedTarget.expired()&&m.attachedTarget.lock()->IsAlive()){
|
||||
m.PerformAnimation("FLYING");
|
||||
HAWK(m,fElapsedTime,"Hawk");
|
||||
m.RunStrategy(HAWK);
|
||||
}else{
|
||||
m.lifetime=10.f;
|
||||
SETPHASE(FLY_AWAY);
|
||||
@ -71,4 +69,4 @@ void Monster::STRATEGY::PARROT(Monster&m,float fElapsedTime,std::string strategy
|
||||
m.SetVelocity({m.F(A::PATH_DIR)*ConfigFloat("Fly Away Speed"),0.f});
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,11 +42,9 @@ All rights reserved.
|
||||
#include "SoundEffect.h"
|
||||
#include "BulletTypes.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(PIRATE_BUCCANEER)
|
||||
#pragma region Phase, Animation, and Helper function setup
|
||||
enum PhaseName{
|
||||
INIT,
|
||||
@ -59,8 +57,8 @@ void Monster::STRATEGY::PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::strin
|
||||
|
||||
switch(PHASE()){
|
||||
case INIT:{
|
||||
m.SetStrategyDeathFunction([](GameEvent&ev,Monster&m,const std::string&strategy){
|
||||
m.SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
||||
m.SetStrategyDeathFunction([](GameEvent&ev,Monster&m,const StrategyName strategy){
|
||||
m.SetStrategyDrawFunction([]STRATEGY_FUNC{});
|
||||
return false;
|
||||
});
|
||||
SETPHASE(MOVE);
|
||||
@ -80,14 +78,14 @@ void Monster::STRATEGY::PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::strin
|
||||
|
||||
if(outsideMaxShootingRange){
|
||||
m.target=game->GetPlayer()->GetPos();
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(m.F(A::ATTACK_COOLDOWN)>=ConfigFloat("Attack Reload Time")){
|
||||
PrepareToShoot();
|
||||
}else
|
||||
if(distToPlayer<ConfigPixels("Run Away Range")){
|
||||
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).upoint(-1);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else
|
||||
if(m.F(A::ATTACK_COOLDOWN)>=ConfigFloat("Attack Reload Time")/2.f){ //Only the stand still and shoot range remains, which is twice as fast...
|
||||
PrepareToShoot();
|
||||
@ -99,7 +97,7 @@ void Monster::STRATEGY::PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::strin
|
||||
m.F(A::ATTACK_COOLDOWN)=0.f;
|
||||
CreateBullet(ChargedArrow)("musket_bullet.png","musket_trail.png",m.GetPos(),util::pointTo(m.GetPos(),m.V(A::LOCKON_POS))*ConfigFloat("Arrow Spd"),ConfigFloat("Arrow Hitbox Radius"),m.GetAttack(),m.OnUpperLevel())EndBullet;
|
||||
m.PerformAnimation("SHOOTING",m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos()));
|
||||
m.SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
||||
m.SetStrategyDrawFunction([]STRATEGY_FUNC{});
|
||||
SETPHASE(FIRE_ANIMATION);
|
||||
m.F(A::SHOOT_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration();
|
||||
}else
|
||||
@ -107,7 +105,7 @@ void Monster::STRATEGY::PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::strin
|
||||
m.V(A::LOCKON_POS)=game->GetPlayer()->GetPos();
|
||||
m.PerformAnimation("SHOOT",m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos()));
|
||||
const float arrowHitboxRadius{ConfigFloat("Arrow Hitbox Radius")};
|
||||
m.SetStrategyDrawFunction([arrowHitboxRadius](AiL*game,Monster&monster,const std::string&strategy){
|
||||
m.SetStrategyDrawFunction([arrowHitboxRadius]STRATEGY_FUNC{
|
||||
const float alphaTimer{float(std::fmod(game->GetRunTime(),2.f))};
|
||||
uint8_t alpha{util::lerp(uint8_t(0),uint8_t(255),alphaTimer)};
|
||||
if(alphaTimer>1.f)alpha=util::lerp(0,255,1-(alphaTimer-1));
|
||||
@ -126,4 +124,4 @@ void Monster::STRATEGY::PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::strin
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,12 +42,10 @@ All rights reserved.
|
||||
#include "SoundEffect.h"
|
||||
#include "BulletTypes.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_ANIMATION_DATA
|
||||
|
||||
void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(PIRATE_CAPTAIN)
|
||||
enum PhaseName{
|
||||
INIT,
|
||||
MOVE,
|
||||
@ -110,7 +108,7 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string
|
||||
else{
|
||||
float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos());
|
||||
if(distToPlayer>ConfigFloat("Attack Spacing")/100.f*24){
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else{
|
||||
SETPHASE(WINDUP);
|
||||
m.I(A::ATTACK_TYPE)=util::random()%2; //Choose randomly between stab or slash.
|
||||
@ -180,4 +178,4 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string
|
||||
if(m.F(A::RECOVERY_TIME)<=0)SETPHASE(MOVE);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -46,7 +46,7 @@ using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(PIRATE_MARAUDER)
|
||||
enum PhaseName{
|
||||
INIT,
|
||||
MOVE,
|
||||
@ -82,7 +82,7 @@ void Monster::STRATEGY::PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string
|
||||
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){
|
||||
m.SetStrategyDrawFunction([impactArea]STRATEGY_FUNC{
|
||||
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;
|
||||
@ -107,7 +107,7 @@ void Monster::STRATEGY::PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string
|
||||
}
|
||||
NormalBehavior:
|
||||
if(distToPlayer>ConfigFloat("Attack Spacing")/100.f*24){
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}else{
|
||||
SETPHASE(WINDUP);
|
||||
m.F(A::CASTING_TIMER)=ConfigFloat("Slash Windup Time");
|
||||
@ -145,7 +145,7 @@ void Monster::STRATEGY::PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string
|
||||
m.SetPos(m.V(A::JUMP_TARGET_POS));
|
||||
SETPHASE(MOVE);
|
||||
m.PerformIdleAnimation();
|
||||
m.SetStrategyDrawFunction([](AiL*game,Monster&monster,const std::string&strategy){});
|
||||
m.SetStrategyDrawFunction([]STRATEGY_FUNC{});
|
||||
}
|
||||
}break;
|
||||
case PREPARE_WHIRLWIND:{
|
||||
@ -172,4 +172,4 @@ void Monster::STRATEGY::PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string
|
||||
game->ProximityKnockback(m.GetPos(),ConfigFloat("Whirlwind Radius")/100.f*24.f,ConfigFloat("Whirlwind Knockback Amount"),HurtType::MONSTER|HurtType::PLAYER);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -44,7 +44,7 @@ using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::PIRATES_COIN(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(PIRATES_COIN)
|
||||
if(m.B(Attribute::COLLIDED_WITH_PLAYER)){
|
||||
game->AddEffect(std::make_unique<CollectCoinEffect>(game->GetPlayer(),ConfigFloat("Coin Collect Rise Amount"),ConfigFloat("Coin Rise Timer"),"coin.png",m.OnUpperLevel()),true);
|
||||
game->GetPlayer()->AddBuff(BuffType::PIRATE_GHOST_CAPTAIN_CURSE_COIN,INFINITY,1);
|
||||
@ -53,4 +53,4 @@ void Monster::STRATEGY::PIRATES_COIN(Monster&m,float fElapsedTime,std::string st
|
||||
m.SetSize(0.f,false);
|
||||
game->GetPlayer()->NotificationDisplay(ConfigString("Coin Owned Text"),INFINITE);
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -45,7 +45,7 @@ INCLUDE_game
|
||||
INCLUDE_MONSTER_LIST
|
||||
INCLUDE_ITEM_DATA
|
||||
|
||||
void Monster::STRATEGY::PIRATES_TREASURE(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(PIRATES_TREASURE)
|
||||
enum Phase{
|
||||
NORMAL,
|
||||
LOCK = 1,
|
||||
@ -101,4 +101,4 @@ void Monster::STRATEGY::PIRATES_TREASURE(Monster&m,float fElapsedTime,std::strin
|
||||
m._DealTrueDamage(m.GetHealth(),HurtFlag::NO_DAMAGE_NUMBER);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -40,56 +40,55 @@ All rights reserved.
|
||||
#include "olcUTIL_DataFile.h"
|
||||
|
||||
INCLUDE_DATA
|
||||
INCLUDE_STRATEGY_DATA
|
||||
|
||||
std::string Monster::STRATEGY::ERR{};
|
||||
|
||||
void Monster::InitializeStrategies(){
|
||||
STRATEGY_DATA.insert("Run Towards",Monster::STRATEGY::RUN_TOWARDS);
|
||||
STRATEGY_DATA.insert("Shoot Afar",Monster::STRATEGY::SHOOT_AFAR);
|
||||
STRATEGY_DATA.insert("Turret",Monster::STRATEGY::TURRET);
|
||||
STRATEGY_DATA.insert("Slime King",Monster::STRATEGY::SLIMEKING);
|
||||
STRATEGY_DATA.insert("Run Away",Monster::STRATEGY::RUN_AWAY);
|
||||
STRATEGY_DATA.insert("Frog",Monster::STRATEGY::FROG);
|
||||
STRATEGY_DATA.insert("Wolf",Monster::STRATEGY::WOLF);
|
||||
STRATEGY_DATA.insert("Bear",Monster::STRATEGY::BEAR);
|
||||
STRATEGY_DATA.insert("Ursule",Monster::STRATEGY::URSULE);
|
||||
STRATEGY_DATA.insert("NPC",Monster::STRATEGY::NPC);
|
||||
STRATEGY_DATA.insert("Boar",Monster::STRATEGY::BOAR);
|
||||
STRATEGY_DATA.insert("Goblin Dagger",Monster::STRATEGY::GOBLIN_DAGGER);
|
||||
STRATEGY_DATA.insert("Goblin Bow",Monster::STRATEGY::GOBLIN_BOW);
|
||||
STRATEGY_DATA.insert("Goblin Boar Rider",Monster::STRATEGY::GOBLIN_BOAR_RIDER);
|
||||
STRATEGY_DATA.insert("Goblin Bomb",Monster::STRATEGY::GOBLIN_BOMB);
|
||||
STRATEGY_DATA.insert("Hawk",Monster::STRATEGY::HAWK);
|
||||
STRATEGY_DATA.insert("Stone Elemental",Monster::STRATEGY::STONE_ELEMENTAL);
|
||||
STRATEGY_DATA.insert("Zephy",Monster::STRATEGY::ZEPHY);
|
||||
STRATEGY_DATA.insert("Major Hawk",Monster::STRATEGY::MAJOR_HAWK);
|
||||
STRATEGY_DATA.insert("Do Nothing",Monster::STRATEGY::DONOTHING);
|
||||
STRATEGY_DATA.insert("Stone Golem",Monster::STRATEGY::STONE_GOLEM);
|
||||
STRATEGY_DATA.insert("Breaking Pillar",Monster::STRATEGY::BREAKING_PILLAR);
|
||||
STRATEGY_DATA.insert("Pirate Marauder",Monster::STRATEGY::PIRATE_MARAUDER);
|
||||
STRATEGY_DATA.insert("Pirate Captain",Monster::STRATEGY::PIRATE_CAPTAIN);
|
||||
STRATEGY_DATA.insert("Pirate Buccaneer",Monster::STRATEGY::PIRATE_BUCCANEER);
|
||||
STRATEGY_DATA.insert("Crab",Monster::STRATEGY::CRAB);
|
||||
STRATEGY_DATA.insert("Seagull",Monster::STRATEGY::SEAGULL);
|
||||
STRATEGY_DATA.insert("Sandworm",Monster::STRATEGY::SANDWORM);
|
||||
STRATEGY_DATA.insert("Parrot",Monster::STRATEGY::PARROT);
|
||||
STRATEGY_DATA.insert("Giant Crab",Monster::STRATEGY::GIANT_CRAB);
|
||||
STRATEGY_DATA.insert("Giant Octopus",Monster::STRATEGY::GIANT_OCTOPUS);
|
||||
STRATEGY_DATA.insert("Octopus Arm",Monster::STRATEGY::OCTOPUS_ARM);
|
||||
STRATEGY_DATA.insert("Ghost of Pirate Captain",Monster::STRATEGY::GHOST_OF_PIRATE_CAPTAIN);
|
||||
STRATEGY_DATA.insert("Pirate's Treasure",Monster::STRATEGY::PIRATES_TREASURE);
|
||||
STRATEGY_DATA.insert("Pirate's Coin",Monster::STRATEGY::PIRATES_COIN);
|
||||
STRATEGY_DATA.insert("Skeleton Barbarian",Monster::STRATEGY::SKELETON_BARBARIAN);
|
||||
STRATEGY_DATA.insert("[TEST]Run Right",Monster::STRATEGY::_RUN_RIGHT);
|
||||
STRATEGY_DATA.insert("Skeleton Captain",Monster::STRATEGY::SKELETON_CAPTAIN);
|
||||
STRATEGY_DATA.insert("Skeleton Captain Flag",Monster::STRATEGY::SKELETON_CAPTAIN_FLAG);
|
||||
STRATEGY_DATA.insert("Skeleton Fire Mage",Monster::STRATEGY::SKELETON_FIRE_MAGE);
|
||||
Monster::monsterStrategies.insert(RUN_TOWARDS,StrategyFunction{"Run Towards",Monster::STRATEGY::RUN_TOWARDS});
|
||||
Monster::monsterStrategies.insert(SHOOT_AFAR,StrategyFunction{"Shoot Afar",Monster::STRATEGY::SHOOT_AFAR});
|
||||
Monster::monsterStrategies.insert(TURRET,StrategyFunction{"Turret",Monster::STRATEGY::TURRET});
|
||||
Monster::monsterStrategies.insert(SLIMEKING,StrategyFunction{"Slime King",Monster::STRATEGY::SLIMEKING});
|
||||
Monster::monsterStrategies.insert(RUN_AWAY,StrategyFunction{"Run Away",Monster::STRATEGY::RUN_AWAY});
|
||||
Monster::monsterStrategies.insert(FROG,StrategyFunction{"Frog",Monster::STRATEGY::FROG});
|
||||
Monster::monsterStrategies.insert(WOLF,StrategyFunction{"Wolf",Monster::STRATEGY::WOLF});
|
||||
Monster::monsterStrategies.insert(BEAR,StrategyFunction{"Bear",Monster::STRATEGY::BEAR});
|
||||
Monster::monsterStrategies.insert(URSULE,StrategyFunction{"Ursule",Monster::STRATEGY::URSULE});
|
||||
Monster::monsterStrategies.insert(NPC,StrategyFunction{"NPC",Monster::STRATEGY::NPC});
|
||||
Monster::monsterStrategies.insert(BOAR,StrategyFunction{"Boar",Monster::STRATEGY::BOAR});
|
||||
Monster::monsterStrategies.insert(GOBLIN_DAGGER,StrategyFunction{"Goblin Dagger",Monster::STRATEGY::GOBLIN_DAGGER});
|
||||
Monster::monsterStrategies.insert(GOBLIN_BOW,StrategyFunction{"Goblin Bow",Monster::STRATEGY::GOBLIN_BOW});
|
||||
Monster::monsterStrategies.insert(GOBLIN_BOAR_RIDER,StrategyFunction{"Goblin Boar Rider",Monster::STRATEGY::GOBLIN_BOAR_RIDER});
|
||||
Monster::monsterStrategies.insert(GOBLIN_BOMB,StrategyFunction{"Goblin Bomb",Monster::STRATEGY::GOBLIN_BOMB});
|
||||
Monster::monsterStrategies.insert(HAWK,StrategyFunction{"Hawk",Monster::STRATEGY::HAWK});
|
||||
Monster::monsterStrategies.insert(STONE_ELEMENTAL,StrategyFunction{"Stone Elemental",Monster::STRATEGY::STONE_ELEMENTAL});
|
||||
Monster::monsterStrategies.insert(ZEPHY,StrategyFunction{"Zephy",Monster::STRATEGY::ZEPHY});
|
||||
Monster::monsterStrategies.insert(MAJOR_HAWK,StrategyFunction{"Major Hawk",Monster::STRATEGY::MAJOR_HAWK});
|
||||
Monster::monsterStrategies.insert(DONOTHING,StrategyFunction{"Do Nothing",Monster::STRATEGY::DONOTHING});
|
||||
Monster::monsterStrategies.insert(STONE_GOLEM,StrategyFunction{"Stone Golem",Monster::STRATEGY::STONE_GOLEM});
|
||||
Monster::monsterStrategies.insert(BREAKING_PILLAR,StrategyFunction{"Breaking Pillar",Monster::STRATEGY::BREAKING_PILLAR});
|
||||
Monster::monsterStrategies.insert(PIRATE_MARAUDER,StrategyFunction{"Pirate Marauder",Monster::STRATEGY::PIRATE_MARAUDER});
|
||||
Monster::monsterStrategies.insert(PIRATE_CAPTAIN,StrategyFunction{"Pirate Captain",Monster::STRATEGY::PIRATE_CAPTAIN});
|
||||
Monster::monsterStrategies.insert(PIRATE_BUCCANEER,StrategyFunction{"Pirate Buccaneer",Monster::STRATEGY::PIRATE_BUCCANEER});
|
||||
Monster::monsterStrategies.insert(CRAB,StrategyFunction{"Crab",Monster::STRATEGY::CRAB});
|
||||
Monster::monsterStrategies.insert(SEAGULL,StrategyFunction{"Seagull",Monster::STRATEGY::SEAGULL});
|
||||
Monster::monsterStrategies.insert(SANDWORM,StrategyFunction{"Sandworm",Monster::STRATEGY::SANDWORM});
|
||||
Monster::monsterStrategies.insert(PARROT,StrategyFunction{"Parrot",Monster::STRATEGY::PARROT});
|
||||
Monster::monsterStrategies.insert(GIANT_CRAB,StrategyFunction{"Giant Crab",Monster::STRATEGY::GIANT_CRAB});
|
||||
Monster::monsterStrategies.insert(GIANT_OCTOPUS,StrategyFunction{"Giant Octopus",Monster::STRATEGY::GIANT_OCTOPUS});
|
||||
Monster::monsterStrategies.insert(OCTOPUS_ARM,StrategyFunction{"Octopus Arm",Monster::STRATEGY::OCTOPUS_ARM});
|
||||
Monster::monsterStrategies.insert(GHOST_OF_PIRATE_CAPTAIN,StrategyFunction{"Ghost of Pirate Captain",Monster::STRATEGY::GHOST_OF_PIRATE_CAPTAIN});
|
||||
Monster::monsterStrategies.insert(PIRATES_TREASURE,StrategyFunction{"Pirate's Treasure",Monster::STRATEGY::PIRATES_TREASURE});
|
||||
Monster::monsterStrategies.insert(PIRATES_COIN,StrategyFunction{"Pirate's Coin",Monster::STRATEGY::PIRATES_COIN});
|
||||
Monster::monsterStrategies.insert(SKELETON_BARBARIAN,StrategyFunction{"Skeleton Barbarian",Monster::STRATEGY::SKELETON_BARBARIAN});
|
||||
Monster::monsterStrategies.insert(_RUN_RIGHT,StrategyFunction{"[TEST]Run Right",Monster::STRATEGY::_RUN_RIGHT});
|
||||
Monster::monsterStrategies.insert(SKELETON_CAPTAIN,StrategyFunction{"Skeleton Captain",Monster::STRATEGY::SKELETON_CAPTAIN});
|
||||
Monster::monsterStrategies.insert(SKELETON_CAPTAIN_FLAG,StrategyFunction{"Skeleton Captain Flag",Monster::STRATEGY::SKELETON_CAPTAIN_FLAG});
|
||||
Monster::monsterStrategies.insert(SKELETON_FIRE_MAGE,StrategyFunction{"Skeleton Fire Mage",Monster::STRATEGY::SKELETON_FIRE_MAGE});
|
||||
|
||||
STRATEGY_DATA.SetInitialized();
|
||||
Monster::monsterStrategies.SetInitialized();
|
||||
}
|
||||
|
||||
int Monster::STRATEGY::_GetInt(Monster&m,std::string param,std::string strategy,int index){
|
||||
int Monster::STRATEGY::_GetInt(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return float(DATA["NPCs"][m.name].GetProperty(param).GetInt(index));
|
||||
}else
|
||||
@ -103,7 +102,7 @@ int Monster::STRATEGY::_GetInt(Monster&m,std::string param,std::string strategy,
|
||||
return{};
|
||||
}
|
||||
}
|
||||
float Monster::STRATEGY::_GetFloat(Monster&m,std::string param,std::string strategy,int index){
|
||||
float Monster::STRATEGY::_GetFloat(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return float(DATA["NPCs"][m.name].GetProperty(param).GetReal(index));
|
||||
}else
|
||||
@ -117,7 +116,7 @@ float Monster::STRATEGY::_GetFloat(Monster&m,std::string param,std::string strat
|
||||
return{};
|
||||
}
|
||||
}
|
||||
const std::string&Monster::STRATEGY::_GetString(Monster&m,std::string param,std::string strategy,int index){
|
||||
const std::string&Monster::STRATEGY::_GetString(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param).GetString(index);
|
||||
}else
|
||||
@ -131,7 +130,7 @@ const std::string&Monster::STRATEGY::_GetString(Monster&m,std::string param,std:
|
||||
return ERR;
|
||||
}
|
||||
}
|
||||
vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string param,std::string strategy,int index){
|
||||
vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return {DATA["NPCs"][m.name].GetProperty(param).GetReal(index),DATA["NPCs"][m.name].GetProperty(param).GetReal(index+1)};
|
||||
}else
|
||||
@ -145,7 +144,7 @@ vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string param,std::string strategy
|
||||
return{};
|
||||
}
|
||||
}
|
||||
const datafile&Monster::STRATEGY::_Get(Monster&m,std::string param,std::string strategy){
|
||||
const datafile&Monster::STRATEGY::_Get(Monster&m,std::string_view param,std::string_view strategy){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param);
|
||||
}else
|
||||
@ -159,7 +158,7 @@ const datafile&Monster::STRATEGY::_Get(Monster&m,std::string param,std::string s
|
||||
return DATA;
|
||||
}
|
||||
}
|
||||
Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string param,std::string strategy,int index){
|
||||
Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param).GetPixel(index);
|
||||
}else
|
||||
@ -174,7 +173,7 @@ Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string param,std::string strat
|
||||
}
|
||||
}
|
||||
|
||||
float Monster::STRATEGY::_GetPixels(Monster&m,std::string param,std::string strategy,int index){
|
||||
float Monster::STRATEGY::_GetPixels(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param).GetReal(index)/100.f*24;
|
||||
}else
|
||||
@ -187,8 +186,4 @@ float Monster::STRATEGY::_GetPixels(Monster&m,std::string param,std::string stra
|
||||
ERR(std::format("Monster {} trying to read non-existent Real Property {}[{}] (for pixel conversion) for Strategy {}. THIS SHOULD NOT BE HAPPENING!",m.GetName(),param,index,strategy))
|
||||
return{};
|
||||
}
|
||||
}
|
||||
|
||||
void Monster::STRATEGY::RUN_STRATEGY(Monster&m,float fElapsedTime){
|
||||
m.GetStrategy()(m,fElapsedTime,m.strategy);
|
||||
}
|
||||
@ -44,9 +44,7 @@ All rights reserved.
|
||||
INCLUDE_BULLET_LIST
|
||||
INCLUDE_game
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::RUN_AWAY(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(RUN_AWAY)
|
||||
m.targetAcquireTimer=std::max(0.f,m.targetAcquireTimer-fElapsedTime);
|
||||
m.attackCooldownTimer=std::max(0.f,m.attackCooldownTimer-fElapsedTime);
|
||||
geom2d::line line(m.pos,game->GetPlayer()->GetPos());
|
||||
@ -123,4 +121,4 @@ void Monster::STRATEGY::RUN_AWAY(Monster&m,float fElapsedTime,std::string strate
|
||||
m.PathAroundBehavior(fElapsedTime);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -47,9 +47,8 @@ INCLUDE_game
|
||||
INCLUDE_MONSTER_DATA
|
||||
INCLUDE_GFX
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(RUN_TOWARDS)
|
||||
const bool jumpingEnabled=ConfigFloat("JumpTimer")>0.f;
|
||||
|
||||
if(!m.B(A::INITIALIZED)){
|
||||
@ -188,4 +187,4 @@ void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime,std::string str
|
||||
}break;
|
||||
default:{}
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,11 +42,9 @@ All rights reserved.
|
||||
#include "SoundEffect.h"
|
||||
#include "BulletTypes.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::SANDWORM(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(SANDWORM)
|
||||
enum PhaseName{
|
||||
INITIALIZE,
|
||||
UNDERGROUND,
|
||||
@ -75,7 +73,7 @@ void Monster::STRATEGY::SANDWORM(Monster&m,float fElapsedTime,std::string strate
|
||||
}break;
|
||||
case UNDERGROUND:{
|
||||
m.SetCollisionRadius(0.f);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
m.PerformAnimation("SWIM",m.GetFacingDirection());
|
||||
if(m.ReachedTargetPos()){
|
||||
m.PerformAnimation("EMERGE",game->GetPlayer()->GetPos());
|
||||
@ -136,4 +134,4 @@ void Monster::STRATEGY::SANDWORM(Monster&m,float fElapsedTime,std::string strate
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,11 +42,9 @@ All rights reserved.
|
||||
#include "SoundEffect.h"
|
||||
#include "BulletTypes.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::SEAGULL(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(SEAGULL)
|
||||
enum PhaseName{
|
||||
CHILLING,
|
||||
STARTLED,
|
||||
@ -83,4 +81,4 @@ void Monster::STRATEGY::SEAGULL(Monster&m,float fElapsedTime,std::string strateg
|
||||
//NO-OP
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -45,7 +45,7 @@ All rights reserved.
|
||||
INCLUDE_BULLET_LIST
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(SHOOT_AFAR)
|
||||
m.targetAcquireTimer=std::max(0.f,m.targetAcquireTimer-fElapsedTime);
|
||||
m.attackCooldownTimer=std::max(0.f,m.attackCooldownTimer-fElapsedTime);
|
||||
if(m.queueShotTimer>0){
|
||||
@ -139,4 +139,4 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,std::string stra
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,9 +42,8 @@ All rights reserved.
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::SKELETON_BARBARIAN(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(SKELETON_BARBARIAN)
|
||||
enum Phase{
|
||||
INITIALIZE,
|
||||
NORMAL,
|
||||
@ -70,7 +69,7 @@ void Monster::STRATEGY::SKELETON_BARBARIAN(Monster&m,float fElapsedTime,std::str
|
||||
SETPHASE(WINDUP_WHIRLWIND);
|
||||
break;
|
||||
}
|
||||
GOBLIN_DAGGER(m,fElapsedTime,"Goblin Dagger");
|
||||
m.RunStrategy(GOBLIN_DAGGER);
|
||||
}break;
|
||||
case WINDUP_WHIRLWIND:{
|
||||
m.F(A::CASTING_TIMER)-=fElapsedTime;
|
||||
@ -99,5 +98,4 @@ void Monster::STRATEGY::SKELETON_BARBARIAN(Monster&m,float fElapsedTime,std::str
|
||||
default:ERR(std::format("WARNING!! Trying to use phase {} in Skeleton Barbarian Strategy code. Phase {} DOES NOT EXIST!",PHASE(),PHASE()));
|
||||
}
|
||||
if(m.GetHealth()<ConfigInt("Hasten Buff Threshold")&&!m.HasBuff(BuffType::HASTEN))m.AddBuff(BuffType::HASTEN,INFINITE,ConfigFloat("Hasten Buff Potency")/100.f);
|
||||
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -45,7 +45,7 @@ INCLUDE_game
|
||||
INCLUDE_MONSTER_LIST
|
||||
INCLUDE_MONSTER_DATA
|
||||
|
||||
void Monster::STRATEGY::SKELETON_CAPTAIN(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(SKELETON_CAPTAIN)
|
||||
enum Phase{
|
||||
INITIAL,
|
||||
RESET,
|
||||
@ -94,7 +94,7 @@ void Monster::STRATEGY::SKELETON_CAPTAIN(Monster&m,float fElapsedTime,std::strin
|
||||
m.PerformJumpAnimation();
|
||||
}else{
|
||||
m.target=m.V(A::LOCKON_POS);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}
|
||||
}break;
|
||||
case RECOVERY:{
|
||||
@ -146,4 +146,4 @@ void Monster::STRATEGY::SKELETON_CAPTAIN(Monster&m,float fElapsedTime,std::strin
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,9 +42,7 @@ All rights reserved.
|
||||
|
||||
INCLUDE_MONSTER_LIST
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::SKELETON_CAPTAIN_FLAG(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(SKELETON_CAPTAIN_FLAG)
|
||||
const float HASTE_REAPPLY_TIME=1.f;
|
||||
|
||||
if(m.GetZ()>0)m.SetZ(std::max(0.f,m.GetZ()-120.f*fElapsedTime));
|
||||
@ -52,8 +50,8 @@ void Monster::STRATEGY::SKELETON_CAPTAIN_FLAG(Monster&m,float fElapsedTime,std::
|
||||
m.F(A::ATTACK_COOLDOWN)-=fElapsedTime;
|
||||
if(m.F(A::ATTACK_COOLDOWN)<=0.f){
|
||||
m.F(A::ATTACK_COOLDOWN)=HASTE_REAPPLY_TIME;
|
||||
for(std::shared_ptr<Monster>&target:MONSTER_LIST|std::views::filter([](std::shared_ptr<Monster>&m){return m->IsAlive()&&!m->isBoss&&m->GetStrategyName()!="Skeleton Captain"&&m->GetStrategyName()!="Skeleton Captain Flag";;})){
|
||||
for(std::shared_ptr<Monster>&target:MONSTER_LIST|std::views::filter([](std::shared_ptr<Monster>&m){return m->IsAlive()&&!m->isBoss&&m->GetStrategyName()!="Skeleton Captain"&&m->GetStrategyName()!="Skeleton Captain Flag";})){
|
||||
if(target->GetDistanceFrom(m.GetPos())<=ConfigFloat("Haste Buff Range")/100.f*24)target->AddBuff(BuffType::HASTEN,HASTE_REAPPLY_TIME,ConfigFloat("Haste Buff")/100.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -38,4 +38,6 @@ All rights reserved.
|
||||
|
||||
#include "Monster.h"
|
||||
|
||||
void Monster::STRATEGY::SKELETON_FIRE_MAGE(Monster&m,float fElapsedTime,std::string strategy){}
|
||||
DEFINE_STRATEGY(SKELETON_FIRE_MAGE)
|
||||
|
||||
END_STRATEGY
|
||||
@ -157,7 +157,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
|
||||
};
|
||||
|
||||
if(m.F(A::RUN_AWAY_TIMER)>0){
|
||||
Monster::STRATEGY::RUN_AWAY(m,fElapsedTime,"Run Away");
|
||||
Monster::STRATEGY::m.RunStrategy(RUN_AWAY);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
|
||||
}break;
|
||||
case 5:{
|
||||
float targetSize=ConfigFloat("Phase5.SizeLossPerHit")/100*m.I(A::HITS_UNTIL_DEATH);
|
||||
Monster::STRATEGY::RUN_AWAY(m,fElapsedTime,"Run Away");
|
||||
Monster::STRATEGY::m.RunStrategy(RUN_AWAY);
|
||||
if(targetSize>0){
|
||||
m.SetSize(targetSize,false);
|
||||
}else{
|
||||
|
||||
@ -52,7 +52,7 @@ INCLUDE_MONSTER_LIST
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(STONE_GOLEM)
|
||||
enum PhaseName{
|
||||
INITIALIZE,
|
||||
BEAR_ATTACK,
|
||||
@ -300,7 +300,7 @@ void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string str
|
||||
}break;
|
||||
case BEAR_ATTACK:{
|
||||
m.F(A::CHASE_TIMER)+=fElapsedTime;
|
||||
BEAR(m,fElapsedTime,"Bear");
|
||||
m.RunStrategy(BEAR);
|
||||
//Extending the bear script's variables to read the state of it...
|
||||
const bool SlamHasFinished=m.I(A::ATTACK_COUNT)!=m.I(A::BEAR_STOMP_COUNT); //The bear script uses the internal phase variable to determine the state of things.
|
||||
if(SlamHasFinished){
|
||||
@ -342,4 +342,4 @@ void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string str
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -60,7 +60,7 @@ Dive under earth and show up 1 second later in a random location 400-700 away fr
|
||||
if range to player > 1200 always use 3rd attack
|
||||
*/
|
||||
|
||||
void Monster::STRATEGY::STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(STONE_ELEMENTAL)
|
||||
enum PhaseName{
|
||||
INITIALIZE,
|
||||
WAITING,
|
||||
@ -140,7 +140,7 @@ void Monster::STRATEGY::STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string
|
||||
geom2d::line<float>stonePillarCastLine{m.V(A::LOCKON_POS),m.GetPos()};
|
||||
const vf2d targetWalkPos=stonePillarCastLine.rpoint(stonePillarCastLine.length()+48.f);
|
||||
m.target=targetWalkPos;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
m.PerformAnimation("STONE PILLAR CAST");
|
||||
m.UpdateFacingDirection(targetWalkPos);
|
||||
}else{
|
||||
@ -192,7 +192,7 @@ void Monster::STRATEGY::STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string
|
||||
}break;
|
||||
case DIVE_UNDERGROUND_MOVE:{
|
||||
m.F(A::CASTING_TIMER)-=fElapsedTime;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
|
||||
if(m.F(A::CASTING_TIMER)<=0.f){
|
||||
m.B(A::IGNORE_DEFAULT_ANIMATIONS)=false;
|
||||
@ -217,4 +217,4 @@ void Monster::STRATEGY::STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -42,12 +42,10 @@ All rights reserved.
|
||||
#include "util.h"
|
||||
#include "MonsterAttribute.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_BULLET_LIST
|
||||
|
||||
void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(TURRET)
|
||||
m.attackCooldownTimer=std::max(0.f,m.attackCooldownTimer-fElapsedTime);
|
||||
if(m.F(A::SHOOT_ANIMATION_TIME)>0){
|
||||
m.F(A::SHOOT_ANIMATION_TIME)=std::max(0.f,m.F(A::SHOOT_ANIMATION_TIME)-fElapsedTime);
|
||||
@ -73,4 +71,4 @@ void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime,std::string strategy
|
||||
m.PerformShootAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -50,9 +50,7 @@ INCLUDE_MONSTER_LIST
|
||||
INCLUDE_MONSTER_DATA
|
||||
INCLUDE_DATA
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(URSULE)
|
||||
switch(PHASE()){
|
||||
case 0:{
|
||||
SETPHASE(ConfigInt("StartPhase"));
|
||||
@ -131,7 +129,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
if(distToCenter>4.0f){
|
||||
m.targetAcquireTimer=20.f;
|
||||
m.target=mapCenter;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
break;
|
||||
}else{ //Now we're finally good for phase 2.
|
||||
TransitionToPhase2();
|
||||
@ -149,7 +147,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
}
|
||||
|
||||
bear:
|
||||
BEAR(m,fElapsedTime,"Bear");
|
||||
m.RunStrategy(BEAR);
|
||||
}break;
|
||||
case 2:{
|
||||
m.PerformAnimation("GLARE");
|
||||
@ -291,7 +289,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
if(distToCenter>4.0f){
|
||||
m.targetAcquireTimer=20.f;
|
||||
m.target=mapCenter;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
break;
|
||||
}else{ //Now we're finally good for phase 2.
|
||||
TransitionToPhase5();
|
||||
@ -338,7 +336,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
}
|
||||
|
||||
bear2:
|
||||
BEAR(m,fElapsedTime,"Bear");
|
||||
m.RunStrategy(BEAR);
|
||||
}break;
|
||||
case 4:{ //A charging phase.
|
||||
m.F(A::TARGET_TIMER)=std::max(0.f,m.F(A::TARGET_TIMER)-fElapsedTime);
|
||||
@ -426,7 +424,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
m.F(A::RUN_AWAY_TIMER)=std::max(0.f,m.F(A::RUN_AWAY_TIMER)-fElapsedTime);
|
||||
m.targetAcquireTimer=20.f;
|
||||
m.target=game->GetPlayer()->GetPos();
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
if(m.F(A::RUN_AWAY_TIMER)==0.f){
|
||||
SETPHASE(m.I(A::PREVIOUS_PHASE));
|
||||
m.RemoveBuff(SPEEDBOOST);
|
||||
@ -437,4 +435,4 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
ERR(std::format("WARNING! Unknown phase {} for {} reached!",PHASE(),m.GetName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 12481
|
||||
#define VERSION_BUILD 12502
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
@ -46,9 +46,7 @@ All rights reserved.
|
||||
INCLUDE_game
|
||||
INCLUDE_BULLET_LIST
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::WOLF(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(WOLF)
|
||||
switch(PHASE()){
|
||||
case 0:{ //Run towards the player.
|
||||
float distToPlayer=geom2d::line<float>(game->GetPlayer()->GetPos(),m.GetPos()).length();
|
||||
@ -58,8 +56,8 @@ void Monster::STRATEGY::WOLF(Monster&m,float fElapsedTime,std::string strategy){
|
||||
m.AddBuff(BuffType::LOCKON_SPEEDBOOST,INFINITE,ConfigFloat("Lockon Speed Boost")/100);
|
||||
m.F(A::TARGET_TIMER)=5.0f;
|
||||
}
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
m.target=game->GetPlayer()->GetPos();
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
}break;
|
||||
case 1:{ //Charge the player.
|
||||
m.F(A::TARGET_TIMER)=std::max(0.f,m.F(A::TARGET_TIMER)-fElapsedTime);
|
||||
@ -70,7 +68,7 @@ void Monster::STRATEGY::WOLF(Monster&m,float fElapsedTime,std::string strategy){
|
||||
m.PerformIdleAnimation();
|
||||
}else{
|
||||
m.target=m.V(A::LOCKON_POS);
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}
|
||||
}break;
|
||||
case 2:{ //Recovery period after charging.
|
||||
@ -121,4 +119,4 @@ void Monster::STRATEGY::WOLF(Monster&m,float fElapsedTime,std::string strategy){
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -48,9 +48,7 @@ INCLUDE_WINDOW_SIZE
|
||||
INCLUDE_GFX
|
||||
INCLUDE_BULLET_LIST
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(ZEPHY)
|
||||
enum Phase{
|
||||
INITIALIZE,
|
||||
IDLE,
|
||||
@ -167,7 +165,7 @@ void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy)
|
||||
}break;
|
||||
case FLY_ACROSS_PREPARE:{
|
||||
m.targetAcquireTimer=20.f;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
if(m.ReachedTargetPos()){
|
||||
const bool RightDirectionChosen=m.I(A::ATTACK_CHOICE)==int(AttackChoice::RIGHT);
|
||||
|
||||
@ -181,7 +179,7 @@ void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy)
|
||||
}break;
|
||||
case FLY_ACROSS:{
|
||||
m.targetAcquireTimer=20.f;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
m.F(A::SHOOT_TIMER)-=fElapsedTime;
|
||||
if(m.F(A::SHOOT_TIMER)<=0.f){
|
||||
CreateBullet(Bullet)(m.GetPos(),vf2d{0.f,ConfigFloat("Fly Across Attack.Attack Y Speed")},4,ConfigInt("Fly Across Attack.Poop Damage"),"birdpoop.png",m.OnUpperLevel(),false,INFINITY,false,NON_FRIENDLY,WHITE,vf2d{1.f,1.25f})EndBullet;
|
||||
@ -206,7 +204,7 @@ void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy)
|
||||
}break;
|
||||
case TORNADO_ATTACK_PREPARE:{
|
||||
m.targetAcquireTimer=20.f;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
if(m.ReachedTargetPos()){
|
||||
SETPHASE(TORNADO_ATTACK);
|
||||
m.PerformAnimation("ATTACK",Direction::SOUTH);
|
||||
@ -239,7 +237,7 @@ void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy)
|
||||
}break;
|
||||
case WIND_ATTACK_FLY:{
|
||||
m.targetAcquireTimer=20.f;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
if(m.ReachedTargetPos()){
|
||||
SETPHASE(WIND_ATTACK_LAND);
|
||||
m.F(A::TARGET_FLYING_HEIGHT)=0.f;
|
||||
@ -330,7 +328,7 @@ void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy)
|
||||
}break;
|
||||
case HALFHEALTH_PREPARE_PHASE:{
|
||||
m.targetAcquireTimer=20.f;
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
if(m.ReachedTargetPos()){
|
||||
m.F(A::TARGET_FLYING_HEIGHT)=0.f;
|
||||
|
||||
@ -382,4 +380,4 @@ void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy)
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -38,6 +38,6 @@ All rights reserved.
|
||||
|
||||
#include "Monster.h"
|
||||
|
||||
void Monster::STRATEGY::_RUN_RIGHT(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(_RUN_RIGHT)
|
||||
m.MoveForward({1.f,0.f},fElapsedTime);
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -54,6 +54,8 @@ utils::datafilefloatdata operator ""_f(const char*key,std::size_t len);
|
||||
utils::datafiledoubledata operator ""_d(const char*key,std::size_t len);
|
||||
//Read a string key from the config.
|
||||
std::string operator ""_S(const char*key,std::size_t len);
|
||||
//Read a string view key from the config.
|
||||
std::string_view operator ""_SV(const char*key,std::size_t len);
|
||||
//Read a full string key from the config.
|
||||
std::string operator ""_FS(const char*key,std::size_t len);
|
||||
//Read a boolean key from the config.
|
||||
|
||||
@ -1624,7 +1624,7 @@ config.flags = MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING; // Optional. Makes `ma_res
|
||||
|
||||
void my_custom_job_thread(...)
|
||||
{
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_job job;
|
||||
ma_result result = ma_resource_manager_next_job(pMyResourceManager, &job);
|
||||
if (result != MA_SUCCESS) {
|
||||
@ -12647,7 +12647,7 @@ MA_API MA_NO_INLINE int ma_strcmp(const char* str1, const char* str2)
|
||||
if (str1 == NULL) return -1;
|
||||
if (str2 == NULL) return 1;
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (str1[0] == '\0') {
|
||||
break;
|
||||
}
|
||||
@ -13238,7 +13238,7 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_
|
||||
/* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
|
||||
{
|
||||
size_t i = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (pOpenMode[i] == 0) {
|
||||
pOpenModeMB[i] = '\0';
|
||||
break;
|
||||
@ -13617,7 +13617,7 @@ static int ma_vscprintf(const ma_allocation_callbacks* pAllocationCallbacks, con
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
char* pNewTempBuffer = (char*)ma_realloc(pTempBuffer, tempBufferCap, pAllocationCallbacks);
|
||||
if (pNewTempBuffer == NULL) {
|
||||
ma_free(pTempBuffer, pAllocationCallbacks);
|
||||
@ -13855,7 +13855,7 @@ Greatest common factor using Euclid's algorithm iteratively.
|
||||
*/
|
||||
static MA_INLINE ma_uint32 ma_gcf_u32(ma_uint32 a, ma_uint32 b)
|
||||
{
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (b == 0) {
|
||||
break;
|
||||
} else {
|
||||
@ -15893,7 +15893,7 @@ extern "C" {
|
||||
typedef ma_atomic_flag ma_atomic_spinlock;
|
||||
static MA_INLINE void ma_atomic_spinlock_lock(volatile ma_atomic_spinlock* pSpinlock)
|
||||
{
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (ma_atomic_flag_test_and_set_explicit(pSpinlock, ma_atomic_memory_order_acquire) == 0) {
|
||||
break;
|
||||
}
|
||||
@ -16057,7 +16057,7 @@ static MA_INLINE ma_result ma_spinlock_lock_ex(volatile ma_spinlock* pSpinlock,
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (ma_atomic_exchange_explicit_32(pSpinlock, 1, ma_atomic_memory_order_acquire) == 0) {
|
||||
break;
|
||||
}
|
||||
@ -16834,7 +16834,7 @@ MA_API ma_result ma_fence_acquire(ma_fence* pFence)
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 oldCounter = ma_atomic_load_32(&pFence->counter);
|
||||
ma_uint32 newCounter = oldCounter + 1;
|
||||
|
||||
@ -16864,7 +16864,7 @@ MA_API ma_result ma_fence_release(ma_fence* pFence)
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 oldCounter = ma_atomic_load_32(&pFence->counter);
|
||||
ma_uint32 newCounter = oldCounter - 1;
|
||||
|
||||
@ -16901,7 +16901,7 @@ MA_API ma_result ma_fence_wait(ma_fence* pFence)
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 counter;
|
||||
|
||||
counter = ma_atomic_load_32(&pFence->counter);
|
||||
@ -17232,7 +17232,7 @@ MA_API ma_result ma_slot_allocator_alloc(ma_slot_allocator* pAllocator, ma_uint6
|
||||
ma_uint32 iGroup;
|
||||
for (iGroup = 0; iGroup < ma_slot_allocator_group_capacity(pAllocator); iGroup += 1) {
|
||||
/* CAS */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 oldBitfield;
|
||||
ma_uint32 newBitfield;
|
||||
ma_uint32 bitOffset;
|
||||
@ -17688,7 +17688,7 @@ MA_API ma_result ma_job_queue_post(ma_job_queue* pQueue, const ma_job* pJob)
|
||||
#endif
|
||||
{
|
||||
/* The job is stored in memory so now we need to add it to our linked list. We only ever add items to the end of the list. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
tail = ma_atomic_load_64(&pQueue->tail);
|
||||
next = ma_atomic_load_64(&pQueue->pJobs[ma_job_extract_slot(tail)].next);
|
||||
|
||||
@ -17762,7 +17762,7 @@ MA_API ma_result ma_job_queue_next(ma_job_queue* pQueue, ma_job* pJob)
|
||||
*/
|
||||
|
||||
/* Now we need to remove the root item from the list. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
head = ma_atomic_load_64(&pQueue->head);
|
||||
tail = ma_atomic_load_64(&pQueue->tail);
|
||||
next = ma_atomic_load_64(&pQueue->pJobs[ma_job_extract_slot(head)].next);
|
||||
@ -18971,7 +18971,7 @@ static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frame
|
||||
const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat;
|
||||
|
||||
/* We just keep going until we've exhaused all of our input frames and cannot generate any more output frames. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 deviceFramesProcessedThisIteration;
|
||||
ma_uint64 clientFramesProcessedThisIteration;
|
||||
|
||||
@ -19013,7 +19013,7 @@ static ma_result ma_device__handle_duplex_callback_capture(ma_device* pDevice, m
|
||||
MA_ASSERT(pRB != NULL);
|
||||
|
||||
/* Write to the ring buffer. The ring buffer is in the client format which means we need to convert. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 framesToProcessInDeviceFormat = (frameCountInDeviceFormat - totalDeviceFramesProcessed);
|
||||
ma_uint32 framesToProcessInClientFormat = MA_DATA_CONVERTER_STACK_BUFFER_SIZE / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
|
||||
ma_uint64 framesProcessedInDeviceFormat;
|
||||
@ -19237,7 +19237,7 @@ static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice)
|
||||
capturedDeviceFramesProcessed = 0;
|
||||
|
||||
/* At this point we have our captured data in device format and we now need to convert it to client format. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint8 capturedClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
ma_uint8 playbackClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
ma_uint32 capturedClientDataCapInFrames = sizeof(capturedClientData) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
|
||||
@ -19266,7 +19266,7 @@ static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice)
|
||||
capturedDeviceFramesRemaining -= (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */
|
||||
|
||||
/* At this point the playbackClientData buffer should be holding data that needs to be written to the device. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 convertedClientFrameCount = capturedClientFramesToProcessThisIteration;
|
||||
ma_uint64 convertedDeviceFrameCount = playbackDeviceDataCapInFrames;
|
||||
result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, playbackClientData, &convertedClientFrameCount, playbackDeviceData, &convertedDeviceFrameCount);
|
||||
@ -19389,7 +19389,7 @@ static ma_thread_result MA_THREADCALL ma_device_thread__null(void* pData)
|
||||
ma_device* pDevice = (ma_device*)pData;
|
||||
MA_ASSERT(pDevice != NULL);
|
||||
|
||||
for (;;) { /* Keep the thread alive until the device is uninitialized. */
|
||||
for (;) { /* Keep the thread alive until the device is uninitialized. */
|
||||
ma_uint32 operation;
|
||||
|
||||
/* Wait for an operation to be requested. */
|
||||
@ -19714,7 +19714,7 @@ static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrame
|
||||
|
||||
/* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
|
||||
targetFrame = pDevice->null_device.lastProcessedFramePlayback;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 currentFrame;
|
||||
|
||||
/* Stop waiting if the device has been stopped. */
|
||||
@ -19785,7 +19785,7 @@ static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_u
|
||||
|
||||
/* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
|
||||
targetFrame = pDevice->null_device.lastProcessedFrameCapture + pDevice->capture.internalPeriodSizeInFrames;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 currentFrame;
|
||||
|
||||
/* Stop waiting if the device has been stopped. */
|
||||
@ -21144,7 +21144,7 @@ static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pU
|
||||
ma_context* pContext = (ma_context*)pUserData;
|
||||
MA_ASSERT(pContext != NULL);
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_context_command__wasapi cmd;
|
||||
result = ma_context_next_command__wasapi(pContext, &cmd);
|
||||
if (result != MA_SUCCESS) {
|
||||
@ -22265,7 +22265,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
|
||||
it and trying it again.
|
||||
*/
|
||||
hr = E_FAIL;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL);
|
||||
if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) {
|
||||
if (bufferDuration > 500*10000) {
|
||||
@ -23049,7 +23049,7 @@ static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice)
|
||||
else {
|
||||
ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1;
|
||||
ma_uint32 framesAvailablePlayback;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
|
||||
if (result != MA_SUCCESS) {
|
||||
break;
|
||||
@ -24890,7 +24890,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
|
||||
/* At this point we have some input data that we need to output. We do not return until every mapped frame of the input data is written to the playback device. */
|
||||
mappedDeviceFramesProcessedCapture = 0;
|
||||
|
||||
for (;;) { /* Keep writing to the playback device. */
|
||||
for (;) { /* Keep writing to the playback device. */
|
||||
ma_uint8 inputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
ma_uint32 inputFramesInClientFormatCap = sizeof(inputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
|
||||
ma_uint8 outputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
@ -24912,7 +24912,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
|
||||
ma_device__handle_data_callback(pDevice, outputFramesInClientFormat, inputFramesInClientFormat, (ma_uint32)clientCapturedFramesToProcess);
|
||||
|
||||
/* At this point we have input and output data in client format. All we need to do now is convert it to the output device format. This may take a few passes. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 framesWrittenThisIteration;
|
||||
DWORD physicalPlayCursorInBytes;
|
||||
DWORD physicalWriteCursorInBytes;
|
||||
@ -25261,7 +25261,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
|
||||
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
|
||||
/* The playback device should be drained before stopping. All we do is wait until the available bytes is equal to the size of the buffer. */
|
||||
if (isPlaybackDeviceStarted) {
|
||||
for (;;) {
|
||||
for (;) {
|
||||
DWORD availableBytesPlayback = 0;
|
||||
DWORD physicalPlayCursorInBytes;
|
||||
DWORD physicalWriteCursorInBytes;
|
||||
@ -26913,7 +26913,7 @@ static ma_bool32 ma_is_device_blacklisted__alsa(ma_device_type deviceType, const
|
||||
static const char* ma_find_char(const char* str, char c, int* index)
|
||||
{
|
||||
int i = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (str[i] == '\0') {
|
||||
if (index) *index = -1;
|
||||
return NULL;
|
||||
@ -28119,7 +28119,7 @@ static ma_result ma_device_stop__alsa(ma_device* pDevice)
|
||||
|
||||
static ma_result ma_device_wait__alsa(ma_device* pDevice, ma_snd_pcm_t* pPCM, struct pollfd* pPollDescriptors, int pollDescriptorCount, short requiredEvent)
|
||||
{
|
||||
for (;;) {
|
||||
for (;) {
|
||||
unsigned short revents;
|
||||
int resultALSA;
|
||||
int resultPoll = poll(pPollDescriptors, pollDescriptorCount, -1);
|
||||
@ -29475,7 +29475,7 @@ static ma_result ma_wait_for_operation__pulse(ma_context* pContext, ma_ptr pMain
|
||||
MA_ASSERT(pContext != NULL);
|
||||
MA_ASSERT(pOP != NULL);
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
state = ((ma_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP);
|
||||
if (state != MA_PA_OPERATION_RUNNING) {
|
||||
break; /* Done. */
|
||||
@ -29509,7 +29509,7 @@ static ma_result ma_wait_for_pa_context_to_connect__pulse(ma_context* pContext,
|
||||
int resultPA;
|
||||
ma_pa_context_state_t state;
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
state = ((ma_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)((ma_pa_context*)pPulseContext);
|
||||
if (state == MA_PA_CONTEXT_READY) {
|
||||
break; /* Done. */
|
||||
@ -29535,7 +29535,7 @@ static ma_result ma_wait_for_pa_stream_to_connect__pulse(ma_context* pContext, m
|
||||
int resultPA;
|
||||
ma_pa_stream_state_t state;
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
state = ((ma_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)((ma_pa_stream*)pStream);
|
||||
if (state == MA_PA_STREAM_READY) {
|
||||
break; /* Done. */
|
||||
@ -35985,7 +35985,7 @@ static ma_format ma_best_format_from_fd__audio4(int fd, ma_format preferredForma
|
||||
/* First check to see if the preferred format is supported. */
|
||||
if (preferredFormat != ma_format_unknown) {
|
||||
counter = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
MA_ZERO_OBJECT(&encoding);
|
||||
encoding.index = counter;
|
||||
if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
|
||||
@ -36006,7 +36006,7 @@ static ma_format ma_best_format_from_fd__audio4(int fd, ma_format preferredForma
|
||||
ma_format format = g_maFormatPriorities[iFormat];
|
||||
|
||||
counter = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
MA_ZERO_OBJECT(&encoding);
|
||||
encoding.index = counter;
|
||||
if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
|
||||
@ -36085,7 +36085,7 @@ static ma_result ma_context_get_device_info_from_fd__audio4(ma_context* pContext
|
||||
|
||||
/* Supported formats. We get this by looking at the encodings. */
|
||||
pDeviceInfo->nativeDataFormatCount = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
audio_encoding_t encoding;
|
||||
ma_format format;
|
||||
|
||||
@ -39376,7 +39376,7 @@ static ma_result ma_device_drain__opensl(ma_device* pDevice, ma_device_type devi
|
||||
pDevice->opensl.isDrainingPlayback = MA_TRUE;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
SLAndroidSimpleBufferQueueState state;
|
||||
|
||||
MA_OPENSL_BUFFERQUEUE(pBufferQueue)->GetState(pBufferQueue, &state);
|
||||
@ -40842,7 +40842,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
||||
ma_device__set_state(pDevice, ma_device_state_stopped);
|
||||
ma_event_signal(&pDevice->stopEvent);
|
||||
|
||||
for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
|
||||
for (;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
|
||||
ma_result startResult;
|
||||
ma_result stopResult; /* <-- This will store the result from onDeviceStop(). If it returns an error, we don't fire the stopped notification callback. */
|
||||
|
||||
@ -41067,7 +41067,7 @@ static ma_thread_result MA_THREADCALL ma_device_job_thread_entry(void* pUserData
|
||||
ma_device_job_thread* pJobThread = (ma_device_job_thread*)pUserData;
|
||||
MA_ASSERT(pJobThread != NULL);
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_result result;
|
||||
ma_job job;
|
||||
|
||||
@ -58479,7 +58479,7 @@ MA_API ma_result ma_paged_audio_buffer_data_append_page(ma_paged_audio_buffer_da
|
||||
/* This function assumes the page has been filled with audio data by this point. As soon as we append, the page will be available for reading. */
|
||||
|
||||
/* First thing to do is update the tail. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_paged_audio_buffer_page* pOldTail = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->pTail);
|
||||
ma_paged_audio_buffer_page* pNewTail = pPage;
|
||||
|
||||
@ -63093,7 +63093,7 @@ static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis)
|
||||
size_t dataCapacity = 0;
|
||||
ma_uint8* pData = NULL; /* <-- Must be initialized to NULL. */
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
int vorbisError;
|
||||
int consumedDataSize; /* <-- Fill by stb_vorbis_open_pushdata(). */
|
||||
size_t bytesRead;
|
||||
@ -63380,7 +63380,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram
|
||||
MA_ASSERT(pVorbis->push.framesRemaining == 0);
|
||||
|
||||
/* Getting here means we've run out of cached frames. We'll need to load some more. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
int samplesRead = 0;
|
||||
int consumedDataSize;
|
||||
|
||||
@ -65358,7 +65358,7 @@ static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_dec
|
||||
/* The frame count is unknown until we try reading. Thus, we just run in a loop. */
|
||||
dataCapInFrames = 0;
|
||||
pPCMFramesOut = NULL;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 frameCountToTryReading;
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
@ -67585,7 +67585,7 @@ static ma_thread_result MA_THREADCALL ma_resource_manager_job_thread(void* pUser
|
||||
ma_resource_manager* pResourceManager = (ma_resource_manager*)pUserData;
|
||||
MA_ASSERT(pResourceManager != NULL);
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_result result;
|
||||
ma_job job;
|
||||
|
||||
@ -68508,7 +68508,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage
|
||||
}
|
||||
|
||||
/* We have the decoder, now decode page by page just like we do when loading asynchronously. */
|
||||
for (;;) {
|
||||
for (;) {
|
||||
/* Decode next page. */
|
||||
result = ma_resource_manager_data_buffer_node_decode_next_page(pResourceManager, pDataBufferNode, pDecoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
@ -71606,7 +71606,7 @@ static ma_node_output_bus* ma_node_input_bus_next(ma_node_input_bus* pInputBus,
|
||||
ma_node_input_bus_next_begin(pInputBus);
|
||||
{
|
||||
pNext = pOutputBus;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
pNext = (ma_node_output_bus*)ma_atomic_load_ptr(&pNext->pNext);
|
||||
if (pNext == NULL) {
|
||||
break; /* Reached the end. */
|
||||
@ -72655,7 +72655,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde
|
||||
/* Getting here means we need to do another round of processing. */
|
||||
pNodeBase->cachedFrameCountOut = 0;
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
frameCountOut = 0;
|
||||
|
||||
/*
|
||||
@ -75185,7 +75185,7 @@ MA_API void ma_engine_uninit(ma_engine* pEngine)
|
||||
*/
|
||||
ma_spinlock_lock(&pEngine->inlinedSoundLock);
|
||||
{
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_sound_inlined* pSoundToDelete = pEngine->pInlinedSoundHead;
|
||||
if (pSoundToDelete == NULL) {
|
||||
break; /* Done. */
|
||||
@ -77658,7 +77658,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav__seek_from_start(ma_dr_wav_seek_proc onSeek, ma_u
|
||||
return MA_FALSE;
|
||||
}
|
||||
offset -= 0x7FFFFFFF;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (offset <= 0x7FFFFFFF) {
|
||||
return onSeek(pUserData, (int)offset, ma_dr_wav_seek_origin_current);
|
||||
}
|
||||
@ -78586,7 +78586,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
||||
metadataParser.pReadSeekUserData = pWav->pUserData;
|
||||
metadataParser.stage = ma_dr_wav__metadata_parser_stage_count;
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_dr_wav_chunk_header header;
|
||||
ma_uint64 chunkSize;
|
||||
result = ma_dr_wav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
|
||||
@ -78858,7 +78858,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
||||
return MA_FALSE;
|
||||
}
|
||||
metadataParser.stage = ma_dr_wav__metadata_parser_stage_read;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_dr_wav_chunk_header header;
|
||||
ma_uint64 metadataBytesRead;
|
||||
result = ma_dr_wav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
|
||||
@ -78876,7 +78876,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
||||
}
|
||||
if (dataChunkSize == 0xFFFFFFFF && (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx) && pWav->isSequentialWrite == MA_FALSE) {
|
||||
dataChunkSize = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint8 temp[4096];
|
||||
size_t bytesRead = pWav->onRead(pWav->pUserData, temp, sizeof(temp));
|
||||
dataChunkSize += bytesRead;
|
||||
@ -82977,7 +82977,7 @@ static ma_bool32 ma_dr_flac__find_and_seek_to_next_sync_code(ma_dr_flac_bs* bs)
|
||||
if (!ma_dr_flac__seek_bits(bs, MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
|
||||
return MA_FALSE;
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint8 hi;
|
||||
#ifndef MA_DR_FLAC_NO_CRC
|
||||
ma_dr_flac__reset_crc16(bs);
|
||||
@ -83507,7 +83507,7 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__reference(ma_dr
|
||||
MA_DR_FLAC_ASSERT(pSamplesOut != NULL);
|
||||
for (i = 0; i < count; ++i) {
|
||||
ma_uint32 zeroCounter = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint8 bit;
|
||||
if (!ma_dr_flac__read_uint8(bs, 1, &bit)) {
|
||||
return MA_FALSE;
|
||||
@ -83546,7 +83546,7 @@ static ma_bool32 ma_dr_flac__read_rice_parts__reference(ma_dr_flac_bs* bs, ma_ui
|
||||
{
|
||||
ma_uint32 zeroCounter = 0;
|
||||
ma_uint32 decodedRice;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint8 bit;
|
||||
if (!ma_dr_flac__read_uint8(bs, 1, &bit)) {
|
||||
return MA_FALSE;
|
||||
@ -83676,7 +83676,7 @@ static MA_INLINE ma_bool32 ma_dr_flac__read_rice_parts_x1(ma_dr_flac_bs* bs, ma_
|
||||
}
|
||||
} else {
|
||||
ma_uint32 zeroCounter = (ma_uint32)(MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) {
|
||||
#ifndef MA_DR_FLAC_NO_CRC
|
||||
ma_dr_flac__update_crc16(bs);
|
||||
@ -83745,7 +83745,7 @@ static MA_INLINE ma_bool32 ma_dr_flac__seek_rice_parts(ma_dr_flac_bs* bs, ma_uin
|
||||
bs_cache <<= riceParamPartLoBitCount;
|
||||
}
|
||||
} else {
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) {
|
||||
#ifndef MA_DR_FLAC_NO_CRC
|
||||
ma_dr_flac__update_crc16(bs);
|
||||
@ -84677,7 +84677,7 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual(ma_dr_flac_bs* bs, ma_
|
||||
}
|
||||
samplesInPartition = (blockSize / (1 << partitionOrder)) - lpcOrder;
|
||||
partitionsRemaining = (1 << partitionOrder);
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint8 riceParam = 0;
|
||||
if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
|
||||
if (!ma_dr_flac__read_uint8(bs, 4, &riceParam)) {
|
||||
@ -84743,7 +84743,7 @@ static ma_bool32 ma_dr_flac__read_and_seek_residual(ma_dr_flac_bs* bs, ma_uint32
|
||||
}
|
||||
samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
|
||||
partitionsRemaining = (1 << partitionOrder);
|
||||
for (;;)
|
||||
for (;)
|
||||
{
|
||||
ma_uint8 riceParam = 0;
|
||||
if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
|
||||
@ -84871,7 +84871,7 @@ static ma_bool32 ma_dr_flac__read_next_flac_frame_header(ma_dr_flac_bs* bs, ma_u
|
||||
const ma_uint8 bitsPerSampleTable[8] = {0, 8, 12, (ma_uint8)-1, 16, 20, 24, (ma_uint8)-1};
|
||||
MA_DR_FLAC_ASSERT(bs != NULL);
|
||||
MA_DR_FLAC_ASSERT(header != NULL);
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint8 crc8 = 0xCE;
|
||||
ma_uint8 reserved = 0;
|
||||
ma_uint8 blockingStrategy = 0;
|
||||
@ -85261,7 +85261,7 @@ static ma_result ma_dr_flac__seek_flac_frame(ma_dr_flac* pFlac)
|
||||
static ma_bool32 ma_dr_flac__read_and_decode_next_flac_frame(ma_dr_flac* pFlac)
|
||||
{
|
||||
MA_DR_FLAC_ASSERT(pFlac != NULL);
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_result result;
|
||||
if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
|
||||
return MA_FALSE;
|
||||
@ -85357,7 +85357,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__brute_force(ma_dr_flac* pFlac, m
|
||||
return MA_FALSE;
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 pcmFrameCountInThisFLACFrame;
|
||||
ma_uint64 firstPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 lastPCMFrameInFLACFrame = 0;
|
||||
@ -85415,7 +85415,7 @@ static ma_bool32 ma_dr_flac__seek_to_approximate_flac_frame_to_byte(ma_dr_flac*
|
||||
MA_DR_FLAC_ASSERT(targetByte >= rangeLo);
|
||||
MA_DR_FLAC_ASSERT(targetByte <= rangeHi);
|
||||
*pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 lastTargetByte = targetByte;
|
||||
if (!ma_dr_flac__seek_to_byte(&pFlac->bs, targetByte)) {
|
||||
if (targetByte == 0) {
|
||||
@ -85474,7 +85474,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__binary_search_internal(ma_dr_fla
|
||||
if (targetByte > byteRangeHi) {
|
||||
targetByte = byteRangeHi;
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (ma_dr_flac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
|
||||
ma_uint64 newPCMRangeLo;
|
||||
ma_uint64 newPCMRangeHi;
|
||||
@ -85621,7 +85621,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__seek_table(ma_dr_flac* pFlac, ma
|
||||
return MA_FALSE;
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 pcmFrameCountInThisFLACFrame;
|
||||
ma_uint64 firstPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 lastPCMFrameInFLACFrame = 0;
|
||||
@ -85821,7 +85821,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea
|
||||
ma_uint64 runningFilePos = 42;
|
||||
ma_uint64 seektablePos = 0;
|
||||
ma_uint32 seektableSize = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_dr_flac_metadata metadata;
|
||||
ma_uint8 isLastBlock = 0;
|
||||
ma_uint8 blockType;
|
||||
@ -86347,7 +86347,7 @@ static ma_result ma_dr_flac_ogg__read_page_header(ma_dr_flac_read_proc onRead, v
|
||||
return MA_AT_END;
|
||||
}
|
||||
*pBytesRead += 4;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (ma_dr_flac_ogg__is_capture_pattern(id)) {
|
||||
ma_result result;
|
||||
*pCRC32 = MA_DR_FLAC_OGG_CAPTURE_PATTERN_CRC32;
|
||||
@ -86426,7 +86426,7 @@ static ma_bool32 ma_dr_flac_oggbs__seek_physical(ma_dr_flac_oggbs* oggbs, ma_uin
|
||||
static ma_bool32 ma_dr_flac_oggbs__goto_next_page(ma_dr_flac_oggbs* oggbs, ma_dr_flac_ogg_crc_mismatch_recovery recoveryMethod)
|
||||
{
|
||||
ma_dr_flac_ogg_page_header header;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 crc32 = 0;
|
||||
ma_uint32 bytesRead;
|
||||
ma_uint32 pageBodySize;
|
||||
@ -86489,7 +86489,7 @@ static ma_uint8 ma_dr_flac_oggbs__get_current_segment_index(ma_dr_flac_oggbs* og
|
||||
}
|
||||
static ma_bool32 ma_dr_flac_oggbs__seek_to_next_packet(ma_dr_flac_oggbs* oggbs)
|
||||
{
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_bool32 atEndOfPage = MA_FALSE;
|
||||
ma_uint8 bytesRemainingInSeg;
|
||||
ma_uint8 iFirstSeg = ma_dr_flac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
|
||||
@ -86601,7 +86601,7 @@ static ma_bool32 ma_dr_flac_ogg__seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64
|
||||
}
|
||||
oggbs->bytesRemainingInPage = 0;
|
||||
runningGranulePosition = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (!ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_recover_on_crc_mismatch)) {
|
||||
ma_dr_flac_oggbs__seek_physical(oggbs, originalBytePos, ma_dr_flac_seek_origin_start);
|
||||
return MA_FALSE;
|
||||
@ -86629,7 +86629,7 @@ static ma_bool32 ma_dr_flac_ogg__seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64
|
||||
return MA_FALSE;
|
||||
}
|
||||
runningPCMFrameCount = runningGranulePosition;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 firstPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 lastPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 pcmFrameCountInThisFrame;
|
||||
@ -86690,7 +86690,7 @@ static ma_bool32 ma_dr_flac__init_private__ogg(ma_dr_flac_init_info* pInit, ma_d
|
||||
return MA_FALSE;
|
||||
}
|
||||
pInit->runningFilePos += bytesRead;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
int pageBodySize;
|
||||
if ((header.headerType & 0x02) == 0) {
|
||||
return MA_FALSE;
|
||||
@ -86805,7 +86805,7 @@ static ma_bool32 ma_dr_flac__init_private(ma_dr_flac_init_info* pInit, ma_dr_fla
|
||||
pInit->bs.pUserData = pUserData;
|
||||
ma_dr_flac__reset_cache(&pInit->bs);
|
||||
relaxed = container != ma_dr_flac_container_unknown;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (onRead(pUserData, id, 4) != 4) {
|
||||
return MA_FALSE;
|
||||
}
|
||||
@ -87007,7 +87007,7 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on
|
||||
}
|
||||
if (!init.hasStreamInfoBlock) {
|
||||
pFlac->currentFLACFrame.header = init.firstFrameHeader;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_result result = ma_dr_flac__decode_flac_frame(pFlac);
|
||||
if (result == MA_SUCCESS) {
|
||||
break;
|
||||
@ -90533,7 +90533,7 @@ static void ma_dr_mp3_L3_huffman(float *dst, ma_dr_mp3_bs *bs, const ma_dr_mp3_L
|
||||
} while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
|
||||
}
|
||||
}
|
||||
for (np = 1 - big_val_cnt;; dst += 4)
|
||||
for (np = 1 - big_val_cnt; dst += 4)
|
||||
{
|
||||
const ma_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32;
|
||||
int leaf = codebook_count1[MA_DR_MP3_PEEK_BITS(4)];
|
||||
@ -91494,7 +91494,7 @@ static MA_INLINE float ma_dr_mp3_mix_f32_fast(float x, float y, float a)
|
||||
}
|
||||
static MA_INLINE ma_uint32 ma_dr_mp3_gcf_u32(ma_uint32 a, ma_uint32 b)
|
||||
{
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (b == 0) {
|
||||
break;
|
||||
} else {
|
||||
@ -91628,7 +91628,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_d
|
||||
if (pMP3->atEnd) {
|
||||
return 0;
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_dr_mp3dec_frame_info info;
|
||||
if (pMP3->dataSize < MA_DR_MP3_MIN_DATA_CHUNK_SIZE) {
|
||||
size_t bytesRead;
|
||||
@ -91711,7 +91711,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__memory(ma_dr_mp3* pMP3, ma_dr_m
|
||||
if (pMP3->atEnd) {
|
||||
return 0;
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
pcmFramesRead = ma_dr_mp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
|
||||
if (pcmFramesRead > 0) {
|
||||
pcmFramesRead = ma_dr_mp3_hdr_frame_samples(pMP3->decoder.header);
|
||||
@ -92163,7 +92163,7 @@ MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint6
|
||||
}
|
||||
totalPCMFrameCount = 0;
|
||||
totalMP3FrameCount = 0;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint32 pcmFramesInCurrentMP3Frame;
|
||||
pcmFramesInCurrentMP3Frame = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL);
|
||||
if (pcmFramesInCurrentMP3Frame == 0) {
|
||||
@ -92271,7 +92271,7 @@ MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSe
|
||||
nextTargetPCMFrame = 0;
|
||||
for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) {
|
||||
nextTargetPCMFrame += pcmFramesBetweenSeekPoints;
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (nextTargetPCMFrame < runningPCMFrameCount) {
|
||||
pSeekPoints[iSeekPoint].seekPosInBytes = mp3FrameInfo[0].bytePos;
|
||||
pSeekPoints[iSeekPoint].pcmFrameIndex = nextTargetPCMFrame;
|
||||
@ -92329,7 +92329,7 @@ static float* ma_dr_mp3__full_read_and_close_f32(ma_dr_mp3* pMP3, ma_dr_mp3_conf
|
||||
float* pFrames = NULL;
|
||||
float temp[4096];
|
||||
MA_DR_MP3_ASSERT(pMP3 != NULL);
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels;
|
||||
ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp);
|
||||
if (framesJustRead == 0) {
|
||||
@ -92380,7 +92380,7 @@ static ma_int16* ma_dr_mp3__full_read_and_close_s16(ma_dr_mp3* pMP3, ma_dr_mp3_c
|
||||
ma_int16* pFrames = NULL;
|
||||
ma_int16 temp[4096];
|
||||
MA_DR_MP3_ASSERT(pMP3 != NULL);
|
||||
for (;;) {
|
||||
for (;) {
|
||||
ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels;
|
||||
ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp);
|
||||
if (framesJustRead == 0) {
|
||||
|
||||
@ -474,7 +474,7 @@ BOOL IsXInputDevice(const GUID *pGuidProductFromDirectInput) {
|
||||
goto LCleanup;
|
||||
|
||||
// Loop over all devices
|
||||
for (;;) {
|
||||
for (;) {
|
||||
// Get 20 at a time
|
||||
hr = pEnumDevices->Next(10000, 20, pDevices, &uReturned);
|
||||
if (FAILED(hr))
|
||||
|
||||
@ -6734,7 +6734,7 @@ namespace olc
|
||||
MAKEINTRESOURCE(102),
|
||||
IMAGE_ICON,
|
||||
32, 32,
|
||||
LR_DEFAULTCOLOR));;
|
||||
LR_DEFAULTCOLOR));
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wc.hInstance = GetModuleHandle(nullptr);
|
||||
|
||||
@ -63,6 +63,7 @@ David Barr, aka javidx9, <20>OneLoneCoder 2019, 2020, 2021, 2022
|
||||
#include <sstream>
|
||||
#include <numeric>
|
||||
#include "Error.h"
|
||||
#include<ranges>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
@ -184,25 +185,22 @@ namespace olc::utils
|
||||
return m_vContent;
|
||||
}
|
||||
|
||||
inline const std::unordered_map<std::string,size_t>&GetKeys()const{
|
||||
inline const std::unordered_map<std::string_view,size_t>&GetKeys()const{
|
||||
return m_mapObjects;
|
||||
}
|
||||
|
||||
//This function is slightly expensive due to a filtering function required to remove all comments!
|
||||
inline std::vector<std::pair<std::string,datafile>> GetOrderedKeys(){
|
||||
std::vector<std::pair<std::string,datafile>>orderedKeys;
|
||||
std::copy_if(m_vecObjects.begin(),m_vecObjects.end(),std::back_inserter(orderedKeys),[&](const std::pair<std::string,datafile>&data){return !datafile::IsComment(data);});
|
||||
return orderedKeys;
|
||||
inline auto GetOrderedKeys(){
|
||||
return m_vecObjects|std::views::filter([](const std::pair<std::string_view,datafile>&data){return !datafile::IsComment(data);});
|
||||
}
|
||||
|
||||
// Checks if a property exists - useful to avoid creating properties
|
||||
// via reading them, though non-essential
|
||||
inline bool HasProperty(const std::string& sName)
|
||||
inline bool HasProperty(std::string_view sName)
|
||||
{
|
||||
size_t x = sName.find_first_of('.');
|
||||
if (x != std::string::npos)
|
||||
{
|
||||
std::string sProperty = sName.substr(0, x);
|
||||
std::string_view sProperty = sName.substr(0, x);
|
||||
if(HasProperty(sProperty)){
|
||||
return GetProperty(sName.substr(0, x)).HasProperty(sName.substr(x + 1, sName.size()));
|
||||
}else{
|
||||
@ -214,13 +212,13 @@ namespace olc::utils
|
||||
}
|
||||
|
||||
// Access a datafile via a convenient name - "root.node.something.property"
|
||||
inline datafile& GetProperty(const std::string& name)
|
||||
inline datafile& GetProperty(const std::string_view name)
|
||||
{
|
||||
[[unlikely]]if(DEBUG_ACCESS_OPTIONS)LOG(std::format("Accessing Property {}",name));
|
||||
size_t x = name.find_first_of('.');
|
||||
if (x != std::string::npos)
|
||||
{
|
||||
std::string sProperty = name.substr(0, x);
|
||||
std::string_view sProperty = name.substr(0, x);
|
||||
lastAccessedProperty=sProperty;
|
||||
if (HasProperty(sProperty))
|
||||
return operator[](sProperty).GetProperty(name.substr(x + 1, name.size()));
|
||||
@ -526,7 +524,7 @@ namespace olc::utils
|
||||
BLANK="";
|
||||
m_bIsComment=false;
|
||||
}
|
||||
inline datafile& operator[](const std::string& name)
|
||||
inline datafile& operator[](const std::string_view name)
|
||||
{
|
||||
// Check if this "node"'s map already contains an object with this name...
|
||||
if (m_mapObjects.count(name) == 0)
|
||||
@ -563,13 +561,13 @@ namespace olc::utils
|
||||
|
||||
// Linkage to create "ordered" unordered_map. We have a vector of
|
||||
// "properties", and the index to a specific element is mapped.
|
||||
std::vector<std::pair<std::string, datafile>> m_vecObjects;
|
||||
std::unordered_map<std::string, size_t> m_mapObjects;
|
||||
std::vector<std::pair<std::string_view, datafile>> m_vecObjects;
|
||||
std::unordered_map<std::string_view, size_t> m_mapObjects;
|
||||
|
||||
inline static std::string lastAccessedProperty="";
|
||||
inline static std::string BLANK="";
|
||||
|
||||
inline static bool IsComment(const std::pair<std::string,datafile>&data){
|
||||
inline static bool IsComment(const std::pair<std::string_view,datafile>&data){
|
||||
return data.first.length()>0&&data.first[0]=='#';
|
||||
}
|
||||
|
||||
|
||||
@ -104,6 +104,9 @@ public:
|
||||
auto erase_if(std::function<bool(std::pair<T,O>)>lambda){
|
||||
return std::erase_if(map,lambda);
|
||||
}
|
||||
auto contains(const T&key)const{
|
||||
return map.contains(key);
|
||||
}
|
||||
};
|
||||
|
||||
//A class that has an initialization lock so that when the lock is activated, any further gets that are missing items in it will report themselves for easier debugging detection.
|
||||
@ -154,4 +157,10 @@ public:
|
||||
auto end()const{
|
||||
return items.end();
|
||||
}
|
||||
auto contains(const T&key)const{
|
||||
return map.contains(key);
|
||||
}
|
||||
auto insert(T key,O obj){
|
||||
return map.insert({key,obj});
|
||||
}
|
||||
};
|
||||
@ -4210,7 +4210,7 @@ unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
|
||||
|
||||
static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last)
|
||||
{
|
||||
for(;;) {
|
||||
for(;) {
|
||||
int n;
|
||||
if (f->eof) return 0;
|
||||
n = get8(f);
|
||||
@ -4427,7 +4427,7 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
|
||||
if (!vorbis_find_page(f, NULL, NULL)) goto error;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
if (!get_seek_page_info(f, &mid)) goto error;
|
||||
if (mid.last_decoded_sample != ~0U) break;
|
||||
// (untested) no frames end on this page
|
||||
@ -4457,7 +4457,7 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
|
||||
end_pos = f->end_seg_with_known_loc;
|
||||
assert(end_pos >= 0);
|
||||
|
||||
for (;;) {
|
||||
for (;) {
|
||||
for (i = end_pos; i > 0; --i)
|
||||
if (f->segments[i-1] != 255)
|
||||
break;
|
||||
@ -5010,7 +5010,7 @@ int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_
|
||||
stb_vorbis_close(v);
|
||||
return -2;
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
|
||||
if (n == 0) break;
|
||||
data_len += n;
|
||||
@ -5050,7 +5050,7 @@ int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *samp
|
||||
stb_vorbis_close(v);
|
||||
return -2;
|
||||
}
|
||||
for (;;) {
|
||||
for (;) {
|
||||
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
|
||||
if (n == 0) break;
|
||||
data_len += n;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user