|
|
|
@ -151,8 +151,16 @@ void Ranger::InitializeClassAbilities(){
|
|
|
|
|
float shootingDist=pointTowardsCursor.length();
|
|
|
|
|
vf2d shootingDirMiddle=pointTowardsCursor.vector();
|
|
|
|
|
float shootingAngle=atan2(shootingDirMiddle.y,shootingDirMiddle.x);
|
|
|
|
|
int arrowCount="Ranger.Ability 3.ArrowCount"_I%2==0?"Ranger.Ability 3.ArrowCount"_I+1:"Ranger.Ability 3.ArrowCount"_I;
|
|
|
|
|
for(int i=0;i<arrowCount;i++){
|
|
|
|
|
// WARNING! This variable is NOT the actual arrow count shot out. If there is an even number, to make the algorithm shoot out a spray of arrows on both sides,
|
|
|
|
|
// it is programmed to add an arrow in the middle and SKIP it. Therefore DO NOT use this value as the actual arrow count.
|
|
|
|
|
// Use config value Ranger.Ability 3.ArrowCount Instead!!!
|
|
|
|
|
int algorithmArrowCount="Ranger.Ability 3.ArrowCount"_I%2==0?"Ranger.Ability 3.ArrowCount"_I+1:"Ranger.Ability 3.ArrowCount"_I;
|
|
|
|
|
const int intendedTotalDamage{int("Ranger.Ability 3.DamageMult"_F*p->GetAttack())};
|
|
|
|
|
const int perArrowDamage{std::max(1,int(p->GetAttack()*("Ranger.Ability 3.DamageMult"_F/"Ranger.Ability 3.ArrowCount"_I)))};
|
|
|
|
|
const int totalArrowDamage{perArrowDamage*"Ranger.Ability 3.ArrowCount"_I};
|
|
|
|
|
const int leftoverArrowDamage{intendedTotalDamage-totalArrowDamage}; //Compared to intended damage, the amount dealt may not be completely evenly divisible. Account for the remainder here to pour into the last arrow.
|
|
|
|
|
int totalDamageCalculated{0};
|
|
|
|
|
for(int i=0;i<algorithmArrowCount;i++){
|
|
|
|
|
if("Ranger.Ability 3.ArrowCount"_I%2==0&&i=="Ranger.Ability 3.ArrowCount"_I/2)continue;
|
|
|
|
|
const float halfAngle="Ranger.Ability 3.MultiShotSpread"_F*PI/180;
|
|
|
|
|
const float leftAngle=-halfAngle;
|
|
|
|
@ -160,8 +168,12 @@ void Ranger::InitializeClassAbilities(){
|
|
|
|
|
const float newAngle=shootingAngle+leftAngle/2+i*increment;
|
|
|
|
|
geom2d::line pointTowardsCursor=geom2d::line(p->GetPos(),p->GetPos()+vf2d{cos(newAngle),sin(newAngle)}*shootingDist);
|
|
|
|
|
vf2d extendedLine=pointTowardsCursor.upoint(1.1f);
|
|
|
|
|
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(p->GetPos(),extendedLine,vf2d{cos(newAngle)*"Ranger.Ability 3.ArrowSpd"_F,float(sin(newAngle)*"Ranger.Ability 3.ArrowSpd"_F-PI/8*"Ranger.Ability 3.ArrowSpd"_F)}+p->movementVelocity,12*"Ranger.Ability 3.ArrowRadius"_F/100,int(p->GetAttack()*"Ranger.Ability 3.DamageMult"_F),p->OnUpperLevel(),true)));
|
|
|
|
|
int finalArrowDamage{perArrowDamage};
|
|
|
|
|
if(i==algorithmArrowCount-1)finalArrowDamage+=leftoverArrowDamage;
|
|
|
|
|
BULLET_LIST.emplace_back(std::make_unique<Arrow>(Arrow(p->GetPos(),extendedLine,vf2d{cos(newAngle)*"Ranger.Ability 3.ArrowSpd"_F,float(sin(newAngle)*"Ranger.Ability 3.ArrowSpd"_F-PI/8*"Ranger.Ability 3.ArrowSpd"_F)}+p->movementVelocity,12*"Ranger.Ability 3.ArrowRadius"_F/100,finalArrowDamage,p->OnUpperLevel(),true)));
|
|
|
|
|
totalDamageCalculated+=finalArrowDamage;
|
|
|
|
|
}
|
|
|
|
|
if(totalDamageCalculated!=intendedTotalDamage)ERR(std::format("WARNING! Multi-shot expected a total damage calculation of {} but added up to {} instead!",intendedTotalDamage,totalDamageCalculated));
|
|
|
|
|
p->rangerShootAnimationTimer=0.3f;
|
|
|
|
|
p->SetState(State::SHOOT_ARROW);
|
|
|
|
|
p->SetAnimationBasedOnTargetingDirection("SHOOT",shootingAngle);
|
|
|
|
|