Add collision intangibility for monsters with a collision radius of zero. Add unit test to check for it. Release Build 11714.
This commit is contained in:
parent
e0644fe809
commit
446be1e02f
@ -532,7 +532,25 @@ namespace MonsterTests
|
|||||||
Game::Update(1.f);
|
Game::Update(1.f);
|
||||||
parrot.Hurt(parrot.GetMaxHealth(),parrot.OnUpperLevel(),parrot.GetZ());
|
parrot.Hurt(parrot.GetMaxHealth(),parrot.OnUpperLevel(),parrot.GetZ());
|
||||||
Assert::IsTrue(parrot.IsUnconscious(),L"Parrot should now be unconscious.");
|
Assert::IsTrue(parrot.IsUnconscious(),L"Parrot should now be unconscious.");
|
||||||
|
}
|
||||||
|
TEST_METHOD(MonsterCollisionRadiusTest){
|
||||||
|
Monster&parrot{game->SpawnMonster({},MONSTER_DATA.at("Parrot"))};
|
||||||
|
Game::Update(1.f);
|
||||||
|
Game::Update(1.f);
|
||||||
|
Assert::AreEqual(parrot.GetOriginalCollisionRadius(),parrot.GetCollisionRadius(),L"Parrot collision radius should be normal.");
|
||||||
|
|
||||||
|
Assert::AreEqual(int(game->GetPlayer()->GetMaxHealth()-parrot.GetCollisionDamage()),game->GetPlayer()->GetHealth(),L"Player should take collision damage from the parrot.");
|
||||||
|
parrot.SetCollisionRadius(0.f);
|
||||||
|
Assert::AreEqual(0.f,parrot.GetCollisionRadius(),L"Parrot collision radius should now be zero.");
|
||||||
|
game->GetPlayer()->Heal(game->GetPlayer()->GetMaxHealth());
|
||||||
|
game->GetPlayer()->_SetIframes(0.f);
|
||||||
|
parrot.SetPos({});
|
||||||
|
game->GetPlayer()->ForceSetPos({});
|
||||||
|
Game::Update(1.f);
|
||||||
|
Assert::AreEqual(game->GetPlayer()->GetMaxHealth(),game->GetPlayer()->GetHealth(),L"Player should be full health.");
|
||||||
|
parrot.SetCollisionRadius(parrot.GetOriginalCollisionRadius());
|
||||||
|
Game::Update(1.f);
|
||||||
|
Assert::AreEqual(int(game->GetPlayer()->GetMaxHealth()-parrot.GetCollisionDamage()),game->GetPlayer()->GetHealth(),L"Player should take collision damage from the parrot.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1560,7 +1560,7 @@ std::optional<std::weak_ptr<Monster>>Monster::GetNearestMonster(const vf2d point
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool Monster::InUndamageableState(const bool onUpperLevel,const float z)const{
|
const bool Monster::InUndamageableState(const bool onUpperLevel,const float z)const{
|
||||||
return Invulnerable()||!IsAlive()||onUpperLevel!=OnUpperLevel()||AttackAvoided(z)||IsNPC();
|
return Invulnerable()||!IsAlive()||onUpperLevel!=OnUpperLevel()||AttackAvoided(z)||IsNPC()||GetCollisionRadius()<=0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monster::AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){
|
void Monster::AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){
|
||||||
|
@ -635,7 +635,7 @@ void Player::Update(float fElapsedTime){
|
|||||||
for(std::shared_ptr<Monster>&m:MONSTER_LIST){
|
for(std::shared_ptr<Monster>&m:MONSTER_LIST){
|
||||||
const float playerRadius{12*GetSizeMult()/2};
|
const float playerRadius{12*GetSizeMult()/2};
|
||||||
const float monsterRadius{m->GetCollisionRadius()};
|
const float monsterRadius{m->GetCollisionRadius()};
|
||||||
if(!HasIframes()&&abs(m->GetZ()-GetZ())<=1&&OnUpperLevel()==m->OnUpperLevel()&&geom2d::overlaps(geom2d::circle(pos,playerRadius),geom2d::circle(m->GetPos(),monsterRadius))){
|
if(!HasIframes()&&abs(m->GetZ()-GetZ())<=1&&OnUpperLevel()==m->OnUpperLevel()&&monsterRadius>0.f&&geom2d::overlaps(geom2d::circle(pos,playerRadius),geom2d::circle(m->GetPos(),monsterRadius))){
|
||||||
if(m->IsAlive()){
|
if(m->IsAlive()){
|
||||||
m->Collision(this);
|
m->Collision(this);
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,14 @@ void Monster::STRATEGY::SANDWORM(Monster&m,float fElapsedTime,std::string strate
|
|||||||
switch(PHASE()){
|
switch(PHASE()){
|
||||||
case INITIALIZE:{
|
case INITIALIZE:{
|
||||||
SETPHASE(UNDERGROUND);
|
SETPHASE(UNDERGROUND);
|
||||||
|
const float randomRange=util::random_range(0,ConfigFloat("Burrow Target Range")/100.f*24);
|
||||||
|
m.V(A::LOCKON_POS)=game->GetPlayer()->GetPos()+vf2d{randomRange,util::random(2*PI)}.cart();
|
||||||
}break;
|
}break;
|
||||||
case UNDERGROUND:{
|
case UNDERGROUND:{
|
||||||
m.SetCollisionRadius(0.f);
|
m.SetCollisionRadius(0.f);
|
||||||
|
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||||
|
m.PerformAnimation("SWIM",m.GetFacingDirection());
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 11711
|
#define VERSION_BUILD 11714
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -1121,7 +1121,8 @@ MonsterStrategy
|
|||||||
}
|
}
|
||||||
Sandworm
|
Sandworm
|
||||||
{
|
{
|
||||||
|
# Furthest distance sandworm travels from the player while burrowing.
|
||||||
|
Burrow Target Range = 400
|
||||||
}
|
}
|
||||||
Pirate Buccaneer
|
Pirate Buccaneer
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user