Tweak Boar behavior. Fix bug with knockback velocity not being saved when player comes into contact with another monster. Release Build 9019.

mac-build
sigonasr2 10 months ago
parent 64dc8bcf10
commit 5ff64da26a
  1. 12
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 25
      Adventures in Lestoria/Boar.cpp
  3. 1
      Adventures in Lestoria/Buff.h
  4. 11
      Adventures in Lestoria/Monster.cpp
  5. 2
      Adventures in Lestoria/Player.cpp
  6. 2
      Adventures in Lestoria/SettingsWindow.cpp
  7. 2
      Adventures in Lestoria/Version.h
  8. 2
      Adventures in Lestoria/assets/config/MonsterStrategies.txt
  9. 3
      Adventures in Lestoria/olcUTIL_Animate2D.h
  10. BIN
      x64/Release/Adventures in Lestoria.exe

@ -1097,8 +1097,8 @@ void AiL::RenderWorld(float fElapsedTime){
#pragma region Debug Collision boxes
#ifdef _DEBUG
if("debug_collision_boxes"_I){
if(tileSheet.tileset->collision.find(tileSheetIndex)!=tileSheet.tileset->collision.end()){
geom2d::rect<float>collision=tileSheet.tileset->collision[tileSheetIndex].collision;
if(tileSheet.tileset.collision.find(tileSheetIndex)!=tileSheet.tileset.collision.end()){
const geom2d::rect<float>collision=const_cast<TilesetData&>(tileSheet.tileset).collision.at(tileSheetIndex).collision;
view.FillRectDecal(vf2d{float(x),float(y)}*float(GetCurrentMapData().tilewidth)+collision.pos,collision.size,{0,0,0,128});
view.DrawRectDecal(vf2d{float(x),float(y)}*float(GetCurrentMapData().tilewidth)+collision.pos,collision.size,GREY);
}
@ -1128,8 +1128,8 @@ void AiL::RenderWorld(float fElapsedTime){
}
#ifdef _DEBUG
if("debug_collision_boxes"_I){
if(tileSheet.tileset->collision.find(tileSheetIndex)!=tileSheet.tileset->collision.end()){
geom2d::rect<float>collision=tileSheet.tileset->collision[tileSheetIndex].collision;
if(tileSheet.tileset.collision.find(tileSheetIndex)!=tileSheet.tileset.collision.end()){
const geom2d::rect<float>collision=const_cast<TilesetData&>(tileSheet.tileset).collision.at(tileSheetIndex).collision;
view.FillRectDecal(vf2d{float(x),float(y)}*float(GetCurrentMapData().tilewidth)+collision.pos,collision.size,{0,0,0,128});
view.DrawRectDecal(vf2d{float(x),float(y)}*float(GetCurrentMapData().tilewidth)+collision.pos,collision.size,GREY);
}
@ -1448,8 +1448,8 @@ void AiL::RenderWorld(float fElapsedTime){
view.DrawPartialDecal(vi2d{x,y}*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset.tilewidth),float(tileSheet.tileset.tileheight)},tileSheet.tileset.tileset->Decal(),vi2d{tileSheetX,tileSheetY}*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset.tilewidth),float(tileSheet.tileset.tileheight)},{255,255,255,uint8_t(255-bridgeFadeFactor/TileGroup::FADE_TIME*TileGroup::FADE_AMT)});
#ifdef _DEBUG
if("debug_collision_boxes"_I){
if(tileSheet.tileset->collision.find(tileSheetIndex)!=tileSheet.tileset->collision.end()){
geom2d::rect<float>collision=tileSheet.tileset->collision[tileSheetIndex].collision;
if(tileSheet.tileset.collision.find(tileSheetIndex)!=tileSheet.tileset.collision.end()){
const geom2d::rect<float>collision=const_cast<TilesetData&>(tileSheet.tileset).collision.at(tileSheetIndex).collision;
view.FillRectDecal(vf2d{float(x),float(y)}*float(game->GetCurrentMapData().tilewidth)+collision.pos,collision.size,{0,0,0,128});
view.DrawRectDecal(vf2d{float(x),float(y)}*float(game->GetCurrentMapData().tilewidth)+collision.pos,collision.size,GREY);
}

@ -61,26 +61,25 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
case PhaseName::MOVE:{
float distToPlayer=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).length();
if(m.canMove&&distToPlayer>=ConfigInt("Closein Range")/100.f*24){
m.RemoveBuff(BuffType::SLOWDOWN);
m.targetAcquireTimer=0.f;
m.RemoveBuff(BuffType::SELF_INFLICTED_SLOWDOWN);
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
}else
if(m.canMove&&distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
m.AddBuff(BuffType::SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f);
if(m.HasLineOfSight(game->GetPlayer()->GetPos())&&m.canMove&&distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){
m.RemoveBuff(BuffType::SELF_INFLICTED_SLOWDOWN);
m.AddBuff(BuffType::SELF_INFLICTED_SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f);
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(-100);
m.targetAcquireTimer=INFINITY;
if(m.attackedByPlayer)goto ScratchPhaseTransition;
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
}else{
ScratchPhaseTransition:
ScratchPhaseTransition:
m.PerformOtherAnimation(0);
m.F(A::CASTING_TIMER)=ConfigInt("Ground Scratch Count")*m.GetCurrentAnimation().GetTotalAnimationDuration();
m.phase=PhaseName::SCRATCH;
}
}break;
case PhaseName::SCRATCH:{
m.RemoveBuff(BuffType::SLOWDOWN);
m.RemoveBuff(BuffType::SELF_INFLICTED_SLOWDOWN);
m.F(A::CASTING_TIMER)-=fElapsedTime;
if(m.F(A::CASTING_TIMER)<=0.f){
m.PerformShootAnimation();
@ -90,9 +89,16 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
m.target=chargeTargetPoint;
m.AddBuff(BuffType::SPEEDBOOST,INFINITE,ConfigFloat("Charge Movespeed")/100.f-1);
float distanceToChargePoint=geom2d::line<float>(m.GetPos(),chargeTargetPoint).length();
m.F(A::TARGET_TIMER)=distanceToChargePoint/(100.f*m.GetMoveSpdMult()); //This should be how long a charge takes.
m.AddBuff(BuffType::COLLISION_KNOCKBACK_STRENGTH,15,ConfigFloat("Charge Knockback Amount"));
}
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
}break;
case PhaseName::CHARGE:{
m.F(A::TARGET_TIMER)-=fElapsedTime;
float distToTarget=geom2d::line<float>(m.GetPos(),m.target).length();
auto TransitionToRecoveryPhase=[&](){
@ -101,15 +107,16 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
m.PerformIdleAnimation();
};
if(m.bumpedIntoTerrain||distToTarget<4.f){
if(m.F(A::TARGET_TIMER)<=0||m.bumpedIntoTerrain||distToTarget<12.f){
TransitionToRecoveryPhase();
}else{
m.targetAcquireTimer=INFINITY; //Don't acquire a new target.
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
m.PerformShootAnimation();
if(!m.canMove)TransitionToRecoveryPhase();
}
}break;
case PhaseName::RECOVERY:{
m.RemoveBuff(BuffType::COLLISION_KNOCKBACK_STRENGTH);
m.F(A::CHARGE_COOLDOWN)-=fElapsedTime;
m.targetAcquireTimer=0.f;
m.RemoveBuff(BuffType::SPEEDBOOST);

@ -51,6 +51,7 @@ enum BuffType{
BARRIER_DAMAGE_REDUCTION, //Creates a visual barrier around the target
FIXED_COLLISION_DMG, //Does a fixed amount of collision damage based on intensity of this buff.
COLLISION_KNOCKBACK_STRENGTH, //Causes an amount of knockback based on intensity when hit via collision with this buff
SELF_INFLICTED_SLOWDOWN, //Used for monsters and can't be applied by any player abilities.
};
class AiL;

@ -107,6 +107,9 @@ float Monster::GetMoveSpdMult(){
for(Buff&b:GetBuffs(SLOWDOWN)){
mod_moveSpd-=moveSpdPct*b.intensity;
}
for(Buff&b:GetBuffs(SELF_INFLICTED_SLOWDOWN)){
mod_moveSpd-=moveSpdPct*b.intensity;
}
for(Buff&b:GetBuffs(LOCKON_SPEEDBOOST)){
mod_moveSpd+=moveSpdPct*b.intensity;
}
@ -531,6 +534,8 @@ bool Monster::Hurt(int damage,bool onUpperLevel,float z){
}
#pragma endregion
lastHitTimer=0.05f;
attackedByPlayer=true;
if(!IsAlive()){
OnDeath();
@ -621,7 +626,7 @@ void Monster::PathAroundBehavior(float fElapsedTime){
//Move towards the new path.
geom2d::line moveTowardsLine=geom2d::line(pos,path.GetSplinePoint(pathIndex).pos);
if(moveTowardsLine.length()>100*fElapsedTime*GetMoveSpdMult()){
canMove=SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
canMove=SetPos(pos+moveTowardsLine.vector().norm()*100.f*fElapsedTime*GetMoveSpdMult());
UpdateFacingDirection(moveTowardsLine.end);
}else{
if(pathIndex>=path.points.size()-1){
@ -629,7 +634,7 @@ void Monster::PathAroundBehavior(float fElapsedTime){
pathIndex=0;
targetAcquireTimer=0;
}else{
while(moveTowardsLine.length()<100*fElapsedTime*GetMoveSpdMult()){
while(moveTowardsLine.length()<100.f*fElapsedTime*GetMoveSpdMult()){
pathIndex+=0.1f;
moveTowardsLine=geom2d::line(pos,path.GetSplinePoint(pathIndex).pos);
if(pathIndex>=path.points.size()-1){
@ -640,7 +645,7 @@ void Monster::PathAroundBehavior(float fElapsedTime){
}
}
//Try to move to the new determined location.
canMove=SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
canMove=SetPos(pos+moveTowardsLine.vector().norm()*100.f*fElapsedTime*GetMoveSpdMult());
UpdateFacingDirection(moveTowardsLine.end);
}
}

@ -522,7 +522,7 @@ void Player::Update(float fElapsedTime){
m->SetPos(line.rpoint(dist*1.1f));
}
if(m->IsAlive()&&!m->IsNPC()){ //Don't set the knockback if this monster is actually an NPC. Let's just push them around.
vel=line.vector().norm()*-128;
vel+=line.vector().norm()*-128;
}
}
}

@ -59,7 +59,7 @@ INCLUDE_WINDOW_SIZE
using A=Attribute;
#define UNLOCK_ALL_BUTTON
#undef UNLOCK_ALL_BUTTON //Comment out to enable unlock all button.
//#undef UNLOCK_ALL_BUTTON //Comment out to enable unlock all button.
void Menu::InitializeSettingsWindow(){
vf2d windowSize=WINDOW_SIZE-vf2d{28,28};

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 8990
#define VERSION_BUILD 9019
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -549,5 +549,7 @@ MonsterStrategy
Charge Recovery Time = 0.3s
Backpedal Movespeed = 50%
Charge Knockback Amount = 140
}
}

@ -144,6 +144,9 @@ namespace olc::utils::Animate2D
case Style::PingPong:
case Style::Reverse: //These two require twice as much time (minus one frame) to complete a full animation cycle.
return m_vFrames.size()*m_fFrameDuration*2.f-m_fFrameDuration;
default:
ERR(std::format("WARNING! Animation style {} was not found! THIS SHOULD NOT BE HAPPENING!",int(m_nStyle)));
return 0.f;
}
}

Loading…
Cancel
Save