2023-11-20 23:25:36 -06:00
# pragma region License
2023-11-14 18:11:32 -06:00
/*
License ( OLC - 3 )
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2024-01-02 00:46:32 -06:00
Copyright 2024 Joshua Sigona < sigonasr2 @ gmail . com >
2023-11-14 18:11:32 -06:00
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 .
2023-11-29 00:50:00 -06:00
2024-01-30 14:48:49 +00:00
Portions of this software are copyright © 2024 The FreeType
2023-11-29 00:50:00 -06:00
Project ( www . freetype . org ) . Please see LICENSE_FT . txt for more information .
All rights reserved .
2023-11-14 18:11:32 -06:00
*/
2023-11-20 23:25:36 -06:00
# pragma endregion
2023-06-19 03:25:01 -05:00
# pragma once
2023-12-23 21:15:08 -06:00
# include <set>
# include "AttributableStat.h"
2023-06-19 03:25:01 -05:00
enum BuffType {
2023-12-23 21:15:08 -06:00
STAT_UP ,
2023-06-19 03:25:01 -05:00
DAMAGE_REDUCTION ,
SLOWDOWN ,
2023-07-29 10:21:53 -05:00
BLOCK_SLOWDOWN ,
2024-01-14 12:53:40 -06:00
LOCKON_SPEEDBOOST , //Specifically used for wolves.
SPEEDBOOST ,
2024-01-24 17:13:33 -06:00
BARRIER_DAMAGE_REDUCTION , //Creates a visual barrier around the target
2024-01-24 22:44:18 -06:00
FIXED_COLLISION_DMG , //Does a fixed amount of collision damage based on intensity of this buff.
COLLISION_KNOCKBACK_STRENGTH , //Causes an amount of knockback based on intensity when hit via collision with this buff
2024-04-19 04:05:51 -05:00
SELF_INFLICTED_SLOWDOWN , //Used for monsters and can't be applied by any player abilities.
2024-08-12 12:27:53 -05:00
ADRENALINE_RUSH , //Intensity indicates the stack count (used by the Bloodlust enchant) this buff gives which in turn increases attack.
2024-07-21 16:11:41 -05:00
TRAPPER_MARK ,
2024-08-14 23:18:29 -07:00
SPECIAL_MARK , //The mark applied by the Opportunity Shot.
2024-07-23 04:07:43 -05:00
OVER_TIME ,
2024-08-12 20:43:34 -05:00
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.
2024-07-23 04:07:43 -05:00
OVER_TIME_DURING_CAST ,
2024-07-28 04:18:52 -05:00
GLOW_PURPLE ,
2024-07-28 07:06:11 -05:00
COLOR_MOD ,
2024-07-28 20:48:09 -05:00
DAMAGE_AMPLIFICATION , //Multiplies all incoming damage by this amount.
2024-08-05 17:33:53 -05:00
LETHAL_TEMPO ,
2024-08-12 20:43:34 -05:00
BURNING_ARROW_BURN ,
2024-08-26 12:04:38 -05:00
SWORD_ENCHANTMENT ,
2024-08-30 22:25:49 -05:00
CURSE_OF_PAIN ,
2024-09-01 02:15:12 -05:00
CURSE_OF_DEATH ,
2024-09-05 21:00:12 -07:00
AFFECTED_BY_LIGHTNING_BOLT , //Intensity indicates number of repeats remaining.
2025-01-03 01:15:31 -06:00
INK_SLOWDOWN , //Intensity indicates % movespd slowdown.
2025-03-07 01:32:16 -06:00
PIRATE_GHOST_CAPTAIN_PRECURSE , //A coin icon appears above the player's head.
PIRATE_GHOST_CAPTAIN_CURSE_COIN , //A coin icon appears above the player's head.
2025-02-21 00:40:36 -06:00
PIRATE_GHOST_CAPTAIN_CURSE_DOT , //The same as above, but now is a damage over time as well.
2023-06-19 03:25:01 -05:00
} ;
2024-07-23 04:07:43 -05:00
enum class BuffRestorationType {
2024-08-12 20:43:34 -05:00
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.
2024-07-23 04:07:43 -05:00
OVER_TIME ,
OVER_TIME_DURING_CAST ,
} ;
namespace BuffOverTimeType {
enum BuffOverTimeType {
HP_RESTORATION ,
2025-02-21 00:40:36 -06:00
HP_PCT_RESTORATION , //Percentage should be the raw percentage, NOT % form! (So 1 for 1%, not 0.01)
2024-07-23 04:07:43 -05:00
MP_RESTORATION ,
2025-02-21 00:40:36 -06:00
MP_PCT_RESTORATION , //Percentage should be the raw percentage, NOT % form! (So 1 for 1%, not 0.01)
2024-07-23 04:07:43 -05:00
HP_DAMAGE_OVER_TIME ,
2025-02-21 00:40:36 -06:00
HP_PCT_DAMAGE_OVER_TIME , //Percentage should be the raw percentage, NOT % form! (So 1 for 1%, not 0.01)
2024-07-23 04:07:43 -05:00
} ;
} ;
2024-01-04 05:21:56 -06:00
class AiL ;
2023-12-22 07:08:53 -06:00
2023-06-19 03:25:01 -05:00
struct Buff {
2024-07-28 03:46:17 -05:00
using PlayerBuffExpireCallbackFunction = std : : function < void ( Player * attachedTarget , Buff & b ) > ;
using MonsterBuffExpireCallbackFunction = std : : function < void ( std : : weak_ptr < Monster > attachedTarget , Buff & b ) > ;
2023-06-19 03:25:01 -05:00
BuffType type ;
2024-09-05 21:00:12 -07:00
BuffRestorationType restorationType { BuffRestorationType : : ONE_OFF } ;
2023-12-22 07:08:53 -06:00
float duration = 1 ;
float timeBetweenTicks = 1 ;
float intensity = 1 ;
float nextTick = 0 ;
2024-08-12 20:43:34 -05:00
float lifetime { } ;
2023-12-23 21:15:08 -06:00
std : : set < ItemAttribute > attr ;
2024-07-28 03:46:17 -05:00
std : : variant < Player * , std : : weak_ptr < Monster > > attachedTarget ; //Who has this buff.
PlayerBuffExpireCallbackFunction playerBuffCallbackFunc = [ ] ( Player * p , Buff & b ) { } ;
MonsterBuffExpireCallbackFunction monsterBuffCallbackFunc = [ ] ( std : : weak_ptr < Monster > m , Buff & b ) { } ;
2024-08-14 23:18:29 -07:00
float originalDuration { } ;
2024-07-23 04:07:43 -05:00
2024-07-28 03:46:17 -05:00
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 < std : : string > attr ) ;
2024-09-05 21:00:12 -07:00
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 ) ;
2024-08-12 20:43:34 -05:00
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 , MonsterBuffExpireCallbackFunction expireCallbackFunc ) ;
Buff ( std : : variant < Player * , std : : weak_ptr < Monster > > attachedTarget , BuffType type , BuffRestorationType restorationType , BuffOverTimeType : : BuffOverTimeType overTimeType , float duration , float intensity , float timeBetweenTicks ) ;
Buff ( std : : variant < Player * , std : : weak_ptr < Monster > > attachedTarget , BuffType type , BuffRestorationType restorationType , BuffOverTimeType : : BuffOverTimeType overTimeType , float duration , float intensity , float timeBetweenTicks , PlayerBuffExpireCallbackFunction expireCallbackFunc ) ;
Buff ( std : : variant < Player * , std : : weak_ptr < Monster > > attachedTarget , BuffType type , BuffRestorationType restorationType , BuffOverTimeType : : BuffOverTimeType overTimeType , float duration , float intensity , float timeBetweenTicks , MonsterBuffExpireCallbackFunction expireCallbackFunc ) ;
2024-07-23 04:07:43 -05:00
void Update ( AiL * game , float fElapsedTime ) ;
private :
2024-08-30 22:25:49 -05:00
bool waitOneTick { true } ;
2024-08-12 20:43:34 -05:00
bool enabled { true } ; //This is only turned off because the ONE_OFF effect. See BuffType::ONE_OFF for more details.
2024-07-23 04:07:43 -05:00
std : : optional < BuffOverTimeType : : BuffOverTimeType > overTimeType ;
void BuffTick ( AiL * game , float fElapsedTime ) ;
2023-06-19 03:25:01 -05:00
} ;