Add in Procedure stat mechanics and proc chances.

CorrectiveAction
sigonasr2 1 year ago
parent 18e8a02579
commit f365e342a2
  1. 23
      olcCodeJam2023Entry/Unit.cpp
  2. 1
      olcCodeJam2023Entry/Unit.h
  3. BIN
      olcCodeJam2023Entry/assets/prc_icon.png
  4. BIN
      olcCodeJam2023Entry/assets/rld_icon.png
  5. BIN
      olcCodeJam2023Entry/assets/rng_icon.png
  6. BIN
      olcCodeJam2023Entry/assets/spd_icon.png

@ -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;
} }
} }
} }

@ -107,6 +107,7 @@ protected:
bool InRange(Unit*target); bool InRange(Unit*target);
bool InRange(vf2d pos); bool InRange(vf2d pos);
float reloadTimer=0; float reloadTimer=0;
bool attackFailed=false;
bool autoAcquireFriendlyTarget=true; bool autoAcquireFriendlyTarget=true;
private: private:
Renderable targetingLine; Renderable targetingLine;

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Loading…
Cancel
Save