Warrior ability custom parameters implemented.
This commit is contained in:
parent
c6cddd88b8
commit
a86362c801
@ -5,11 +5,11 @@
|
||||
INCLUDE_ANIMATION_DATA
|
||||
INCLUDE_game
|
||||
|
||||
Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col)
|
||||
:pos(pos),vel(vel),radius(radius),damage(damage),col(col),friendly(friendly),upperLevel(upperLevel){};
|
||||
Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col,vf2d scale)
|
||||
:pos(pos),vel(vel),radius(radius),damage(damage),col(col),friendly(friendly),upperLevel(upperLevel),scale(scale){};
|
||||
|
||||
Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool upperLevel,bool hitsMultiple,float lifetime,bool rotatesWithAngle,bool friendly,Pixel col)
|
||||
:pos(pos),vel(vel),radius(radius),damage(damage),col(col),animated(true),rotates(rotatesWithAngle),lifetime(lifetime),hitsMultiple(hitsMultiple),friendly(friendly),upperLevel(upperLevel){
|
||||
Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool upperLevel,bool hitsMultiple,float lifetime,bool rotatesWithAngle,bool friendly,Pixel col,vf2d scale)
|
||||
:pos(pos),vel(vel),radius(radius),damage(damage),col(col),animated(true),rotates(rotatesWithAngle),lifetime(lifetime),hitsMultiple(hitsMultiple),friendly(friendly),upperLevel(upperLevel),scale(scale){
|
||||
this->animation.AddState(animation,ANIMATION_DATA[animation]);
|
||||
this->animation.ChangeState(internal_animState,animation);
|
||||
};
|
||||
@ -17,7 +17,6 @@ Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animatio
|
||||
Animate2D::Frame Bullet::GetFrame(){
|
||||
return animation.GetFrame(internal_animState);
|
||||
}
|
||||
|
||||
void Bullet::UpdateFadeTime(float fElapsedTime)
|
||||
{
|
||||
if(fadeOutTime>0){
|
||||
@ -34,7 +33,7 @@ void Bullet::Draw(){
|
||||
auto lerp=[](uint8_t f1,uint8_t f2,float t){return uint8_t((float(f2)*t)+f1*(1-t));};
|
||||
|
||||
if(animated){
|
||||
game->view.DrawPartialRotatedDecal(pos,GetFrame().GetSourceImage()->Decal(),rotates?atan2(vel.y,vel.x)-PI/2:0,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{1,1},fadeOutTime==0?col:Pixel{col.r,col.g,col.b,lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
|
||||
game->view.DrawPartialRotatedDecal(pos,GetFrame().GetSourceImage()->Decal(),rotates?atan2(vel.y,vel.x)-PI/2:0,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,scale,fadeOutTime==0?col:Pixel{col.r,col.g,col.b,lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
|
||||
} else {
|
||||
game->view.DrawDecal(pos,game->GFX_BulletCircle.Decal(),{radius,radius},fadeOutTime==0?col:Pixel{col.r,col.g,col.b,lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
|
||||
game->view.DrawDecal(pos,game->GFX_BulletCircleOutline.Decal(),{radius,radius},fadeOutTime==0?WHITE:Pixel{WHITE.r,WHITE.g,WHITE.b,lerp(WHITE.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
|
||||
|
@ -24,14 +24,15 @@ protected:
|
||||
float fadeOutTimer=0;
|
||||
private:
|
||||
void UpdateFadeTime(float fElapsedTime);
|
||||
vf2d scale={1,1};
|
||||
public:
|
||||
Animate2D::Animation<AnimationState>animation;
|
||||
Animate2D::AnimationState internal_animState;
|
||||
std::map<Monster*,bool>hitList;
|
||||
virtual ~Bullet()=default;
|
||||
Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE);
|
||||
Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1});
|
||||
//Initializes a bullet with an animation.
|
||||
Bullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool upperLevel,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,bool friendly=false,Pixel col=WHITE);
|
||||
Bullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool upperLevel,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1});
|
||||
public:
|
||||
virtual void Update(float fElapsedTime);
|
||||
//Return true when the bullet should be destroyed. Return false to handle it otherwise (like deactivating it instead). You become responsible for getting rid of the bullet.
|
||||
|
@ -14,14 +14,22 @@ INCLUDE_BULLET_LIST
|
||||
INCLUDE_DAMAGENUMBER_LIST
|
||||
INCLUDE_game
|
||||
|
||||
const float Player::GROUND_SLAM_SPIN_TIME=0.6f;
|
||||
float Player::GROUND_SLAM_SPIN_TIME=0.6f;
|
||||
|
||||
Player::Player()
|
||||
:state(State::NORMAL),lastReleasedMovementKey(DOWN),facingDirection(DOWN){}
|
||||
:lastReleasedMovementKey(DOWN),facingDirection(DOWN),state(State::NORMAL){
|
||||
Initialize();
|
||||
}
|
||||
|
||||
Player::Player(Player*player)
|
||||
:pos(player->GetPos()),vel(player->GetVelocity()),iframe_time(player->iframe_time),lastReleasedMovementKey(DOWN),
|
||||
facingDirection(DOWN),state(State::NORMAL){}
|
||||
facingDirection(DOWN),state(State::NORMAL){
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void Player::Initialize(){
|
||||
Player::GROUND_SLAM_SPIN_TIME="Warrior.Ability 2.SpinTime"_F;
|
||||
}
|
||||
|
||||
bool Player::SetX(float x){
|
||||
vf2d newPos={x,pos.y};
|
||||
@ -213,15 +221,15 @@ void Player::Update(float fElapsedTime){
|
||||
spin_angle-=spin_spd*fElapsedTime;
|
||||
}
|
||||
if(spin_attack_timer>0){
|
||||
z=50*sin(3.3*(GROUND_SLAM_SPIN_TIME-spin_attack_timer)/GROUND_SLAM_SPIN_TIME);
|
||||
z="Warrior.Ability 2.SpinMaxHeight"_I*sin(3.3*(GROUND_SLAM_SPIN_TIME-spin_attack_timer)/GROUND_SLAM_SPIN_TIME);
|
||||
spin_attack_timer=std::max(0.f,spin_attack_timer-fElapsedTime);
|
||||
} else {
|
||||
SetState(NORMAL);
|
||||
spin_angle=0;
|
||||
z=0;
|
||||
float numb=4;
|
||||
game->HurtEnemies(pos,3*12,GetAttack()*2.5,OnUpperLevel());
|
||||
game->AddEffect(std::make_unique<Effect>(GetPos(),0.5,AnimationState::GROUND_SLAM_ATTACK_FRONT,upperLevel,1.33f,0.6f),std::make_unique<Effect>(GetPos(),0.5,AnimationState::GROUND_SLAM_ATTACK_BACK,upperLevel,1.33f,0.6f));
|
||||
game->HurtEnemies(pos,"Warrior.Ability 2.Range"_F/100*12,GetAttack()*"Warrior.Ability 2.DamageMult"_F,OnUpperLevel());
|
||||
game->AddEffect(std::make_unique<Effect>(GetPos(),"Warrior.Ability 2.EffectLifetime"_F,AnimationState::GROUND_SLAM_ATTACK_FRONT,upperLevel,"Warrior.Ability 2.Range"_F/300*1.33f,"Warrior.Ability 2.EffectFadetime"_F),std::make_unique<Effect>(GetPos(),"Warrior.Ability 2.EffectLifetime"_F,AnimationState::GROUND_SLAM_ATTACK_BACK,upperLevel,"Warrior.Ability 2.Range"_F/300*1.33f,"Warrior.Ability 2.EffectFadetime"_F));
|
||||
}
|
||||
if(lastAnimationFlip>0){
|
||||
lastAnimationFlip=std::max(0.f,lastAnimationFlip-fElapsedTime);
|
||||
|
@ -52,6 +52,7 @@ struct Player{
|
||||
vf2d movementVelocity={};//This tells us if the player is moving (mostly controlled by user input) since their velocity is not used for regular movement.
|
||||
float lastHitTimer=0; //When this is greater than zero, if we get hit again it adds to our displayed combo number.
|
||||
std::shared_ptr<DamageNumber>damageNumberPtr;
|
||||
void Initialize();
|
||||
protected:
|
||||
const float ATTACK_COOLDOWN="Warrior.Auto Attack.Cooldown"_F;
|
||||
const float MAGIC_ATTACK_COOLDOWN=0.85f;
|
||||
@ -103,7 +104,7 @@ public:
|
||||
//using a new object type... Because of that we'll take the pointer reference to the old object and copy some of its properties to this new
|
||||
//one. It's hackish but it means we can reduce the amount of extra boilerplate when class changing...I don't know how to feel about this.
|
||||
Player(Player*player);
|
||||
const static float GROUND_SLAM_SPIN_TIME;
|
||||
static float GROUND_SLAM_SPIN_TIME;
|
||||
vf2d&GetPos();
|
||||
float GetX();
|
||||
float GetY();
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 877
|
||||
#define VERSION_BUILD 890
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -94,8 +94,8 @@ void Warrior::InitializeClassAbilities(){
|
||||
#pragma region Warrior Ability 2 (Ground Slam)
|
||||
Warrior::ability2.action=
|
||||
[](Player*p,vf2d pos={}){
|
||||
p->Spin(GROUND_SLAM_SPIN_TIME,14*PI);
|
||||
p->iframe_time=GROUND_SLAM_SPIN_TIME+0.1;
|
||||
p->Spin(GROUND_SLAM_SPIN_TIME,"Warrior.Ability 2.SpinSpd"_F*PI);
|
||||
p->iframe_time="Warrior.Ability 2.IframeTime"_F;
|
||||
return true;
|
||||
};
|
||||
#pragma endregion
|
||||
@ -103,32 +103,32 @@ void Warrior::InitializeClassAbilities(){
|
||||
Warrior::ability3.action=
|
||||
[](Player*p,vf2d pos={}){
|
||||
p->SetState(State::SWING_SONIC_SWORD);
|
||||
p->AddBuff(BuffType::SLOWDOWN,0.5,1);
|
||||
p->AddBuff(BuffType::SLOWDOWN,"Warrior.Ability 3.StuckTime"_F,1);
|
||||
vf2d bulletVel={};
|
||||
switch(p->GetFacingDirection()){
|
||||
case UP:{
|
||||
p->vel.y=70;
|
||||
bulletVel.y=-400;
|
||||
p->vel.y="Warrior.Ability 3.AbilityPushback"_F;
|
||||
bulletVel.y=-"Warrior.Ability 3.BulletSpd"_F;
|
||||
p->UpdateAnimation(AnimationState::WARRIOR_SWINGSONICSWORD_N,WARRIOR);
|
||||
}break;
|
||||
case LEFT:{
|
||||
p->vel.x=70;
|
||||
bulletVel.x=-400;
|
||||
p->vel.x="Warrior.Ability 3.AbilityPushback"_F;
|
||||
bulletVel.x=-"Warrior.Ability 3.BulletSpd"_F;
|
||||
p->UpdateAnimation(AnimationState::WARRIOR_SWINGSONICSWORD_W,WARRIOR);
|
||||
}break;
|
||||
case RIGHT:{
|
||||
p->vel.x=-70;
|
||||
bulletVel.x=400;
|
||||
p->vel.x=-"Warrior.Ability 3.AbilityPushback"_F;
|
||||
bulletVel.x="Warrior.Ability 3.BulletSpd"_F;
|
||||
p->UpdateAnimation(AnimationState::WARRIOR_SWINGSONICSWORD_E,WARRIOR);
|
||||
}break;
|
||||
case DOWN:{
|
||||
p->vel.y=-70;
|
||||
bulletVel.y=400;
|
||||
p->vel.y=-"Warrior.Ability 3.AbilityPushback"_F;
|
||||
bulletVel.y="Warrior.Ability 3.BulletSpd"_F;
|
||||
p->UpdateAnimation(AnimationState::WARRIOR_SWINGSONICSWORD_S,WARRIOR);
|
||||
}break;
|
||||
}
|
||||
BULLET_LIST.push_back(std::make_unique<Bullet>(p->GetPos(),bulletVel,30,p->GetAttack()*8,AnimationState::SONICSLASH,p->upperLevel,true,2.25,true,true,WHITE));
|
||||
game->SetupWorldShake(0.5);
|
||||
BULLET_LIST.push_back(std::make_unique<Bullet>(p->GetPos(),bulletVel,"Warrior.Ability 3.Radius"_F,p->GetAttack()*"Warrior.Ability 3.DamageMult"_F,AnimationState::SONICSLASH,p->upperLevel,true,"Warrior.Ability 3.Lifetime"_F,true,true,WHITE,vf2d{"Warrior.Ability 3.Radius"_F/30,"Warrior.Ability 3.Radius"_F/30}));
|
||||
game->SetupWorldShake("Warrior.Ability 3.ShakeTime"_F);
|
||||
return true;
|
||||
};
|
||||
#pragma endregion
|
||||
|
@ -85,6 +85,20 @@ Warrior
|
||||
Precast Time = 0
|
||||
Casting Range = 0
|
||||
Casting Size = 0
|
||||
|
||||
SpinTime = 0.6
|
||||
SpinSpd = 14
|
||||
SpinMaxHeight = 50
|
||||
|
||||
IframeTime = 0.7
|
||||
|
||||
Range = 300
|
||||
DamageMult = 2.5
|
||||
|
||||
# Amount of time the effect lives for on-screen before fading begins.
|
||||
EffectLifetime = 0.5
|
||||
# Amount of time the effect fades out.
|
||||
EffectFadetime = 0.6
|
||||
}
|
||||
Ability 3
|
||||
{
|
||||
@ -99,5 +113,19 @@ Warrior
|
||||
Precast Time = 0
|
||||
Casting Range = 0
|
||||
Casting Size = 0
|
||||
|
||||
# Speed of the sonic slash.
|
||||
BulletSpd = 400
|
||||
|
||||
Radius = 30
|
||||
DamageMult = 8
|
||||
Lifetime = 2.25
|
||||
|
||||
# Amount of seconds the player will be unable to move when using this ability.
|
||||
StuckTime = 0.5
|
||||
# How far the player gets pushed back when using this ability.
|
||||
AbilityPushback = 70
|
||||
|
||||
ShakeTime = 0.5
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user