Fix sound effect bug when lightning bolt hits a player (doesn't currently happen in-game). Implement Chain Lightning. Release Build 11328.

pull/65/head
sigonasr2 3 months ago
parent 6fbb8a8ed1
commit 4f18cd41fb
  1. 1
      Adventures in Lestoria Tests/Adventures in Lestoria Tests.vcxproj
  2. 3
      Adventures in Lestoria Tests/Adventures in Lestoria Tests.vcxproj.filters
  3. 123
      Adventures in Lestoria Tests/BuffTests.cpp
  4. 8
      Adventures in Lestoria/Buff.cpp
  5. 5
      Adventures in Lestoria/Buff.h
  6. 7
      Adventures in Lestoria/BulletTypes.h
  7. 50
      Adventures in Lestoria/LightningBolt.cpp
  8. 8
      Adventures in Lestoria/Monster.cpp
  9. 1
      Adventures in Lestoria/Monster.h
  10. 20
      Adventures in Lestoria/Player.cpp
  11. 1
      Adventures in Lestoria/Player.h
  12. 2
      Adventures in Lestoria/Version.h
  13. 3
      Adventures in Lestoria/assets/config/classes/Wizard.txt
  14. 4
      Adventures in Lestoria/assets/config/items/ItemEnchants.txt
  15. BIN
      Adventures in Lestoria/assets/gamepack.pak
  16. BIN
      x64/Release/Adventures in Lestoria.exe

@ -103,6 +103,7 @@
<ClCompile Include="..\Adventures in Lestoria\discord-files\store_manager.cpp" /> <ClCompile Include="..\Adventures in Lestoria\discord-files\store_manager.cpp" />
<ClCompile Include="..\Adventures in Lestoria\discord-files\user_manager.cpp" /> <ClCompile Include="..\Adventures in Lestoria\discord-files\user_manager.cpp" />
<ClCompile Include="..\Adventures in Lestoria\discord-files\voice_manager.cpp" /> <ClCompile Include="..\Adventures in Lestoria\discord-files\voice_manager.cpp" />
<ClCompile Include="BuffTests.cpp" />
<ClCompile Include="EnchantTests.cpp"> <ClCompile Include="EnchantTests.cpp">
<SubType> <SubType>
</SubType> </SubType>

@ -75,6 +75,9 @@
<ClCompile Include="EngineTests.cpp"> <ClCompile Include="EngineTests.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="BuffTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="GameHelper.h"> <ClInclude Include="GameHelper.h">

@ -0,0 +1,123 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua 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 "CppUnitTest.h"
#include "AdventuresInLestoria.h"
#include "config.h"
#include "ItemDrop.h"
#include "Tutorial.h"
#include "DamageNumber.h"
#include "GameHelper.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace olc::utils;
INCLUDE_MONSTER_DATA
INCLUDE_game
INCLUDE_GFX
INCLUDE_DAMAGENUMBER_LIST
INCLUDE_MONSTER_LIST
INCLUDE_INITIALIZEGAMECONFIGURATIONS
TEST_MODULE_INITIALIZE(AiLTestSuite)
{
debugLogger.open("debug.log");
}
namespace BuffTests
{
TEST_CLASS(BuffTest)
{
public:
std::unique_ptr<AiL>testGame;
#pragma region Setup Functions
void SetupTestMonster(){
InitializeGameConfigurations();
testGame.reset(new AiL(true));
ItemAttribute::Initialize();
ItemInfo::InitializeItems();
testGame->InitializeGraphics();
testGame->InitializeClasses();
sig::Animation::InitializeAnimations();
testGame->InitializeDefaultKeybinds();
testGame->InitializePlayer();
sig::Animation::SetupPlayerAnimations();
Menu::InitializeMenus();
Tutorial::Initialize();
Stats::InitializeDamageReductionTable();
GameState::Initialize();
GameState::STATE=GameState::states.at(States::State::GAME_RUN);
testGame->ResetLevelStates();
#pragma region Setup a fake test map
game->MAP_DATA["CAMPAIGN_1_1"];
game->_SetCurrentLevel("CAMPAIGN_1_1");
ItemDrop::ClearDrops();
#pragma endregion
MonsterData testMonsterData{"TestName","Test Monster",30,10,5,{MonsterDropData{"Health Potion",100.f,1,1}},200.f};
MONSTER_DATA["TestName"]=testMonsterData;
Menu::themes.SetInitialized();
GFX.SetInitialized();
DAMAGENUMBER_LIST.clear();
}
void SetupMockMap(){
game->MAP_DATA["CAMPAIGN_1_1"];
ItemDrop::ClearDrops();
}
#pragma endregion
TEST_METHOD_INITIALIZE(MonsterInitialize){
SetupTestMonster();
SetupMockMap();
}
~BuffTest(){
testGame.release();
}
TEST_METHOD(AddBuffMonsterCallbackExpireFunctionTest){
Monster&m{game->SpawnMonster({},MONSTER_DATA.at("TestName"))};
Game::Update(0.f);
Assert::AreEqual(size_t(0),m.GetBuffs(BuffType::AFFECTED_BY_LIGHTNING_BOLT).size(),L"Monsters do not have any lightning bolt affected buffs when spawning.");
m.AddBuff(BuffType::AFFECTED_BY_LIGHTNING_BOLT,3.f,1,[](std::weak_ptr<Monster>attachedTarget,Buff&b){attachedTarget.lock()->Hurt(5,attachedTarget.lock()->OnUpperLevel(),attachedTarget.lock()->GetZ());});
Assert::AreEqual(size_t(1),m.GetBuffs(BuffType::AFFECTED_BY_LIGHTNING_BOLT).size(),L"Monster now has Affected By Lightning Bolt buff. Should get hurt for 5 damage in 3 seconds...");
Game::Update(3.f);
Assert::AreEqual(25,m.GetHealth(),L"Monster should have taken 5 health from the expired callback provided.");
}
};
}

@ -41,7 +41,13 @@ All rights reserved.
#include "Monster.h" #include "Monster.h"
Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity) Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity)
:attachedTarget(attachedTarget),type(type),duration(duration),intensity(intensity),originalDuration(this->duration){} :Buff(attachedTarget,type,duration,intensity,[](std::weak_ptr<Monster>m,Buff&b){}){}
Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,PlayerBuffExpireCallbackFunction expireCallbackFunc)
:attachedTarget(attachedTarget),type(type),duration(duration),intensity(intensity),originalDuration(this->duration),playerBuffCallbackFunc(expireCallbackFunc){}
Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,MonsterBuffExpireCallbackFunction expireCallbackFunc)
:attachedTarget(attachedTarget),type(type),duration(duration),intensity(intensity),originalDuration(this->duration),monsterBuffCallbackFunc(expireCallbackFunc){}
Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<ItemAttribute> attr) Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<ItemAttribute> attr)
:attachedTarget(attachedTarget),type(type),duration(duration),intensity(intensity),attr(attr),originalDuration(this->duration){} :attachedTarget(attachedTarget),type(type),duration(duration),intensity(intensity),attr(attr),originalDuration(this->duration){}
Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<std::string> attr) Buff::Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<std::string> attr)

@ -64,6 +64,7 @@ enum BuffType{
SWORD_ENCHANTMENT, SWORD_ENCHANTMENT,
CURSE_OF_PAIN, CURSE_OF_PAIN,
CURSE_OF_DEATH, CURSE_OF_DEATH,
AFFECTED_BY_LIGHTNING_BOLT, //Intensity indicates number of repeats remaining.
}; };
enum class BuffRestorationType{ enum class BuffRestorationType{
ONE_OFF, //This is used as a hack fix for the RestoreDuringCast Item script since they require us to restore 1 tick immediately. Over time buffs do not apply a tick immediately. ONE_OFF, //This is used as a hack fix for the RestoreDuringCast Item script since they require us to restore 1 tick immediately. Over time buffs do not apply a tick immediately.
@ -88,7 +89,7 @@ struct Buff{
using MonsterBuffExpireCallbackFunction=std::function<void(std::weak_ptr<Monster>attachedTarget,Buff&b)>; using MonsterBuffExpireCallbackFunction=std::function<void(std::weak_ptr<Monster>attachedTarget,Buff&b)>;
BuffType type; BuffType type;
BuffRestorationType restorationType; BuffRestorationType restorationType{BuffRestorationType::ONE_OFF};
float duration=1; float duration=1;
float timeBetweenTicks=1; float timeBetweenTicks=1;
float intensity=1; float intensity=1;
@ -103,6 +104,8 @@ struct Buff{
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity); Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity);
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<ItemAttribute> attr); Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<ItemAttribute> attr);
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<std::string> attr); Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,std::set<std::string> attr);
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,PlayerBuffExpireCallbackFunction expireCallbackFunc);
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffType type,float duration,float intensity,MonsterBuffExpireCallbackFunction expireCallbackFunc);
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks); Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks);
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,PlayerBuffExpireCallbackFunction expireCallbackFunc); Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,PlayerBuffExpireCallbackFunction expireCallbackFunc);
Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,MonsterBuffExpireCallbackFunction expireCallbackFunc); Buff(std::variant<Player*,std::weak_ptr<Monster>>attachedTarget,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,MonsterBuffExpireCallbackFunction expireCallbackFunc);

@ -62,12 +62,19 @@ private:
}; };
struct LightningBolt:public Bullet{ struct LightningBolt:public Bullet{
enum ChainLightningStatus{//Any other number represents something not defined here, the number of hits remaining.
ORIGINAL_BOLT=-1,
NO_MORE_HITS=0,
};
float lastParticleSpawn=0; float lastParticleSpawn=0;
LightningBolt(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE); LightningBolt(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE);
void Update(float fElapsedTime)override; void Update(float fElapsedTime)override;
BulletDestroyState PlayerHit(Player*player)override;//DO NOT CALL THIS DIRECTLY! INSTEAD USE _PlayerHit()!! BulletDestroyState PlayerHit(Player*player)override;//DO NOT CALL THIS DIRECTLY! INSTEAD USE _PlayerHit()!!
BulletDestroyState MonsterHit(Monster&monster,const uint8_t markStacksBeforeHit)override;//DO NOT CALL THIS DIRECTLY! INSTEAD USE _MonsterHit()!! BulletDestroyState MonsterHit(Monster&monster,const uint8_t markStacksBeforeHit)override;//DO NOT CALL THIS DIRECTLY! INSTEAD USE _MonsterHit()!!
void ModifyOutgoingDamageData(HurtDamageInfo&data); void ModifyOutgoingDamageData(HurtDamageInfo&data);
private:
/*chainLightningRepeatCount - Set to higher amount to indicate when this monster instead affects monsters due to the enchantment, which changes which shock count variable we look at and will be used for counting down shock times.*/
static void ApplyLightningShock(const Monster&monster,const bool onUpperLevel,const ChainLightningStatus chainLightningRepeatCount=ORIGINAL_BOLT);
}; };
struct Arrow:public Bullet{ struct Arrow:public Bullet{

@ -48,8 +48,7 @@ INCLUDE_MONSTER_LIST
INCLUDE_EMITTER_LIST INCLUDE_EMITTER_LIST
LightningBolt::LightningBolt(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col) LightningBolt::LightningBolt(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col)
:Bullet(pos,vel,radius,damage, :Bullet(pos,vel,radius,damage,"lightning_bolt.png",upperLevel,false,INFINITE,true,friendly,col){}
"lightning_bolt.png",upperLevel,false,INFINITE,true,friendly,col){}
void LightningBolt::Update(float fElapsedTime){ void LightningBolt::Update(float fElapsedTime){
lastParticleSpawn=std::max(0.f,lastParticleSpawn-fElapsedTime); lastParticleSpawn=std::max(0.f,lastParticleSpawn-fElapsedTime);
@ -77,38 +76,51 @@ void LightningBolt::Update(float fElapsedTime){
} }
} }
BulletDestroyState LightningBolt::PlayerHit(Player*player) BulletDestroyState LightningBolt::PlayerHit(Player*player){
{
fadeOutTime="Wizard.Ability 2.BulletFadeoutTime"_F; fadeOutTime="Wizard.Ability 2.BulletFadeoutTime"_F;
game->AddEffect(std::make_unique<Effect>(player->GetPos(),"Wizard.Ability 2.SplashLifetime"_F,"lightning_splash_effect.png",upperLevel,player->GetSizeMult(),"Wizard.Ability 2.SplashFadeoutTime"_F,vf2d{},WHITE,"Wizard.Ability 2.SplashRotationRange"_FRange)); game->AddEffect(std::make_unique<Effect>(player->GetPos(),"Wizard.Ability 2.SplashLifetime"_F,"lightning_splash_effect.png",upperLevel,player->GetSizeMult(),"Wizard.Ability 2.SplashFadeoutTime"_F,vf2d{},WHITE,"Wizard.Ability 2.SplashRotationRange"_FRange));
SoundEffect::PlaySFX("Wizard Lightning Bolt Hit",pos); SoundEffect::PlaySFX("Wizard Lightning Bolt Hit",pos);
return BulletDestroyState::KEEP_ALIVE; return BulletDestroyState::KEEP_ALIVE;
} }
BulletDestroyState LightningBolt::MonsterHit(Monster&monster,const uint8_t markStacksBeforeHit) BulletDestroyState LightningBolt::MonsterHit(Monster&monster,const uint8_t markStacksBeforeHit){
{
fadeOutTime="Wizard.Ability 2.BulletFadeoutTime"_F; fadeOutTime="Wizard.Ability 2.BulletFadeoutTime"_F;
game->AddEffect(std::make_unique<Effect>(monster.GetPos(),"Wizard.Ability 2.SplashLifetime"_F,"lightning_splash_effect.png",upperLevel,monster.GetSizeMult(),"Wizard.Ability 2.SplashFadeoutTime"_F,vf2d{},WHITE,"Wizard.Ability 2.SplashRotationRange"_FRange)); game->AddEffect(std::make_unique<Effect>(monster.GetPos(),"Wizard.Ability 2.SplashLifetime"_F,"lightning_splash_effect.png",upperLevel,monster.GetSizeMult(),"Wizard.Ability 2.SplashFadeoutTime"_F,vf2d{},WHITE,"Wizard.Ability 2.SplashRotationRange"_FRange));
LightningBolt::ApplyLightningShock(monster,monster.OnUpperLevel());
SoundEffect::PlaySFX("Wizard Lightning Bolt Hit",pos);
return BulletDestroyState::KEEP_ALIVE;
}
void LightningBolt::ModifyOutgoingDamageData(HurtDamageInfo&data){
if(friendly)data.hurtFlags|=HurtFlag::PLAYER_ABILITY;
}
void LightningBolt::ApplyLightningShock(const Monster&monster,const bool onUpperLevel,const ChainLightningStatus chainLightningRepeatCount/*Set to higher amount to indicate when this monster instead affects monsters due to the enchantment, which changes which shock count variable we look at and will be used for counting down shock times.*/){
int targetsHit=0; int targetsHit=0;
for(std::shared_ptr<Monster>&m:MONSTER_LIST){ for(std::shared_ptr<Monster>&m:MONSTER_LIST){
if(&*m==&monster||monster.OnUpperLevel()!=m->OnUpperLevel())continue; if(&*m==&monster||m->InUndamageableState(m->OnUpperLevel(),m->GetZ()))continue;
geom2d::line<float>lineToTarget=geom2d::line<float>(monster.GetPos(),m->GetPos()); geom2d::line<float>lineToTarget=geom2d::line<float>(monster.GetPos(),m->GetPos());
float dist=lineToTarget.length(); float dist=lineToTarget.length();
if(dist<="Wizard.Ability 2.LightningChainRadius"_F/100*24){ if(dist<="Wizard.Ability 2.LightningChainRadius"_F/100*24){
if(m->Hurt(int(game->GetPlayer()->GetAttack()*"Wizard.Ability 2.LightningChainDamageMult"_F),OnUpperLevel(),0,HurtFlag::PLAYER_ABILITY)){ int lightningChainDamage{int(game->GetPlayer()->GetAttack()*"Wizard.Ability 2.LightningChainDamageMult"_F)};
EMITTER_LIST.push_back(std::make_unique<LightningBoltEmitter>(LightningBoltEmitter(monster.GetPos(),m->GetPos(),"Wizard.Ability 2.LightningChainFrequency"_F,"Wizard.Ability 2.LightningChainLifetime"_F,upperLevel))); if(chainLightningRepeatCount>0)lightningChainDamage=int(game->GetPlayer()->GetAttack()*"Chain Lightning"_ENC["SHOCK DAMAGE"]/100.f);
game->AddEffect(std::make_unique<Effect>(m->GetPos(),"Wizard.Ability 2.LightningChainSplashLifetime"_F,"lightning_splash_effect.png",upperLevel,monster.GetSizeMult(),"Wizard.Ability 2.LightningChainSplashFadeoutTime"_F,vf2d{},WHITE,"Wizard.Ability 2.LightningChainSplashRotationRange"_FRange)); if(m->Hurt(lightningChainDamage,onUpperLevel,0,HurtFlag::PLAYER_ABILITY)){
EMITTER_LIST.emplace_back(std::make_unique<LightningBoltEmitter>(LightningBoltEmitter(monster.GetPos(),m->GetPos(),"Wizard.Ability 2.LightningChainFrequency"_F,"Wizard.Ability 2.LightningChainLifetime"_F,onUpperLevel)));
game->AddEffect(std::make_unique<Effect>(m->GetPos(),"Wizard.Ability 2.LightningChainSplashLifetime"_F,"lightning_splash_effect.png",onUpperLevel,monster.GetSizeMult(),"Wizard.Ability 2.LightningChainSplashFadeoutTime"_F,vf2d{},WHITE,"Wizard.Ability 2.LightningChainSplashRotationRange"_FRange));
int chainLightningRepeat{};
if(chainLightningRepeatCount>0)chainLightningRepeat=chainLightningRepeatCount-1;
else if(game->GetPlayer()->HasEnchant("Chain Lightning")&&chainLightningRepeatCount==ORIGINAL_BOLT)chainLightningRepeat=int("Chain Lightning"_ENC["REPEAT COUNT"]);
if(chainLightningRepeat>0&&game->GetPlayer()->HasEnchant("Chain Lightning"))m->AddBuff(BuffType::AFFECTED_BY_LIGHTNING_BOLT,"Chain Lightning"_ENC["ADDITIONAL SHOCK DELAY"],chainLightningRepeat,[](std::weak_ptr<Monster>attachedTarget,Buff&b){
LightningBolt::ApplyLightningShock(*attachedTarget.lock(),attachedTarget.lock()->OnUpperLevel(),ChainLightningStatus(b.intensity));
});
targetsHit++; targetsHit++;
} }
} }
if(targetsHit>=2)break; int targetHitLimit{"Wizard.Ability 2.LightningChainTargets"_I};
if(chainLightningRepeatCount>0)targetHitLimit="Chain Lightning"_ENC["ADDITIONAL SHOCK COUNT"];
if(targetsHit>=targetHitLimit)break;
} }
SoundEffect::PlaySFX("Wizard Lightning Bolt Hit",pos);
return BulletDestroyState::KEEP_ALIVE;
}
void LightningBolt::ModifyOutgoingDamageData(HurtDamageInfo&data){
if(friendly)data.hurtFlags|=HurtFlag::PLAYER_ABILITY;
} }

@ -346,7 +346,7 @@ bool Monster::Update(float fElapsedTime){
std::erase_if(buffList,[](Buff&b){ std::erase_if(buffList,[](Buff&b){
if(b.duration<=0.f){ if(b.duration<=0.f){
if(!std::holds_alternative<std::weak_ptr<Monster>>(b.attachedTarget))ERR(std::format("WARNING! Somehow removed buff of type {} is inside the player buff list but is not attached to the Player? THIS SHOULD NOT BE HAPPENING!",int(b.type))); if(!std::holds_alternative<std::weak_ptr<Monster>>(b.attachedTarget))ERR(std::format("WARNING! Somehow removed buff of type {} is inside the player buff list but is not attached to the Player? THIS SHOULD NOT BE HAPPENING!",int(b.type)));
b.monsterBuffCallbackFunc(std::get<std::weak_ptr<Monster>>(b.attachedTarget),b); if(b.monsterBuffCallbackFunc)b.monsterBuffCallbackFunc(std::get<std::weak_ptr<Monster>>(b.attachedTarget),b);
return true; return true;
} }
return false; return false;
@ -862,7 +862,7 @@ const bool Monster::OnUpperLevel()const{
} }
void Monster::AddBuff(BuffType type,float duration,float intensity){ void Monster::AddBuff(BuffType type,float duration,float intensity){
buffList.push_back(Buff{GetWeakPointer(),type,duration,intensity}); buffList.emplace_back(GetWeakPointer(),type,duration,intensity);
} }
void Monster::AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr){ void Monster::AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr){
@ -875,6 +875,10 @@ void Monster::AddBuff(BuffType type,float duration,float intensity,std::set<std:
buffList.emplace_back(GetWeakPointer(),type,duration,intensity,attr); buffList.emplace_back(GetWeakPointer(),type,duration,intensity,attr);
} }
void Monster::AddBuff(BuffType type,float duration,float intensity,Buff::MonsterBuffExpireCallbackFunction expireCallback){
buffList.emplace_back(GetWeakPointer(),type,duration,intensity,expireCallback);
}
void Monster::AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){ void Monster::AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){
if(type==STAT_UP)ERR("WARNING! Incorrect usage of STAT_UP buff! It should not be an overtime buff! Use a different consutrctor!!!"); if(type==STAT_UP)ERR("WARNING! Incorrect usage of STAT_UP buff! It should not be an overtime buff! Use a different consutrctor!!!");
buffList.emplace_back(GetWeakPointer(),type,restorationType,overTimeType,duration,intensity,timeBetweenTicks); buffList.emplace_back(GetWeakPointer(),type,restorationType,overTimeType,duration,intensity,timeBetweenTicks);

@ -141,6 +141,7 @@ public:
void AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr); void AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr);
//NOTE: If adding a % increase stat, please use the percentage version! 100% = 1!! //NOTE: If adding a % increase stat, please use the percentage version! 100% = 1!!
void AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr); void AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr);
void AddBuff(BuffType type,float duration,float intensity,Buff::MonsterBuffExpireCallbackFunction expireCallback);
void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks); void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks);
void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::MonsterBuffExpireCallbackFunction expireCallback); void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::MonsterBuffExpireCallbackFunction expireCallback);
void AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks); void AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks);

@ -429,7 +429,7 @@ void Player::Update(float fElapsedTime){
std::erase_if(buffList,[](Buff&b){ std::erase_if(buffList,[](Buff&b){
if(b.duration<=0.f){ if(b.duration<=0.f){
if(!std::holds_alternative<Player*>(b.attachedTarget))ERR(std::format("WARNING! Somehow removed buff of type {} is inside the player buff list but is not attached to the Player? THIS SHOULD NOT BE HAPPENING!",int(b.type))); if(!std::holds_alternative<Player*>(b.attachedTarget))ERR(std::format("WARNING! Somehow removed buff of type {} is inside the player buff list but is not attached to the Player? THIS SHOULD NOT BE HAPPENING!",int(b.type)));
b.playerBuffCallbackFunc(std::get<Player*>(b.attachedTarget),b); if(b.playerBuffCallbackFunc)b.playerBuffCallbackFunc(std::get<Player*>(b.attachedTarget),b);
return true; return true;
} }
return false; return false;
@ -1131,33 +1131,37 @@ void Player::UpdateIdleAnimation(Key direction){
} }
void Player::AddBuff(BuffType type,float duration,float intensity){ void Player::AddBuff(BuffType type,float duration,float intensity){
Buff&newBuff{buffList.emplace_back(Buff{this,type,duration,intensity})}; Buff&newBuff{buffList.emplace_back(this,type,duration,intensity)};
OnBuffAdd(newBuff);
}
void Player::AddBuff(BuffType type,float duration,float intensity,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc){
Buff&newBuff{buffList.emplace_back(this,type,duration,intensity,expireCallbackFunc)};
OnBuffAdd(newBuff); OnBuffAdd(newBuff);
} }
void Player::AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr){ void Player::AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr){
if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const ItemAttribute&attr){if(attr.ActualName()!="Health"&&attr.ActualName()!="Health %"&&attr.ActualName()!="Attack"&&attr.ActualName()!="Attack %"&&attr.ActualName()!="Defense"&&attr.ActualName()!="Defense %"&&attr.ActualName()!="CDR"&&attr.ActualName()!="Move Spd %")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr.ActualName()));}); if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const ItemAttribute&attr){if(attr.ActualName()!="Health"&&attr.ActualName()!="Health %"&&attr.ActualName()!="Attack"&&attr.ActualName()!="Attack %"&&attr.ActualName()!="Defense"&&attr.ActualName()!="Defense %"&&attr.ActualName()!="CDR"&&attr.ActualName()!="Move Spd %")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr.ActualName()));});
Buff&newBuff{buffList.emplace_back(Buff{this,type,duration,intensity,attr})}; Buff&newBuff{buffList.emplace_back(this,type,duration,intensity,attr)};
OnBuffAdd(newBuff); OnBuffAdd(newBuff);
} }
void Player::AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr){ void Player::AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr){
if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const std::string&attr){if(attr!="Health"&&attr!="Health %"&&attr!="Attack"&&attr!="Attack %"&&attr!="Defense"&&attr!="Defense %"&&attr!="CDR"&&attr!="Move Spd %")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr));}); if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const std::string&attr){if(attr!="Health"&&attr!="Health %"&&attr!="Attack"&&attr!="Attack %"&&attr!="Defense"&&attr!="Defense %"&&attr!="CDR"&&attr!="Move Spd %")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr));});
Buff&newBuff{buffList.emplace_back(Buff{this,type,duration,intensity,attr})}; Buff&newBuff{buffList.emplace_back(this,type,duration,intensity,attr)};
OnBuffAdd(newBuff); OnBuffAdd(newBuff);
} }
void Player::AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){ void Player::AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){
Buff&newBuff{buffList.emplace_back(Buff{this,type,overTimeType,duration,intensity,timeBetweenTicks})}; Buff&newBuff{buffList.emplace_back(this,type,overTimeType,duration,intensity,timeBetweenTicks)};
OnBuffAdd(newBuff); OnBuffAdd(newBuff);
} }
void Player::AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc){ void Player::AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc){
Buff&newBuff{buffList.emplace_back(Buff{this,type,overTimeType,duration,intensity,timeBetweenTicks,expireCallbackFunc})}; Buff&newBuff{buffList.emplace_back(this,type,overTimeType,duration,intensity,timeBetweenTicks,expireCallbackFunc)};
OnBuffAdd(newBuff); OnBuffAdd(newBuff);
} }
void Player::AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){ void Player::AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){
Buff&newBuff{buffList.emplace_back(Buff{this,type,restorationType,overTimeType,duration,intensity,timeBetweenTicks})}; Buff&newBuff{buffList.emplace_back(this,type,restorationType,overTimeType,duration,intensity,timeBetweenTicks)};
OnBuffAdd(newBuff); OnBuffAdd(newBuff);
} }
void Player::AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc){ void Player::AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc){
Buff&newBuff{buffList.emplace_back(Buff{this,type,restorationType,overTimeType,duration,intensity,timeBetweenTicks,expireCallbackFunc})}; Buff&newBuff{buffList.emplace_back(this,type,restorationType,overTimeType,duration,intensity,timeBetweenTicks,expireCallbackFunc)};
OnBuffAdd(newBuff); OnBuffAdd(newBuff);
} }

@ -180,6 +180,7 @@ public:
void AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr); void AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr);
//NOTE: If adding a % increase stat, please use the percentage version! 100% = 1!! //NOTE: If adding a % increase stat, please use the percentage version! 100% = 1!!
void AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr); void AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr);
void AddBuff(BuffType type,float duration,float intensity,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc);
void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks); void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks);
void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc); void AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks,Buff::PlayerBuffExpireCallbackFunction expireCallbackFunc);
void AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks); void AddBuff(BuffType type,BuffRestorationType restorationType,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks);

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 5 #define VERSION_PATCH 5
#define VERSION_BUILD 11309 #define VERSION_BUILD 11328
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -184,6 +184,9 @@ Wizard
BulletFadeoutTime = 0.2 BulletFadeoutTime = 0.2
# Number of targets that will be hit by the lightning chain.
LightningChainTargets = 2
# How far away to look for nearby enemies to chain lightning to. # How far away to look for nearby enemies to chain lightning to.
LightningChainRadius = 300 LightningChainRadius = 300
# Damage multiplier for enemies hit by lightning chain. # Damage multiplier for enemies hit by lightning chain.

@ -529,7 +529,7 @@ Item Enchants
} }
Summon Comet Summon Comet
{ {
Description = "Meteor cast time reduced to {METEOR CAST TIME} seconds. Meteor attack falls {FALL SPEED MULT}x as quickly. Damage is reduced by {DAMAGE REDUCTION PCT}% and Cooldown reduced by {COOLDOWN REDUCTION} seconds." Description = "Meteor cast time reduced to {METEOR CAST TIME} seconds. Meteor attack falls twice as quick. Damage is reduced by {DAMAGE REDUCTION PCT}% and -{COOLDOWN REDUCTION}s cooldown time."
Affects = Ability 3 Affects = Ability 3
METEOR CAST TIME = 0.5s METEOR CAST TIME = 0.5s
@ -542,7 +542,7 @@ Item Enchants
} }
Solar Flare Solar Flare
{ {
Description = "Meteor cast time increased to {METEOR CAST TIME} seconds. Meteor is {SIZE MULT}x as large and deals {METEOR ATTACK}% attack. Lingering fire rings last {FIRE RING DURATION MULT}x as long. Cooldown increased by {COOLDOWN INCREASE} seconds." Description = "Meteor cast time increased to {METEOR CAST TIME} seconds. Meteor is double size and deals {METEOR ATTACK}% attack. Fire rings last twice as long. +{COOLDOWN INCREASE}s cooldown time."
Affects = Ability 3 Affects = Ability 3
METEOR CAST TIME = 3.5s METEOR CAST TIME = 3.5s

Loading…
Cancel
Save