Resolve Issue #53. Flipped directional value so monsters face west when their target is west and east when their target is east. Add error checking to detect when a missing monster strategy value is found in MonsterStrategies.txt to prevent potential future game crashes. Fix Turret monster strategy not utilizing shooting animation, replace with new animation duration code. Release Build 9207.

mac-build
sigonasr2 7 months ago
parent 45060e9160
commit e67a1ba684
  1. 5
      Adventures in Lestoria/Monster.cpp
  2. 2
      Adventures in Lestoria/Monster.h
  3. 42
      Adventures in Lestoria/RUN_STRATEGY.cpp
  4. 2
      Adventures in Lestoria/Turret.cpp
  5. 2
      Adventures in Lestoria/Version.h
  6. 7
      Adventures in Lestoria/assets/Campaigns/2_1.tmx
  7. 2
      Adventures in Lestoria/assets/config/Monsters.txt
  8. BIN
      x64/Release/Adventures in Lestoria.exe

@ -75,6 +75,7 @@ Monster::Monster(vf2d pos,MonsterData data,bool upperLevel,bool bossMob):
stats.A("Move Spd %")=data.GetMoveSpdMult(); stats.A("Move Spd %")=data.GetMoveSpdMult();
randomFrameOffset=(util::random()%1000)/1000.f; randomFrameOffset=(util::random()%1000)/1000.f;
monsterWalkSoundTimer=util::random(1.f); monsterWalkSoundTimer=util::random(1.f);
UpdateFacingDirection(game->GetPlayer()->GetPos());
} }
const vf2d&Monster::GetPos()const{ const vf2d&Monster::GetPos()const{
return pos; return pos;
@ -383,9 +384,9 @@ void Monster::UpdateFacingDirection(vf2d facingTargetPoint){
if(HasMountedMonster())mounted_animation.value().ModifyDisplaySprite(internal_mounted_animState.value(),std::format("{}_{}",mounted_animation.value().currentStateName.substr(0,mounted_animation.value().currentStateName.length()-2),int(facingDirection))); if(HasMountedMonster())mounted_animation.value().ModifyDisplaySprite(internal_mounted_animState.value(),std::format("{}_{}",mounted_animation.value().currentStateName.substr(0,mounted_animation.value().currentStateName.length()-2),int(facingDirection)));
}else{ }else{
if(diff.x>0){ if(diff.x>0){
facingDirection=Direction::EAST;
}else{
facingDirection=Direction::WEST; facingDirection=Direction::WEST;
}else{
facingDirection=Direction::EAST;
} }
} }
} }

@ -176,7 +176,7 @@ private:
float queueShotTimer=0; float queueShotTimer=0;
float z=0; float z=0;
float iframe_timer=0; float iframe_timer=0;
Direction facingDirection=Direction::SOUTH; Direction facingDirection=Direction::WEST;
std::string strategy; std::string strategy;
State::State state=State::NORMAL; State::State state=State::NORMAL;
std::string overlaySprite=""; std::string overlaySprite="";

@ -67,8 +67,12 @@ int Monster::STRATEGY::_GetInt(Monster&m,std::string param,std::string strategy,
}else }else
if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){ if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){
return DATA["Monsters"][m.name].GetProperty(param).GetInt(index); return DATA["Monsters"][m.name].GetProperty(param).GetInt(index);
} else { }else
if(DATA["MonsterStrategy"][strategy].HasProperty(param)){
return DATA["MonsterStrategy"][strategy].GetProperty(param).GetInt(index); return DATA["MonsterStrategy"][strategy].GetProperty(param).GetInt(index);
}else{
ERR(std::format("Monster {} trying to read non-existent Integer Property {}[{}] for Strategy {}. THIS SHOULD NOT BE HAPPENING!",m.GetName(),param,index,strategy));
return{};
} }
} }
float Monster::STRATEGY::_GetFloat(Monster&m,std::string param,std::string strategy,int index){ float Monster::STRATEGY::_GetFloat(Monster&m,std::string param,std::string strategy,int index){
@ -77,8 +81,12 @@ float Monster::STRATEGY::_GetFloat(Monster&m,std::string param,std::string strat
}else }else
if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){ if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){
return float(DATA["Monsters"][m.name].GetProperty(param).GetReal(index)); return float(DATA["Monsters"][m.name].GetProperty(param).GetReal(index));
} else { }else
if(DATA["MonsterStrategy"][strategy].HasProperty(param)){
return float(DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index)); return float(DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index));
}else{
ERR(std::format("Monster {} trying to read non-existent Float Property {}[{}] for Strategy {}. THIS SHOULD NOT BE HAPPENING!",m.GetName(),param,index,strategy))
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 param,std::string strategy,int index){
@ -87,8 +95,12 @@ const std::string&Monster::STRATEGY::_GetString(Monster&m,std::string param,std:
}else }else
if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){ if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){
return DATA["Monsters"][m.name].GetProperty(param).GetString(index); return DATA["Monsters"][m.name].GetProperty(param).GetString(index);
} else { }else
if(DATA["MonsterStrategy"][strategy].HasProperty(param)){
return DATA["MonsterStrategy"][strategy].GetProperty(param).GetString(index); return DATA["MonsterStrategy"][strategy].GetProperty(param).GetString(index);
}else{
ERR(std::format("Monster {} trying to read non-existent String Property {}[{}] for Strategy {}. THIS SHOULD NOT BE HAPPENING!",m.GetName(),param,index,strategy))
return{};
} }
} }
vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string param,std::string strategy,int index){ vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string param,std::string strategy,int index){
@ -97,8 +109,12 @@ vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string param,std::string strategy
}else }else
if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){ if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){
return {DATA["Monsters"][m.name].GetProperty(param).GetReal(index),DATA["Monsters"][m.name].GetProperty(param).GetReal(index+1)}; return {DATA["Monsters"][m.name].GetProperty(param).GetReal(index),DATA["Monsters"][m.name].GetProperty(param).GetReal(index+1)};
} else { }else
if(DATA["MonsterStrategy"][strategy].HasProperty(param)){
return {DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index),DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index+1)}; return {DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index),DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index+1)};
}else{
ERR(std::format("Monster {} trying to read non-existent Vf2d Property {}[{}] for Strategy {}. THIS SHOULD NOT BE HAPPENING!",m.GetName(),param,index,strategy))
return{};
} }
} }
const datafile&Monster::STRATEGY::_Get(Monster&m,std::string param,std::string strategy){ const datafile&Monster::STRATEGY::_Get(Monster&m,std::string param,std::string strategy){
@ -107,8 +123,12 @@ const datafile&Monster::STRATEGY::_Get(Monster&m,std::string param,std::string s
}else }else
if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){ if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){
return DATA["Monsters"][m.name].GetProperty(param); return DATA["Monsters"][m.name].GetProperty(param);
} else { }else
if(DATA["MonsterStrategy"][strategy].HasProperty(param)){
return DATA["MonsterStrategy"][strategy].GetProperty(param); return DATA["MonsterStrategy"][strategy].GetProperty(param);
}else{
ERR(std::format("Monster {} trying to read non-existent Data Property {} for Strategy {}",m.GetName(),param,strategy));
return{};
} }
} }
Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string param,std::string strategy,int index){ Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string param,std::string strategy,int index){
@ -117,8 +137,12 @@ Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string param,std::string strat
}else }else
if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){ if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){
return DATA["Monsters"][m.name].GetProperty(param).GetPixel(index); return DATA["Monsters"][m.name].GetProperty(param).GetPixel(index);
} else { }else
if(DATA["MonsterStrategy"][strategy].HasProperty(param)){
return DATA["MonsterStrategy"][strategy].GetProperty(param).GetPixel(index); return DATA["MonsterStrategy"][strategy].GetProperty(param).GetPixel(index);
}else{
ERR(std::format("Monster {} trying to read non-existent Pixel Property {}[{}] for Strategy {}. THIS SHOULD NOT BE HAPPENING!",m.GetName(),param,index,strategy))
return{};
} }
} }
@ -128,8 +152,12 @@ double Monster::STRATEGY::_GetPixels(Monster&m,std::string param,std::string str
}else }else
if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){ if(!m.IsNPC()&&DATA["Monsters"][m.name].HasProperty(param)){
return DATA["Monsters"][m.name].GetProperty(param).GetReal(index)/100.f*24; return DATA["Monsters"][m.name].GetProperty(param).GetReal(index)/100.f*24;
} else { }else
if(DATA["MonsterStrategy"][strategy].HasProperty(param)){
return DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index)/100.f*24; return DATA["MonsterStrategy"][strategy].GetProperty(param).GetReal(index)/100.f*24;
}else{
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{};
} }
} }

@ -69,7 +69,7 @@ void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime,std::string strategy
if(m.attackCooldownTimer==0){ if(m.attackCooldownTimer==0){
m.attackCooldownTimer=ConfigFloat("ShootingSpeed"); m.attackCooldownTimer=ConfigFloat("ShootingSpeed");
m.queueShotTimer=std::min(m.attackCooldownTimer-0.001f,0.3f); m.queueShotTimer=std::min(m.attackCooldownTimer-0.001f,0.3f);
m.F(A::SHOOT_ANIMATION_TIME)=ConfigIntArr("ShootAnimation",0)*ConfigFloatArr("ShootAnimation",1); m.F(A::SHOOT_ANIMATION_TIME)=m.GetCurrentAnimation().GetTotalAnimationDuration();
m.PerformShootAnimation(); m.PerformShootAnimation();
} }
} }

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 9200 #define VERSION_BUILD 9207
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="238" height="369" tilewidth="24" tileheight="24" infinite="0" nextlayerid="7" nextobjectid="34"> <map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="238" height="369" tilewidth="24" tileheight="24" infinite="0" nextlayerid="7" nextobjectid="35">
<properties> <properties>
<property name="Backdrop" propertytype="Backdrop" value="mountain_day"/> <property name="Backdrop" propertytype="Backdrop" value="mountain_day"/>
<property name="Background Music" propertytype="BGM" value="foresty1_1"/> <property name="Background Music" propertytype="BGM" value="foresty1_1"/>
@ -1887,5 +1887,10 @@
<property name="spawner" type="object" value="15"/> <property name="spawner" type="object" value="15"/>
</properties> </properties>
</object> </object>
<object id="34" template="../maps/Monsters/Green Slime.tx" x="4515" y="8107">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
</objectgroup> </objectgroup>
</map> </map>

@ -197,7 +197,7 @@ Monsters
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 7, 0.1, PingPong IDLE = 7, 0.1, PingPong
JUMP = 1, 0.1, OneShot JUMP = 1, 0.1, OneShot
SHOOT = 5, 0.1, Repeat SHOOT = 5, 0.1, OneShot
DEATH = 5, 0.2, OneShot DEATH = 5, 0.2, OneShot
} }

Loading…
Cancel
Save