Fix backpedal logic to use move run towards strategy instead. Attacked by Player trigger added.

mac-build
sigonasr2 9 months ago
parent ed0d5e2507
commit e2101d5da0
  1. 12
      Adventures in Lestoria/Boar.cpp
  2. 12
      Adventures in Lestoria/Monster.cpp
  3. 2
      Adventures in Lestoria/RunTowards.cpp

@ -60,18 +60,20 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
switch(m.phase){
case PhaseName::MOVE:{
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.targetAcquireTimer=0.f;
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
}else
if(distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
Key prevFacingDirection=m.GetFacingDirection();
if(m.canMove&&distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
m.AddBuff(BuffType::SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f);
m.targetAcquireTimer=0.f;
RUN_AWAY(m,fElapsedTime,"Run Away");
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(-100);
m.targetAcquireTimer=INFINITY;
if(m.attackedByPlayer)goto ScratchPhaseTransition;
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
}else{
ScratchPhaseTransition:
m.PerformOtherAnimation(0);
m.F(A::CASTING_TIMER)=ConfigInt("Ground Scratch Count")*m.GetCurrentAnimation().GetTotalAnimationDuration();
m.phase=PhaseName::SCRATCH;

@ -616,17 +616,12 @@ bool Monster::StartPathfinding(float pathingTime){
}
void Monster::PathAroundBehavior(float fElapsedTime){
canMove=false;
if(path.points.size()>0){
//Move towards the new path.
geom2d::line moveTowardsLine=geom2d::line(pos,path.GetSplinePoint(pathIndex).pos);
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;
}*/
canMove=SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
UpdateFacingDirection(moveTowardsLine.end);
}else{
if(pathIndex>=path.points.size()-1){
@ -644,6 +639,9 @@ void Monster::PathAroundBehavior(float fElapsedTime){
break;
}
}
//Try to move to the new determined location.
canMove=SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
UpdateFacingDirection(moveTowardsLine.end);
}
}
} else {

@ -95,7 +95,7 @@ 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();
m.SetPos(newPos);
m.canMove=m.SetPos(newPos);
if(m.GetPos()!=newPos){
bool pathFound=m.StartPathfinding(4);
if(!pathFound){

Loading…
Cancel
Save