Added overrides for playing default animations in move towards and run away scripts. Implemented Bomb Goblin AI. Include convenience methods for proximity knockback functions. Prepped AI functions for the Hawk and Stone Elementals. Release Build 9230.
parent
a4e24b030d
commit
b8e1006901
@ -0,0 +1,94 @@ |
|||||||
|
#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 "util.h" |
||||||
|
#include "AdventuresInLestoria.h" |
||||||
|
#include "BombBoom.h" |
||||||
|
|
||||||
|
INCLUDE_DATA |
||||||
|
INCLUDE_ANIMATION_DATA |
||||||
|
INCLUDE_game |
||||||
|
|
||||||
|
Bomb::Bomb(const vf2d pos,const float z,const float gravity,const float detonationTime,const float bombFadeoutTime,const float bombKnockbackFactor,const vf2d targetPos,const float radius,const int damage,const bool upperLevel,const bool friendly,const Pixel col,const vf2d scale) |
||||||
|
:Bullet(pos,{},radius,damage,"goblin_bomb.png",upperLevel,true,INFINITY,false,friendly,col,scale) |
||||||
|
,gravity(gravity),detonationTime(detonationTime),bombFadeoutTime(bombFadeoutTime),bombKnockbackFactor(bombKnockbackFactor),targetPos(targetPos){ |
||||||
|
this->z=z; |
||||||
|
deactivated=true; |
||||||
|
bomb_animation.AddState("Fuse",ANIMATION_DATA.at("goblin_bomb_fuse.png")); |
||||||
|
bomb_animation.ChangeState(animation,"Fuse"); |
||||||
|
} |
||||||
|
void Bomb::Update(float fElapsedTime){ |
||||||
|
vel=geom2d::line<float>(pos,targetPos).vector(); |
||||||
|
detonationTime-=fElapsedTime; |
||||||
|
bomb_animation.UpdateState(animation,fElapsedTime); |
||||||
|
if(detonationTime>0.f){ |
||||||
|
zVel+=gravity*fElapsedTime; |
||||||
|
z=std::max(0.f,z+zVel*fElapsedTime); |
||||||
|
if(z==0.f)zVel*=-1.f; |
||||||
|
}else |
||||||
|
if(fadeOutTime==0.f){ |
||||||
|
z=0; //Force the bomb to be grounded.
|
||||||
|
fadeOutTime=bombFadeoutTime; |
||||||
|
game->AddEffect(std::make_unique<BombBoom>(pos,0.f,OnUpperLevel(),scale*1.5f/*Upscale 24x24 to 36x36*/,1.f,vf2d{},WHITE,0.f,0.f,true)); |
||||||
|
if(friendly){ |
||||||
|
const MonsterHurtList hurtEnemies=game->HurtEnemies(pos,radius,damage,OnUpperLevel(),z); |
||||||
|
for(auto&[monsterPtr,wasHit]:hurtEnemies){ |
||||||
|
if(wasHit)monsterPtr->ProximityKnockback(pos,bombKnockbackFactor); |
||||||
|
} |
||||||
|
}else{ |
||||||
|
float distToPlayer=geom2d::line<float>(pos,game->GetPlayer()->GetPos()).length(); |
||||||
|
if(distToPlayer<=radius){ |
||||||
|
if(game->GetPlayer()->Hurt(damage,OnUpperLevel(),z)){ |
||||||
|
game->GetPlayer()->ProximityKnockback(pos,bombKnockbackFactor); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
bool Bomb::PlayerHit(Player*player){ |
||||||
|
return false; |
||||||
|
} |
||||||
|
bool Bomb::MonsterHit(Monster&monster){ |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
void Bomb::Draw()const{ |
||||||
|
Bullet::Draw(); |
||||||
|
game->view.DrawPartialRotatedDecal(pos-vf2d{0,GetZ()},bomb_animation.GetFrame(animation).GetSourceImage()->Decal(),rotates?atan2(vel.y,vel.x)-PI/2:0,bomb_animation.GetFrame(animation).GetSourceRect().size/2,bomb_animation.GetFrame(animation).GetSourceRect().pos,bomb_animation.GetFrame(animation).GetSourceRect().size,scale,fadeOutTime==0?col:Pixel{col.r,col.g,col.b,uint8_t(util::lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime)))});
|
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
#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 "Effect.h" |
||||||
|
#include "DEFINES.h" |
||||||
|
#include "safemap.h" |
||||||
|
|
||||||
|
INCLUDE_GFX |
||||||
|
|
||||||
|
class BombBoom:public Effect{ |
||||||
|
public: |
||||||
|
inline BombBoom(vf2d pos,float lifetime,bool upperLevel,vf2d size={1,1},float fadeout=0.0f,vf2d spd={},Pixel col=WHITE,float rotation=0,float rotationSpd=0,bool additiveBlending=false) |
||||||
|
:Effect(pos,lifetime,"bomb_boom.png",upperLevel,size,fadeout,spd,col,rotation,rotationSpd,additiveBlending){} |
||||||
|
|
||||||
|
inline bool Update(float fElapsedTime)override{ |
||||||
|
return Effect::Update(fElapsedTime); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,86 @@ |
|||||||
|
#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 "AdventuresInLestoria.h" |
||||||
|
#include "DEFINES.h" |
||||||
|
#include "Monster.h" |
||||||
|
#include "MonsterStrategyHelpers.h" |
||||||
|
#include "BulletTypes.h" |
||||||
|
#include "util.h" |
||||||
|
|
||||||
|
INCLUDE_ANIMATION_DATA |
||||||
|
INCLUDE_BULLET_LIST |
||||||
|
INCLUDE_game |
||||||
|
|
||||||
|
using A=Attribute; |
||||||
|
|
||||||
|
/*
|
||||||
|
* Attack Strategie:
|
||||||
|
Throws every 4 seconds a bomb on top of the player that detonates after 3.5 seconds in a 300 radius.
|
||||||
|
Tries to keeps his distance on a 600 radius. Throws bombs even while moving. |
||||||
|
*/ |
||||||
|
|
||||||
|
void Monster::STRATEGY::GOBLIN_BOMB(Monster&m,float fElapsedTime,std::string strategy){ |
||||||
|
enum PhaseName{ |
||||||
|
INITIALIZE, |
||||||
|
RUN, |
||||||
|
}; |
||||||
|
|
||||||
|
switch(m.phase){ |
||||||
|
case INITIALIZE:{ |
||||||
|
m.F(A::SHOOT_TIMER)=m.randomFrameOffset; |
||||||
|
m.phase=RUN; |
||||||
|
}break; |
||||||
|
case RUN:{ |
||||||
|
m.F(A::SHOOT_TIMER)+=fElapsedTime; |
||||||
|
m.F(A::SHOOT_ANIMATION_TIME)-=fElapsedTime; |
||||||
|
float distToPlayer=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).length(); |
||||||
|
if(m.F(A::SHOOT_TIMER)>=ConfigFloat("Bomb Reload Time")&&distToPlayer<=ConfigFloat("Bomb Max Range")){ |
||||||
|
vf2d targetThrowPos=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(distToPlayer-ConfigFloat("Bomb Distance Variation")+util::random(ConfigFloat("Bomb Distance Variation")*2.f)); |
||||||
|
CreateBullet(Bomb)(m.GetPos(),ConfigFloat("Bomb Starting Z"),ConfigFloat("Bomb Gravity"),ConfigFloat("Bomb Detonation Time"),ConfigFloat("Bomb Fadeout Time"),ConfigFloat("Bomb Knockback Factor"),targetThrowPos,ConfigFloat("Bomb Radius")/100.f*24,m.GetAttack(),m.OnUpperLevel(),false,WHITE,vf2d{3,3})EndBullet; |
||||||
|
m.UpdateFacingDirection(game->GetPlayer()->GetPos()); |
||||||
|
m.PerformShootAnimation(); |
||||||
|
m.B(A::IGNORE_DEFAULT_ANIMATIONS)=true; |
||||||
|
m.F(A::SHOOT_ANIMATION_TIME)=m.GetCurrentAnimation().GetTotalAnimationDuration(); |
||||||
|
m.F(A::SHOOT_TIMER)=0.f; |
||||||
|
} |
||||||
|
if(m.F(A::SHOOT_ANIMATION_TIME)<0.f)m.B(A::IGNORE_DEFAULT_ANIMATIONS)=false; |
||||||
|
RUN_AWAY(m,fElapsedTime,"Run Away"); |
||||||
|
}break; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
#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 "AdventuresInLestoria.h" |
||||||
|
#include "DEFINES.h" |
||||||
|
#include "Monster.h" |
||||||
|
#include "MonsterStrategyHelpers.h" |
||||||
|
#include "BulletTypes.h" |
||||||
|
|
||||||
|
INCLUDE_ANIMATION_DATA |
||||||
|
INCLUDE_BULLET_LIST |
||||||
|
INCLUDE_game |
||||||
|
|
||||||
|
using A=Attribute; |
||||||
|
|
||||||
|
void Monster::STRATEGY::HAWK(Monster&m,float fElapsedTime,std::string strategy){ |
||||||
|
|
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
#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 "AdventuresInLestoria.h" |
||||||
|
#include "DEFINES.h" |
||||||
|
#include "Monster.h" |
||||||
|
#include "MonsterStrategyHelpers.h" |
||||||
|
#include "BulletTypes.h" |
||||||
|
|
||||||
|
INCLUDE_ANIMATION_DATA |
||||||
|
INCLUDE_BULLET_LIST |
||||||
|
INCLUDE_game |
||||||
|
|
||||||
|
using A=Attribute; |
||||||
|
|
||||||
|
void Monster::STRATEGY::STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string strategy){ |
||||||
|
|
||||||
|
} |
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 708 B |
Binary file not shown.
Loading…
Reference in new issue