Add in Charged Shot ability and allow precasting without the targeting indicator.
This commit is contained in:
parent
918fc112bd
commit
045441b595
@ -1,6 +1,8 @@
|
|||||||
#include "Ability.h"
|
#include "Ability.h"
|
||||||
|
|
||||||
PrecastData::PrecastData(){};
|
PrecastData::PrecastData(){};
|
||||||
|
PrecastData::PrecastData(float castTime)
|
||||||
|
:castTime(castTime),range(0),size(0){precastTargetingRequired=true;};
|
||||||
PrecastData::PrecastData(float castTime,float range,float size)
|
PrecastData::PrecastData(float castTime,float range,float size)
|
||||||
:castTime(castTime),range(range),size(size){precastTargetingRequired=true;};
|
:castTime(castTime),range(range),size(size){precastTargetingRequired=true;};
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ struct PrecastData{
|
|||||||
//Whether or not this ability requires precasting (automatically set to true when precast time is greater than zero)
|
//Whether or not this ability requires precasting (automatically set to true when precast time is greater than zero)
|
||||||
bool precastTargetingRequired=false;
|
bool precastTargetingRequired=false;
|
||||||
PrecastData();
|
PrecastData();
|
||||||
|
//Cast an ability without a targeting indicator, just starts the cast.
|
||||||
|
PrecastData(float castTime);
|
||||||
PrecastData(float castTime,float range,float size);
|
PrecastData(float castTime,float range,float size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,6 +218,8 @@ void sig::Animation::InitializeAnimations(){
|
|||||||
ANIMATION_DATA[AnimationState(AnimationState::FIRE_RING1+i)]=firering;
|
ANIMATION_DATA[AnimationState(AnimationState::FIRE_RING1+i)]=firering;
|
||||||
}
|
}
|
||||||
CreateStillAnimation(game->GFX_Arrow,{24,24},AnimationState::ARROW);
|
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(){
|
void sig::Animation::SetupPlayerAnimations(){
|
||||||
|
@ -24,6 +24,7 @@ enum AnimationState{
|
|||||||
WIZARD_CAST_S,WIZARD_CAST_N,WIZARD_CAST_E,WIZARD_CAST_W,METEOR,
|
WIZARD_CAST_S,WIZARD_CAST_N,WIZARD_CAST_E,WIZARD_CAST_W,METEOR,
|
||||||
FIRE_RING1,FIRE_RING2,FIRE_RING3,FIRE_RING4,FIRE_RING5,ARROW,
|
FIRE_RING1,FIRE_RING2,FIRE_RING3,FIRE_RING4,FIRE_RING5,ARROW,
|
||||||
RANGER_SHOOT_S,RANGER_SHOOT_N,RANGER_SHOOT_E,RANGER_SHOOT_W,
|
RANGER_SHOOT_S,RANGER_SHOOT_N,RANGER_SHOOT_E,RANGER_SHOOT_W,
|
||||||
|
LASER,CHARGED_ARROW
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace sig{
|
namespace sig{
|
||||||
|
@ -34,4 +34,12 @@ struct Arrow:public Bullet{
|
|||||||
void Update(float fElapsedTime)override;
|
void Update(float fElapsedTime)override;
|
||||||
bool PlayerHit(Player*player)override;
|
bool PlayerHit(Player*player)override;
|
||||||
bool MonsterHit(Monster&monster)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;
|
||||||
};
|
};
|
33
Crawler/ChargedArrow.cpp
Normal file
33
Crawler/ChargedArrow.cpp
Normal file
@ -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<Effect>(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;
|
||||||
|
}
|
@ -80,6 +80,8 @@ bool Crawler::OnUserCreate(){
|
|||||||
GFX_LightningSplash.Load("assets/lightning_splash_effect.png");
|
GFX_LightningSplash.Load("assets/lightning_splash_effect.png");
|
||||||
GFX_Meteor.Load("assets/meteor.png");
|
GFX_Meteor.Load("assets/meteor.png");
|
||||||
GFX_Arrow.Load("assets/arrow.png");
|
GFX_Arrow.Load("assets/arrow.png");
|
||||||
|
GFX_Laser.Load("assets/laser.png");
|
||||||
|
GFX_ChargedArrow.Load("assets/charged_shot_arrow.png");
|
||||||
|
|
||||||
//Animations
|
//Animations
|
||||||
sig::Animation::InitializeAnimations();
|
sig::Animation::InitializeAnimations();
|
||||||
|
@ -27,7 +27,8 @@ class Crawler : public olc::PixelGameEngine
|
|||||||
GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash,GFX_EnergyParticle,
|
GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash,GFX_EnergyParticle,
|
||||||
GFX_Splash_Effect,GFX_LightningBolt,GFX_LightningBoltParticle1,
|
GFX_Splash_Effect,GFX_LightningBolt,GFX_LightningBoltParticle1,
|
||||||
GFX_LightningBoltParticle2,GFX_LightningBoltParticle3,GFX_LightningBoltParticle4,
|
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:
|
public:
|
||||||
Renderable GFX_BulletCircle,GFX_BulletCircleOutline,GFX_EnergyBolt,GFX_Circle;
|
Renderable GFX_BulletCircle,GFX_BulletCircleOutline,GFX_EnergyBolt,GFX_Circle;
|
||||||
Pathfinding pathfinder;
|
Pathfinding pathfinder;
|
||||||
|
@ -205,6 +205,7 @@
|
|||||||
<ClCompile Include="Animation.cpp" />
|
<ClCompile Include="Animation.cpp" />
|
||||||
<ClCompile Include="Arrow.cpp" />
|
<ClCompile Include="Arrow.cpp" />
|
||||||
<ClCompile Include="Bullet.cpp" />
|
<ClCompile Include="Bullet.cpp" />
|
||||||
|
<ClCompile Include="ChargedArrow.cpp" />
|
||||||
<ClCompile Include="Crawler.cpp" />
|
<ClCompile Include="Crawler.cpp" />
|
||||||
<ClCompile Include="DamageNumber.cpp" />
|
<ClCompile Include="DamageNumber.cpp" />
|
||||||
<ClCompile Include="Effect.cpp" />
|
<ClCompile Include="Effect.cpp" />
|
||||||
|
@ -194,6 +194,9 @@
|
|||||||
<ClCompile Include="Arrow.cpp">
|
<ClCompile Include="Arrow.cpp">
|
||||||
<Filter>Source Files\Bullet Types</Filter>
|
<Filter>Source Files\Bullet Types</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="ChargedArrow.cpp">
|
||||||
|
<Filter>Source Files\Bullet Types</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="cpp.hint" />
|
<None Include="cpp.hint" />
|
||||||
|
@ -590,7 +590,11 @@ bool Player::CanPathfindTo(vf2d pos,vf2d targetPos,float range){
|
|||||||
|
|
||||||
void Player::PrepareCast(Ability&ability){
|
void Player::PrepareCast(Ability&ability){
|
||||||
castPrepAbility=&ability;
|
castPrepAbility=&ability;
|
||||||
SetState(State::PREP_CAST);
|
if(ability.precastInfo.range>0){
|
||||||
|
SetState(State::PREP_CAST);
|
||||||
|
}else{
|
||||||
|
CastSpell(ability);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetVelocity(vf2d vel){
|
void Player::SetVelocity(vf2d vel){
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
#include "Crawler.h"
|
#include "Crawler.h"
|
||||||
#include "BulletTypes.h"
|
#include "BulletTypes.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
INCLUDE_MONSTER_LIST
|
INCLUDE_MONSTER_LIST
|
||||||
INCLUDE_BULLET_LIST
|
INCLUDE_BULLET_LIST
|
||||||
@ -14,7 +15,7 @@ std::string Ranger::name="Ranger";
|
|||||||
Class Ranger::cl=RANGER;
|
Class Ranger::cl=RANGER;
|
||||||
Ability Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE);
|
Ability Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE);
|
||||||
Ability Ranger::ability1=Ability("Rapid Fire",12,35);
|
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::ability3=Ability("Multishot",25,50);
|
||||||
Ability Ranger::ability4=Ability("???",0,0);
|
Ability Ranger::ability4=Ability("???",0,0);
|
||||||
AnimationState Ranger::idle_n=RANGER_IDLE_N;
|
AnimationState Ranger::idle_n=RANGER_IDLE_N;
|
||||||
@ -72,7 +73,9 @@ void Ranger::InitializeClassAbilities(){
|
|||||||
#pragma region Ranger Ability 2 (???)
|
#pragma region Ranger Ability 2 (???)
|
||||||
Ranger::ability2.action=
|
Ranger::ability2.action=
|
||||||
[](Player*p,vf2d pos={}){
|
[](Player*p,vf2d pos={}){
|
||||||
return false;
|
vf2d arrowVelocity=util::pointTo(p->GetPos(),game->GetWorldMousePos());
|
||||||
|
BULLET_LIST.push_back(std::make_unique<ChargedArrow>(p->GetPos(),arrowVelocity*600,20,p->GetAttack()*2.5,p->OnUpperLevel(),true));
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma region Ranger Ability 3 (???)
|
#pragma region Ranger Ability 3 (???)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 836
|
#define VERSION_BUILD 846
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
BIN
Crawler/assets/charged_shot_arrow.png
Normal file
BIN
Crawler/assets/charged_shot_arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
BIN
Crawler/assets/laser.png
Normal file
BIN
Crawler/assets/laser.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 582 B |
@ -2,4 +2,8 @@
|
|||||||
|
|
||||||
float util::random(float range){
|
float util::random(float range){
|
||||||
return float(rand())/RAND_MAX*range;
|
return float(rand())/RAND_MAX*range;
|
||||||
|
}
|
||||||
|
|
||||||
|
vf2d util::pointTo(vf2d posFrom,vf2d posTo){
|
||||||
|
return geom2d::line(posFrom,posTo).vector().norm();
|
||||||
}
|
}
|
@ -1,6 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "olcUTIL_Geometry2D.h"
|
||||||
namespace util{
|
namespace util{
|
||||||
//Returns 0-range (as a float).
|
//Returns 0-range (as a float).
|
||||||
float random(float range);
|
float random(float range);
|
||||||
|
//Returns a normalized vector pointing from posFrom towards posTo.
|
||||||
|
vf2d pointTo(vf2d posFrom,vf2d posTo);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user