Sandworm implementation + Monster collision radius changing implemented.

master
sigonasr2 1 month ago
parent e9f02ea885
commit e0644fe809
  1. 1
      Adventures in Lestoria/Animation.cpp
  2. 10
      Adventures in Lestoria/Monster.cpp
  3. 3
      Adventures in Lestoria/Monster.h
  4. 14
      Adventures in Lestoria/Sandworm.cpp
  5. 1
      Adventures in Lestoria/assets/config/gfx/gfx.txt
  6. BIN
      Adventures in Lestoria/assets/sand_suction.png

@ -401,6 +401,7 @@ void sig::Animation::InitializeAnimations(){
CreateHorizontalAnimationSequence("bomb_boom.png",5,{36,36},AnimationData{.frameDuration{0.2f},.style{Animate2D::Style::OneShot}});
CreateHorizontalAnimationSequence("tornado2.png",4,{24,48},AnimationData{.frameDuration{0.1f},.style{Animate2D::Style::Repeat}});
CreateHorizontalAnimationSequence("large_tornado.png",4,{72,144},AnimationData{.frameDuration{0.1f},.style{Animate2D::Style::Repeat}});
CreateHorizontalAnimationSequence("sand_suction.png",4,{72,72},AnimationData{.frameDuration{0.2f},.style{Animate2D::Style::Repeat}});
CreateStillAnimation("meteor.png",{192,192});

@ -70,7 +70,7 @@ safemap<std::string,std::function<void(Monster&,float,std::string)>>STRATEGY_DAT
std::unordered_map<std::string,Renderable*>MonsterData::imgs;
Monster::Monster(vf2d pos,MonsterData data,bool upperLevel,bool bossMob):
pos(pos),spawnPos(pos),hp(data.GetHealth()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),name(data.GetInternalName()),upperLevel(upperLevel),isBoss(bossMob),facingDirection(Direction::WEST),lifetime(GetTotalLifetime()){
pos(pos),spawnPos(pos),hp(data.GetHealth()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),name(data.GetInternalName()),upperLevel(upperLevel),isBoss(bossMob),facingDirection(Direction::WEST),lifetime(GetTotalLifetime()),collisionRadius(data.GetCollisionRadius()){
for(const std::string&anim:data.GetAnimations()){
animation.AddState(anim,ANIMATION_DATA[std::format("{}_{}",name,anim)]);
}
@ -1368,7 +1368,7 @@ const std::optional<float>Monster::GetTotalLifetime()const{
return MONSTER_DATA.at(GetName()).GetLifetime();
}
const float Monster::GetCollisionRadius()const{
return MONSTER_DATA.at(GetName()).GetCollisionRadius()*GetSizeMult();
return collisionRadius;
}
void Monster::MarkForDeletion(){
@ -1665,3 +1665,9 @@ const int Monster::GetPhase(const std::string&strategyName){
const bool Monster::HasBuff(BuffType buff)const{
return std::find_if(buffList.begin(),buffList.end(),[type=buff](const Buff&buff){return buff.type==type;})!=buffList.end();
}
const float Monster::GetOriginalCollisionRadius()const{
return MONSTER_DATA.at(GetName()).GetCollisionRadius()*GetSizeMult();
}
void Monster::SetCollisionRadius(const float collisionRadius){
this->collisionRadius=collisionRadius;
}

@ -234,6 +234,8 @@ public:
void MoveForward(const vf2d&moveForwardVec,const float fElapsedTime); //Moves the monster forward in given 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);
const float GetOriginalCollisionRadius()const;
void SetCollisionRadius(const float collisionRadius);
private:
//NOTE: Marking a monster for deletion does not trigger any death events. It just simply removes the monster from the field!!
// The way this works is that monsters marked for deletion will cause the monster update loop to detect there's at least one or more monsters that must be deleted and will call erase_if on the list at the end of the iteration loop.
@ -330,6 +332,7 @@ private:
const bool IsUnconscious()const;
const float UnconsciousTime()const;
bool manualIgnoreTerrain{false}; //A manual flag that can be toggled on to dynamically make this monster ignore terrain collision.
float collisionRadius{}; //The collision radius can be modified, it's just set initially to the monster database entry.
struct STRATEGY{
static std::string ERR;

@ -47,5 +47,17 @@ using A=Attribute;
INCLUDE_game
void Monster::STRATEGY::SANDWORM(Monster&m,float fElapsedTime,std::string strategy){
enum PhaseName{
INITIALIZE,
UNDERGROUND,
};
switch(PHASE()){
case INITIALIZE:{
SETPHASE(UNDERGROUND);
}break;
case UNDERGROUND:{
m.SetCollisionRadius(0.f);
}break;
}
}

@ -137,6 +137,7 @@ Images
GFX_MusketTrail = musket_trail.png
GFX_LineIndicator = line_indicator.png
GFX_MusketBullet = musket_bullet.png
GFX_SandSuction = sand_suction.png
GFX_Thief_Sheet = nico-thief.png
GFX_Trapper_Sheet = nico-trapper.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Loading…
Cancel
Save