|
|
|
|
#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 <EFBFBD> 2024 The FreeType
|
|
|
|
|
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
|
|
|
|
All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
|
|
#include "BulletTypes.h"
|
|
|
|
|
#include "AdventuresInLestoria.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
INCLUDE_game
|
|
|
|
|
|
|
|
|
|
PurpleEnergyBall::PurpleEnergyBall(vf2d pos,float radius,float homingRadius,int damage,bool upperLevel,vf2d speed,bool hitsMultiple,float lifetime,bool friendly,Pixel col,vf2d scale)
|
|
|
|
|
:initialScale(scale),homingRadius(homingRadius),Bullet(pos,speed,radius,damage,"mark_trail.png",upperLevel,hitsMultiple,INFINITE,false,friendly,col,scale/2.f,0.f){}
|
|
|
|
|
|
|
|
|
|
void PurpleEnergyBall::Update(float fElapsedTime){
|
|
|
|
|
if(homingTarget.has_value()){
|
|
|
|
|
if(!homingTarget.value().expired()){
|
|
|
|
|
const bool TargetInRange{util::distance(pos,homingTarget.value().lock()->GetPos())<="Witch.Auto Attack.Homing Range"_F};
|
|
|
|
|
const bool TargetIsAlive{homingTarget.value().lock()->IsAlive()};
|
|
|
|
|
if(TargetIsAlive&&TargetInRange){
|
|
|
|
|
const float targetAngle{util::angleTo(pos,homingTarget.value().lock()->GetPos())};
|
|
|
|
|
float currentAngle{vel.polar().y};
|
|
|
|
|
util::turn_towards_direction(currentAngle,targetAngle,util::degToRad("Witch.Auto Attack.Homing Turning Radius"_F)*fElapsedTime);
|
|
|
|
|
vel=vf2d{vel.mag(),currentAngle}.cart();
|
|
|
|
|
}else{
|
|
|
|
|
homingTarget.reset();
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
homingTarget.reset();
|
|
|
|
|
}
|
|
|
|
|
}else homingTarget=Monster::GetNearestMonster(pos,"Witch.Auto Attack.Homing Range"_F,OnUpperLevel(),GetZ());
|
|
|
|
|
if(distanceTraveled>"Witch.Auto Attack.Range"_F&&IsActivated()){
|
|
|
|
|
fadeOutTime="Witch.Auto Attack.BulletHitFadeoutTime"_F;
|
|
|
|
|
}
|
|
|
|
|
const vf2d energyBallScale{initialScale.lerp(initialScale*0.9f,cos(12*PI*game->GetRunTime())/2.f+0.5f)};
|
|
|
|
|
scale=energyBallScale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PurpleEnergyBall::Draw(const Pixel blendCol)const{
|
|
|
|
|
const vf2d lightOrbScale{initialScale.lerp(initialScale/2.f,sin(12*PI*game->GetRunTime())/2.f+0.5f)};
|
|
|
|
|
game->SetDecalMode(DecalMode::ADDITIVE);
|
|
|
|
|
game->view.DrawPartialRotatedDecal(pos,animation.GetFrame(internal_animState).GetSourceImage()->Decal(),0.f,animation.GetFrame(internal_animState).GetSourceRect().size/2.f,animation.GetFrame(internal_animState).GetSourceRect().pos,animation.GetFrame(internal_animState).GetSourceRect().size,lightOrbScale+0.2f,blendCol);
|
|
|
|
|
game->SetDecalMode(DecalMode::NORMAL);
|
|
|
|
|
Bullet::Draw(blendCol);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BulletDestroyState PurpleEnergyBall::PlayerHit(Player*player)
|
|
|
|
|
{
|
|
|
|
|
fadeOutTime="Witch.Auto Attack.BulletHitFadeoutTime"_F;
|
|
|
|
|
std::unique_ptr<Effect>hitEffect{std::make_unique<Effect>(player->GetPos(),0,"purpleenergyball_hit.png",upperLevel,player->GetSizeMult(),"Witch.Auto Attack.SplashEffectFadeoutTime"_F,vf2d{},WHITE,util::random(2*PI),5*PI)};
|
|
|
|
|
hitEffect->scaleSpd={-0.3f,-0.3f};
|
|
|
|
|
game->AddEffect(std::move(hitEffect));
|
|
|
|
|
return BulletDestroyState::KEEP_ALIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BulletDestroyState PurpleEnergyBall::MonsterHit(Monster&monster,const uint8_t markStacksBeforeHit)
|
|
|
|
|
{
|
|
|
|
|
fadeOutTime="Witch.Auto Attack.BulletHitFadeoutTime"_F;
|
|
|
|
|
std::unique_ptr<Effect>hitEffect{std::make_unique<Effect>(monster.GetPos(),0,"purpleenergyball_hit.png",upperLevel,monster.GetSizeMult(),"Witch.Auto Attack.SplashEffectFadeoutTime"_F,vf2d{},WHITE,util::random(2*PI),5*PI)};
|
|
|
|
|
hitEffect->scaleSpd={-0.3f,-0.3f};
|
|
|
|
|
game->AddEffect(std::move(hitEffect));
|
|
|
|
|
return BulletDestroyState::KEEP_ALIVE;
|
|
|
|
|
}
|