Add in Procedure stat mechanics and proc chances.

CorrectiveAction
sigonasr2 1 year ago
parent 18e8a02579
commit f365e342a2
  1. 11
      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){
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;
}
}
}

@ -107,6 +107,7 @@ protected:
bool InRange(Unit*target);
bool InRange(vf2d pos);
float reloadTimer=0;
bool attackFailed=false;
bool autoAcquireFriendlyTarget=true;
private:
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