From dbc68b8c4be3ddc2e6a8a7cfe6f840e02114a2fe Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Fri, 15 Sep 2023 17:07:14 +0000 Subject: [PATCH] Redundant collision tile error handling. And allow a flag for abilities to cancel casts (Wizard Teleport) Co-authored-by: sigonasr2 --- Crawler/Ability.h | 1 + Crawler/Crawler.cpp | 2 +- Crawler/Player.h | 10 +++++++--- Crawler/TSXParser.h | 4 ++++ Crawler/Warrior.cpp | 2 +- Crawler/Wizard.cpp | 1 - Crawler/assets/config/classes/Ranger.txt | 11 +++++++++++ Crawler/assets/config/classes/Thief.txt | 8 ++++++++ Crawler/assets/config/classes/Trapper.txt | 8 ++++++++ Crawler/assets/config/classes/Warrior.txt | 8 ++++++++ Crawler/assets/config/classes/Witch.txt | 8 ++++++++ Crawler/assets/config/classes/Wizard.txt | 10 ++++++++++ Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx | 1 - Crawler/assets/maps/Tilesheet_No_Shadow24x24.tsx | 1 - 14 files changed, 67 insertions(+), 8 deletions(-) diff --git a/Crawler/Ability.h b/Crawler/Ability.h index 171edc1d..2839c75b 100644 --- a/Crawler/Ability.h +++ b/Crawler/Ability.h @@ -22,6 +22,7 @@ struct Ability{ float COOLDOWN_TIME=0; int manaCost=0; Pixel barColor1,barColor2; + bool canCancelCast=false; PrecastData precastInfo; std::functionaction=[](Player*,vf2d){return false;}; Ability(); diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 28b68305..d3f7a868 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -578,7 +578,7 @@ void Crawler::RenderWorld(float fElapsedTime){ playerScale.x=120*abs(pow(player->teleportAnimationTimer-0.175,3)); pos=player->teleportStartPosition.lerp(player->teleportTarget,(0.35-player->teleportAnimationTimer)/0.35); } - view.DrawPartialRotatedDecal(pos+vf2d{0,-player->GetZ()*(signbit(scale.y)?-1:1)},player->GetFrame().GetSourceImage()->Decal(),player->GetSpinAngle(),{12,12},player->GetFrame().GetSourceRect().pos,player->GetFrame().GetSourceRect().size,playerScale*scale,player->GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player->GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player->GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE); + view.DrawPartialRotatedDecal(pos+vf2d{0,-player->GetZ()*(std::signbit(scale.y)?-1:1)},player->GetFrame().GetSourceImage()->Decal(),player->GetSpinAngle(),{12,12},player->GetFrame().GetSourceRect().pos,player->GetFrame().GetSourceRect().size,playerScale*scale,player->GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player->GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player->GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE); }; enum class RenderMode{ diff --git a/Crawler/Player.h b/Crawler/Player.h index ade674df..5a3f3ea3 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -352,7 +352,8 @@ struct Witch:Player{ #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])}, \ {uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[0]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[1]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[2]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[3]==0?255:#class".Right Click Ability.Cooldown Bar Color 2"_f[3])}, \ - {#class".Right Click Ability.Precast Time"_F,#class".Right Click Ability.Casting Range"_I/100.f*24,#class".Right Click Ability.Casting Size"_I/100.f*24} \ + {#class".Right Click Ability.Precast Time"_F,#class".Right Click Ability.Casting Range"_I/100.f*24,#class".Right Click Ability.Casting Size"_I/100.f*24}, \ + bool(#class".Right Click Ability.CancelCast"_I) \ }; \ class::ability1={ \ #class".Ability 1.Name"_S, \ @@ -360,7 +361,8 @@ struct Witch:Player{ #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])}, \ {uint8_t(#class".Ability 1.Cooldown Bar Color 2"_f[0]),uint8_t(#class".Ability 1.Cooldown Bar Color 2"_f[1]),uint8_t(#class".Ability 1.Cooldown Bar Color 2"_f[2]),uint8_t(#class".Ability 1.Cooldown Bar Color 2"_f[3]==0?255:#class".Ability 1.Cooldown Bar Color 2"_f[3])}, \ - {#class".Ability 1.Precast Time"_F,#class".Ability 1.Casting Range"_I/100.f*24,#class".Ability 1.Casting Size"_I/100.f*24} \ + {#class".Ability 1.Precast Time"_F,#class".Ability 1.Casting Range"_I/100.f*24,#class".Ability 1.Casting Size"_I/100.f*24}, \ + bool(#class".Ability 1.CancelCast"_I) \ }; \ class::ability2={ \ #class".Ability 2.Name"_S, \ @@ -369,6 +371,7 @@ struct Witch:Player{ {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])}, \ {uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[0]),uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[1]),uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[2]),uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[3]==0?255:#class".Ability 2.Cooldown Bar Color 2"_f[3])}, \ {#class".Ability 2.Precast Time"_F,#class".Ability 2.Casting Range"_I/100.f*24,#class".Ability 2.Casting Size"_I/100.f*24} \ + bool(#class".Ability 2.CancelCast"_I) \ }; \ class::ability3={ \ #class".Ability 3.Name"_S, \ @@ -376,6 +379,7 @@ struct Witch:Player{ #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])}, \ {uint8_t(#class".Ability 3.Cooldown Bar Color 2"_f[0]),uint8_t(#class".Ability 3.Cooldown Bar Color 2"_f[1]),uint8_t(#class".Ability 3.Cooldown Bar Color 2"_f[2]),uint8_t(#class".Ability 3.Cooldown Bar Color 2"_f[3]==0?255:#class".Ability 3.Cooldown Bar Color 2"_f[3])}, \ - {#class".Ability 3.Precast Time"_F,#class".Ability 3.Casting Range"_I/100.f*24,#class".Ability 3.Casting Size"_I/100.f*24} \ + {#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}; \ No newline at end of file diff --git a/Crawler/TSXParser.h b/Crawler/TSXParser.h index 357f4949..d3165342 100644 --- a/Crawler/TSXParser.h +++ b/Crawler/TSXParser.h @@ -128,6 +128,10 @@ class TSXParser{ if (newTag.tag=="object"&&previousTag=="tile"){ TileCollisionData data; data.collision=geom2d::rect{{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}}; + if(parsedTilesetInfo.CollisionData.count(previousTagID)){ + std::cout<<"WARNING! There was already collision data defined for tile "<GetState()==State::CASTING)return false; 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{p->GetPos(),game->GetWorldMousePos()}.length(),0.f,"Wizard.Right Click Ability.TeleportRange"_F/100*24); diff --git a/Crawler/assets/config/classes/Ranger.txt b/Crawler/assets/config/classes/Ranger.txt index 9263e38c..96858460 100644 --- a/Crawler/assets/config/classes/Ranger.txt +++ b/Crawler/assets/config/classes/Ranger.txt @@ -7,14 +7,19 @@ Ranger DamageMult = 1 Radius = 100 Cooldown = 0.6 + # Whether or not this ability cancels casts. + CancelCast = 0 ArrowSpd = 250 + } Right Click Ability { Name = Retreat Cooldown = 7 Mana Cost = 0 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 0, 0, 64, 255 @@ -34,6 +39,8 @@ Ranger Name = Rapid Fire Cooldown = 12 Mana Cost = 35 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -62,6 +69,8 @@ Ranger Name = Charged Shot Cooldown = 15 Mana Cost = 40 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -88,6 +97,8 @@ Ranger Name = Multishot Cooldown = 25 Mana Cost = 50 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 diff --git a/Crawler/assets/config/classes/Thief.txt b/Crawler/assets/config/classes/Thief.txt index 58fdd136..8a36b51b 100644 --- a/Crawler/assets/config/classes/Thief.txt +++ b/Crawler/assets/config/classes/Thief.txt @@ -7,6 +7,8 @@ Thief Name = ??? Cooldown = 8 Mana Cost = 5 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 0, 0, 64, 255 @@ -21,6 +23,8 @@ Thief Name = ??? Cooldown = 6 Mana Cost = 30 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -35,6 +39,8 @@ Thief Name = ??? Cooldown = 6 Mana Cost = 25 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -49,6 +55,8 @@ Thief Name = ??? Cooldown = 40 Mana Cost = 75 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 diff --git a/Crawler/assets/config/classes/Trapper.txt b/Crawler/assets/config/classes/Trapper.txt index 41ec5c1b..70341563 100644 --- a/Crawler/assets/config/classes/Trapper.txt +++ b/Crawler/assets/config/classes/Trapper.txt @@ -7,6 +7,8 @@ Trapper Name = ??? Cooldown = 8 Mana Cost = 5 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 0, 0, 64, 255 @@ -21,6 +23,8 @@ Trapper Name = ??? Cooldown = 6 Mana Cost = 30 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -35,6 +39,8 @@ Trapper Name = ??? Cooldown = 6 Mana Cost = 25 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -49,6 +55,8 @@ Trapper Name = ??? Cooldown = 40 Mana Cost = 75 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 diff --git a/Crawler/assets/config/classes/Warrior.txt b/Crawler/assets/config/classes/Warrior.txt index 87dba103..fb3e4b98 100644 --- a/Crawler/assets/config/classes/Warrior.txt +++ b/Crawler/assets/config/classes/Warrior.txt @@ -7,6 +7,8 @@ Warrior DamageMult = 1 Range = 150 Cooldown = 0.35 + # Whether or not this ability cancels casts. + CancelCast = 0 SwordSwingTime = 0.2 } @@ -15,6 +17,8 @@ Warrior Name = Block Cooldown = 15 Mana Cost = 0 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 0, 0, 64, 255 @@ -37,6 +41,8 @@ Warrior Name = Battlecry Cooldown = 12 Mana Cost = 40 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -79,6 +85,8 @@ Warrior Name = Ground Slam Cooldown = 15 Mana Cost = 50 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 diff --git a/Crawler/assets/config/classes/Witch.txt b/Crawler/assets/config/classes/Witch.txt index ad08401f..efef1555 100644 --- a/Crawler/assets/config/classes/Witch.txt +++ b/Crawler/assets/config/classes/Witch.txt @@ -7,6 +7,8 @@ Witch Name = ??? Cooldown = 8 Mana Cost = 5 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 0, 0, 64, 255 @@ -21,6 +23,8 @@ Witch Name = ??? Cooldown = 6 Mana Cost = 30 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -35,6 +39,8 @@ Witch Name = ??? Cooldown = 6 Mana Cost = 25 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -49,6 +55,8 @@ Witch Name = ??? Cooldown = 40 Mana Cost = 75 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 diff --git a/Crawler/assets/config/classes/Wizard.txt b/Crawler/assets/config/classes/Wizard.txt index 2dccacfb..d71c79cb 100644 --- a/Crawler/assets/config/classes/Wizard.txt +++ b/Crawler/assets/config/classes/Wizard.txt @@ -8,6 +8,8 @@ Wizard Radius = 100 Speed = 200 Cooldown = 0.85 + # Whether or not this ability cancels casts. + CancelCast = 0 # When bullet makes contact, how fast the bullet will fade out. BulletHitFadeoutTime = 0.2 @@ -28,6 +30,8 @@ Wizard Name = Teleport Cooldown = 8 Mana Cost = 5 + # Whether or not this ability cancels casts. + CancelCast = 1 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 0, 0, 64, 255 @@ -64,6 +68,8 @@ Wizard Name = Firebolt Cooldown = 6 Mana Cost = 30 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -126,6 +132,8 @@ Wizard Name = Lightning Bolt Cooldown = 6 Mana Cost = 25 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 @@ -178,6 +186,8 @@ Wizard Name = Meteor Cooldown = 40 Mana Cost = 75 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255 diff --git a/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx b/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx index 20c7d16c..3027dac1 100644 --- a/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx +++ b/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx @@ -446,7 +446,6 @@ - diff --git a/Crawler/assets/maps/Tilesheet_No_Shadow24x24.tsx b/Crawler/assets/maps/Tilesheet_No_Shadow24x24.tsx index 2afb154b..f03bacc4 100644 --- a/Crawler/assets/maps/Tilesheet_No_Shadow24x24.tsx +++ b/Crawler/assets/maps/Tilesheet_No_Shadow24x24.tsx @@ -1986,7 +1986,6 @@ -