|
|
|
|
#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 <ranges>
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "SoundEffect.h"
|
|
|
|
|
|
|
|
|
|
INCLUDE_ANIMATION_DATA
|
|
|
|
|
INCLUDE_game
|
|
|
|
|
|
|
|
|
|
ExplosiveTrap::ExplosiveTrap(vf2d pos,float radius,float explosionRadius,float automaticDetonationTime,int damage,float fadeinTime,float fadeoutTime,float activationWaitTime,bool upperLevel,bool hitsMultiple,float lifetime,bool friendly,Pixel col,vf2d scale)
|
|
|
|
|
:activationWaitTime(activationWaitTime),automaticDetonationTime(automaticDetonationTime),activationRadius(radius),explosionRadius(explosionRadius),explosionCount(game->GetPlayer()->HasEnchant("Concussive Trap")?"Concussive Trap"_ENC["TRAP EXPLODE COUNT"]:1),Bullet(pos,{},0.f,damage,"Ability Icons/explosive_trap.png",upperLevel,hitsMultiple,INFINITE,false,friendly,col,scale,0.f,"Trap Hit"){
|
|
|
|
|
fadeInTime=fadeinTime;
|
|
|
|
|
animation.AddState("explosive_trap.png",ANIMATION_DATA["explosive_trap.png"]);
|
|
|
|
|
if(!friendly)ERR("WARNING! Trying to use unimplemented enemy version of the Explosive Trap Bullet!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExplosiveTrap::Update(float fElapsedTime){
|
|
|
|
|
const bool trapActivated{radius==activationRadius};
|
|
|
|
|
|
|
|
|
|
if(IsDeactivated())return;
|
|
|
|
|
|
|
|
|
|
if(rearmTime>0.f){
|
|
|
|
|
rearmTime-=fElapsedTime;
|
|
|
|
|
if(rearmTime<=0.f)Detonate();
|
|
|
|
|
}else if(!trapActivated){
|
|
|
|
|
activationWaitTime-=fElapsedTime;
|
|
|
|
|
if(activationWaitTime<=0.f){
|
|
|
|
|
radius=activationRadius;
|
|
|
|
|
animation.ChangeState(internal_animState,"explosive_trap.png");
|
|
|
|
|
beepCount=std::min(4U,beepCount+1U);
|
|
|
|
|
SoundEffect::PlaySFX(std::format("Beep {}",beepCount),pos);
|
|
|
|
|
lastBeepTime=1.f;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
automaticDetonationTime-=fElapsedTime;
|
|
|
|
|
lastBeepTime-=fElapsedTime;
|
|
|
|
|
if(lastBeepTime<=0.f){
|
|
|
|
|
beepCount=std::min(4U,beepCount+1U);
|
|
|
|
|
SoundEffect::PlaySFX(std::format("Beep {}",beepCount),pos);
|
|
|
|
|
lastBeepTime=1.f;
|
|
|
|
|
}
|
|
|
|
|
if(IsActivated()&&automaticDetonationTime<=0.f)Detonate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExplosiveTrap::ModifyOutgoingDamageData(HurtDamageInfo&data){
|
|
|
|
|
data.hurtFlags|=HurtFlag::PLAYER_ABILITY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BulletDestroyState ExplosiveTrap::PlayerHit(Player*player){
|
|
|
|
|
fadeOutTime=0.5f;
|
|
|
|
|
return BulletDestroyState::KEEP_ALIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExplosiveTrap::Detonate(){
|
|
|
|
|
const HurtList list{game->Hurt(pos,"Trapper.Ability 3.Explosion Radius"_F/100.f*24,damage,OnUpperLevel(),GetZ(),HurtType::MONSTER,HurtFlag::PLAYER_ABILITY)};
|
|
|
|
|
for(const auto&[targetPtr,wasHit]:list){
|
|
|
|
|
if(wasHit){
|
|
|
|
|
std::get<Monster*>(targetPtr)->ApplyMark("Trapper.Ability 3.Explosion Mark Stack Time"_F,"Trapper.Ability 3.Explosion Mark Stack Increase"_I);
|
|
|
|
|
if(explosionCount==1)std::get<Monster*>(targetPtr)->ProximityKnockback(pos,"Trapper.Ability 3.Explosion Knockback Amount"_F);
|
|
|
|
|
else std::get<Monster*>(targetPtr)->ProximityKnockback(pos,20.f);
|
|
|
|
|
if(explosionCount==1)std::get<Monster*>(targetPtr)->Knockup("Trapper.Ability 3.Explosion Knockup Amount"_F);
|
|
|
|
|
else std::get<Monster*>(targetPtr)->Knockup(0.1f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<Effect>explodeEffect{std::make_unique<Effect>(pos,ANIMATION_DATA["explosionframes.png"].GetTotalAnimationDuration()-0.2f,"explosionframes.png",OnUpperLevel(),scale*2.f,0.2f,vf2d{0,-6.f},WHITE,util::random(2*PI),0.f)};
|
|
|
|
|
explodeEffect->scaleSpd={0.125f,0.125f};
|
|
|
|
|
game->AddEffect(std::move(explodeEffect));
|
|
|
|
|
SoundEffect::PlaySFX("Explosion",pos);
|
|
|
|
|
explosionCount--;
|
|
|
|
|
if(explosionCount>0)rearmTime=0.6f;
|
|
|
|
|
else{
|
|
|
|
|
fadeOutTime=0.5f;
|
|
|
|
|
Deactivate();
|
|
|
|
|
lifetime=0.f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BulletDestroyState ExplosiveTrap::MonsterHit(Monster&monster,const uint8_t markStacksBeforeHit){
|
|
|
|
|
for(int i:std::ranges::iota_view(0,"Trapper.Ability 3.Trap Mark Trigger Count"_I-1)){
|
|
|
|
|
monster.Hurt(0,monster.OnUpperLevel(),monster.GetZ(),HurtFlag::PLAYER_ABILITY);//Triggers mark multiple times after the first mark.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Detonate();
|
|
|
|
|
|
|
|
|
|
return BulletDestroyState::KEEP_ALIVE;
|
|
|
|
|
}
|