Rapid Fire ranger ability implemented.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
2023-07-25 20:32:29 +00:00
co-authored by AMay
parent b2b94eaf06
commit d4183180e1
5 changed files with 33 additions and 9 deletions
+24 -4
View File
@@ -61,6 +61,23 @@ void Ranger::OnUpdate(float fElapsedTime){
ghostFrameTimer=RETREAT_GHOST_FRAME_DELAY;
}
}
if(rapidFireTimer>0){
rapidFireTimer-=fElapsedTime;
if(rapidFireTimer<=0){
if(remainingRapidFireShots>0){
remainingRapidFireShots--;
rapidFireTimer=RAPID_FIRE_SHOOT_DELAY;
geom2d::line pointTowardsCursor(GetPos(),game->GetWorldMousePos());
vf2d extendedLine=pointTowardsCursor.upoint(1.1);
float angleToCursor=atan2(extendedLine.y-GetPos().y,extendedLine.x-GetPos().x);
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN;
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*250,float(sin(angleToCursor)*250-PI/8*250)}+movementVelocity,12,GetAttack(),OnUpperLevel(),true)));
SetAnimationBasedOnTargetingDirection(angleToCursor);
}else{
SetState(State::NORMAL);
}
}
}
}
bool Ranger::AutoAttack(){
@@ -71,11 +88,11 @@ bool Ranger::AutoAttack(){
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*250,float(sin(angleToCursor)*250-PI/8*250)}+movementVelocity,12,GetAttack(),OnUpperLevel(),true)));
SetState(State::SHOOT_ARROW);
SetAnimationBasedOnTargetingDirection(angleToCursor);
return false;
return true;
}
void Ranger::InitializeClassAbilities(){
#pragma region Ranger Right-click Ability (???)
#pragma region Ranger Right-click Ability (Retreat)
Ranger::rightClickAbility.action=
[](Player*p,vf2d pos={}){
geom2d::line mouseDir{game->GetWorldMousePos(),p->GetPos()};
@@ -92,10 +109,13 @@ void Ranger::InitializeClassAbilities(){
return true;
};
#pragma endregion
#pragma region Ranger Ability 1 (???)
#pragma region Ranger Ability 1 (Rapid Fire)
Ranger::ability1.action=
[](Player*p,vf2d pos={}){
return false;
p->remainingRapidFireShots=p->RAPID_FIRE_SHOOT_AMOUNT;
p->rapidFireTimer=p->RAPID_FIRE_SHOOT_DELAY;
p->SetState(State::ANIMATION_LOCK);
return true;
};
#pragma endregion
#pragma region Ranger Ability 2 (???)