|
|
@ -345,7 +345,7 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std: |
|
|
|
if(reloadTimer>0){ |
|
|
|
if(reloadTimer>0){ |
|
|
|
util::ApplyMatrixEffect(game.GetPGE(),attackingLine,*IMAGES[ATTACKING_LINE],IMAGES[MATRIX]); |
|
|
|
util::ApplyMatrixEffect(game.GetPGE(),attackingLine,*IMAGES[ATTACKING_LINE],IMAGES[MATRIX]); |
|
|
|
float reloadSpd=1.f/(GetAtkSpd()/2.f); |
|
|
|
float reloadSpd=1.f/(GetAtkSpd()/2.f); |
|
|
|
game.DrawPartialRotatedDecal(lineToTarget.upoint(0.5),attackingLine.Decal(),lineToTarget.vector().polar().y,{lineToTarget.length()/2,12},{lineShift*30,0},{lineToTarget.length(),24},{1,1+(reloadTimer/reloadSpd)*0.25f},{attackingLineCol.r,attackingLineCol.g,attackingLineCol.b,uint8_t(IsFriendly()?200:160)}); |
|
|
|
game.DrawPartialRotatedDecal(lineToTarget.upoint(0.5),attackingLine.Decal(),lineToTarget.vector().polar().y,{lineToTarget.length()/2,12},{lineShift*30,0},{lineToTarget.length(),24},{1,1+(attackFailed?-0.3f:(reloadTimer/reloadSpd)*0.25f)},attackFailed?Pixel{192,192,192,130}:Pixel{attackingLineCol.r,attackingLineCol.g,attackingLineCol.b,uint8_t(IsFriendly()?200:160)}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); |
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); |
|
|
@ -564,14 +564,21 @@ void Unit::_Attacked(std::weak_ptr<Unit>attacker){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Unit::_Attack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>finalTarget,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
void Unit::_Attack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>finalTarget,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
if(GetAtkSpd()>0){ |
|
|
|
if(GetProcedure()>0&&GetAtkSpd()>0){ |
|
|
|
Attack(*finalTarget.lock(),otherUnits); |
|
|
|
attackFailed=false; |
|
|
|
finalTarget.lock()->_Attacked(attacker); |
|
|
|
float procChance=float(GetProcedure())/procedure.size; |
|
|
|
reloadTimer=1.f/(GetAtkSpd()/2.f); |
|
|
|
if(util::random(1)>=1-procChance){ |
|
|
|
if(GetCurrentTarget().expired()&&!IsFriendly()){ |
|
|
|
Attack(*finalTarget.lock(),otherUnits); |
|
|
|
if(finalTarget.lock()->IsFriendly()!=IsFriendly()&&CanInteractWithEnemies()){ |
|
|
|
finalTarget.lock()->_Attacked(attacker); |
|
|
|
SetTargetUnit(finalTarget); |
|
|
|
reloadTimer=1.f/(GetAtkSpd()/2.f); |
|
|
|
|
|
|
|
if(GetCurrentTarget().expired()&&!IsFriendly()){ |
|
|
|
|
|
|
|
if(finalTarget.lock()->IsFriendly()!=IsFriendly()&&CanInteractWithEnemies()){ |
|
|
|
|
|
|
|
SetTargetUnit(finalTarget); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
reloadTimer=1.f/(GetAtkSpd()/2.f); |
|
|
|
|
|
|
|
attackFailed=true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|