|
|
|
@ -303,7 +303,17 @@ void Monster::Draw(){ |
|
|
|
|
vf2d shadowScale=vf2d{8*GetSizeMult()/3.f,1}/std::max(1.f,GetZ()/24); |
|
|
|
|
game->view.DrawDecal(GetPos()-vf2d{3,3}*shadowScale/2+vf2d{0,6*GetSizeMult()},GFX["circle.png"].Decal(),shadowScale,BLACK); |
|
|
|
|
} |
|
|
|
|
game->view.DrawPartialRotatedDecal(GetPos()-vf2d{0,GetZ()},GetFrame().GetSourceImage()->Decal(),spriteRot,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,vf2d(GetSizeMult()*(GetFacingDirection()==RIGHT?-1:1),GetSizeMult()),GetBuffs(BuffType::SLOWDOWN).size()>0?Pixel{uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(128+127*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration)))}:WHITE); |
|
|
|
|
Pixel blendCol=GetBuffs(BuffType::SLOWDOWN).size()>0?Pixel{uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(128+127*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration)))}:WHITE; |
|
|
|
|
|
|
|
|
|
game->view.DrawPartialRotatedDecal(GetPos()-vf2d{0,GetZ()},GetFrame().GetSourceImage()->Decal(),spriteRot,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,vf2d(GetSizeMult()*(GetFacingDirection()==RIGHT?-1:1),GetSizeMult()),blendCol); |
|
|
|
|
if(overlaySprite.length()!=0){ |
|
|
|
|
game->view.DrawPartialRotatedDecal(GetPos()-vf2d{0,GetZ()},GFX[overlaySprite].Decal(),spriteRot,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,vf2d(GetSizeMult()*(GetFacingDirection()==RIGHT?-1:1),GetSizeMult()),{blendCol.r,blendCol.g,blendCol.b,overlaySpriteTransparency});
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<Buff>shieldBuffs=GetBuffs(BARRIER_DAMAGE_REDUCTION); |
|
|
|
|
if(shieldBuffs.size()>0){ |
|
|
|
|
game->view.DrawRotatedDecal(GetPos()-vf2d{0,GetZ()},GFX["block.png"].Decal(),0.f,GFX["block.png"].Sprite()->Size()/2,{GetSizeMult(),GetSizeMult()}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#pragma region Debug Pathfinding |
|
|
|
|
#ifdef _DEBUG |
|
|
|
@ -439,9 +449,8 @@ bool Monster::Hurt(int damage,bool onUpperLevel,float z){ |
|
|
|
|
} |
|
|
|
|
#pragma endregion |
|
|
|
|
|
|
|
|
|
for(Buff&b:GetBuffs(BuffType::DAMAGE_REDUCTION)){ |
|
|
|
|
mod_dmg-=damage*b.intensity; |
|
|
|
|
} |
|
|
|
|
mod_dmg-=mod_dmg*GetDamageReductionFromBuffs(); |
|
|
|
|
|
|
|
|
|
mod_dmg=std::ceil(mod_dmg); |
|
|
|
|
hp=std::max(0,hp-int(mod_dmg)); |
|
|
|
|
|
|
|
|
@ -567,9 +576,9 @@ void Monster::PathAroundBehavior(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<Buff>Monster::GetBuffs(BuffType buff){ |
|
|
|
|
std::vector<Buff>Monster::GetBuffs(BuffType buff)const{ |
|
|
|
|
std::vector<Buff>filteredBuffs; |
|
|
|
|
std::copy_if(buffList.begin(),buffList.end(),std::back_inserter(filteredBuffs),[buff](Buff&b){return b.type==buff;}); |
|
|
|
|
std::copy_if(buffList.begin(),buffList.end(),std::back_inserter(filteredBuffs),[buff](const Buff&b){return b.type==buff;}); |
|
|
|
|
return filteredBuffs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -690,4 +699,15 @@ void Monster::RotateTowardsPos(const vf2d&targetPos){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#pragma endregion |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const float Monster::GetDamageReductionFromBuffs()const{ |
|
|
|
|
float dmgReduction=0; |
|
|
|
|
for(const Buff&b:GetBuffs(BuffType::DAMAGE_REDUCTION)){ |
|
|
|
|
dmgReduction+=b.intensity; |
|
|
|
|
} |
|
|
|
|
for(const Buff&b:GetBuffs(BuffType::BARRIER_DAMAGE_REDUCTION)){ |
|
|
|
|
dmgReduction+=b.intensity; |
|
|
|
|
} |
|
|
|
|
return std::min(1.0f,dmgReduction); |
|
|
|
|
} |