|
|
|
@ -1275,6 +1275,7 @@ const vf2d Player::GetWorldAimingLocation(){ |
|
|
|
|
const vf2d Player::GetAimingLocation(){ |
|
|
|
|
if(Input::UsingGamepad()){ |
|
|
|
|
float xAxis=0.f,yAxis=0.f; |
|
|
|
|
#pragma region Manual Aiming |
|
|
|
|
for(GamePad*gamepad:GamePad::getGamepads()){ |
|
|
|
|
if(gamepad->stillConnected){ |
|
|
|
|
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){ |
|
|
|
@ -1294,10 +1295,27 @@ const vf2d Player::GetAimingLocation(){ |
|
|
|
|
if(xAxis!=0.f||yAxis!=0.f)break; //Found a controller, so we're good to break.
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#pragma endregion |
|
|
|
|
if(xAxis!=0.f||yAxis!=0.f){ |
|
|
|
|
return {(game->ScreenWidth()*xAxis)/2+game->ScreenWidth()/2,(game->ScreenHeight()*yAxis)/2+game->ScreenHeight()/2}; |
|
|
|
|
}else{ |
|
|
|
|
return game->GetScreenSize()/2+vf2d{"Player.Aiming Cursor Max Distance"_F/100*24.f,aimingAngle.y}.cart(); |
|
|
|
|
//Find the closest monster target.
|
|
|
|
|
vf2d closestPoint={std::numeric_limits<float>::max(),std::numeric_limits<float>::max()}; |
|
|
|
|
for(Monster&m:MONSTER_LIST){ |
|
|
|
|
if(m.IsAlive()){ |
|
|
|
|
float distToMonster=geom2d::line<float>(GetPos(),m.GetPos()).length(); |
|
|
|
|
geom2d::line<float>aimingLine=geom2d::line<float>(GetPos(),m.GetPos()); |
|
|
|
|
vf2d aimingPoint=aimingLine.rpoint(operator""_Pixels("Player.Aiming Cursor Max Distance"_F)); |
|
|
|
|
float distToClosestPoint=geom2d::line<float>(GetPos(),closestPoint).length(); |
|
|
|
|
if(distToClosestPoint>distToMonster&&distToMonster<=operator""_Pixels("Player.Auto Aim Detection Distance"_F)){ |
|
|
|
|
closestPoint=aimingPoint; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(closestPoint!=vf2d{std::numeric_limits<float>::max(),std::numeric_limits<float>::max()}){ |
|
|
|
|
return game->GetScreenSize()/2+closestPoint-GetPos(); |
|
|
|
|
}else |
|
|
|
|
return game->GetScreenSize()/2+vf2d{float(operator""_Pixels("Player.Aiming Cursor Max Distance"_F)),aimingAngle.y}.cart(); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
return game->GetMousePos(); |
|
|
|
|