Extra implementations in phase 2
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
2f54400e8e
commit
1bb87eab23
@ -386,41 +386,6 @@ void Monster::SetSize(float newSize,bool immediate){
|
||||
}
|
||||
}
|
||||
|
||||
float&Monster::GetFloat(Attribute a){
|
||||
if(attributes.count(a)==0){
|
||||
attributes[a]=0.f;
|
||||
}
|
||||
return std::get<float>(attributes[a]);
|
||||
}
|
||||
|
||||
int&Monster::GetInt(Attribute a){
|
||||
if(attributes.count(a)==0){
|
||||
attributes[a]=0;
|
||||
}
|
||||
return std::get<int>(attributes[a]);
|
||||
}
|
||||
|
||||
std::string&Monster::GetString(Attribute a){
|
||||
if(attributes.count(a)==0){
|
||||
attributes[a]="";
|
||||
}
|
||||
return std::get<std::string>(attributes[a]);
|
||||
}
|
||||
|
||||
bool&Monster::GetBool(Attribute a){
|
||||
if(attributes.count(a)==0){
|
||||
attributes[a]=false;
|
||||
}
|
||||
return std::get<bool>(attributes[a]);
|
||||
}
|
||||
|
||||
vf2d&Monster::GetVf2d(Attribute a){
|
||||
if(attributes.count(a)==0){
|
||||
attributes[a]=vf2d{};
|
||||
}
|
||||
return std::get<vf2d>(attributes[a]);
|
||||
}
|
||||
|
||||
void Monster::SetZ(float z){
|
||||
this->z=z;
|
||||
}
|
||||
|
@ -22,4 +22,7 @@ enum class Attribute{
|
||||
RECOVERY_TIME,
|
||||
SHOOT_ANIMATION_TIME,
|
||||
SHOOT_TIMER,
|
||||
JUMP_MOVE_SPD,
|
||||
JUMP_COUNT,
|
||||
CASTING_TIMER,
|
||||
};
|
@ -23,6 +23,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
m.F(A::SHOOT_RING_TIMER)=std::max(0.f,m.F(A::SHOOT_RING_TIMER)-fElapsedTime);
|
||||
m.F(A::SHOOT_RING_DELAY)=std::max(0.f,m.F(A::SHOOT_RING_DELAY)-fElapsedTime);
|
||||
m.F(A::JUMP_LANDING_TIMER)=std::max(0.f,m.F(A::JUMP_LANDING_TIMER)-fElapsedTime);
|
||||
m.F(A::CASTING_TIMER)=std::max(0.f,m.F(A::CASTING_TIMER)-fElapsedTime);
|
||||
|
||||
const auto ShootBulletRing=[&](float angleOffset){
|
||||
int bulletCount=ConfigInt("Phase1.RingBulletCount");
|
||||
@ -47,7 +48,6 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
const auto SpawnMonsterFromConfig=[&](int phase){
|
||||
std::string spawnMonster=ConfigStringArr("Phase"+std::to_string(phase)+".MonsterSpawnOnChange",0);
|
||||
int spawnCount=ConfigIntArr("Phase"+std::to_string(phase)+".MonsterSpawnOnChange",1);
|
||||
|
||||
for(int i=0;i<spawnCount;i++){
|
||||
float randomAngle=util::random(2*PI);
|
||||
vf2d spawnPos=m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12;
|
||||
@ -74,23 +74,24 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
}
|
||||
};
|
||||
|
||||
const auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime){
|
||||
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.F(A::RECOVERY_TIME)=recoveryTime;
|
||||
m.state=State::JUMP;
|
||||
m.F(A::JUMP_MOVE_SPD)=jumpMoveSpd;
|
||||
m.SetState(State::JUMP);
|
||||
};
|
||||
|
||||
if(m.state==State::RECOVERY){
|
||||
if(m.GetState()==State::RECOVERY){
|
||||
m.F(A::RECOVERY_TIME)=std::max(0.f,m.F(A::RECOVERY_TIME)-fElapsedTime);
|
||||
if(m.F(A::RECOVERY_TIME)==0){
|
||||
m.state=State::NORMAL;
|
||||
m.GetState()==State::NORMAL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(m.state==State::JUMP){
|
||||
if(m.GetState()==State::JUMP){
|
||||
float jumpLandingTimerRatio=m.F(A::JUMP_LANDING_TIMER)/m.F(A::JUMP_ORIGINAL_LANDING_TIMER);
|
||||
if(m.GetPos().x>game->GetPlayer()->GetPos().x){
|
||||
m.SetX(std::max(game->GetPlayer()->GetPos().x,m.GetPos().x-ConfigInt("JumpMoveSpd")*game->GetElapsedTime()));
|
||||
@ -139,8 +140,15 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
return;
|
||||
}
|
||||
|
||||
if(m.state==State::CASTING){
|
||||
if(m.GetState()==State::CASTING){
|
||||
m.UpdateAnimation("monsters/Slime King - Cast.png");
|
||||
if(m.F(A::CASTING_TIMER)==0){
|
||||
m.SetState(State::NORMAL);
|
||||
m.I(A::JUMP_COUNT)++;
|
||||
float jumpTime=ConfigFloatArr("Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",0);
|
||||
float jumpSpd=ConfigFloatArr("Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",1);
|
||||
StartJump(jumpTime,game->GetPlayer()->GetPos(),0.2,jumpSpd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -161,7 +169,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"));
|
||||
StartJump(ConfigFloat("Phase1.AirborneTime"),game->GetPlayer()->GetPos(),ConfigFloat("Phase1.LandingRecoveryTime"),ConfigFloat("JumpMoveSpd"));
|
||||
m.I(A::PATTERN_REPEAT_COUNT)=0;
|
||||
return;
|
||||
}
|
||||
@ -204,6 +212,8 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
}
|
||||
if(m.I(A::PATTERN_REPEAT_COUNT)>ConfigInt("Phase2.ShootCount")){
|
||||
m.I(A::PATTERN_REPEAT_COUNT)=0;
|
||||
m.I(A::JUMP_COUNT)=0;
|
||||
m.F(A::CASTING_TIMER)=5;
|
||||
m.SetState(State::CASTING);
|
||||
}
|
||||
}break;
|
||||
|
@ -115,10 +115,10 @@ MonsterStrategy
|
||||
JumpChargeTime = 5.0
|
||||
JumpAfter = 5 shots
|
||||
JumpCount = 3
|
||||
# Delay times per jump in seconds.
|
||||
Jump[1] = 2.0
|
||||
Jump[2] = 0.3
|
||||
Jump[3] = 0.75
|
||||
# Delay times per jump in seconds followed by the move speeds.
|
||||
Jump[1] = 2.0, 75
|
||||
Jump[2] = 0.3, 120
|
||||
Jump[3] = 0.75, 75
|
||||
}
|
||||
Phase3
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user