Mana costs and ability short names are now displayed on the HUD.

pull/28/head
sigonasr2 1 year ago
parent b80d791578
commit 388cf0ba2d
  1. 4
      Crawler/Ability.cpp
  2. 3
      Crawler/Ability.h
  3. 87
      Crawler/Crawler.cpp
  4. 1
      Crawler/Crawler.h
  5. 10
      Crawler/DEFINES.h
  6. 2
      Crawler/Player.cpp
  7. 6
      Crawler/Player.h
  8. 2
      Crawler/Version.h
  9. 4
      Crawler/assets/config/classes/Ranger.txt
  10. 4
      Crawler/assets/config/classes/Thief.txt
  11. 4
      Crawler/assets/config/classes/Trapper.txt
  12. 4
      Crawler/assets/config/classes/Warrior.txt
  13. 4
      Crawler/assets/config/classes/Witch.txt
  14. 4
      Crawler/assets/config/classes/Wizard.txt
  15. 1
      Crawler/assets/config/gfx/gfx.txt
  16. BIN
      Crawler/assets/skill_overlay_icon_overlay.png

@ -10,5 +10,5 @@ PrecastData::PrecastData(float castTime,float range,float size)
};
Ability::Ability(){};
Ability::Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1,Pixel barColor2,PrecastData precastInfo,bool canCancelCast)
:name(name),cooldown(0),COOLDOWN_TIME(cooldownTime),manaCost(manaCost),barColor1(barColor1),barColor2(barColor2),precastInfo(precastInfo),canCancelCast(canCancelCast){}
Ability::Ability(std::string name,std::string shortName,float cooldownTime,int manaCost,Pixel barColor1,Pixel barColor2,PrecastData precastInfo,bool canCancelCast)
:name(name),shortName(shortName),cooldown(0),COOLDOWN_TIME(cooldownTime),manaCost(manaCost),barColor1(barColor1),barColor2(barColor2),precastInfo(precastInfo),canCancelCast(canCancelCast){}

@ -18,6 +18,7 @@ struct PrecastData{
//Abilities are tied to class data which is defined in Class.cpp.
struct Ability{
std::string name="";
std::string shortName="";
float cooldown=0;
float COOLDOWN_TIME=0;
int manaCost=0;
@ -26,5 +27,5 @@ struct Ability{
bool canCancelCast=false;
std::function<bool(Player*,vf2d)>action=[](Player*,vf2d){return false;};
Ability();
Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={},bool canCancelCast=false);
Ability(std::string name,std::string shortName,float cooldownTime,int manaCost,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={},bool canCancelCast=false);
};

@ -993,42 +993,7 @@ Player*Crawler::GetPlayer(){
}
void Crawler::RenderHud(){
const std::function<std::string(std::string)>capitalize=[](std::string name)->std::string{
std::string newName="";
for(int i=0;i<name.length();i++){
newName.append(1,name[i]>='a'?name[i]-32:name[i]);
newName.append(1,' ');
}
return newName;
};
std::vector<Ability>cooldowns{
player->GetAbility1(),
player->GetAbility2(),
player->GetAbility3(),
player->GetAbility4(),
};
const auto DrawCooldown=[&](vf2d pos,Ability&a){
if(a.name!="???"){
if(a.cooldown>0.1){
DrawPie(pos+vf2d{12,12},12,360-(a.cooldown/a.COOLDOWN_TIME)*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.COOLDOWN_TIME)));
std::stringstream cooldownTimeDisplay;
cooldownTimeDisplay<<std::fixed<<std::setprecision(1)<<a.cooldown;
DrawShadowStringPropDecal(pos+vf2d{12,12}-vf2d{float(GetTextSizeProp(cooldownTimeDisplay.str()).x*0.5),float(GetTextSizeProp(cooldownTimeDisplay.str()).y*1)}/2,cooldownTimeDisplay.str(),WHITE,BLACK,{0.5,1});
}
DrawDecal(pos,GFX["skill_overlay_icon.png"].Decal());
}
};
vf2d iconPos={8.f,float(ScreenHeight()-32)};
for(Ability&a:cooldowns){
if(a.name!="???"){
DrawCooldown(iconPos,a);
iconPos+={32,0};
}
}
DrawCooldown({float(ScreenWidth()-32),float(ScreenHeight()-32)},player->GetRightClickAbility());
RenderCooldowns();
if(GetPlayer()->GetCastInfo().castTimer>0){
FillRectDecal(vf2d{ScreenWidth()/2-92.f,ScreenHeight()-90.f},{184,20},BLACK);
@ -1065,6 +1030,56 @@ void Crawler::RenderHud(){
}
}
void Crawler::RenderCooldowns(){
std::vector<Ability>cooldowns{
player->GetAbility1(),
player->GetAbility2(),
player->GetAbility3(),
player->GetAbility4(),
};
const auto DrawCooldown=[&](vf2d pos,Ability&a){
if(a.name!="???"){
if(a.cooldown>0.1){
DrawPie(pos+vf2d{12,12},12,360-(a.cooldown/a.COOLDOWN_TIME)*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.COOLDOWN_TIME)));
std::stringstream cooldownTimeDisplay;
cooldownTimeDisplay<<std::fixed<<std::setprecision(1)<<a.cooldown;
DrawShadowStringPropDecal(pos+vf2d{12,12}-vf2d{float(GetTextSizeProp(cooldownTimeDisplay.str()).x*0.5),float(GetTextSizeProp(cooldownTimeDisplay.str()).y*1)}/2,cooldownTimeDisplay.str(),WHITE,BLACK,{0.5,1});
}
DrawDecal(pos,GFX["skill_overlay_icon.png"].Decal());
Pixel shortNameCol=BLUE,manaCostShadowCol=DARK_BLUE;
if(player->GetMana()<a.manaCost){
DrawDecal(pos,GFX["skill_overlay_icon_overlay.png"].Decal(),{1,1},DARK_RED);
shortNameCol=RED;
manaCostShadowCol=DARK_RED;
}else
if(a.cooldown>0){
shortNameCol=GREY;
manaCostShadowCol=DARK_GREY;
}
if(a.manaCost>0){
vf2d manaCostSize=vf2d{GetTextSize(std::to_string(a.manaCost))}*vf2d{0.5,0.75};
DrawShadowStringDecal(pos+vf2d{20,4}-manaCostSize/2,std::to_string(a.manaCost),{192,192,255},manaCostShadowCol,{0.5,0.75});
}
vf2d shortNameSize=vf2d{GetTextSize(a.shortName)}*vf2d{0.5,0.75};
DrawShadowStringDecal(pos+vf2d{13,24}-shortNameSize/2,a.shortName,shortNameCol,{255,255,255,64},{0.5,0.75});
}
};
vf2d iconPos={8.f,float(ScreenHeight()-32)};
for(Ability&a:cooldowns){
if(a.name!="???"){
DrawCooldown(iconPos,a);
iconPos+={32,0};
}
}
DrawCooldown({float(ScreenWidth()-32),float(ScreenHeight()-32)},player->GetRightClickAbility());
}
void Crawler::AddEffect(std::unique_ptr<Effect>foreground,std::unique_ptr<Effect> background){
AddEffect(std::move(background),true);
AddEffect(std::move(foreground));

@ -113,6 +113,7 @@ public:
bool IsReflectiveTile(TilesheetData tileSheet,int tileID);
void SpawnMonster(vf2d pos,MonsterData*data,bool upperLevel=false); //Queues a monster for spawning on the next frame.
void DrawPie(vf2d center,float radius,float degreesCut,Pixel col);
void RenderCooldowns();
struct TileGroupData{
vi2d tilePos;

@ -42,11 +42,11 @@ std::string&class::GetIdleSAnimation(){return idle_s;}; \
std::string&class::GetIdleWAnimation(){return idle_w;}; \
std::string class::name=""; \
Class class::cl=ANY; \
Ability class::rightClickAbility=Ability("",0,0); \
Ability class::ability1=Ability("",0,0); \
Ability class::ability2=Ability("",0,0); \
Ability class::ability3=Ability("",0,0); \
Ability class::ability4=Ability("",0,0); \
Ability class::rightClickAbility=Ability("???","???",0,0); \
Ability class::ability1=Ability("???","???",0,0); \
Ability class::ability2=Ability("???","???",0,0); \
Ability class::ability3=Ability("???","???",0,0); \
Ability class::ability4=Ability("???","???",0,0); \
std::string class::idle_n="WARRIOR_IDLE_N"; \
std::string class::idle_e="WARRIOR_IDLE_E"; \
std::string class::idle_s="WARRIOR_IDLE_S"; \

@ -492,7 +492,7 @@ bool Player::CanMove(){
}
bool Player::CanAct(){
Ability dummyAbility{"Dummy Ability",0,0};
Ability dummyAbility{"Dummy Ability","DUMMY",0,0};
return CanAct(dummyAbility);
}

@ -350,6 +350,7 @@ struct Witch:Player{
class::cl=enum; \
class::rightClickAbility={ \
#class".Right Click Ability.Name"_S, \
#class".Right Click Ability.Short Name"_S, \
#class".Right Click Ability.Cooldown"_F, \
#class".Right Click Ability.Mana Cost"_I, \
{uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[0]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[1]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[2]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[3]==0?255:#class".Right Click Ability.Cooldown Bar Color 1"_f[3])}, \
@ -359,6 +360,7 @@ struct Witch:Player{
}; \
class::ability1={ \
#class".Ability 1.Name"_S, \
#class".Ability 1.Short Name"_S, \
#class".Ability 1.Cooldown"_F, \
#class".Ability 1.Mana Cost"_I, \
{uint8_t(#class".Ability 1.Cooldown Bar Color 1"_f[0]),uint8_t(#class".Ability 1.Cooldown Bar Color 1"_f[1]),uint8_t(#class".Ability 1.Cooldown Bar Color 1"_f[2]),uint8_t(#class".Ability 1.Cooldown Bar Color 1"_f[3]==0?255:#class".Ability 1.Cooldown Bar Color 1"_f[3])}, \
@ -368,6 +370,7 @@ struct Witch:Player{
}; \
class::ability2={ \
#class".Ability 2.Name"_S, \
#class".Ability 2.Short Name"_S, \
#class".Ability 2.Cooldown"_F, \
#class".Ability 2.Mana Cost"_I, \
{uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[0]),uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[1]),uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[2]),uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[3]==0?255:#class".Ability 2.Cooldown Bar Color 1"_f[3])}, \
@ -377,6 +380,7 @@ struct Witch:Player{
}; \
class::ability3={ \
#class".Ability 3.Name"_S, \
#class".Ability 3.Short Name"_S, \
#class".Ability 3.Cooldown"_F, \
#class".Ability 3.Mana Cost"_I, \
{uint8_t(#class".Ability 3.Cooldown Bar Color 1"_f[0]),uint8_t(#class".Ability 3.Cooldown Bar Color 1"_f[1]),uint8_t(#class".Ability 3.Cooldown Bar Color 1"_f[2]),uint8_t(#class".Ability 3.Cooldown Bar Color 1"_f[3]==0?255:#class".Ability 3.Cooldown Bar Color 1"_f[3])}, \
@ -384,4 +388,4 @@ struct Witch:Player{
{#class".Ability 3.Precast Time"_F,#class".Ability 3.Casting Range"_I/100.f*24,#class".Ability 3.Casting Size"_I/100.f*24}, \
bool(#class".Ability 3.CancelCast"_I) \
}; \
class::ability4={"???",0,0};
class::ability4={"???","",0,0};

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 1509
#define VERSION_BUILD 1529
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -16,6 +16,7 @@ Ranger
Right Click Ability
{
Name = Retreat
Short Name = B.STEP
Cooldown = 7
Mana Cost = 0
# Whether or not this ability cancels casts.
@ -37,6 +38,7 @@ Ranger
Ability 1
{
Name = Rapid Fire
Short Name = RAPID
Cooldown = 12
Mana Cost = 35
# Whether or not this ability cancels casts.
@ -67,6 +69,7 @@ Ranger
Ability 2
{
Name = Charged Shot
Short Name = CHRG.S
Cooldown = 15
Mana Cost = 40
# Whether or not this ability cancels casts.
@ -95,6 +98,7 @@ Ranger
Ability 3
{
Name = Multishot
Short Name = MULTI
Cooldown = 25
Mana Cost = 50
# Whether or not this ability cancels casts.

@ -5,6 +5,7 @@ Thief
Right Click Ability
{
Name = ???
Short Name = ???
Cooldown = 8
Mana Cost = 5
# Whether or not this ability cancels casts.
@ -21,6 +22,7 @@ Thief
Ability 1
{
Name = ???
Short Name = ???
Cooldown = 6
Mana Cost = 30
# Whether or not this ability cancels casts.
@ -37,6 +39,7 @@ Thief
Ability 2
{
Name = ???
Short Name = ???
Cooldown = 6
Mana Cost = 25
# Whether or not this ability cancels casts.
@ -53,6 +56,7 @@ Thief
Ability 3
{
Name = ???
Short Name = ???
Cooldown = 40
Mana Cost = 75
# Whether or not this ability cancels casts.

@ -5,6 +5,7 @@ Trapper
Right Click Ability
{
Name = ???
Short Name = ???
Cooldown = 8
Mana Cost = 5
# Whether or not this ability cancels casts.
@ -21,6 +22,7 @@ Trapper
Ability 1
{
Name = ???
Short Name = ???
Cooldown = 6
Mana Cost = 30
# Whether or not this ability cancels casts.
@ -37,6 +39,7 @@ Trapper
Ability 2
{
Name = ???
Short Name = ???
Cooldown = 6
Mana Cost = 25
# Whether or not this ability cancels casts.
@ -53,6 +56,7 @@ Trapper
Ability 3
{
Name = ???
Short Name = ???
Cooldown = 40
Mana Cost = 75
# Whether or not this ability cancels casts.

@ -15,6 +15,7 @@ Warrior
Right Click Ability
{
Name = Block
Short Name = BLOCK
Cooldown = 15
Mana Cost = 0
# Whether or not this ability cancels casts.
@ -39,6 +40,7 @@ Warrior
Ability 1
{
Name = Battlecry
Short Name = B.CRY
Cooldown = 12
Mana Cost = 40
# Whether or not this ability cancels casts.
@ -83,6 +85,7 @@ Warrior
Ability 2
{
Name = Ground Slam
Short Name = SLAM
Cooldown = 15
Mana Cost = 50
# Whether or not this ability cancels casts.
@ -113,6 +116,7 @@ Warrior
Ability 3
{
Name = Sonic Slash
Short Name = S.SLASH
Cooldown = 40
Mana Cost = 60
# Whether or not this ability cancels casts.

@ -5,6 +5,7 @@ Witch
Right Click Ability
{
Name = ???
Short Name = ???
Cooldown = 8
Mana Cost = 5
# Whether or not this ability cancels casts.
@ -21,6 +22,7 @@ Witch
Ability 1
{
Name = ???
Short Name = ???
Cooldown = 6
Mana Cost = 30
# Whether or not this ability cancels casts.
@ -37,6 +39,7 @@ Witch
Ability 2
{
Name = ???
Short Name = ???
Cooldown = 6
Mana Cost = 25
# Whether or not this ability cancels casts.
@ -53,6 +56,7 @@ Witch
Ability 3
{
Name = ???
Short Name = ???
Cooldown = 40
Mana Cost = 75
# Whether or not this ability cancels casts.

@ -28,6 +28,7 @@ Wizard
Right Click Ability
{
Name = Teleport
Short Name = TELE
Cooldown = 8
Mana Cost = 5
# Whether or not this ability cancels casts.
@ -66,6 +67,7 @@ Wizard
Ability 1
{
Name = Firebolt
Short Name = F.BOLT
Cooldown = 6
Mana Cost = 30
# Whether or not this ability cancels casts.
@ -130,6 +132,7 @@ Wizard
Ability 2
{
Name = Lightning Bolt
Short Name = L.BOLT
Cooldown = 6
Mana Cost = 25
# Whether or not this ability cancels casts.
@ -184,6 +187,7 @@ Wizard
Ability 3
{
Name = Meteor
Short Name = METEOR
Cooldown = 40
Mana Cost = 75
# Whether or not this ability cancels casts.

@ -37,4 +37,5 @@ Images
GFX_Wizard_Sheet = nico-wizard.png
GFX_SlimeKing_Cast = monsters/Slime King - Cast.png
GFX_SkillOverlayIcon = skill_overlay_icon.png
GFX_SkillOverlayIconOverlay = skill_overlay_icon_overlay.png
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Loading…
Cancel
Save