Moved all enemy reading over to purely using config files. Removed all enemy enum dependencies. Removed bugs involving loading infinite maps by accident.
parent
13eff22485
commit
6a12a45cb2
@ -0,0 +1,15 @@ |
||||
#include "Monster.h" |
||||
|
||||
void Monster::STRATEGY::RUN_STRATEGY(Monster&m,float fElapsedTime){ |
||||
switch(m.strategy){ |
||||
case 0:{//Run Towards
|
||||
Monster::STRATEGY::RUN_TOWARDS(m,fElapsedTime); |
||||
}break; |
||||
case 1:{//Shoot Afar
|
||||
Monster::STRATEGY::SHOOT_AFAR(m,fElapsedTime); |
||||
}break; |
||||
case 2:{//Turret.
|
||||
Monster::STRATEGY::TURRET(m,fElapsedTime); |
||||
}break; |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
#include "Monster.h" |
||||
#include "DEFINES.h" |
||||
#include "Crawler.h" |
||||
|
||||
INCLUDE_game |
||||
INCLUDE_MONSTER_DATA |
||||
|
||||
void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime){ |
||||
m.targetAcquireTimer=std::max(0.f,m.targetAcquireTimer-fElapsedTime); |
||||
if(m.targetAcquireTimer==0){ |
||||
m.targetAcquireTimer=3; |
||||
m.target=geom2d::line(m.pos,game->GetPlayer()->GetPos()).upoint(1.2); |
||||
m.SetState(MOVE_TOWARDS); |
||||
m.hasHitPlayer=false; |
||||
} |
||||
switch(m.state){ |
||||
case MOVE_TOWARDS:{ |
||||
if(geom2d::line(m.pos,m.target).length()>100*fElapsedTime*m.GetMoveSpdMult()){ |
||||
vf2d newPos=m.pos+geom2d::line(m.pos,m.target).vector().norm()*100*fElapsedTime*m.GetMoveSpdMult(); |
||||
if(!m.SetX(newPos.x)||!m.SetY(newPos.y)){ |
||||
m.StartPathfinding(4); |
||||
} |
||||
m.PerformJumpAnimation(); |
||||
} else { |
||||
m.SetState(NORMAL);//Revert state once we've finished moving towards target.
|
||||
m.UpdateAnimation(MONSTER_DATA[m.id].GetIdleAnimation()); |
||||
} |
||||
}break; |
||||
case PATH_AROUND:{ |
||||
m.PathAroundBehavior(fElapsedTime); |
||||
}break; |
||||
default:{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,95 @@ |
||||
#include "Monster.h" |
||||
#include "DEFINES.h" |
||||
#include "Crawler.h" |
||||
|
||||
INCLUDE_BULLET_LIST |
||||
INCLUDE_game |
||||
|
||||
void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime){ |
||||
m.targetAcquireTimer=std::max(0.f,m.targetAcquireTimer-fElapsedTime); |
||||
m.attackCooldownTimer=std::max(0.f,m.attackCooldownTimer-fElapsedTime); |
||||
if(m.queueShotTimer>0){ |
||||
m.queueShotTimer-=fElapsedTime; |
||||
if(m.queueShotTimer<0){ |
||||
m.queueShotTimer=0; |
||||
{ |
||||
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(m.pos + vf2d{ 0,-4 }, geom2d::line(m.pos + vf2d{ 0,-4 }, game->GetPlayer()->GetPos()).vector().norm() * 24 * 3.f, 2, m.GetAttack(),m.upperLevel,false, { 75 / 2,162 / 2,225 / 2 }))); |
||||
} |
||||
} |
||||
} |
||||
geom2d::line line(m.pos,game->GetPlayer()->GetPos()); |
||||
if(m.targetAcquireTimer==0&&m.queueShotTimer==0){ |
||||
m.targetAcquireTimer=1; |
||||
if(line.length()<24*6){ |
||||
m.target=line.upoint(-1.2); |
||||
if(m.canMove){ |
||||
m.SetState(MOVE_AWAY); |
||||
} else { |
||||
m.SetState(NORMAL); |
||||
} |
||||
} else |
||||
if(line.length()>24*7){ |
||||
m.target=line.upoint(1.2); |
||||
m.SetState(MOVE_TOWARDS); |
||||
} else { |
||||
m.SetState(NORMAL); |
||||
} |
||||
} |
||||
m.canMove=true; |
||||
geom2d::line moveTowardsLine=geom2d::line(m.pos,m.target); |
||||
bool pathfindingDecision=false; |
||||
switch(m.state){ |
||||
case MOVE_TOWARDS:{ |
||||
if(moveTowardsLine.length()>1){ |
||||
vf2d newPos=m.pos+moveTowardsLine.vector().norm()*100*fElapsedTime*m.GetMoveSpdMult(); |
||||
bool movedX=m.SetX(newPos.x); |
||||
bool movedY=m.SetY(newPos.y); |
||||
pathfindingDecision=movedX|movedY; |
||||
m.canMove=movedX&&movedY; |
||||
} |
||||
if(!pathfindingDecision){ |
||||
m.StartPathfinding(2.5); |
||||
}else |
||||
if(line.length()<=24*7){ |
||||
m.SetState(NORMAL); |
||||
} |
||||
if(moveTowardsLine.vector().x>0){ |
||||
m.facingDirection=RIGHT; |
||||
} else { |
||||
m.facingDirection=LEFT; |
||||
} |
||||
m.PerformJumpAnimation(); |
||||
}break; |
||||
case MOVE_AWAY:{ |
||||
if(moveTowardsLine.length()>1){ |
||||
vf2d newPos=m.pos+moveTowardsLine.vector().norm()*100*fElapsedTime*m.GetMoveSpdMult(); |
||||
bool movedX=m.SetX(newPos.x); |
||||
bool movedY=m.SetY(newPos.y); |
||||
pathfindingDecision=movedX|movedY; |
||||
m.canMove=movedX&&movedY; |
||||
} |
||||
if(!pathfindingDecision){ |
||||
m.StartPathfinding(2.5); |
||||
}else |
||||
if(line.length()>=24*6){ |
||||
m.SetState(NORMAL); |
||||
} |
||||
if(moveTowardsLine.vector().x>0){ |
||||
m.facingDirection=RIGHT; |
||||
} else { |
||||
m.facingDirection=LEFT; |
||||
} |
||||
m.PerformJumpAnimation(); |
||||
}break; |
||||
case PATH_AROUND:{ |
||||
m.PathAroundBehavior(fElapsedTime); |
||||
}break; |
||||
default:{ |
||||
if(m.attackCooldownTimer==0){ |
||||
m.attackCooldownTimer=1; |
||||
m.queueShotTimer=0.7; |
||||
m.PerformShootAnimation(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,5 @@ |
||||
#include "Monster.h" |
||||
|
||||
void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime){ |
||||
|
||||
} |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in new issue