Phase 1 Bullet shot pattern for Slime King implemented.

pull/28/head
sigonasr2 1 year ago
parent 54e72d088e
commit efdf696d2c
  1. 1
      Crawler/MonsterAttribute.h
  2. 32
      Crawler/SlimeKing.cpp
  3. 2
      Crawler/Version.h
  4. 4
      Crawler/assets/config/MonsterStrategies.txt
  5. 8
      Crawler/utils.cpp
  6. 2
      Crawler/utils.h

@ -12,4 +12,5 @@ enum class Attribute{
SHOOT_RING_DELAY, SHOOT_RING_DELAY,
SHOOT_RING_COUNTER, SHOOT_RING_COUNTER,
SHOOT_RING_RIGHT, SHOOT_RING_RIGHT,
SHOOT_RING_OFFSET,
}; };

@ -10,10 +10,19 @@ INCLUDE_BULLET_LIST
typedef Attribute A; typedef Attribute A;
void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumber){ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumber){
float bulletSpd=ConfigFloat("BulletSpd")/100*24; float bulletSpd=ConfigFloat("BulletSpd")/100*24;
m.F(Attribute::SHOOT_RING_TIMER)=std::max(0.f,m.F(Attribute::SHOOT_RING_TIMER)-fElapsedTime); m.F(A::SHOOT_RING_TIMER)=std::max(0.f,m.F(A::SHOOT_RING_TIMER)-fElapsedTime);
m.F(Attribute::SHOOT_RING_DELAY)=std::max(0.f,m.F(Attribute::SHOOT_RING_DELAY)-fElapsedTime); m.F(A::SHOOT_RING_DELAY)=std::max(0.f,m.F(A::SHOOT_RING_DELAY)-fElapsedTime);
auto ShootBulletRing=[&](float angleOffset){
int bulletCount=ConfigInt("Phase1.RingBulletCount");
for(int i=0;i<bulletCount;i++){
float angle=((2*PI)/bulletCount)*i+angleOffset;
BULLET_LIST.emplace_back(std::make_unique<Bullet>(m.GetPos(),vf2d{cos(angle),sin(angle)}*bulletSpd,6,ConfigInt("ProjectileDamage"),m.OnUpperLevel(),false,YELLOW,vf2d{6,6}));
}
};
switch(m.phase){ switch(m.phase){
case 0:{ case 0:{
@ -28,20 +37,23 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
m.phase=2; m.phase=2;
m.SetSize(ConfigFloat("Phase2.Size")/100,false); m.SetSize(ConfigFloat("Phase2.Size")/100,false);
} }
if(m.GetFloat(Attribute::SHOOT_RING_TIMER)==0){ if(m.F(A::SHOOT_RING_TIMER)==0){
m.I(A::SHOOT_RING_COUNTER)=ConfigInt("Phase1.ShootRingCount")-1; m.I(A::SHOOT_RING_COUNTER)=ConfigInt("Phase1.ShootRingCount")-1;
m.F(A::SHOOT_RING_DELAY)=ConfigFloat("Phase1.ShootRingDelay"); m.F(A::SHOOT_RING_DELAY)=ConfigFloat("Phase1.ShootRingDelay");
int bulletCount=ConfigInt("Phase1.RingBulletCount"); ShootBulletRing(m.F(A::SHOOT_RING_OFFSET));
for(int i=0;i<bulletCount;i++){
float angle=((2*PI)/bulletCount)*i;
BULLET_LIST.emplace_back(std::make_unique<Bullet>(m.GetPos(),vf2d{cos(angle),sin(angle)}*bulletSpd,6,ConfigInt("ProjectileDamage"),m.OnUpperLevel(),false,YELLOW,vf2d{6,6}));
}
m.F(A::SHOOT_RING_TIMER)=ConfigFloat("Phase1.ShootRepeatTime"); m.F(A::SHOOT_RING_TIMER)=ConfigFloat("Phase1.ShootRepeatTime");
m.B(A::SHOOT_RING_RIGHT)=bool(rand()%2); m.B(A::SHOOT_RING_RIGHT)=bool(rand()%2);
} }
if(m.GetInt(Attribute::SHOOT_RING_COUNTER)>0){ if(m.I(A::SHOOT_RING_COUNTER)>0){
if(m.GetFloat(Attribute::SHOOT_RING_DELAY)==0){ if(m.F(A::SHOOT_RING_DELAY)==0){
m.I(A::SHOOT_RING_COUNTER)--; m.I(A::SHOOT_RING_COUNTER)--;
m.F(A::SHOOT_RING_DELAY)=ConfigFloat("Phase1.ShootRingDelay");
if(m.B(A::SHOOT_RING_RIGHT)){
m.F(A::SHOOT_RING_OFFSET)+=util::degToRad(ConfigFloat("Phase1.RingOffset"));
}else{
m.F(A::SHOOT_RING_OFFSET)-=util::degToRad(ConfigFloat("Phase1.RingOffset"));
}
ShootBulletRing(m.F(A::SHOOT_RING_OFFSET));
} }
} }
}break; }break;

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

@ -79,7 +79,7 @@ MonsterStrategy
ProjectileDamage = 10 ProjectileDamage = 10
JumpAttackDamage = 20 JumpAttackDamage = 20
BulletSpd = 150 BulletSpd = 250
Phase1 Phase1
{ {
@ -90,7 +90,7 @@ MonsterStrategy
ShootRingDelay = 0.2 ShootRingDelay = 0.2
RingBulletCount = 16 RingBulletCount = 16
# In degrees. # In degrees.
RingOffset = 10 RingOffset = 10.0
JumpAfter = 4 shots JumpAfter = 4 shots
AirborneTime = 3.0 AirborneTime = 3.0
LandingRingCount = 1 LandingRingCount = 1

@ -6,4 +6,12 @@ float util::random(float range){
vf2d util::pointTo(vf2d posFrom,vf2d posTo){ vf2d util::pointTo(vf2d posFrom,vf2d posTo){
return geom2d::line(posFrom,posTo).vector().norm(); return geom2d::line(posFrom,posTo).vector().norm();
}
float util::degToRad(float deg){
return deg*(PI/180);
}
float util::radToDeg(float rad){
return rad*57.2957795130823208767;
} }

@ -6,4 +6,6 @@ namespace util{
float random(float range); float random(float range);
//Returns a normalized vector pointing from posFrom towards posTo. //Returns a normalized vector pointing from posFrom towards posTo.
vf2d pointTo(vf2d posFrom,vf2d posTo); vf2d pointTo(vf2d posFrom,vf2d posTo);
float degToRad(float deg);
float radToDeg(float rad);
} }
Loading…
Cancel
Save