Fix backpedal logic to use move run towards strategy instead. Attacked by Player trigger added.
This commit is contained in:
parent
ed0d5e2507
commit
e2101d5da0
@ -60,18 +60,20 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
|
|||||||
switch(m.phase){
|
switch(m.phase){
|
||||||
case PhaseName::MOVE:{
|
case PhaseName::MOVE:{
|
||||||
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(m.canMove&&distToPlayer>=ConfigInt("Closein Range")/100.f*24){
|
||||||
m.RemoveBuff(BuffType::SLOWDOWN);
|
m.RemoveBuff(BuffType::SLOWDOWN);
|
||||||
m.targetAcquireTimer=0.f;
|
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(m.canMove&&distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
|
||||||
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;
|
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(-100);
|
||||||
RUN_AWAY(m,fElapsedTime,"Run Away");
|
m.targetAcquireTimer=INFINITY;
|
||||||
|
if(m.attackedByPlayer)goto ScratchPhaseTransition;
|
||||||
|
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||||
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
|
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
|
||||||
}else{
|
}else{
|
||||||
|
ScratchPhaseTransition:
|
||||||
m.PerformOtherAnimation(0);
|
m.PerformOtherAnimation(0);
|
||||||
m.F(A::CASTING_TIMER)=ConfigInt("Ground Scratch Count")*m.GetCurrentAnimation().GetTotalAnimationDuration();
|
m.F(A::CASTING_TIMER)=ConfigInt("Ground Scratch Count")*m.GetCurrentAnimation().GetTotalAnimationDuration();
|
||||||
m.phase=PhaseName::SCRATCH;
|
m.phase=PhaseName::SCRATCH;
|
||||||
|
@ -616,17 +616,12 @@ bool Monster::StartPathfinding(float pathingTime){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Monster::PathAroundBehavior(float fElapsedTime){
|
void Monster::PathAroundBehavior(float fElapsedTime){
|
||||||
|
canMove=false;
|
||||||
if(path.points.size()>0){
|
if(path.points.size()>0){
|
||||||
//Move towards the new path.
|
//Move towards the new path.
|
||||||
geom2d::line moveTowardsLine=geom2d::line(pos,path.GetSplinePoint(pathIndex).pos);
|
geom2d::line moveTowardsLine=geom2d::line(pos,path.GetSplinePoint(pathIndex).pos);
|
||||||
if(moveTowardsLine.length()>100*fElapsedTime*GetMoveSpdMult()){
|
if(moveTowardsLine.length()>100*fElapsedTime*GetMoveSpdMult()){
|
||||||
SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
|
canMove=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);
|
UpdateFacingDirection(moveTowardsLine.end);
|
||||||
}else{
|
}else{
|
||||||
if(pathIndex>=path.points.size()-1){
|
if(pathIndex>=path.points.size()-1){
|
||||||
@ -644,6 +639,9 @@ void Monster::PathAroundBehavior(float fElapsedTime){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Try to move to the new determined location.
|
||||||
|
canMove=SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
|
||||||
|
UpdateFacingDirection(moveTowardsLine.end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,7 +95,7 @@ void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime,std::string str
|
|||||||
case State::MOVE_TOWARDS:{
|
case State::MOVE_TOWARDS:{
|
||||||
if(geom2d::line(m.pos,m.target).length()>100*fElapsedTime*m.GetMoveSpdMult()){
|
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();
|
vf2d newPos=m.pos+geom2d::line(m.pos,m.target).vector().norm()*100*fElapsedTime*m.GetMoveSpdMult();
|
||||||
m.SetPos(newPos);
|
m.canMove=m.SetPos(newPos);
|
||||||
if(m.GetPos()!=newPos){
|
if(m.GetPos()!=newPos){
|
||||||
bool pathFound=m.StartPathfinding(4);
|
bool pathFound=m.StartPathfinding(4);
|
||||||
if(!pathFound){
|
if(!pathFound){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user