|
|
|
@ -345,7 +345,7 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std: |
|
|
|
|
if(reloadTimer>0){ |
|
|
|
|
util::ApplyMatrixEffect(game.GetPGE(),attackingLine,*IMAGES[ATTACKING_LINE],IMAGES[MATRIX]); |
|
|
|
|
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(); |
|
|
|
@ -564,7 +564,10 @@ 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){ |
|
|
|
|
if(GetAtkSpd()>0){ |
|
|
|
|
if(GetProcedure()>0&&GetAtkSpd()>0){ |
|
|
|
|
attackFailed=false; |
|
|
|
|
float procChance=float(GetProcedure())/procedure.size; |
|
|
|
|
if(util::random(1)>=1-procChance){ |
|
|
|
|
Attack(*finalTarget.lock(),otherUnits); |
|
|
|
|
finalTarget.lock()->_Attacked(attacker); |
|
|
|
|
reloadTimer=1.f/(GetAtkSpd()/2.f); |
|
|
|
@ -573,6 +576,10 @@ void Unit::_Attack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>finalTarget,st |
|
|
|
|
SetTargetUnit(finalTarget); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
reloadTimer=1.f/(GetAtkSpd()/2.f); |
|
|
|
|
attackFailed=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|