The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
4.8 KiB
114 lines
4.8 KiB
#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 © 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),Bullet(pos,{},0.f,damage,"Ability Icons/explosive_trap.png",upperLevel,hitsMultiple,lifetime,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(!trapActivated){
|
|
activationWaitTime-=fElapsedTime;
|
|
if(activationWaitTime<=0.f){
|
|
radius=activationRadius;
|
|
animation.ChangeState(internal_animState,"explosive_trap.png");
|
|
SoundEffect::PlaySFX("Beep",pos);
|
|
lastBeepTime=1.f;
|
|
}
|
|
}else{
|
|
automaticDetonationTime-=fElapsedTime;
|
|
lastBeepTime-=fElapsedTime;
|
|
if(lastBeepTime<=0.f){
|
|
SoundEffect::PlaySFX("Beep",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(){
|
|
fadeOutTime=0.5f;
|
|
const HurtList list{game->HurtNotHit(pos,"Trapper.Ability 3.Explosion Radius"_F/100.f*24,damage,hitList,OnUpperLevel(),GetZ(),HurtType::MONSTER,HurtFlag::PLAYER_ABILITY)};
|
|
for(const auto&[targetPtr,wasHit]:list){
|
|
if(wasHit){
|
|
std::get<Monster*>(targetPtr)->ProximityKnockback(pos,"Trapper.Ability 3.Explosion Knockup Amount"_F);
|
|
std::get<Monster*>(targetPtr)->Knockup("Trapper.Ability 3.Explosion Knockup Amount"_F);
|
|
std::get<Monster*>(targetPtr)->ApplyMark("Trapper.Ability 3.Explosion Mark Stack Time"_F,"Trapper.Ability 3.Explosion Mark Stack Increase"_I);
|
|
}
|
|
}
|
|
|
|
game->AddEffect(std::make_unique<Effect>(pos,ANIMATION_DATA["explosionframes.png"].GetTotalAnimationDuration()-0.2f,"explosionframes.png",OnUpperLevel(),scale*2.f,0.2f,vf2d{},WHITE,util::random(2*PI),0.f));
|
|
|
|
Deactivate();
|
|
}
|
|
|
|
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.
|
|
}
|
|
|
|
monster.ProximityKnockback(pos,"Trapper.Ability 3.Explosion Knockup Amount"_F);
|
|
monster.Knockup("Trapper.Ability 3.Explosion Knockup Amount"_F);
|
|
|
|
Detonate();
|
|
|
|
return BulletDestroyState::KEEP_ALIVE;
|
|
} |