|
|
|
/*
|
|
|
|
License (OLC-3)
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Copyright 2018 - 2023 OneLoneCoder.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.
|
|
|
|
*/
|
|
|
|
#include "Effect.h"
|
|
|
|
#include "DEFINES.h"
|
|
|
|
#include "Crawler.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "safemap.h"
|
|
|
|
|
|
|
|
INCLUDE_game
|
|
|
|
INCLUDE_ANIMATION_DATA
|
|
|
|
INCLUDE_MONSTER_LIST
|
|
|
|
|
|
|
|
PulsatingFire::PulsatingFire(vf2d pos, float lifetime, std::string animation, bool upperLevel, vf2d size, float fadeout, vf2d spd, Pixel col, float rotation, float rotationSpd, bool additiveBlending)
|
|
|
|
:Effect(pos,lifetime,animation,upperLevel,size,fadeout,spd,col,rotation,rotationSpd,additiveBlending){
|
|
|
|
for(int i=0;i<8;i++){
|
|
|
|
pulsatingFireValues.push_back(util::random(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PulsatingFire::Update(float fElapsedTime){
|
|
|
|
lastParticleTimer-=fElapsedTime;
|
|
|
|
lastDamageTimer-=fElapsedTime;
|
|
|
|
if(lastParticleTimer<=0){
|
|
|
|
int particleCount="Wizard.Ability 3.FireRingParticleSpawnAmtRange"_FRange;
|
|
|
|
for(int i=0;i<particleCount;i++){
|
|
|
|
float randomAngle="Wizard.Ability 3.FireRingParticleAngleRange"_FRange;
|
|
|
|
float randomRange=12*size.x*(1-util::random("Wizard.Ability 3.FireRingParticleRandomVariance"_F))*(1-util::random("Wizard.Ability 3.FireRingParticleRandomVariance"_F));
|
|
|
|
float randomColorTintG=128*(1-util::random("Wizard.Ability 3.FireRingParticleColorGVariance"_F))*(1-util::random("Wizard.Ability 3.FireRingParticleColorGVariance"_F));
|
|
|
|
float randomColorTint="Wizard.Ability 3.FireRingParticleColorBlueRange"_FRange;
|
|
|
|
game->AddEffect(std::make_unique<Effect>(pos+vf2d{cos(randomAngle),sin(randomAngle)}*randomRange,0,"circle.png",OnUpperLevel(),vf2d{"Wizard.Ability 3.FireRingParticleXSizeRange"_FRange,"Wizard.Ability 3.FireRingParticleYSizeRange"_FRange},"Wizard.Ability 3.FireRingParticleFadeoutTimeRange"_FRange,vf2d{"Wizard.Ability 3.FireRingParticleXSpeedRange"_FRange,"Wizard.Ability 3.FireRingParticleYSpeedRange"_FRange},Pixel{128,uint8_t(randomColorTintG),uint8_t(randomColorTint),uint8_t("Wizard.Ability 3.FireRingParticleAlphaRange"_FRange)}));
|
|
|
|
}
|
|
|
|
lastParticleTimer="Wizard.Ability 3.FireRingParticleFreqRange"_FRange;
|
|
|
|
}
|
|
|
|
if(lastDamageTimer<=0){
|
|
|
|
lastDamageTimer="Wizard.Ability 3.FireRingDamageFreq"_F-0.01;
|
|
|
|
game->HurtEnemies(pos,"Wizard.Ability 3.MeteorRadius"_F/100*24,game->GetPlayer()->GetAttack()*"Wizard.Ability 3.FireRingDamageMult"_F,OnUpperLevel(),0);
|
|
|
|
}
|
|
|
|
return Effect::Update(fElapsedTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PulsatingFire::Draw(){
|
|
|
|
for(int i=0;i<8;i++){
|
|
|
|
Animate2D::FrameSequence*effectSpr=nullptr;
|
|
|
|
switch(int(pulsatingFireValues[i]*5)){
|
|
|
|
case 0:{
|
|
|
|
effectSpr=&ANIMATION_DATA["fire_ring0.png"];
|
|
|
|
}break;
|
|
|
|
case 1:{
|
|
|
|
effectSpr=&ANIMATION_DATA["fire_ring1.png"];
|
|
|
|
}break;
|
|
|
|
case 2:{
|
|
|
|
effectSpr=&ANIMATION_DATA["fire_ring2.png"];
|
|
|
|
}break;
|
|
|
|
case 3:{
|
|
|
|
effectSpr=&ANIMATION_DATA["fire_ring3.png"];
|
|
|
|
}break;
|
|
|
|
case 4:{
|
|
|
|
effectSpr=&ANIMATION_DATA["fire_ring4.png"];
|
|
|
|
}break;
|
|
|
|
default:
|
|
|
|
effectSpr=&ANIMATION_DATA["fire_ring0.png"];
|
|
|
|
}
|
|
|
|
const Renderable*img=effectSpr->GetFrame(0).GetSourceImage();
|
|
|
|
game->view.DrawPartialDecal(pos-effectSpr->GetFrame(0).GetSourceRect().size/2*size,img->Decal(),effectSpr->GetFrame(0).GetSourceRect().pos,effectSpr->GetFrame(0).GetSourceRect().size,size,{255,uint8_t(pulsatingFireValues[i]*256),0,uint8_t((63*(sin("Wizard.Ability 3.FireRingOscillatingFrequency"_F*lifetime+PI*pulsatingFireValues[i]))+63)*(fadeout/original_fadeoutTime))});
|
|
|
|
}
|
|
|
|
}
|