Boar test behaviors and general AI implemented. Release Build 8958.
This commit is contained in:
parent
c15fc769e1
commit
ed0d5e2507
@ -4102,3 +4102,12 @@ void AiL::ComputeModeColors(TilesetData&tileset){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiL::UpdateEntities(){
|
||||||
|
UpdateEffects(GetElapsedTime());
|
||||||
|
GetPlayer()->Update(GetElapsedTime());
|
||||||
|
UpdateMonsters();
|
||||||
|
|
||||||
|
ItemDrop::UpdateDrops(GetElapsedTime());
|
||||||
|
UpdateBullets(GetElapsedTime());
|
||||||
|
}
|
@ -336,6 +336,7 @@ public:
|
|||||||
const bool PreviousStageCompleted()const;
|
const bool PreviousStageCompleted()const;
|
||||||
void SetCompletedStageFlag();
|
void SetCompletedStageFlag();
|
||||||
void ResetCompletedStageFlag();
|
void ResetCompletedStageFlag();
|
||||||
|
void UpdateEntities();
|
||||||
Minimap minimap;
|
Minimap minimap;
|
||||||
|
|
||||||
struct TileGroupData{
|
struct TileGroupData{
|
||||||
|
@ -54,6 +54,7 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
|
|||||||
MOVE,
|
MOVE,
|
||||||
SCRATCH,
|
SCRATCH,
|
||||||
CHARGE,
|
CHARGE,
|
||||||
|
RECOVERY,
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(m.phase){
|
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();
|
float distToPlayer=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).length();
|
||||||
if(distToPlayer>=ConfigInt("Closein Range")/100.f*24){
|
if(distToPlayer>=ConfigInt("Closein Range")/100.f*24){
|
||||||
m.RemoveBuff(BuffType::SLOWDOWN);
|
m.RemoveBuff(BuffType::SLOWDOWN);
|
||||||
|
m.targetAcquireTimer=0.f;
|
||||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||||
}else
|
}else
|
||||||
if(distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
|
if(distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
|
||||||
Key prevFacingDirection=m.GetFacingDirection();
|
Key prevFacingDirection=m.GetFacingDirection();
|
||||||
m.AddBuff(BuffType::SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f);
|
m.AddBuff(BuffType::SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f);
|
||||||
|
m.targetAcquireTimer=0.f;
|
||||||
RUN_AWAY(m,fElapsedTime,"Run Away");
|
RUN_AWAY(m,fElapsedTime,"Run Away");
|
||||||
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
|
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
|
||||||
}else{
|
}else{
|
||||||
m.PerformOtherAnimation(0);
|
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;
|
m.phase=PhaseName::SCRATCH;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case PhaseName::SCRATCH:{
|
case PhaseName::SCRATCH:{
|
||||||
m.RemoveBuff(BuffType::SLOWDOWN);
|
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;
|
}break;
|
||||||
case PhaseName::CHARGE:{
|
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;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -259,6 +259,22 @@ bool Monster::Update(float fElapsedTime){
|
|||||||
}
|
}
|
||||||
#pragma endregion
|
#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()){
|
if(IsAlive()){
|
||||||
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){
|
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){
|
||||||
Buff&b=*it;
|
Buff&b=*it;
|
||||||
@ -297,20 +313,6 @@ bool Monster::Update(float fElapsedTime){
|
|||||||
}
|
}
|
||||||
Monster::STRATEGY::RUN_STRATEGY(*this,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()){
|
if(!IsAlive()){
|
||||||
deathTimer+=fElapsedTime;
|
deathTimer+=fElapsedTime;
|
||||||
if(deathTimer>3){
|
if(deathTimer>3){
|
||||||
@ -319,6 +321,7 @@ bool Monster::Update(float fElapsedTime){
|
|||||||
}
|
}
|
||||||
animation.UpdateState(internal_animState,randomFrameOffset+fElapsedTime);
|
animation.UpdateState(internal_animState,randomFrameOffset+fElapsedTime);
|
||||||
randomFrameOffset=0;
|
randomFrameOffset=0;
|
||||||
|
attackedByPlayer=false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Key Monster::GetFacingDirection()const{
|
Key Monster::GetFacingDirection()const{
|
||||||
|
@ -230,6 +230,8 @@ private:
|
|||||||
static void NPC(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 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{
|
struct MonsterSpawner{
|
||||||
|
@ -81,13 +81,8 @@ void State_GameRun::OnUserUpdate(AiL*game){
|
|||||||
|
|
||||||
game->HandleUserInput(game->GetElapsedTime());
|
game->HandleUserInput(game->GetElapsedTime());
|
||||||
|
|
||||||
game->UpdateEffects(game->GetElapsedTime());
|
|
||||||
GameEvent::UpdateEvents();
|
GameEvent::UpdateEvents();
|
||||||
game->GetPlayer()->Update(game->GetElapsedTime());
|
game->UpdateEntities();
|
||||||
game->UpdateMonsters();
|
|
||||||
|
|
||||||
ItemDrop::UpdateDrops(game->GetElapsedTime());
|
|
||||||
game->UpdateBullets(game->GetElapsedTime());
|
|
||||||
game->UpdateCamera(game->GetElapsedTime());
|
game->UpdateCamera(game->GetElapsedTime());
|
||||||
}
|
}
|
||||||
void State_GameRun::Draw(AiL*game){
|
void State_GameRun::Draw(AiL*game){
|
||||||
|
@ -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 8947
|
#define VERSION_BUILD 8958
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #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="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="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="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">
|
<object id="7" template="../maps/Monsters/Boar.tx" x="4764" y="8049">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="spawner" type="object" value="15"/>
|
<property name="spawner" type="object" value="15"/>
|
||||||
</properties>
|
</properties>
|
||||||
</object>
|
</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">
|
<object id="15" name="Spawn Group 1" type="SpawnGroup" x="4439" y="7869" width="496" height="424">
|
||||||
<ellipse/>
|
<ellipse/>
|
||||||
</object>
|
</object>
|
||||||
|
@ -537,12 +537,17 @@ MonsterStrategy
|
|||||||
|
|
||||||
Backpedal Range = 400
|
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
|
Ground Scratch Count = 2
|
||||||
|
|
||||||
Charge Movespeed = 130%
|
Charge Movespeed = 130%
|
||||||
|
|
||||||
Charge Distance = 900
|
Charge Distance = 900
|
||||||
|
|
||||||
|
# Amount of time to wait after charging before returning to Move Phase.
|
||||||
|
Charge Recovery Time = 0.3s
|
||||||
|
|
||||||
Backpedal Movespeed = 50%
|
Backpedal Movespeed = 50%
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -458,7 +458,7 @@ Monsters
|
|||||||
|
|
||||||
XP = 19
|
XP = 19
|
||||||
|
|
||||||
Strategy = Run Towards
|
Strategy = Boar
|
||||||
|
|
||||||
#Size of each animation frame
|
#Size of each animation frame
|
||||||
SheetFrameSize = 24,24
|
SheetFrameSize = 24,24
|
||||||
@ -479,7 +479,8 @@ Monsters
|
|||||||
#Additional custom animations go down below. Start with ANIMATION[0] Order is:
|
#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)
|
# 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.
|
# 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)
|
Goblin (Dagger)
|
||||||
{
|
{
|
||||||
@ -514,8 +515,7 @@ Monsters
|
|||||||
#Additional custom animations go down below. Start with ANIMATION[0] Order is:
|
#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)
|
# 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.
|
# 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)
|
Goblin (Bow)
|
||||||
{
|
{
|
||||||
@ -690,6 +690,6 @@ Monsters
|
|||||||
#Additional custom animations go down below. Start with ANIMATION[0] Order is:
|
#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)
|
# 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.
|
# 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);
|
return ChangeState(state,sStateName);
|
||||||
}
|
}
|
||||||
// Change an animation state token to a new state
|
// 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;
|
currentStateName=sStateName;
|
||||||
size_t idx = m_mapStateIndices.at(sStateName);
|
size_t idx = m_mapStateIndices.at(sStateName);
|
||||||
@ -226,7 +226,7 @@ namespace olc::utils::Animate2D
|
|||||||
return m_vSequences[state.nIndex].GetFrame(state.fTime);
|
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);
|
return m_vSequences[state.nIndex].GetFrameIndex(state.fTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user