The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
9.8 KiB
135 lines
9.8 KiB
#include "Class.h"
|
|
#include "olcPixelGameEngine.h"
|
|
#include "DEFINES.h"
|
|
#include "Player.h"
|
|
#include "Effect.h"
|
|
#include "Crawler.h"
|
|
#include "config.h"
|
|
|
|
INCLUDE_MONSTER_LIST
|
|
INCLUDE_BULLET_LIST
|
|
INCLUDE_game
|
|
|
|
void Warrior::Initialize(){
|
|
Warrior::name="Warrior"".ClassName"_S; Warrior::cl=WARRIOR; Warrior::rightClickAbility=Ability{ "Warrior"".Right Click Ability.Name"_S, "Warrior"".Right Click Ability.Cooldown"_F, "Warrior"".Right Click Ability.Mana Cost"_I, {uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Right Click Ability.Precast Time"_F,"Warrior"".Right Click Ability.Casting Range"_I/100.f*24,"Warrior"".Right Click Ability.Casting Size"_I/100.f*24}, bool("Warrior"".Right Click Ability.CancelCast"_I) }; Warrior::ability1={ "Warrior"".Ability 1.Name"_S, "Warrior"".Ability 1.Cooldown"_F, "Warrior"".Ability 1.Mana Cost"_I, {uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Ability 1.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Ability 1.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Ability 1.Precast Time"_F,"Warrior"".Ability 1.Casting Range"_I/100.f*24,"Warrior"".Ability 1.Casting Size"_I/100.f*24}, bool("Warrior"".Ability 1.CancelCast"_I) }; Warrior::ability2={ "Warrior"".Ability 2.Name"_S, "Warrior"".Ability 2.Cooldown"_F, "Warrior"".Ability 2.Mana Cost"_I, {uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Ability 2.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Ability 2.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Ability 2.Precast Time"_F,"Warrior"".Ability 2.Casting Range"_I/100.f*24,"Warrior"".Ability 2.Casting Size"_I/100.f*24} bool("Warrior"".Ability 2.CancelCast"_I) }; Warrior::ability3={ "Warrior"".Ability 3.Name"_S, "Warrior"".Ability 3.Cooldown"_F, "Warrior"".Ability 3.Mana Cost"_I, {uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Ability 3.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Ability 3.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Ability 3.Precast Time"_F,"Warrior"".Ability 3.Casting Range"_I/100.f*24,"Warrior"".Ability 3.Casting Size"_I/100.f*24}, bool("Warrior"".Ability 3.CancelCast"_I) }; Warrior::ability4={"???",0,0};
|
|
Warrior::idle_n="WARRIOR_IDLE_N";
|
|
Warrior::idle_e="WARRIOR_IDLE_E";
|
|
Warrior::idle_s="WARRIOR_IDLE_S";
|
|
Warrior::idle_w="WARRIOR_IDLE_W";
|
|
Warrior::walk_n="WARRIOR_WALK_N";
|
|
Warrior::walk_e="WARRIOR_WALK_E";
|
|
Warrior::walk_s="WARRIOR_WALK_S";
|
|
Warrior::walk_w="WARRIOR_WALK_W";
|
|
}
|
|
|
|
SETUP_CLASS(Warrior)
|
|
|
|
void Warrior::OnUpdate(float fElapsedTime){
|
|
|
|
}
|
|
|
|
bool Warrior::AutoAttack(){
|
|
if(GetState()!=State::SPIN){
|
|
bool attack=false;
|
|
Monster*closest=nullptr;
|
|
float closest_dist=999999;
|
|
for(Monster&m:MONSTER_LIST){
|
|
if(m.IsAlive()
|
|
&&geom2d::overlaps(geom2d::circle<float>(GetPos(),attack_range*GetSizeMult()*12),geom2d::circle<float>(m.GetPos(),m.GetSizeMult()*12))
|
|
&&geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length()<closest_dist){
|
|
closest_dist=geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length();
|
|
closest=&m;
|
|
}
|
|
}
|
|
if(closest!=nullptr&&closest->Hurt(GetAttack()*"Warrior.Auto Attack.DamageMult"_F,OnUpperLevel(),GetZ())){
|
|
attack_cooldown_timer=ATTACK_COOLDOWN;
|
|
swordSwingTimer="Warrior.Auto Attack.SwordSwingTime"_F;
|
|
SetState(State::SWING_SWORD);
|
|
switch(facingDirection){
|
|
case DOWN:{
|
|
UpdateAnimation("WARRIOR_SWINGSWORD_S",WARRIOR|THIEF);
|
|
}break;
|
|
case RIGHT:{
|
|
UpdateAnimation("WARRIOR_SWINGSWORD_E",WARRIOR|THIEF);
|
|
}break;
|
|
case LEFT:{
|
|
UpdateAnimation("WARRIOR_SWINGSWORD_W",WARRIOR|THIEF);
|
|
}break;
|
|
case UP:{
|
|
UpdateAnimation("WARRIOR_SWINGSWORD_N",WARRIOR|THIEF);
|
|
}break;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
void Warrior::InitializeClassAbilities(){
|
|
#pragma region Warrior Right-click Ability (Block)
|
|
Warrior::rightClickAbility.action=
|
|
[](Player*p,vf2d pos={}){
|
|
if(p->GetState()==State::NORMAL){
|
|
rightClickAbility.cooldown=rightClickAbility.COOLDOWN_TIME;
|
|
p->SetState(State::BLOCK);
|
|
p->blockTimer="Warrior.Right Click Ability.Duration"_F;
|
|
p->AddBuff(BuffType::BLOCK_SLOWDOWN,"Warrior.Right Click Ability.Duration"_F,"Warrior.Right Click Ability.SlowAmt"_F);
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
#pragma endregion
|
|
#pragma region Warrior Ability 1 (Battlecry)
|
|
Warrior::ability1.action=
|
|
[](Player*p,vf2d pos={}){
|
|
game->AddEffect(std::make_unique<Effect>(p->GetPos(),"Warrior.Ability 1.EffectLifetime"_F,"BATTLECRY_EFFECT",p->upperLevel,"Warrior.Ability 1.Range"_F/350,"Warrior.Ability 1.EffectFadetime"_F));
|
|
p->AddBuff(BuffType::ATTACK_UP,"Warrior.Ability 1.AttackUpDuration"_F,"Warrior.Ability 1.AttackIncrease"_F);
|
|
p->AddBuff(BuffType::DAMAGE_REDUCTION,"Warrior.Ability 1.DamageReductionDuration"_F,"Warrior.Ability 1.DamageReduction"_F);
|
|
for(Monster&m:MONSTER_LIST){
|
|
if(m.GetSizeMult()>="Warrior.Ability 1.AffectedSizeRange"_f[0]&&m.GetSizeMult()<="Warrior.Ability 1.AffectedSizeRange"_f[1]&&geom2d::overlaps(geom2d::circle<float>(p->GetPos(),12*"Warrior.Ability 1.Range"_I/100.f),geom2d::circle<float>(m.GetPos(),m.GetSizeMult()*12))){
|
|
m.AddBuff(BuffType::SLOWDOWN,"Warrior.Ability 1.SlowdownDuration"_F,"Warrior.Ability 1.SlowdownAmt"_F);
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
#pragma endregion
|
|
#pragma region Warrior Ability 2 (Ground Slam)
|
|
Warrior::ability2.action=
|
|
[](Player*p,vf2d pos={}){
|
|
p->Spin(GROUND_SLAM_SPIN_TIME,"Warrior.Ability 2.SpinSpd"_F*PI);
|
|
p->iframe_time="Warrior.Ability 2.IframeTime"_F;
|
|
return true;
|
|
};
|
|
#pragma endregion
|
|
#pragma region Warrior Ability 3 (Sonic Slash)
|
|
Warrior::ability3.action=
|
|
[](Player*p,vf2d pos={}){
|
|
p->SetState(State::SWING_SONIC_SWORD);
|
|
p->AddBuff(BuffType::SLOWDOWN,"Warrior.Ability 3.StuckTime"_F,1);
|
|
vf2d bulletVel={};
|
|
switch(p->GetFacingDirection()){
|
|
case UP:{
|
|
p->vel.y="Warrior.Ability 3.AbilityPushback"_F;
|
|
bulletVel.y=-"Warrior.Ability 3.BulletSpd"_F;
|
|
p->UpdateAnimation("WARRIOR_SWINGSONICSWORD_N",WARRIOR);
|
|
}break;
|
|
case LEFT:{
|
|
p->vel.x="Warrior.Ability 3.AbilityPushback"_F;
|
|
bulletVel.x=-"Warrior.Ability 3.BulletSpd"_F;
|
|
p->UpdateAnimation("WARRIOR_SWINGSONICSWORD_W",WARRIOR);
|
|
}break;
|
|
case RIGHT:{
|
|
p->vel.x=-"Warrior.Ability 3.AbilityPushback"_F;
|
|
bulletVel.x="Warrior.Ability 3.BulletSpd"_F;
|
|
p->UpdateAnimation("WARRIOR_SWINGSONICSWORD_E",WARRIOR);
|
|
}break;
|
|
case DOWN:{
|
|
p->vel.y=-"Warrior.Ability 3.AbilityPushback"_F;
|
|
bulletVel.y="Warrior.Ability 3.BulletSpd"_F;
|
|
p->UpdateAnimation("WARRIOR_SWINGSONICSWORD_S",WARRIOR);
|
|
}break;
|
|
}
|
|
BULLET_LIST.push_back(std::make_unique<Bullet>(p->GetPos(),bulletVel,"Warrior.Ability 3.Radius"_F,p->GetAttack()*"Warrior.Ability 3.DamageMult"_F,"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
|
|
} |