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.
277 lines
9.5 KiB
277 lines
9.5 KiB
|
|
#include "DEFINES.h"
|
|
#include "Crawler.h"
|
|
#include "BulletTypes.h"
|
|
|
|
INCLUDE_game
|
|
INCLUDE_MONSTER_LIST
|
|
INCLUDE_BULLET_LIST
|
|
|
|
std::map<Class,std::unique_ptr<ClassData>>CLASS_DATA;
|
|
|
|
void ClassData::InitializeClassData(){
|
|
CLASS_DATA[WARRIOR]=std::make_unique<Warrior>(Warrior("Warrior",WARRIOR,
|
|
,
|
|
,
|
|
,
|
|
,
|
|
WARRIOR_WALK_N,WARRIOR_WALK_E,WARRIOR_WALK_S,WARRIOR_WALK_W,
|
|
WARRIOR_IDLE_N,WARRIOR_IDLE_E,WARRIOR_IDLE_S,WARRIOR_IDLE_W));
|
|
CLASS_DATA[RANGER]=std::make_unique<Ranger>(Ranger("Ranger",RANGER,
|
|
{"Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE},
|
|
{"Rapid Fire",12,35},
|
|
{"Charged Shot",15,40},
|
|
{"Multishot",25,50},
|
|
RANGER_WALK_N,RANGER_WALK_E,RANGER_WALK_S,RANGER_WALK_W,
|
|
RANGER_IDLE_N,RANGER_IDLE_E,RANGER_IDLE_S,RANGER_IDLE_W));
|
|
CLASS_DATA[TRAPPER]=std::make_unique<Bard>(Bard("Bard",TRAPPER,
|
|
{"???",7,0,VERY_DARK_BLUE,DARK_BLUE},
|
|
{"???",12,0},
|
|
{"???",15,0},
|
|
{"???",25,0},
|
|
WARRIOR_WALK_N,WARRIOR_WALK_E,WARRIOR_WALK_S,WARRIOR_WALK_W,
|
|
WARRIOR_IDLE_N,WARRIOR_IDLE_E,WARRIOR_IDLE_S,WARRIOR_IDLE_W));
|
|
CLASS_DATA[WIZARD]=std::make_unique<Wizard>(Wizard("Wizard",WIZARD,
|
|
{"Teleport",8,5,VERY_DARK_BLUE,DARK_BLUE},
|
|
{"Firebolt",6,30},
|
|
{"Lightning Bolt",6,25},
|
|
{"Meteor",40,75},
|
|
WIZARD_WALK_N,WIZARD_WALK_E,WIZARD_WALK_S,WIZARD_WALK_W,
|
|
WIZARD_IDLE_N,WIZARD_IDLE_E,WIZARD_IDLE_S,WIZARD_IDLE_W));
|
|
CLASS_DATA[WITCH]=std::make_unique<Witch>(Witch("Witch",WITCH,
|
|
{"???",8,0,VERY_DARK_BLUE,DARK_BLUE},
|
|
{"???",6,0},
|
|
{"???",6,0},
|
|
{"???",40,0},
|
|
WARRIOR_WALK_N,WARRIOR_WALK_E,WARRIOR_WALK_S,WARRIOR_WALK_W,
|
|
WARRIOR_IDLE_N,WARRIOR_IDLE_E,WARRIOR_IDLE_S,WARRIOR_IDLE_W));
|
|
}
|
|
|
|
ClassData::ClassData(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
|
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w)
|
|
:name(name),cl(cl),rightClickAbility(rightClickAbility),ability1(ability1),ability2(ability2),ability3(ability3),
|
|
walk_n(walk_n),walk_e(walk_e),walk_s(walk_s),walk_w(walk_w),idle_n(idle_n),idle_w(idle_w),idle_s(idle_s),idle_e(idle_e)
|
|
{}
|
|
|
|
Warrior::Warrior(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
|
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w)
|
|
:ClassData(name,cl,rightClickAbility,ability1,ability2,ability3,
|
|
walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w)
|
|
{}
|
|
|
|
Thief::Thief(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
|
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w)
|
|
:ClassData(name,cl,rightClickAbility,ability1,ability2,ability3,
|
|
walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w)
|
|
{}
|
|
|
|
void Thief::Update(float fElapsedTime){
|
|
}
|
|
|
|
bool Thief::AutoAttack(){
|
|
return true;
|
|
}
|
|
|
|
bool Thief::Ability1(){
|
|
return true;
|
|
}
|
|
|
|
bool Thief::Ability2(){
|
|
return true;
|
|
}
|
|
|
|
bool Thief::Ability3(){
|
|
return true;
|
|
}
|
|
|
|
bool Thief::RightClickAbility(){
|
|
return true;
|
|
}
|
|
|
|
Ranger::Ranger(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
|
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w)
|
|
:ClassData(name,cl,rightClickAbility,ability1,ability2,ability3,
|
|
walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w)
|
|
{}
|
|
|
|
void Ranger::Update(float fElapsedTime){
|
|
}
|
|
|
|
bool Ranger::AutoAttack(){
|
|
return true;
|
|
}
|
|
|
|
bool Ranger::Ability1(){
|
|
return true;
|
|
}
|
|
|
|
bool Ranger::Ability2(){
|
|
return true;
|
|
}
|
|
|
|
bool Ranger::Ability3(){
|
|
return true;
|
|
}
|
|
|
|
bool Ranger::RightClickAbility(){
|
|
return true;
|
|
}
|
|
|
|
Bard::Bard(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
|
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w)
|
|
:ClassData(name,cl,rightClickAbility,ability1,ability2,ability3,
|
|
walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w)
|
|
{}
|
|
|
|
void Bard::Update(float fElapsedTime){
|
|
}
|
|
|
|
bool Bard::AutoAttack(){
|
|
return true;
|
|
}
|
|
|
|
bool Bard::Ability1(){
|
|
return true;
|
|
}
|
|
|
|
bool Bard::Ability2(){
|
|
return true;
|
|
}
|
|
|
|
bool Bard::Ability3(){
|
|
return true;
|
|
}
|
|
|
|
bool Bard::RightClickAbility(){
|
|
return true;
|
|
}
|
|
|
|
Wizard::Wizard(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
|
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w)
|
|
:ClassData(name,cl,rightClickAbility,ability1,ability2,ability3,
|
|
walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w)
|
|
{}
|
|
|
|
void Wizard::Update(float fElapsedTime){
|
|
ACCESS_PLAYER
|
|
if(p->attack_cooldown_timer>0){
|
|
CLASS_DATA[cl]->idle_n=AnimationState::WIZARD_IDLE_ATTACK_N;
|
|
CLASS_DATA[cl]->idle_e=AnimationState::WIZARD_IDLE_ATTACK_E;
|
|
CLASS_DATA[cl]->idle_s=AnimationState::WIZARD_IDLE_ATTACK_S;
|
|
CLASS_DATA[cl]->idle_w=AnimationState::WIZARD_IDLE_ATTACK_W;
|
|
CLASS_DATA[cl]->walk_n=AnimationState::WIZARD_ATTACK_N;
|
|
CLASS_DATA[cl]->walk_e=AnimationState::WIZARD_ATTACK_E;
|
|
CLASS_DATA[cl]->walk_s=AnimationState::WIZARD_ATTACK_S;
|
|
CLASS_DATA[cl]->walk_w=AnimationState::WIZARD_ATTACK_W;
|
|
} else {
|
|
CLASS_DATA[cl]->idle_n=AnimationState::WIZARD_IDLE_N;
|
|
CLASS_DATA[cl]->idle_e=AnimationState::WIZARD_IDLE_E;
|
|
CLASS_DATA[cl]->idle_s=AnimationState::WIZARD_IDLE_S;
|
|
CLASS_DATA[cl]->idle_w=AnimationState::WIZARD_IDLE_W;
|
|
CLASS_DATA[cl]->walk_n=AnimationState::WIZARD_WALK_N;
|
|
CLASS_DATA[cl]->walk_e=AnimationState::WIZARD_WALK_E;
|
|
CLASS_DATA[cl]->walk_s=AnimationState::WIZARD_WALK_S;
|
|
CLASS_DATA[cl]->walk_w=AnimationState::WIZARD_WALK_W;
|
|
}
|
|
if(p->GetState()==State::CASTING){
|
|
switch(p->GetFacingDirection()){
|
|
case UP:{
|
|
p->UpdateAnimation(AnimationState::WIZARD_CAST_N);
|
|
}break;
|
|
case DOWN:{
|
|
p->UpdateAnimation(AnimationState::WIZARD_CAST_S);
|
|
}break;
|
|
case LEFT:{
|
|
p->UpdateAnimation(AnimationState::WIZARD_CAST_W);
|
|
}break;
|
|
case RIGHT:{
|
|
p->UpdateAnimation(AnimationState::WIZARD_CAST_E);
|
|
}break;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool Wizard::AutoAttack(){
|
|
ACCESS_PLAYER
|
|
p->attack_cooldown_timer=p->MAGIC_ATTACK_COOLDOWN;
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x);
|
|
BULLET_LIST.push_back(std::make_unique<EnergyBolt>(EnergyBolt(p->GetPos(),{cos(angleToCursor)*200,sin(angleToCursor)*200},12,p->GetAttack(),p->upperLevel,true,WHITE)));
|
|
return true;
|
|
}
|
|
|
|
bool Wizard::Ability1(){
|
|
ACCESS_PLAYER
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x);
|
|
BULLET_LIST.push_back(std::make_unique<FireBolt>(FireBolt(p->GetPos(),{cos(angleToCursor)*275,sin(angleToCursor)*275},12,p->GetAttack(),p->upperLevel,true,{240,120,60})));
|
|
return true;
|
|
}
|
|
|
|
bool Wizard::Ability2(){
|
|
ACCESS_PLAYER
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x);
|
|
BULLET_LIST.push_back(std::make_unique<LightningBolt>(LightningBolt(p->GetPos(),{cos(angleToCursor)*230,sin(angleToCursor)*230},12,p->GetAttack()*4,p->upperLevel,true,WHITE)));
|
|
return true;
|
|
}
|
|
|
|
bool Wizard::Ability3(){
|
|
ACCESS_PLAYER
|
|
p->SetState(State::CASTING);
|
|
game->AddEffect(std::make_unique<Meteor>(p->GetPos(),3,AnimationState::METEOR,p->OnUpperLevel(),vf2d{1,1},2));
|
|
return true;
|
|
}
|
|
|
|
bool Wizard::RightClickAbility(){
|
|
ACCESS_PLAYER
|
|
float pointMouseDirection=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x);
|
|
vf2d pointTowardsMouse={cos(pointMouseDirection),sin(pointMouseDirection)};
|
|
float dist=std::clamp(geom2d::line<float>{p->GetPos(),game->GetWorldMousePos()}.length(),0.f,6.5f*24);
|
|
if(dist<12)return false;
|
|
vf2d teleportPoint=p->GetPos()+pointTowardsMouse*dist;
|
|
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)&&p->CanPathfindTo(p->GetPos(),teleportPoint)){
|
|
dist-=24;
|
|
teleportPoint=p->GetPos()+pointTowardsMouse*dist;
|
|
}
|
|
if(dist>0&&p->CanPathfindTo(p->GetPos(),teleportPoint)){
|
|
p->SetState(State::TELEPORT);
|
|
p->teleportAnimationTimer=0.35;
|
|
p->teleportTarget=teleportPoint;
|
|
p->teleportStartPosition=p->GetPos();
|
|
p->iframe_time=0.35;
|
|
for(int i=0;i<16;i++){
|
|
game->AddEffect(std::make_unique<Effect>(p->GetPos()+vf2d{(rand()%160-80)/10.f,(rand()%160-80)/10.f},float(rand()%300)/1000,AnimationState::DOT_PARTICLE,p->upperLevel,0.3,0.2,vf2d{float(rand()%1000-500)/100,float(rand()%1000-500)/100},BLACK));
|
|
}
|
|
return true;
|
|
} else {
|
|
p->notificationDisplay={"Cannot Teleport to that location!",0.5};
|
|
return false;
|
|
}
|
|
}
|
|
|
|
Witch::Witch(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
|
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w)
|
|
:ClassData(name,cl,rightClickAbility,ability1,ability2,ability3,
|
|
walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w)
|
|
{}
|
|
|
|
void Witch::Update(float fElapsedTime){
|
|
}
|
|
|
|
bool Witch::AutoAttack(){
|
|
return true;
|
|
}
|
|
|
|
bool Witch::Ability1(){
|
|
return true;
|
|
}
|
|
|
|
bool Witch::Ability2(){
|
|
return true;
|
|
}
|
|
|
|
bool Witch::Ability3(){
|
|
return true;
|
|
}
|
|
|
|
bool Witch::RightClickAbility(){
|
|
return true;
|
|
}
|
|
|