Boar test behaviors and general AI implemented. Release Build 8958.

mac-build
sigonasr2 8 months ago
parent c15fc769e1
commit ed0d5e2507
  1. 9
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 32
      Adventures in Lestoria/Boar.cpp
  4. 31
      Adventures in Lestoria/Monster.cpp
  5. 2
      Adventures in Lestoria/Monster.h
  6. 7
      Adventures in Lestoria/State_GameRun.cpp
  7. 2
      Adventures in Lestoria/Version.h
  8. 40
      Adventures in Lestoria/assets/Campaigns/2_1.tmx
  9. 5
      Adventures in Lestoria/assets/config/MonsterStrategies.txt
  10. 10
      Adventures in Lestoria/assets/config/Monsters.txt
  11. BIN
      Adventures in Lestoria/assets/monsters/Boar.png
  12. 4
      Adventures in Lestoria/olcUTIL_Animate2D.h
  13. BIN
      x64/Release/Adventures in Lestoria.exe

@ -4101,4 +4101,13 @@ void AiL::ComputeModeColors(TilesetData&tileset){
#pragma endregion
}
}
}
void AiL::UpdateEntities(){
UpdateEffects(GetElapsedTime());
GetPlayer()->Update(GetElapsedTime());
UpdateMonsters();
ItemDrop::UpdateDrops(GetElapsedTime());
UpdateBullets(GetElapsedTime());
}

@ -336,6 +336,7 @@ public:
const bool PreviousStageCompleted()const;
void SetCompletedStageFlag();
void ResetCompletedStageFlag();
void UpdateEntities();
Minimap minimap;
struct TileGroupData{

@ -54,6 +54,7 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
MOVE,
SCRATCH,
CHARGE,
RECOVERY,
};
switch(m.phase){
@ -61,25 +62,50 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
float distToPlayer=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).length();
if(distToPlayer>=ConfigInt("Closein Range")/100.f*24){
m.RemoveBuff(BuffType::SLOWDOWN);
m.targetAcquireTimer=0.f;
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
}else
if(distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
Key prevFacingDirection=m.GetFacingDirection();
m.AddBuff(BuffType::SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f);
m.targetAcquireTimer=0.f;
RUN_AWAY(m,fElapsedTime,"Run Away");
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
}else{
m.PerformOtherAnimation(0);
m.F(A::CASTING_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration();
m.F(A::CASTING_TIMER)=ConfigInt("Ground Scratch Count")*m.GetCurrentAnimation().GetTotalAnimationDuration();
m.phase=PhaseName::SCRATCH;
}
}break;
case PhaseName::SCRATCH:{
m.RemoveBuff(BuffType::SLOWDOWN);
m.F(A::CASTING_TIMER)-=fElapsedTime;
if(m.F(A::CASTING_TIMER)<=0.f){
m.PerformShootAnimation();
m.phase=PhaseName::CHARGE;
vf2d chargeTargetPoint=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(ConfigFloat("Charge Distance")/100.f*24);
m.target=chargeTargetPoint;
m.AddBuff(BuffType::SPEEDBOOST,INFINITE,ConfigFloat("Charge Movespeed")/100.f-1);
}
}break;
case PhaseName::CHARGE:{
float distToTarget=geom2d::line<float>(m.GetPos(),m.target).length();
if(m.bumpedIntoTerrain||distToTarget<4.f){
m.phase=PhaseName::RECOVERY;
m.F(A::CHARGE_COOLDOWN)=ConfigFloat("Charge Recovery Time");
m.PerformIdleAnimation();
}else{
m.targetAcquireTimer=INFINITY; //Don't acquire a new target.
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
}
}break;
case PhaseName::RECOVERY:{
m.F(A::CHARGE_COOLDOWN)-=fElapsedTime;
m.targetAcquireTimer=0.f;
m.RemoveBuff(BuffType::SPEEDBOOST);
if(m.F(A::CHARGE_COOLDOWN)<=0)m.phase=PhaseName::MOVE;
}break;
}
}

@ -258,6 +258,22 @@ bool Monster::Update(float fElapsedTime){
}
}
#pragma endregion
if(vel.x>0){
vel.x=std::max(0.f,vel.x-friction*fElapsedTime);
} else {
vel.x=std::min(0.f,vel.x+friction*fElapsedTime);
}
if(vel.y>0){
vel.y=std::max(0.f,vel.y-friction*fElapsedTime);
} else {
vel.y=std::min(0.f,vel.y+friction*fElapsedTime);
}
bumpedIntoTerrain=false;
if(vel!=vf2d{0,0}){
bumpedIntoTerrain|=SetX(pos.x+vel.x*fElapsedTime);
bumpedIntoTerrain|=SetY(pos.y+vel.y*fElapsedTime);
}
if(IsAlive()){
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){
@ -297,20 +313,6 @@ bool Monster::Update(float fElapsedTime){
}
Monster::STRATEGY::RUN_STRATEGY(*this,fElapsedTime);
}
if(vel.x>0){
vel.x=std::max(0.f,vel.x-friction*fElapsedTime);
} else {
vel.x=std::min(0.f,vel.x+friction*fElapsedTime);
}
if(vel.y>0){
vel.y=std::max(0.f,vel.y-friction*fElapsedTime);
} else {
vel.y=std::min(0.f,vel.y+friction*fElapsedTime);
}
if(vel!=vf2d{0,0}){
SetX(pos.x+vel.x*fElapsedTime);
SetY(pos.y+vel.y*fElapsedTime);
}
if(!IsAlive()){
deathTimer+=fElapsedTime;
if(deathTimer>3){
@ -319,6 +321,7 @@ bool Monster::Update(float fElapsedTime){
}
animation.UpdateState(internal_animState,randomFrameOffset+fElapsedTime);
randomFrameOffset=0;
attackedByPlayer=false;
return true;
}
Key Monster::GetFacingDirection()const{

@ -230,6 +230,8 @@ private:
static void NPC(Monster&m,float fElapsedTime,std::string strategy);
static void BOAR(Monster&m,float fElapsedTime,std::string strategy);
};
bool bumpedIntoTerrain=false; //Gets set to true before a strategy executes if the monster runs into some terrain on this frame.
bool attackedByPlayer=false; //Gets set to true before a strategy executes if the monster has been attacked by the player.
};
struct MonsterSpawner{

@ -81,13 +81,8 @@ void State_GameRun::OnUserUpdate(AiL*game){
game->HandleUserInput(game->GetElapsedTime());
game->UpdateEffects(game->GetElapsedTime());
GameEvent::UpdateEvents();
game->GetPlayer()->Update(game->GetElapsedTime());
game->UpdateMonsters();
ItemDrop::UpdateDrops(game->GetElapsedTime());
game->UpdateBullets(game->GetElapsedTime());
game->UpdateEntities();
game->UpdateCamera(game->GetElapsedTime());
}
void State_GameRun::Draw(AiL*game){

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

@ -1878,51 +1878,11 @@
<object id="1" name="Player Spawn" type="PlayerSpawnLocation" x="5112" y="8064" width="24" height="24"/>
<object id="2" name="Time Trial Clock" type="TrialClock" x="5112" y="8016" width="24" height="24"/>
<object id="5" name="End Ring" type="EndZone" x="3349" y="165" width="145" height="145"/>
<object id="6" template="../maps/Monsters/Boar.tx" x="4700" y="8021">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="7" template="../maps/Monsters/Boar.tx" x="4764" y="8049">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="8" template="../maps/Monsters/Goblin (Bombs).tx" x="4650" y="8048">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="9" template="../maps/Monsters/Goblin (Bow).tx" x="4618" y="8065">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="10" template="../maps/Monsters/Goblin (Dagger).tx" x="4660" y="8088">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="11" template="../maps/Monsters/Goblin Boar Rider.tx" x="4797" y="8132">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="12" template="../maps/Monsters/Hawk.tx" x="4633" y="8138">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="13" template="../maps/Monsters/Stone Elemental.tx" x="4543" y="8028">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="14" template="../maps/Monsters/Stone Elemental.tx" x="4533" y="8065">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="15" name="Spawn Group 1" type="SpawnGroup" x="4439" y="7869" width="496" height="424">
<ellipse/>
</object>

@ -537,12 +537,17 @@ MonsterStrategy
Backpedal Range = 400
# Number of times the boar scratches the ground before charging.
# The amount of time this takes is also dependent on the animation speed (extra animation 0)
Ground Scratch Count = 2
Charge Movespeed = 130%
Charge Distance = 900
# Amount of time to wait after charging before returning to Move Phase.
Charge Recovery Time = 0.3s
Backpedal Movespeed = 50%
}
}

@ -458,7 +458,7 @@ Monsters
XP = 19
Strategy = Run Towards
Strategy = Boar
#Size of each animation frame
SheetFrameSize = 24,24
@ -479,7 +479,8 @@ Monsters
#Additional custom animations go down below. Start with ANIMATION[0] Order is:
# File name, Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse)
# NOTE: ANIMATION[0] will always be row 5 of an animation sheet, all numbers that follow are each below each other.
# ANIMATION[0] = 4, 0.1, OneShot
# Scratch animation.
ANIMATION[0] = 4, 0.2, OneShot
}
Goblin (Dagger)
{
@ -514,8 +515,7 @@ Monsters
#Additional custom animations go down below. Start with ANIMATION[0] Order is:
# File name, Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse)
# NOTE: ANIMATION[0] will always be row 5 of an animation sheet, all numbers that follow are each below each other.
# Scratch animation.
ANIMATION[0] = 1, 0.1, OneShot
# ANIMATION[0] = 1, 0.1, OneShot
}
Goblin (Bow)
{
@ -690,6 +690,6 @@ Monsters
#Additional custom animations go down below. Start with ANIMATION[0] Order is:
# File name, Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse)
# NOTE: ANIMATION[0] will always be row 5 of an animation sheet, all numbers that follow are each below each other.
# ANIMATION[0] = 4, 0.1, OneShot
# ANIMATION[0] = 4, 0.2, OneShot
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 12 KiB

@ -199,7 +199,7 @@ namespace olc::utils::Animate2D
return ChangeState(state,sStateName);
}
// Change an animation state token to a new state
inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName) const
inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName)
{
currentStateName=sStateName;
size_t idx = m_mapStateIndices.at(sStateName);
@ -226,7 +226,7 @@ namespace olc::utils::Animate2D
return m_vSequences[state.nIndex].GetFrame(state.fTime);
}
inline const size_t GetFrameIndex()const{
inline const size_t GetFrameIndex(const AnimationState& state)const{
return m_vSequences[state.nIndex].GetFrameIndex(state.fTime);
}

Loading…
Cancel
Save