Rapid Fire ranger ability implemented.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
b2b94eaf06
commit
d4183180e1
@ -52,13 +52,12 @@ private:
|
|||||||
void InitializeClassAbilities();
|
void InitializeClassAbilities();
|
||||||
public:
|
public:
|
||||||
Crawler();
|
Crawler();
|
||||||
|
bool OnUserCreate() override;
|
||||||
|
bool OnUserUpdate(float fElapsedTime) override;
|
||||||
public:
|
public:
|
||||||
geom2d::rect<int>NO_COLLISION={};
|
geom2d::rect<int>NO_COLLISION={};
|
||||||
vi2d WORLD_SIZE={120,8};
|
vi2d WORLD_SIZE={120,8};
|
||||||
TileTransformedView view;
|
TileTransformedView view;
|
||||||
bool OnUserCreate() override;
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override;
|
|
||||||
void InitializeLevel(std::string mapFile,MapName map);
|
void InitializeLevel(std::string mapFile,MapName map);
|
||||||
void LoadLevel(MapName map);
|
void LoadLevel(MapName map);
|
||||||
void HandleUserInput(float fElapsedTime);
|
void HandleUserInput(float fElapsedTime);
|
||||||
|
|||||||
@ -319,7 +319,7 @@ void Player::Update(float fElapsedTime){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto AllowedToCast=[&](Ability&ability){return !ability.precastInfo.precastTargetingRequired;};
|
auto AllowedToCast=[&](Ability&ability){return !ability.precastInfo.precastTargetingRequired&&GetState()!=State::ANIMATION_LOCK;};
|
||||||
//If pressed is set to false, uses held instead.
|
//If pressed is set to false, uses held instead.
|
||||||
auto CheckAndPerformAbility=[&](Ability&ability,HWButton key){
|
auto CheckAndPerformAbility=[&](Ability&ability,HWButton key){
|
||||||
if(ability.name!="???"){
|
if(ability.name!="???"){
|
||||||
@ -402,7 +402,7 @@ vf2d Player::GetVelocity(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Player::CanMove(){
|
bool Player::CanMove(){
|
||||||
return state!=State::CASTING;
|
return state!=State::CASTING&&state!=State::ANIMATION_LOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::HasIframes(){
|
bool Player::HasIframes(){
|
||||||
|
|||||||
@ -90,6 +90,10 @@ protected:
|
|||||||
float ghostRemoveTimer=0;
|
float ghostRemoveTimer=0;
|
||||||
float retreatTimer=0;
|
float retreatTimer=0;
|
||||||
std::vector<vf2d>ghostPositions;
|
std::vector<vf2d>ghostPositions;
|
||||||
|
float rapidFireTimer=0;
|
||||||
|
int remainingRapidFireShots=0;
|
||||||
|
const float RAPID_FIRE_SHOOT_DELAY=0.1;
|
||||||
|
const int RAPID_FIRE_SHOOT_AMOUNT=4;
|
||||||
public:
|
public:
|
||||||
Player();
|
Player();
|
||||||
//So this is rather fascinating and only exists because we have the ability to change classes which means we need to initialize a class
|
//So this is rather fascinating and only exists because we have the ability to change classes which means we need to initialize a class
|
||||||
|
|||||||
@ -61,6 +61,23 @@ void Ranger::OnUpdate(float fElapsedTime){
|
|||||||
ghostFrameTimer=RETREAT_GHOST_FRAME_DELAY;
|
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(){
|
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)));
|
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);
|
SetState(State::SHOOT_ARROW);
|
||||||
SetAnimationBasedOnTargetingDirection(angleToCursor);
|
SetAnimationBasedOnTargetingDirection(angleToCursor);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ranger::InitializeClassAbilities(){
|
void Ranger::InitializeClassAbilities(){
|
||||||
#pragma region Ranger Right-click Ability (???)
|
#pragma region Ranger Right-click Ability (Retreat)
|
||||||
Ranger::rightClickAbility.action=
|
Ranger::rightClickAbility.action=
|
||||||
[](Player*p,vf2d pos={}){
|
[](Player*p,vf2d pos={}){
|
||||||
geom2d::line mouseDir{game->GetWorldMousePos(),p->GetPos()};
|
geom2d::line mouseDir{game->GetWorldMousePos(),p->GetPos()};
|
||||||
@ -92,10 +109,13 @@ void Ranger::InitializeClassAbilities(){
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma region Ranger Ability 1 (???)
|
#pragma region Ranger Ability 1 (Rapid Fire)
|
||||||
Ranger::ability1.action=
|
Ranger::ability1.action=
|
||||||
[](Player*p,vf2d pos={}){
|
[](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 endregion
|
||||||
#pragma region Ranger Ability 2 (???)
|
#pragma region Ranger Ability 2 (???)
|
||||||
|
|||||||
@ -14,4 +14,5 @@ enum State{
|
|||||||
PREP_CAST,
|
PREP_CAST,
|
||||||
SHOOT_ARROW,
|
SHOOT_ARROW,
|
||||||
RETREAT,
|
RETREAT,
|
||||||
|
ANIMATION_LOCK,
|
||||||
};
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user