diff --git a/Crawler/Ability.cpp b/Crawler/Ability.cpp index a316c922..aa21e5a0 100644 --- a/Crawler/Ability.cpp +++ b/Crawler/Ability.cpp @@ -1,6 +1,8 @@ #include "Ability.h" PrecastData::PrecastData(){}; +PrecastData::PrecastData(float castTime) + :castTime(castTime),range(0),size(0){precastTargetingRequired=true;}; PrecastData::PrecastData(float castTime,float range,float size) :castTime(castTime),range(range),size(size){precastTargetingRequired=true;}; diff --git a/Crawler/Ability.h b/Crawler/Ability.h index 9c12c35d..171edc1d 100644 --- a/Crawler/Ability.h +++ b/Crawler/Ability.h @@ -10,6 +10,8 @@ struct PrecastData{ //Whether or not this ability requires precasting (automatically set to true when precast time is greater than zero) bool precastTargetingRequired=false; PrecastData(); + //Cast an ability without a targeting indicator, just starts the cast. + PrecastData(float castTime); PrecastData(float castTime,float range,float size); }; diff --git a/Crawler/Animation.cpp b/Crawler/Animation.cpp index 97ad6b15..110d8ecd 100644 --- a/Crawler/Animation.cpp +++ b/Crawler/Animation.cpp @@ -218,6 +218,8 @@ void sig::Animation::InitializeAnimations(){ ANIMATION_DATA[AnimationState(AnimationState::FIRE_RING1+i)]=firering; } CreateStillAnimation(game->GFX_Arrow,{24,24},AnimationState::ARROW); + CreateStillAnimation(game->GFX_ChargedArrow,{48,48},AnimationState::CHARGED_ARROW); + CreateStillAnimation(game->GFX_Laser,{5,1},AnimationState::LASER); } void sig::Animation::SetupPlayerAnimations(){ diff --git a/Crawler/Animation.h b/Crawler/Animation.h index 29895d95..a5d2643d 100644 --- a/Crawler/Animation.h +++ b/Crawler/Animation.h @@ -24,6 +24,7 @@ enum AnimationState{ WIZARD_CAST_S,WIZARD_CAST_N,WIZARD_CAST_E,WIZARD_CAST_W,METEOR, FIRE_RING1,FIRE_RING2,FIRE_RING3,FIRE_RING4,FIRE_RING5,ARROW, RANGER_SHOOT_S,RANGER_SHOOT_N,RANGER_SHOOT_E,RANGER_SHOOT_W, + LASER,CHARGED_ARROW }; namespace sig{ diff --git a/Crawler/BulletTypes.h b/Crawler/BulletTypes.h index f8443c46..2180f07d 100644 --- a/Crawler/BulletTypes.h +++ b/Crawler/BulletTypes.h @@ -34,4 +34,12 @@ struct Arrow:public Bullet{ void Update(float fElapsedTime)override; bool PlayerHit(Player*player)override; bool MonsterHit(Monster&monster)override; +}; + +struct ChargedArrow:public Bullet{ + vf2d lastLaserPos; + ChargedArrow(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE); + void Update(float fElapsedTime)override; + bool PlayerHit(Player*player)override; + bool MonsterHit(Monster&monster)override; }; \ No newline at end of file diff --git a/Crawler/ChargedArrow.cpp b/Crawler/ChargedArrow.cpp new file mode 100644 index 00000000..1510fc69 --- /dev/null +++ b/Crawler/ChargedArrow.cpp @@ -0,0 +1,33 @@ +#include "BulletTypes.h" +#include "Effect.h" +#include "Crawler.h" +#include "DEFINES.h" +#include "utils.h" +#include "olcUTIL_Geometry2D.h" + +INCLUDE_game + +ChargedArrow::ChargedArrow(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col) + :lastLaserPos(pos), + Bullet(pos,vel,radius,damage, + AnimationState::CHARGED_ARROW,upperLevel,true,INFINITE,true,friendly,col){} + +void ChargedArrow::Update(float fElapsedTime){ + geom2d::line lineToCurrentPos(geom2d::line(lastLaserPos,pos)); + float dist=lineToCurrentPos.length(); + if(dist>=1){ + vf2d midpoint(lineToCurrentPos.rpoint(0.5)); + game->AddEffect(std::make_unique(midpoint,0.1,AnimationState::LASER,upperLevel,vf2d{1,dist},0.3,vf2d{},Pixel{192,128,238},atan2(pos.y-lastLaserPos.y,pos.x-lastLaserPos.x)+PI/2,0,true)); + lastLaserPos=pos; + } +} + +bool ChargedArrow::PlayerHit(Player*player) +{ + return false; +} + +bool ChargedArrow::MonsterHit(Monster& monster) +{ + return false; +} \ No newline at end of file diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 9b12905d..87f3eaa4 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -80,6 +80,8 @@ bool Crawler::OnUserCreate(){ GFX_LightningSplash.Load("assets/lightning_splash_effect.png"); GFX_Meteor.Load("assets/meteor.png"); GFX_Arrow.Load("assets/arrow.png"); + GFX_Laser.Load("assets/laser.png"); + GFX_ChargedArrow.Load("assets/charged_shot_arrow.png"); //Animations sig::Animation::InitializeAnimations(); diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 45397d91..cb1bdd10 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -27,7 +27,8 @@ class Crawler : public olc::PixelGameEngine GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash,GFX_EnergyParticle, GFX_Splash_Effect,GFX_LightningBolt,GFX_LightningBoltParticle1, GFX_LightningBoltParticle2,GFX_LightningBoltParticle3,GFX_LightningBoltParticle4, - GFX_ChainLightning,GFX_LightningSplash,GFX_Meteor,GFX_Arrow; + GFX_ChainLightning,GFX_LightningSplash,GFX_Meteor,GFX_Arrow, + GFX_Laser,GFX_ChargedArrow; public: Renderable GFX_BulletCircle,GFX_BulletCircleOutline,GFX_EnergyBolt,GFX_Circle; Pathfinding pathfinder; diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 7352a8a7..e96b2f8e 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -205,6 +205,7 @@ + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index 0d282523..460f1d66 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -194,6 +194,9 @@ Source Files\Bullet Types + + Source Files\Bullet Types + diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index ee002877..c5831aa5 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -590,7 +590,11 @@ bool Player::CanPathfindTo(vf2d pos,vf2d targetPos,float range){ void Player::PrepareCast(Ability&ability){ castPrepAbility=&ability; - SetState(State::PREP_CAST); + if(ability.precastInfo.range>0){ + SetState(State::PREP_CAST); + }else{ + CastSpell(ability); + } } void Player::SetVelocity(vf2d vel){ diff --git a/Crawler/Ranger.cpp b/Crawler/Ranger.cpp index 964d8f6a..431bf9a3 100644 --- a/Crawler/Ranger.cpp +++ b/Crawler/Ranger.cpp @@ -5,6 +5,7 @@ #include "Effect.h" #include "Crawler.h" #include "BulletTypes.h" +#include "utils.h" INCLUDE_MONSTER_LIST INCLUDE_BULLET_LIST @@ -14,7 +15,7 @@ std::string Ranger::name="Ranger"; Class Ranger::cl=RANGER; Ability Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE); Ability Ranger::ability1=Ability("Rapid Fire",12,35); -Ability Ranger::ability2=Ability("Charged Shot",15,40); +Ability Ranger::ability2=Ability("Charged Shot",15,40,VERY_DARK_RED,DARK_RED,PrecastData(0.3)); Ability Ranger::ability3=Ability("Multishot",25,50); Ability Ranger::ability4=Ability("???",0,0); AnimationState Ranger::idle_n=RANGER_IDLE_N; @@ -72,7 +73,9 @@ void Ranger::InitializeClassAbilities(){ #pragma region Ranger Ability 2 (???) Ranger::ability2.action= [](Player*p,vf2d pos={}){ - return false; + vf2d arrowVelocity=util::pointTo(p->GetPos(),game->GetWorldMousePos()); + BULLET_LIST.push_back(std::make_unique(p->GetPos(),arrowVelocity*600,20,p->GetAttack()*2.5,p->OnUpperLevel(),true)); + return true; }; #pragma endregion #pragma region Ranger Ability 3 (???) diff --git a/Crawler/Version.h b/Crawler/Version.h index 943ace7d..4f806844 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 836 +#define VERSION_BUILD 846 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/charged_shot_arrow.png b/Crawler/assets/charged_shot_arrow.png new file mode 100644 index 00000000..cca7f15f Binary files /dev/null and b/Crawler/assets/charged_shot_arrow.png differ diff --git a/Crawler/assets/laser.png b/Crawler/assets/laser.png new file mode 100644 index 00000000..0f6f9c83 Binary files /dev/null and b/Crawler/assets/laser.png differ diff --git a/Crawler/utils.cpp b/Crawler/utils.cpp index a50d1179..f8a4bab6 100644 --- a/Crawler/utils.cpp +++ b/Crawler/utils.cpp @@ -2,4 +2,8 @@ float util::random(float range){ return float(rand())/RAND_MAX*range; +} + +vf2d util::pointTo(vf2d posFrom,vf2d posTo){ + return geom2d::line(posFrom,posTo).vector().norm(); } \ No newline at end of file diff --git a/Crawler/utils.h b/Crawler/utils.h index 72b68257..e694e790 100644 --- a/Crawler/utils.h +++ b/Crawler/utils.h @@ -1,6 +1,9 @@ #pragma once #include +#include "olcUTIL_Geometry2D.h" namespace util{ //Returns 0-range (as a float). float random(float range); + //Returns a normalized vector pointing from posFrom towards posTo. + vf2d pointTo(vf2d posFrom,vf2d posTo); } \ No newline at end of file