|
|
|
@ -140,7 +140,7 @@ bool Monster::_SetX(float x,const bool monsterInvoked){ |
|
|
|
|
} else { |
|
|
|
|
geom2d::rect<float>collision={collisionRect.pos,collisionRect.size}; |
|
|
|
|
#pragma region lambdas |
|
|
|
|
auto NoEnemyCollisionWithTile=[&](){return !geom2d::overlaps(geom2d::circle<float>(newPos,game->GetCurrentMapData().tilewidth/2*GetSizeMult()),collision);}; |
|
|
|
|
auto NoEnemyCollisionWithTile=[&](){return isBoss||!geom2d::overlaps(newPos,collision);}; |
|
|
|
|
#pragma endregion |
|
|
|
|
collision.pos+=tilePos; |
|
|
|
|
if(NoEnemyCollisionWithTile()){ |
|
|
|
@ -170,7 +170,7 @@ bool Monster::_SetY(float y,const bool monsterInvoked){ |
|
|
|
|
} else { |
|
|
|
|
geom2d::rect<float>collision={collisionRect.pos,collisionRect.size}; |
|
|
|
|
#pragma region lambdas |
|
|
|
|
auto NoEnemyCollisionWithTile=[&](){return !geom2d::overlaps(geom2d::circle<float>(newPos,game->GetCurrentMapData().tilewidth/2*GetSizeMult()),collision);}; |
|
|
|
|
auto NoEnemyCollisionWithTile=[&](){return isBoss||!geom2d::overlaps(newPos,collision);}; |
|
|
|
|
#pragma endregion |
|
|
|
|
collision.pos+=tilePos; |
|
|
|
|
if(NoEnemyCollisionWithTile()){ |
|
|
|
@ -540,7 +540,7 @@ void Monster::RemoveBuff(BuffType type){ |
|
|
|
|
|
|
|
|
|
bool Monster::StartPathfinding(float pathingTime){ |
|
|
|
|
SetState(State::PATH_AROUND); |
|
|
|
|
path=game->pathfinder.Solve_WalkPath(pos,target,12,OnUpperLevel()); |
|
|
|
|
path=game->pathfinder.Solve_WalkPath(pos,target,24,OnUpperLevel()); |
|
|
|
|
if(path.points.size()>0){ |
|
|
|
|
pathIndex=0.f; |
|
|
|
|
//We gives this mob 5 seconds to figure out a path to the target.
|
|
|
|
@ -553,13 +553,14 @@ void Monster::PathAroundBehavior(float fElapsedTime){ |
|
|
|
|
if(path.points.size()>0){ |
|
|
|
|
//Move towards the new path.
|
|
|
|
|
geom2d::line moveTowardsLine=geom2d::line(pos,path.GetSplinePoint(pathIndex).pos); |
|
|
|
|
if(moveTowardsLine.length()>2){ |
|
|
|
|
if(!SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult())){ |
|
|
|
|
if(moveTowardsLine.length()>100*fElapsedTime*GetMoveSpdMult()){ |
|
|
|
|
SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult()); |
|
|
|
|
/*if(!SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult())){
|
|
|
|
|
//We are stuck, so stop pathfinding.
|
|
|
|
|
path.points.clear(); |
|
|
|
|
pathIndex=0; |
|
|
|
|
targetAcquireTimer=0; |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
UpdateFacingDirection(moveTowardsLine.end); |
|
|
|
|
}else{ |
|
|
|
|
if(pathIndex>=path.points.size()-1){ |
|
|
|
@ -567,7 +568,16 @@ void Monster::PathAroundBehavior(float fElapsedTime){ |
|
|
|
|
pathIndex=0; |
|
|
|
|
targetAcquireTimer=0; |
|
|
|
|
}else{ |
|
|
|
|
pathIndex+=0.5f; |
|
|
|
|
while(moveTowardsLine.length()<100*fElapsedTime*GetMoveSpdMult()){ |
|
|
|
|
pathIndex+=0.1f; |
|
|
|
|
moveTowardsLine=geom2d::line(pos,path.GetSplinePoint(pathIndex).pos); |
|
|
|
|
if(pathIndex>=path.points.size()-1){ |
|
|
|
|
//We have reached the end of the path!
|
|
|
|
|
pathIndex=0; |
|
|
|
|
targetAcquireTimer=0; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|