Bosses no longer have tile collision. Tweaked general pathfinding rules for run towards script.
This commit is contained in:
parent
7a557fe5fc
commit
bc702788cf
@ -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 {
|
||||
|
@ -65,7 +65,8 @@ void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime,std::string str
|
||||
case State::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.SetPos(newPos)){
|
||||
m.SetPos(newPos);
|
||||
if(m.GetPos()!=newPos){
|
||||
bool pathFound=m.StartPathfinding(4);
|
||||
if(!pathFound){
|
||||
m.SetState(State::MOVE_TOWARDS);
|
||||
|
@ -62,19 +62,33 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
|
||||
auto TransitionToPhase2=[&](){
|
||||
m.phase=2;
|
||||
m.PerformOtherAnimation(1);
|
||||
m.AddBuff(BARRIER_DAMAGE_REDUCTION,INFINITE,ConfigFloat("Phase 2.Barrier Damage Reduction")/100.f);
|
||||
};
|
||||
|
||||
if(m.GetRemainingHPPct()<=ConfigFloat("Phase 2.Change")/100.f){
|
||||
if(m.F(A::RUN_AWAY_TIMER)==0.f)m.F(A::RUN_AWAY_TIMER)=10.f;
|
||||
else{
|
||||
m.F(A::RUN_AWAY_TIMER)-=fElapsedTime;
|
||||
if(m.F(A::RUN_AWAY_TIMER)==0.f)TransitionToPhase2();
|
||||
}
|
||||
//before moving to Phase 2, we need to make sure we're in Phase 0 of the bear AI.
|
||||
//We also need to move to the center of the map.
|
||||
if(m.I(A::PHASE)!=0.f)goto bear;
|
||||
else{
|
||||
if(m.overlaySpriteTransparency<210U){
|
||||
if(m.I(A::PHASE)!=0.f)goto bear;
|
||||
else{
|
||||
if(m.F(A::RUN_AWAY_TIMER)==0.f)m.F(A::RUN_AWAY_TIMER)=ConfigFloat("Phase 1.Fur Change Color Time");
|
||||
else{
|
||||
m.F(A::RUN_AWAY_TIMER)=std::max(0.f,m.F(A::RUN_AWAY_TIMER)-fElapsedTime);
|
||||
if(m.F(A::RUN_AWAY_TIMER)==0.f)m.overlaySpriteTransparency=210U;
|
||||
}
|
||||
m.overlaySpriteTransparency=util::lerp(0U,210U,1-(m.F(A::RUN_AWAY_TIMER)/ConfigFloat("Phase 1.Fur Change Color Time")));
|
||||
}
|
||||
break;
|
||||
}else{
|
||||
//We also need to move to the center of the map.
|
||||
if(m.F(A::RUN_AWAY_TIMER)==0.f)m.F(A::RUN_AWAY_TIMER)=ConfigFloat("Phase 1.Run to Center Time");
|
||||
else{
|
||||
m.F(A::RUN_AWAY_TIMER)=std::max(0.f,m.F(A::RUN_AWAY_TIMER)-fElapsedTime);
|
||||
if(m.F(A::RUN_AWAY_TIMER)==0.f){
|
||||
TransitionToPhase2();
|
||||
break;
|
||||
}
|
||||
}
|
||||
vf2d mapCenter=game->GetCurrentMap().MapData.MapSize*vf2d{float(game->GetCurrentMap().MapData.tilewidth),float(game->GetCurrentMap().MapData.tileheight)}/2.0f;
|
||||
float distToCenter=geom2d::line<float>(m.GetPos(),mapCenter).length();
|
||||
if(distToCenter>4.0f){
|
||||
@ -84,6 +98,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
|
||||
break;
|
||||
}else{ //Now we're finally good for phase 2.
|
||||
TransitionToPhase2();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 6284
|
||||
#define VERSION_BUILD 6300
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -323,6 +323,9 @@ MonsterStrategy
|
||||
|
||||
Phase 1
|
||||
{
|
||||
# The amount of time it takes for the fur transformation to take place.
|
||||
Fur Change Color Time = 2.0s
|
||||
|
||||
# Maximum amount of time the boss takes to run towards the center before giving up and continuing through Phase 2.
|
||||
Run to Center Time = 10.0s
|
||||
}
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user