Implement rock toss and stone pillar spawning behaviors for stone elemental. Refactor HurtEnemies functions to instead hurt any target with targeting flags. Fix bug with player to monster collision not respecting new collision radii. Release Build 9318.

This commit is contained in:
2024-05-18 05:04:52 -05:00
parent 177d62af58
commit fa0caa5fa9
26 changed files with 313 additions and 83 deletions
+69 -29
View File
@@ -736,39 +736,79 @@ void AiL::UpdateBullets(float fElapsedTime){
}
std::erase_if(BULLET_LIST,[](std::unique_ptr<Bullet>&b){return b->IsDead();});
}
const MonsterHurtList AiL::HurtEnemies(vf2d pos,float radius,int damage,bool upperLevel,float z)const{
MonsterHurtList hitList;
for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m->GetPos(),12*m->GetSizeMult()))){
HurtReturnValue returnVal=m->Hurt(damage,upperLevel,z);
hitList.push_back({&*m,returnVal});
const HurtList AiL::Hurt(vf2d pos,float radius,int damage,bool upperLevel,float z,const HurtType hurtTargets)const{
HurtList hitList;
const bool CheckForMonsterCollisions=hurtTargets&HurtType::MONSTER;
const bool CheckForPlayerCollisions=hurtTargets&HurtType::PLAYER;
if(CheckForMonsterCollisions){
for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m->GetPos(),12*m->GetSizeMult()))){
HurtReturnValue returnVal=m->Hurt(damage,upperLevel,z);
hitList.push_back({&*m,returnVal});
}
}
}
if(CheckForPlayerCollisions){
if(geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(GetPlayer()->GetPos(),12*GetPlayer()->GetSizeMult()))){
HurtReturnValue returnVal=GetPlayer()->Hurt(damage,upperLevel,z);
hitList.push_back({GetPlayer(),returnVal});
}
}
return hitList;
}
const MonsterHurtList AiL::HurtEnemiesNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z){
MonsterHurtList affectedList;
for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(!hitList.count(&*m)&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m->GetPos(),12*m->GetSizeMult()))){
HurtReturnValue returnVal=m->Hurt(damage,upperLevel,z);
affectedList.push_back({&*m,returnVal});
hitList.insert(&*m);
const HurtList AiL::HurtNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const{
HurtList affectedList;
const bool CheckForMonsterCollisions=hurtTargets&HurtType::MONSTER;
const bool CheckForPlayerCollisions=hurtTargets&HurtType::PLAYER;
if(CheckForMonsterCollisions){
for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(!hitList.count(&*m)&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m->GetPos(),12*m->GetSizeMult()))){
HurtReturnValue returnVal=m->Hurt(damage,upperLevel,z);
affectedList.push_back({&*m,returnVal});
hitList.insert(&*m);
}
}
}
if(CheckForPlayerCollisions){
if(!hitList.count(GetPlayer())&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(GetPlayer()->GetPos(),12*GetPlayer()->GetSizeMult()))){
HurtReturnValue returnVal=GetPlayer()->Hurt(damage,upperLevel,z);
affectedList.push_back({GetPlayer(),returnVal});
hitList.insert(GetPlayer());
}
}
return affectedList;
}
const MonsterHurtList AiL::HurtEnemiesConeNotHit(vf2d pos,float radius,float angle,float sweepAngle,int damage,HitList&hitList,bool upperLevel,float z){
MonsterHurtList affectedList;
for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(!hitList.count(&*m)&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m->GetPos(),12*m->GetSizeMult()))){
float angleToMonster=geom2d::line<float>{pos,m->GetPos()}.vector().polar().y;
float angleDiff=util::angle_difference(angleToMonster,angle);
const HurtList AiL::HurtConeNotHit(vf2d pos,float radius,float angle,float sweepAngle,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const{
HurtList affectedList;
const bool CheckForMonsterCollisions=hurtTargets&HurtType::MONSTER;
const bool CheckForPlayerCollisions=hurtTargets&HurtType::PLAYER;
if(CheckForMonsterCollisions){
for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(!hitList.count(&*m)&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m->GetPos(),12*m->GetSizeMult()))){
float angleToMonster=geom2d::line<float>{pos,m->GetPos()}.vector().polar().y;
float angleDiff=util::angle_difference(angleToMonster,angle);
if(abs(angleDiff)<=sweepAngle){
HurtReturnValue returnVal=m->Hurt(damage,upperLevel,z);
affectedList.push_back({&*m,returnVal});
hitList.insert(&*m);
}
}
}
}
if(CheckForPlayerCollisions){
if(!hitList.count(GetPlayer())&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(GetPlayer()->GetPos(),12*GetPlayer()->GetSizeMult()))){
float angleToPlayer=geom2d::line<float>{pos,GetPlayer()->GetPos()}.vector().polar().y;
float angleDiff=util::angle_difference(angleToPlayer,angle);
if(abs(angleDiff)<=sweepAngle){
HurtReturnValue returnVal=m->Hurt(damage,upperLevel,z);
affectedList.push_back({&*m,returnVal});
hitList.insert(&*m);
HurtReturnValue returnVal=GetPlayer()->Hurt(damage,upperLevel,z);
affectedList.push_back({GetPlayer(),returnVal});
hitList.insert(GetPlayer());
}
}
}
@@ -1339,12 +1379,12 @@ void AiL::RenderWorld(float fElapsedTime){
m->strategyDraw(this,*m,MONSTER_DATA[m->GetName()].GetAIStrategy());
m->Draw();
}
for(const Bullet*const b:bulletsLower){
b->Draw();
}
for(const Effect*const e:backgroundEffectsLower){
e->Draw();
}
for(const Bullet*const b:bulletsLower){
b->Draw();
}
for(const int dropInd:dropsBeforeLower){
ItemDrop::drops[dropInd].Draw();
}
@@ -1587,12 +1627,12 @@ void AiL::RenderWorld(float fElapsedTime){
m->strategyDraw(this,*m,MONSTER_DATA[m->GetName()].GetAIStrategy());
m->Draw();
}
for(const Bullet*const b:bulletsUpper){
b->Draw();
}
for(const Effect*const e:backgroundEffectsUpper){
e->Draw();
}
for(const Bullet*const b:bulletsUpper){
b->Draw();
}
for(const int dropInd:dropsBeforeUpper){
ItemDrop::drops[dropInd].Draw();
}
@@ -1695,7 +1735,7 @@ void AiL::RenderWorld(float fElapsedTime){
#endif
}
Player*AiL::GetPlayer(){
Player*const AiL::GetPlayer()const{
return player.get();
}