Monster spawning now adds to a queue to prevent memory adjustment corruption while inside of monster update functions.
Monster spawning on phase transition now occurs.
This commit is contained in:
+47
-3
@@ -10,6 +10,7 @@
|
||||
INCLUDE_game
|
||||
INCLUDE_BULLET_LIST
|
||||
INCLUDE_ANIMATION_DATA
|
||||
INCLUDE_MONSTER_NAME_DATA
|
||||
|
||||
typedef Attribute A;
|
||||
|
||||
@@ -22,7 +23,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
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);
|
||||
|
||||
auto ShootBulletRing=[&](float angleOffset){
|
||||
const auto ShootBulletRing=[&](float angleOffset){
|
||||
int bulletCount=ConfigInt("Phase1.RingBulletCount");
|
||||
for(int i=0;i<bulletCount;i++){
|
||||
float angle=((2*PI)/bulletCount)*i+angleOffset;
|
||||
@@ -30,13 +31,48 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
}
|
||||
};
|
||||
|
||||
auto Landed=[&ShootBulletRing,&m](int currentPhase){
|
||||
const auto Landed=[&ShootBulletRing,&m](int currentPhase){
|
||||
if(currentPhase==1){
|
||||
ShootBulletRing(m.F(A::SHOOT_RING_OFFSET));
|
||||
}
|
||||
};
|
||||
|
||||
auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime){
|
||||
const auto TransitionPhase=[&](int newPhase){
|
||||
switch(newPhase){
|
||||
case 2:{
|
||||
std::string spawnMonster=ConfigStringArr("Phase2.MonsterSpawnOnChange",0);
|
||||
int spawnCount=ConfigIntArr("Phase2.MonsterSpawnOnChange",1);
|
||||
|
||||
for(int i=0;i<spawnCount;i++){
|
||||
float randomAngle=util::random(2*PI);
|
||||
game->SpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]);
|
||||
}
|
||||
}break;
|
||||
case 3:{
|
||||
std::string spawnMonster=ConfigStringArr("Phase3.MonsterSpawnOnChange",0);
|
||||
int spawnCount=ConfigIntArr("Phase3.MonsterSpawnOnChange",1);
|
||||
|
||||
for(int i=0;i<spawnCount;i++){
|
||||
float randomAngle=util::random(2*PI);
|
||||
game->SpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]);
|
||||
}
|
||||
}break;
|
||||
case 4:{
|
||||
std::string spawnMonster=ConfigStringArr("Phase4.MonsterSpawnOnChange",0);
|
||||
int spawnCount=ConfigIntArr("Phase4.MonsterSpawnOnChange",1);
|
||||
|
||||
for(int i=0;i<spawnCount;i++){
|
||||
float randomAngle=util::random(2*PI);
|
||||
game->SpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]);
|
||||
}
|
||||
}break;
|
||||
case 5:{
|
||||
|
||||
}break;
|
||||
}
|
||||
};
|
||||
|
||||
const auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime){
|
||||
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;
|
||||
@@ -112,6 +148,8 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
if(m.hp<=m.maxhp*ConfigFloat("Phase2.Change")/100){
|
||||
m.phase=2;
|
||||
m.SetSize(ConfigFloat("Phase2.Size")/100,false);
|
||||
TransitionPhase(m.phase);
|
||||
return;
|
||||
}
|
||||
if(m.F(A::SHOOT_RING_TIMER)==0){
|
||||
if(m.I(A::PATTERN_REPEAT_COUNT)>=ConfigInt("Phase1.JumpAfter")){
|
||||
@@ -143,18 +181,24 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
|
||||
if(m.hp<=m.maxhp*ConfigFloat("Phase3.Change")/100){
|
||||
m.phase=3;
|
||||
m.SetSize(ConfigFloat("Phase3.Size")/100,false);
|
||||
TransitionPhase(m.phase);
|
||||
return;
|
||||
}
|
||||
}break;
|
||||
case 3:{
|
||||
if(m.hp<=m.maxhp*ConfigFloat("Phase4.Change")/100){
|
||||
m.phase=4;
|
||||
m.SetSize(ConfigFloat("Phase4.Size")/100,false);
|
||||
TransitionPhase(m.phase);
|
||||
return;
|
||||
}
|
||||
}break;
|
||||
case 4:{
|
||||
if(m.hp<=0){
|
||||
m.phase=5;
|
||||
m.F(A::IFRAME_TIME_UPON_HIT)=1;
|
||||
TransitionPhase(m.phase);
|
||||
return;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user