Isolate Ground Slam into its own effect. Prepped effect for implementation. Release Build 13575.
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Successful in 7m55s
Emscripten Build / UnitTesting (push) Failing after 9m26s

This commit is contained in:
AMay 2026-05-05 17:27:00 -05:00
parent fdd37280f1
commit ffeab76719
17 changed files with 176 additions and 40 deletions

View File

@ -416,6 +416,9 @@
</SubType>
</ClInclude>
<ClInclude Include="Effect.h" />
<ClInclude Include="EffectData.h" />
<ClInclude Include="EffectManager.h" />
<ClInclude Include="EffectRef.h" />
<ClInclude Include="Entity.h">
<SubType>
</SubType>
@ -888,6 +891,7 @@
</SubType>
</ClCompile>
<ClCompile Include="GiantOctopus.cpp" />
<ClCompile Include="GroundSlamEffect.cpp" />
<ClCompile Include="HomingBullet.cpp">
<SubType>
</SubType>

View File

@ -741,6 +741,15 @@
<ClInclude Include="GameHelper.h">
<Filter>Header Files\Unit Testing</Filter>
</ClInclude>
<ClInclude Include="EffectRef.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EffectManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EffectData.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Player.cpp">
@ -1421,6 +1430,9 @@
<ClCompile Include="tests\PlayerTests.cpp">
<Filter>Source Files\Unit Tests</Filter>
</ClCompile>
<ClCompile Include="GroundSlamEffect.cpp">
<Filter>Source Files\Effects</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

View File

@ -350,4 +350,25 @@ public:
bool Update(float fElapsedTime)override;
private:
mutableconst float gravity;
};
class GroundSlamEffect:public Effect{
public:
struct GroundSlamSettings{
float range;
float knockbackAmt;
float knockbackReduction;
float knockbackWeightFactor;
int damage;
FriendlyType friendly;
int visualRadius;
bool hasSlamShockEnchant;
std::string soundEffectName;
};
GroundSlamEffect(vf2d pos,const float z,const float lifetime,GroundSlamSettings settings,bool upperLevel,float fadeout=0.0f,Pixel col=WHITE,bool additiveBlending=false);
bool Update(float fElapsedTime)override;
private:
mutableconst GroundSlamSettings settings;
};

View File

@ -157,4 +157,12 @@ void Entity::ForMonster(std::function<void(Monster&p)>func){
const float Entity::GetZ()const{
CallClassFunc(GetZ());
}
void Entity::Spin(float duration,float spinSpd){
CallClassFunc(Spin(duration,spinSpd));
}
void Entity::Knockback(vf2d vel){
CallClassFunc(Knockback(vel));
}

View File

@ -83,6 +83,8 @@ public:
float&GetBlockTimer()const;
Buff&AddBuff(BuffType type,float duration,float intensity);
Buff&AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr);
void Spin(float duration,float spinSpd);
void Knockback(vf2d vel);
private:
mutableconst std::variant<Monster*,Player*>entity;
inline bool operator==(const Entity&rhs){return entity==rhs.entity;}

View File

@ -0,0 +1,72 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2026 Amy Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Effect.h"
#include "AdventuresInLestoria.h"
#include "DEFINES.h"
#include "util.h"
#include"SoundEffect.h"
INCLUDE_game
GroundSlamEffect::GroundSlamEffect(vf2d pos,const float z,const float lifetime,GroundSlamSettings settings,bool upperLevel,float fadeout,Pixel col,bool additiveBlending)
:settings(settings),Effect(pos,lifetime,"ground-slam-attack-front.png",upperLevel,settings.visualRadius/64.f/2,fadeout,{},col,0.f,0.f,additiveBlending){
game->AddEffect(Effect{pos,lifetime,"ground-slam-attack-back.png",upperLevel,settings.visualRadius/64.f/2,fadeout,{},col,0.f,0.f,additiveBlending},true);
}
bool GroundSlamEffect::Update(float fElapsedTime){
#pragma region Knockback effect
for(auto&[targetPtr,wasHurt]:game->Hurt(pos,settings.range,settings.damage,OnUpperLevel(),0,settings.friendly?HurtType::MONSTER:HurtType::PLAYER,settings.friendly?HurtFlag::PLAYER_ABILITY:HurtFlag::NONE)){
Entity entity{targetPtr};
float knockbackDir=0;
float knockbackAmt=0;
if(settings.hasSlamShockEnchant)if(std::holds_alternative<Monster*>(targetPtr))std::get<Monster*>(targetPtr)->Stun("Slam Shock"_ENC["STUN DURATION"]);
if(geom2d::line<float>(pos,entity.GetPos()).length()<=0.001f){
knockbackDir=util::random(2*PI);
knockbackAmt=settings.knockbackAmt;
}else{
knockbackDir=geom2d::line<float>(pos,entity.GetPos()).vector().norm().polar().y;
knockbackAmt=std::clamp(settings.knockbackAmt-geom2d::line<float>(pos,entity.GetPos()).length()*settings.knockbackReduction,1.f,settings.knockbackAmt);
}
knockbackAmt=std::max(1.f,knockbackAmt-settings.knockbackWeightFactor*(entity.GetSizeMult()-1.f));
entity.Knockback(vf2d{knockbackAmt,knockbackDir}.cart());
}
#pragma endregion
SoundEffect::PlaySFX("Warrior Ground Slam",pos);
return Effect::Update(fElapsedTime);
}

View File

@ -1827,3 +1827,8 @@ uint8_t Monster::GetTransparency()const{
return transparency;
}
void Monster::Spin(float duration,float spinSpd){
SetPhase(GetStrategyName(),GetInt(A::SPIN_STATE_ENUM_SLOT));
GetFloat(A::SPIN_ANGLE)=0;
GetFloat(A::SPIN_ATTACK_TIMER)=Monster::STRATEGY::_GetFloat(*this,"Warrior.Ability 2.SpinTime",GetStrategyName());
}

View File

@ -366,6 +366,7 @@ public:
void CastAbility(const MonsterAbilityData&data,const vf2d pos={});
void SetTransparency(uint8_t alpha);
uint8_t GetTransparency()const;
void Spin(float duration,float spinSpd);
private:
//NOTE: Marking a monster for deletion does not trigger any death events. It just simply removes the monster from the field!!
// The way this works is that monsters marked for deletion will cause the monster update loop to detect there's at least one or more monsters that must be deleted and will call erase_if on the list at the end of the iteration loop.

View File

@ -185,4 +185,7 @@ enum class Attribute{
WAIT_ONE_TICK,
ALPHA_AMOUNT,
DEFENSIVE_COOLDOWN,
SPIN_STATE_ENUM_SLOT,
SPIN_ATTACK_TIMER,
SPIN_ANGLE,
};

View File

@ -75,7 +75,6 @@ INCLUDE_game
INCLUDE_DATA
std::vector<std::reference_wrapper<Ability>>Player::ABILITY_LIST;
float Player::GROUND_SLAM_SPIN_TIME=0.6f;
const bool Player::INVERTED=true;
const bool Player::USE_WALK_DIR=true;
@ -102,7 +101,6 @@ Player::Player(Player*player)
}
void Player::Initialize(){
Player::GROUND_SLAM_SPIN_TIME="Warrior.Ability 2.SpinTime"_F;
SetBaseStat("Health","Warrior.BaseHealth"_I);
SetBaseStat("Mana","Player.BaseMana"_I);
SetBaseStat("Defense",0);
@ -464,42 +462,16 @@ void Player::Update(float fElapsedTime){
spin_angle-=spin_spd*fElapsedTime;
}
if(spin_attack_timer>0){
z=float("Warrior.Ability 2.SpinMaxHeight"_I)*sin(3.3f*(GROUND_SLAM_SPIN_TIME-spin_attack_timer)/GROUND_SLAM_SPIN_TIME);
z=float("Warrior.Ability 2.SpinMaxHeight"_I)*sin(PI*("Warrior.Ability 2.SpinTime"_F-spin_attack_timer)/"Warrior.Ability 2.SpinTime"_F);
spin_attack_timer=std::max(0.f,spin_attack_timer-fElapsedTime);
} else {
SetState(State::NORMAL);
spin_angle=0;
z=0;
float numb=4;
float groundSlamVisualRange{"Warrior.Ability 2.Range"_F/300*1.33f};
float groundSlamRange{"Warrior.Ability 2.Range"_F/100*12};
int groundSlamDamage{int(GetAttack()*"Warrior.Ability 2.DamageMult"_F)};
if(HasEnchant("Improved Ground Slam")){
groundSlamVisualRange+=groundSlamVisualRange*"Improved Ground Slam"_ENC["GROUND SLAM RADIUS INCREASE"]/100.f;
groundSlamRange+=groundSlamRange*"Improved Ground Slam"_ENC["GROUND SLAM RADIUS INCREASE"]/100.f;
groundSlamDamage+=GetDefense()*"Improved Ground Slam"_ENC["DEFENSE DAMAGE"]/100.f;
}
const HurtList&hitEnemies=game->Hurt(pos,groundSlamRange,groundSlamDamage,OnUpperLevel(),0,HurtType::MONSTER,HurtFlag::PLAYER_ABILITY);
#pragma region Knockback effect
for(auto&[targetPtr,wasHurt]:hitEnemies){
if(!std::holds_alternative<Monster*>(targetPtr))ERR("WARNING! A hurt request list was expecting only monster pointers, but got another type instead! THIS SHOULD NOT BE HAPPENING!");
Monster*monsterPtr=std::get<Monster*>(targetPtr);
float knockbackDir=0;
float knockbackAmt=0;
if(HasEnchant("Slam Shock"))monsterPtr->Stun("Slam Shock"_ENC["STUN DURATION"]);
if(geom2d::line<float>(GetPos(),monsterPtr->GetPos()).length()<=0.001f){
knockbackDir=util::random(2*PI);
knockbackAmt="Warrior.Ability 2.KnockbackAmt"_F;
}else{
knockbackDir=geom2d::line<float>(GetPos(),monsterPtr->GetPos()).vector().norm().polar().y;
knockbackAmt=std::clamp("Warrior.Ability 2.KnockbackAmt"_F-geom2d::line<float>(GetPos(),monsterPtr->GetPos()).length()*"Warrior.Ability 2.KnockbackReduction"_F,1.f,"Warrior.Ability 2.KnockbackAmt"_F);
}
knockbackAmt=std::max(1.f,knockbackAmt-"Warrior.Ability 2.KnockbackWeightFactor"_F*(monsterPtr->GetSizeMult()-1.f));
monsterPtr->Knockback(vf2d{knockbackAmt,knockbackDir}.cart());
}
#pragma endregion
game->AddEffect<Effect,Effect>({GetPos(),"Warrior.Ability 2.EffectLifetime"_F,"ground-slam-attack-front.png",upperLevel,groundSlamVisualRange,"Warrior.Ability 2.EffectFadetime"_F},{GetPos(),"Warrior.Ability 2.EffectLifetime"_F,"ground-slam-attack-back.png",upperLevel,groundSlamVisualRange,"Warrior.Ability 2.EffectFadetime"_F});
SoundEffect::PlaySFX("Warrior Ground Slam",SoundEffect::CENTERED);
game->AddEffect<Effect,Effect>({GetPos(),"Warrior.Ability 2.EffectLifetime"_F,"ground-slam-attack-front.png",upperLevel,groundSlamVisualRange,"Warrior.Ability 2.EffectFadetime"_F},{GetPos(),"Warrior.Ability 2.EffectLifetime"_F,"ground-slam-attack-back.png",upperLevel,groundSlamVisualRange,"Warrior.Ability 2.EffectFadetime"_F});
}
if(lastAnimationFlip>0){
lastAnimationFlip=std::max(0.f,lastAnimationFlip-fElapsedTime);
@ -2354,4 +2326,4 @@ const float Player::GetHastePct()const{
const float Player::GetDistanceFrom(vf2d target)const{
return geom2d::line<float>(GetPos(),target).length();
}
}

View File

@ -103,7 +103,6 @@ public:
//using a new object type... Because of that we'll take the pointer reference to the old object and copy some of its properties to this new
//one. It's hackish but it means we can reduce the amount of extra boilerplate when class changing...I don't know how to feel about this.
Player(Player*player);
static float GROUND_SLAM_SPIN_TIME;
const vf2d&GetPos()const;
float GetX();
float GetY();

View File

@ -57,6 +57,7 @@ No damage / No loadout items used / Defeat All
Bug in objects in stages? (1-1 bridge)
Fix coloring of selected git blame items
DEMO
====

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 13553
#define VERSION_BUILD 13575
#define stringify(a) stringify_(a)
#define stringify_(a) #a

View File

@ -45,11 +45,13 @@ DEFINE_STRATEGY(WARRIORTHIEF)
enum Phase{
INIT,
RUN,
SPIN,
};
switch(PHASE()){
case INIT:{
m.F(A::DEFENSIVE_COOLDOWN)=0.f;
SETPHASE(RUN);
m.I(A::SPIN_STATE_ENUM_SLOT)=SPIN;
}break;
case RUN:{
m.F(A::DEFENSIVE_COOLDOWN)-=game->GetElapsedTime();
@ -57,8 +59,16 @@ DEFINE_STRATEGY(WARRIORTHIEF)
const float distToPlayer{util::distance(m.GetPos(),game->GetPlayer()->GetPos())};
if(distToPlayer<100.f&&m.F(A::DEFENSIVE_COOLDOWN)<=0.f){
m.F(A::DEFENSIVE_COOLDOWN)=ConfigFloat("Warrior.Right Click Ability.Cooldown");
Warrior::ability1.action(&m,m.GetPos());
Warrior::ability2.action(&m,m.GetPos());
}
}break;
case SPIN:{
m.target=game->GetPlayer()->GetPos();
m.RunStrategy(MonsterStrategy::RUN_TOWARDS);
m.F(A::SPIN_ANGLE)+=ConfigFloat("Warrior.Ability 2.SpinSpd")*game->GetElapsedTime();
if((m.F(A::SPIN_ATTACK_TIMER)-=game->GetElapsedTime())>0){
m.SetZ(float("Warrior.Ability 2.SpinMaxHeight"_I)*sin(PI*(ConfigFloat("Warrior.Ability 2.SpinTime")-m.F(A::SPIN_ATTACK_TIMER))/ConfigFloat("Warrior.Ability 2.SpinTime")));
}else SETPHASE(RUN);
}break;
}
END_STRATEGY

View File

@ -130,9 +130,8 @@ void Warrior::InitializeClassAbilities(){
game->AddEffect(Effect{e.GetPos(),CONFIG_F("Warrior.Ability 1.EffectLifetime"),"battlecry_effect.png",e.OnUpperLevel(),CONFIG_F("Warrior.Ability 1.Range")/350,CONFIG_F("Warrior.Ability 1.EffectFadetime")});
e.AddBuff(BuffType::STAT_UP,CONFIG_F("Warrior.Ability 1.AttackUpDuration"),CONFIG_F("Warrior.Ability 1.AttackIncrease"),{"Attack %"});
e.AddBuff(BuffType::DAMAGE_REDUCTION,CONFIG_F("Warrior.Ability 1.DamageReductionDuration"),CONFIG_F("Warrior.Ability 1.DamageReduction"));
for(Entity&affectedEntity:game->GetTargetsInRange(e.GetPos(),12*CONFIG_I("Warrior.Ability 1.Range")/100.f,e.OnUpperLevel(),e.GetZ(),e.IsFriendly()?HurtType::MONSTER:HurtType::PLAYER)|std::views::filter([&e](Entity&filteredEnt){
return filteredEnt.GetSizeMult()>=CONFIG_f("Warrior.Ability 1.AffectedSizeRange",0)&&filteredEnt.GetSizeMult()<=CONFIG_f("Warrior.Ability 1.AffectedSizeRange",1);})){
return filteredEnt.GetSizeMult()<=>std::pair<float,float>{CONFIG_f("Warrior.Ability 1.AffectedSizeRange",0),CONFIG_f("Warrior.Ability 1.AffectedSizeRange",1)};})){
affectedEntity.AddBuff(BuffType::SLOWDOWN,CONFIG_F("Warrior.Ability 1.SlowdownDuration"),CONFIG_F("Warrior.Ability 1.SlowdownAmt"));
IFPLAYER{if(p.HasEnchant("Battle Shout"))affectedEntity.Hurt(p.GetDefense()*"Battle Shout"_ENC["DEFENSE DAMAGE"]/100.f,p.OnUpperLevel(),p.GetZ());}ENDIF
}
@ -142,9 +141,9 @@ void Warrior::InitializeClassAbilities(){
#pragma endregion
#pragma region Warrior Ability 2 (Ground Slam)
Warrior::ability2.action=
[](Entity e,vf2d pos={}){Player*p=e.ToPlayer(); //TODO
p->Spin(GROUND_SLAM_SPIN_TIME,"Warrior.Ability 2.SpinSpd"_F*PI);
p->iframe_time="Warrior.Ability 2.IframeTime"_F;
[](Entity e,vf2d pos={}){
e.Spin(CONFIG_F("Warrior.Ability 2.SpinTime"),CONFIG_F("Warrior.Ability 2.SpinSpd")*PI);
e.SetIframeTime(CONFIG_F("Warrior.Ability 2.IframeTime"));
return true;
};
#pragma endregion

View File

@ -1510,5 +1510,27 @@ MonsterStrategy
Warrior.Ability 1.Cooldown = 12
Warrior.Ability 1.Range = 500
Warrior.Ability 2.Cooldown = 15
Warrior.Ability 2.SpinTime = 0.6
Warrior.Ability 2.SpinSpd = 14
Warrior.Ability 2.SpinMaxHeight = 50
Warrior.Ability 2.IframeTime = 0.7
Warrior.Ability 2.Range = 350
Warrior.Ability 2.DamageMult = 2.5
# Amount of time the effect lives for on-screen before fading begins.
Warrior.Ability 2.EffectLifetime = 0.5
# Amount of time the effect fades out.
Warrior.Ability 2.EffectFadetime = 0.6
# Max knockback effect amount
Warrior.Ability 2.KnockbackAmt = 100
# Knockback Dropoff per pixel of distance
Warrior.Ability 2.KnockbackReduction = 0.45
# How much knockback is reduced per 100% larger size.
Warrior.Ability 2.KnockbackWeightFactor = 25
}
}

View File

@ -139,4 +139,9 @@ constexpr auto circ_add(
}
//Converts unit distances to pixels. (Every 100 units = 24 pixels)
long double operator""_Pixels(long double unitDist);
long double operator""_Pixels(long double unitDist);
template<class T>
bool operator<=>(const T&lhs,const std::pair<T,T>&rhs){
return lhs>=rhs.first&&lhs<=rhs.second;
}