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-07-06 04:35:40 -05:00
# include "BulletTypes.h"
# include "Effect.h"
2024-01-04 05:21:56 -06:00
# include "AdventuresInLestoria.h"
2023-07-06 04:35:40 -05:00
# include "DEFINES.h"
2023-11-13 21:26:34 -06:00
# include "util.h"
2024-01-09 06:42:09 -06:00
# include "SoundEffect.h"
2024-09-05 19:24:40 -05:00
# include "TrailEffect.h"
2023-07-06 04:35:40 -05:00
INCLUDE_game
INCLUDE_MONSTER_LIST
2023-07-07 06:42:49 -05:00
FireBolt : : FireBolt ( vf2d pos , vf2d vel , float radius , int damage , bool upperLevel , bool friendly , Pixel col )
2023-07-23 08:13:40 -05:00
: Bullet ( pos , vel , radius , damage ,
2024-09-05 19:24:40 -05:00
" energy_bolt.png " , upperLevel , false , INFINITE , true , friendly , col ) {
if ( game - > GetPlayer ( ) - > HasEnchant ( " Trail of Fire " ) ) flameTrail = dynamic_cast < TrailEffect & > ( game - > AddEffect ( std : : make_unique < TrailEffect > ( pos , " Trail of Fire " _ENC [ " TRAIL DURATION " ] , " FlamesTexture.png " , " Trail of Fire " _ENC [ " TRAIL DAMAGE " ] / 100.f * game - > GetPlayer ( ) - > GetAttack ( ) , " Trail of Fire " _ENC [ " TRAIL TICK FREQUENCY " ] , upperLevel , 1.f , vf2d { 1.f , 2.f } , 30000.f , Oscillator < Pixel > { { 255 , 0 , 0 , 128 } , Pixel ( 0xE74F30 ) , 2.f } , EffectType : : TRAIL_OF_FIRE , true ) , true ) ) ;
}
2023-07-06 04:35:40 -05:00
void FireBolt : : Update ( float fElapsedTime ) {
lastParticleSpawn = std : : max ( 0.f , lastParticleSpawn - fElapsedTime ) ;
if ( lastParticleSpawn = = 0 ) {
2023-07-28 18:02:30 -05:00
lastParticleSpawn = " Wizard.Ability 1.ParticleFrequency " _F ;
2023-09-16 07:00:38 -05:00
game - > AddEffect ( std : : make_unique < Effect > ( pos , " Wizard.Ability 1.ParticleLifetimeRange " _FRange , " energy_particle.png " , upperLevel , " Wizard.Ability 1.ParticleSizeRange " _FRange , " Wizard.Ability 1.ParticleFadeoutTime " _F , vf2d { " Wizard.Ability 1.ParticleXSpeedRange " _FRange , " Wizard.Ability 1.ParticleYSpeedRange " _FRange } , Pixel { uint8_t ( " Wizard.Ability 1.ParticleRedRange " _FRange ) , uint8_t ( " Wizard.Ability 1.ParticleGreenRange " _FRange ) , uint8_t ( " Wizard.Ability 1.ParticleBlueRange " _FRange ) , uint8_t ( " Wizard.Ability 1.ParticleAlphaRange " _FRange ) } ) ) ;
2023-07-06 04:35:40 -05:00
}
2024-08-29 18:17:18 -05:00
if ( distanceTraveled > " Wizard.Ability 1.Max Range " _F & & IsActivated ( ) ) {
2024-01-29 17:02:20 -06:00
fadeOutTime = " Wizard.Ability 1.BulletHitFadeoutTime " _F ;
for ( int i = 0 ; i < " Wizard.Ability 1.BulletHitExplosionParticleCount " _I ; i + + ) {
game - > AddEffect ( std : : make_unique < Effect > ( pos , " Wizard.Ability 1.BulletHitExplosionParticleLifetimeRange " _FRange , " circle.png " , upperLevel , " Wizard.Ability 1.BulletHitExplosionParticleSizeRange " _FRange , " Wizard.Ability 1.BulletHitExplosionParticleFadeoutTimeRange " _FRange , vf2d { " Wizard.Ability 1.BulletHitExplosionParticleSpeedRange " _FRange , " Wizard.Ability 1.BulletHitExplosionParticleSpeedRange " _FRange } , Pixel { uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleRedRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleGreenRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleBlueRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleAlphaRange " _FRange ) } ) ) ;
}
game - > SetupWorldShake ( " Wizard.Ability 1.WorldShakeTime " _F ) ;
if ( friendly ) {
2024-07-21 16:11:41 -05:00
game - > Hurt ( pos , " Wizard.Ability 1.BulletHitExplosionRange " _F / 100 * 12 , int ( " Wizard.Ability 1.BulletHitExplosionDamageMult " _F * game - > GetPlayer ( ) - > GetAttack ( ) ) , OnUpperLevel ( ) , 0 , HurtType : : MONSTER , HurtFlag : : PLAYER_ABILITY ) ;
2024-01-29 17:02:20 -06:00
} else {
if ( geom2d : : overlaps ( geom2d : : circle < float > { pos , " Wizard.Ability 1.BulletHitExplosionRange " _F / 100 * 12 } , geom2d : : circle < float > { game - > GetPlayer ( ) - > GetPos ( ) , 12.f } ) ) {
game - > GetPlayer ( ) - > Hurt ( damage , OnUpperLevel ( ) , 0.f ) ;
}
}
game - > AddEffect ( std : : make_unique < Effect > ( pos , 0 , " splash_effect.png " , upperLevel , " Wizard.Ability 1.BulletHitExplosionRange " _F / 100 * 2 , " Wizard.Ability 1.BulletHitExplosionFadeoutTime " _F , vf2d { } , " Wizard.Ability 1.BulletHitExplosionColor " _Pixel ) ) ;
SoundEffect : : PlaySFX ( " Wizard Fire Bolt Hit " , pos ) ;
}
2024-09-05 19:24:40 -05:00
if ( flameTrail ) flameTrail . value ( ) . get ( ) . SetEndPos ( pos ) ;
2023-07-06 04:35:40 -05:00
}
2024-06-02 15:51:35 -05:00
BulletDestroyState FireBolt : : PlayerHit ( Player * player )
2023-07-06 04:35:40 -05:00
{
2023-07-28 18:02:30 -05:00
fadeOutTime = " Wizard.Ability 1.BulletHitFadeoutTime " _F ;
2024-01-29 17:02:20 -06:00
for ( int i = 0 ; i < " Wizard.Ability 1.BulletHitExplosionParticleCount " _I ; i + + ) {
game - > AddEffect ( std : : make_unique < Effect > ( player - > GetPos ( ) , " Wizard.Ability 1.BulletHitExplosionParticleLifetimeRange " _FRange , " circle.png " , upperLevel , " Wizard.Ability 1.BulletHitExplosionParticleSizeRange " _FRange , " Wizard.Ability 1.BulletHitExplosionParticleFadeoutTimeRange " _FRange , vf2d { " Wizard.Ability 1.BulletHitExplosionParticleSpeedRange " _FRange , " Wizard.Ability 1.BulletHitExplosionParticleSpeedRange " _FRange } , Pixel { uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleRedRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleGreenRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleBlueRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleAlphaRange " _FRange ) } ) ) ;
game - > SetupWorldShake ( " Wizard.Ability 1.WorldShakeTime " _F ) ; }
2023-09-16 07:00:38 -05:00
game - > AddEffect ( std : : make_unique < Effect > ( player - > GetPos ( ) , 0 , " splash_effect.png " , upperLevel , 5 , 0.25 , vf2d { } , Pixel { 240 , 120 , 60 } ) ) ;
2024-01-09 06:42:09 -06:00
SoundEffect : : PlaySFX ( " Wizard Fire Bolt Hit " , pos ) ;
2024-06-02 15:51:35 -05:00
return BulletDestroyState : : KEEP_ALIVE ;
2023-07-06 04:35:40 -05:00
}
2024-07-23 04:07:43 -05:00
BulletDestroyState FireBolt : : MonsterHit ( Monster & monster , const uint8_t markStacksBeforeHit )
2023-07-06 04:35:40 -05:00
{
2023-07-28 18:02:30 -05:00
fadeOutTime = " Wizard.Ability 1.BulletHitFadeoutTime " _F ;
for ( int i = 0 ; i < " Wizard.Ability 1.BulletHitExplosionParticleCount " _I ; i + + ) {
2023-09-16 07:00:38 -05:00
game - > AddEffect ( std : : make_unique < Effect > ( monster . GetPos ( ) , " Wizard.Ability 1.BulletHitExplosionParticleLifetimeRange " _FRange , " circle.png " , upperLevel , " Wizard.Ability 1.BulletHitExplosionParticleSizeRange " _FRange , " Wizard.Ability 1.BulletHitExplosionParticleFadeoutTimeRange " _FRange , vf2d { " Wizard.Ability 1.BulletHitExplosionParticleSpeedRange " _FRange , " Wizard.Ability 1.BulletHitExplosionParticleSpeedRange " _FRange } , Pixel { uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleRedRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleGreenRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleBlueRange " _FRange ) , uint8_t ( " Wizard.Ability 1.BulletHitExplosionParticleAlphaRange " _FRange ) } ) ) ;
2023-07-06 04:35:40 -05:00
}
2023-07-28 18:02:30 -05:00
game - > SetupWorldShake ( " Wizard.Ability 1.WorldShakeTime " _F ) ;
2024-07-21 16:11:41 -05:00
game - > Hurt ( monster . GetPos ( ) , " Wizard.Ability 1.BulletHitExplosionRange " _F / 100 * 12 , int ( " Wizard.Ability 1.BulletHitExplosionDamageMult " _F * game - > GetPlayer ( ) - > GetAttack ( ) ) , OnUpperLevel ( ) , 0 , HurtType : : MONSTER , HurtFlag : : PLAYER_ABILITY ) ;
2023-09-16 07:00:38 -05:00
game - > AddEffect ( std : : make_unique < Effect > ( monster . GetPos ( ) , 0 , " splash_effect.png " , upperLevel , " Wizard.Ability 1.BulletHitExplosionRange " _F / 100 * 2 , " Wizard.Ability 1.BulletHitExplosionFadeoutTime " _F , vf2d { } , " Wizard.Ability 1.BulletHitExplosionColor " _Pixel ) ) ;
2024-01-09 06:42:09 -06:00
SoundEffect : : PlaySFX ( " Wizard Fire Bolt Hit " , pos ) ;
2024-06-02 15:51:35 -05:00
return BulletDestroyState : : KEEP_ALIVE ;
2023-07-06 04:35:40 -05:00
}
2024-07-21 16:11:41 -05:00
2024-07-23 04:07:43 -05:00
void FireBolt : : ModifyOutgoingDamageData ( HurtDamageInfo & data ) {
if ( friendly ) data . hurtFlags | = HurtFlag : : PLAYER_ABILITY ;
2024-07-21 16:11:41 -05:00
}