Remove dependency of MonsterAttribute in Monster header to avoid long recompiles. Fix distance snapping on slime king jumps.

pull/28/head
sigonasr2 1 year ago
parent de04905983
commit caddaefb02
  1. 2
      Crawler/DEFINES.h
  2. 1
      Crawler/Monster.cpp
  3. 4
      Crawler/Monster.h
  4. 3
      Crawler/MonsterAttribute.h
  5. 47
      Crawler/SlimeKing.cpp
  6. 1
      Crawler/Turret.cpp
  7. 2
      Crawler/Version.h
  8. 7
      Crawler/assets/config/MonsterStrategies.txt

@ -16,6 +16,8 @@
#define ACCESS_PLAYER Player*p=game->GetPlayer();
#define VARIANTS float,int,std::string,bool,vf2d
#define INFINITE 999999
#define SETUP_CLASS(class) \

@ -7,6 +7,7 @@
#include "safemap.h"
#include "MonsterStrategyHelpers.h"
#include "utils.h"
#include "MonsterAttribute.h"
INCLUDE_ANIMATION_DATA
INCLUDE_MONSTER_DATA

@ -5,12 +5,14 @@
#include "Buff.h"
#include "olcUTIL_Animate2D.h"
#include "DamageNumber.h"
#include "DEFINES.h"
#include <variant>
#include "MonsterAttribute.h"
struct Player;
class Crawler;
enum class Attribute;
enum MonsterAnimation{
IDLE,
JUMP,

@ -1,5 +1,4 @@
#pragma once
#define VARIANTS float,int,std::string,bool,vf2d
#include <string>
#define F(attr) GetFloat(attr)
#define I(attr) GetInt(attr)
@ -25,7 +24,7 @@ enum class Attribute{
JUMP_MOVE_SPD,
JUMP_COUNT,
CASTING_TIMER,
TELEPORT_TO_PLAYER,
RUN_AWAY_TIMER,
PHASE_REPEAT_COUNT,
JUMP_TOWARDS_PLAYER,
};

@ -6,6 +6,7 @@
#include "safemap.h"
#include "Effect.h"
#include "FallingDebris.h"
#include "MonsterAttribute.h"
INCLUDE_game
INCLUDE_BULLET_LIST
@ -15,8 +16,6 @@ INCLUDE_MONSTER_NAME_DATA
typedef Attribute A;
void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumber){
float bulletSpd=ConfigFloat("BulletSpd")/100*24;
m.F(A::SHOOT_TIMER)=std::max(0.f,m.F(A::SHOOT_TIMER)-fElapsedTime);
@ -76,13 +75,22 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
}
};
const auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime,float jumpMoveSpd,bool teleportToPlayer=false){
const auto StartJumpTowardsPlayer=[&](float jumpDuration,float recoveryTime,float jumpMoveSpd){
m.V(A::JUMP_ORIGINAL_POS)=m.GetPos();
m.F(A::JUMP_ORIGINAL_LANDING_TIMER)=m.F(A::JUMP_LANDING_TIMER)=jumpDuration;
m.B(A::JUMP_TOWARDS_PLAYER)=true;
m.F(A::RECOVERY_TIME)=recoveryTime;
m.F(A::JUMP_MOVE_SPD)=jumpMoveSpd;
m.SetState(State::JUMP);
};
const auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime,float jumpMoveSpd){
m.V(A::JUMP_ORIGINAL_POS)=m.GetPos();
m.F(A::JUMP_ORIGINAL_LANDING_TIMER)=m.F(A::JUMP_LANDING_TIMER)=jumpDuration;
m.V(A::JUMP_TARGET_POS)=targetPos;
m.B(A::JUMP_TOWARDS_PLAYER)=false;
m.F(A::RECOVERY_TIME)=recoveryTime;
m.F(A::JUMP_MOVE_SPD)=jumpMoveSpd;
m.B(A::TELEPORT_TO_PLAYER)=teleportToPlayer;
m.SetState(State::JUMP);
};
@ -95,8 +103,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
m.I(A::JUMP_COUNT)++;
float jumpTime=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",0);
float jumpSpd=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",1);
bool jumpTeleport=bool(ConfigIntArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",2));
StartJump(jumpTime,game->GetPlayer()->GetPos(),0.2,jumpSpd,jumpTeleport);
StartJumpTowardsPlayer(jumpTime,0.2,jumpSpd);
}break;
default:{
m.PerformIdleAnimation();
@ -124,17 +131,21 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
if(m.GetState()==State::JUMP){
float jumpLandingTimerRatio=m.F(A::JUMP_LANDING_TIMER)/m.F(A::JUMP_ORIGINAL_LANDING_TIMER);
if(m.GetPos().x>m.V(A::JUMP_TARGET_POS).x){
m.SetX(std::max(m.V(A::JUMP_TARGET_POS).x,m.GetPos().x-m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
vf2d jumpTargetPos=m.V(A::JUMP_TARGET_POS);
if(m.B(A::JUMP_TOWARDS_PLAYER)){
jumpTargetPos=game->GetPlayer()->GetPos();
}
if(m.GetPos().x>jumpTargetPos.x){
m.SetX(std::max(jumpTargetPos.x,m.GetPos().x-m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
} else
if(m.GetPos().x<m.V(A::JUMP_TARGET_POS).x){
m.SetX(std::min(m.V(A::JUMP_TARGET_POS).x,m.GetPos().x+m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
if(m.GetPos().x<jumpTargetPos.x){
m.SetX(std::min(jumpTargetPos.x,m.GetPos().x+m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
}
if(m.GetPos().y>m.V(A::JUMP_TARGET_POS).y){
m.SetY(std::max(m.V(A::JUMP_TARGET_POS).y,m.GetPos().y-m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
m.SetY(std::max(jumpTargetPos.y,m.GetPos().y-m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
} else
if(m.GetPos().y<m.V(A::JUMP_TARGET_POS).y){
m.SetY(std::min(m.V(A::JUMP_TARGET_POS).y,m.GetPos().y+m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
m.SetY(std::min(jumpTargetPos.y,m.GetPos().y+m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
}
if(m.F(A::JUMP_LANDING_TIMER)>=m.F(A::JUMP_ORIGINAL_LANDING_TIMER)/2){
m.SetZ(util::lerp(0,ConfigInt("JumpHeight"),1-jumpLandingTimerRatio));
@ -165,10 +176,6 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
m.SetStrategyDrawFunction([](Crawler*game){});
} else
if(m.F(A::JUMP_LANDING_TIMER)<=ConfigFloat("JumpWarningIndicatorTime")){
if(m.B(A::TELEPORT_TO_PLAYER)){
m.B(A::TELEPORT_TO_PLAYER)=false;
m.SetPos(game->GetPlayer()->GetPos());
}
m.SetStrategyDrawFunction([&](Crawler*game){
Decal*dec=ANIMATION_DATA["range_indicator.png"].GetFrame(game->GetElapsedTime()).GetSourceImage()->Decal();
game->view.DrawRotatedDecal(m.GetPos(),dec,0,dec->sprite->Size()/2,vf2d{m.GetSizeMult(),m.GetSizeMult()},RED);
@ -184,7 +191,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
m.I(A::JUMP_COUNT)++;
float jumpTime=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",0);
float jumpSpd=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",1);
StartJump(jumpTime,game->GetPlayer()->GetPos(),0.2,jumpSpd);
StartJumpTowardsPlayer(jumpTime,0.2,jumpSpd);
}
return;
}
@ -206,7 +213,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
}
if(m.F(A::SHOOT_RING_TIMER)==0){
if(m.I(A::PATTERN_REPEAT_COUNT)>=ConfigInt("Phase1.JumpAfter")){
StartJump(ConfigFloat("Phase1.AirborneTime"),game->GetPlayer()->GetPos(),ConfigFloat("Phase1.LandingRecoveryTime"),ConfigFloat("JumpMoveSpd"));
StartJumpTowardsPlayer(ConfigFloat("Phase1.AirborneTime"),ConfigFloat("Phase1.LandingRecoveryTime"),ConfigFloat("JumpMoveSpd"));
m.I(A::PATTERN_REPEAT_COUNT)=0;
return;
}
@ -258,12 +265,12 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
if(m.hp<=m.maxhp*ConfigFloat("Phase4.Change")/100){
m.phase=4;
m.SetSize(ConfigFloat("Phase4.Size")/100,false);
m.AddBuff(BuffType::SLOWDOWN,9999999,ConfigFloat("Phase4.MoveSpdModifier")/100);
m.AddBuff(BuffType::SLOWDOWN,99999,ConfigFloat("Phase4.MoveSpdModifier")/100);
TransitionPhase(m.phase);
return;
}
if(m.I(A::PATTERN_REPEAT_COUNT)==0){
StartJump(ConfigFloat("Phase3.JumpDelayTime"),game->GetPlayer()->GetPos(),ConfigFloat("Phase3.JumpRecoveryTime"),ConfigFloat("Phase3.JumpMoveSpd"));
StartJumpTowardsPlayer(ConfigFloat("Phase3.JumpDelayTime"),ConfigFloat("Phase3.JumpRecoveryTime"),ConfigFloat("Phase3.JumpMoveSpd"));
m.I(A::PATTERN_REPEAT_COUNT)++;
}else
if(m.I(A::PATTERN_REPEAT_COUNT)<4&&m.F(A::SHOOT_TIMER)==0){

@ -3,6 +3,7 @@
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "MonsterAttribute.h"
typedef Attribute A;

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 1400
#define VERSION_BUILD 1407
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -118,10 +118,9 @@ MonsterStrategy
# Argument 0 is jump time.
# Argument 1 is move speed.
# Argument 2 is whether to teleport to the player or not (0=Don't Teleport, 1=Teleport)
Jump[1] = 2.0, 75, 0
Jump[2] = 0.3, 300, 1
Jump[3] = 1.2, 70, 0
Jump[1] = 2.0, 75
Jump[2] = 0.3, 850
Jump[3] = 1.2, 70
}
Phase3
{

Loading…
Cancel
Save