Advertisement
Pr0nogo

Untitled

Mar 29th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include "sight_range.h"
  2. #include <SCBW/api.h>
  3.  
  4. const int DEFAULT_SIGHT_RANGE = 4;
  5. const int BLIND_SIGHT_RANGE = 2;
  6. const int MAX_SIGHT_RANGE = 11;
  7.  
  8. namespace hooks {
  9.  
  10. /// Returns the modified sight range of the unit, measured in matrices.
  11. /// StarCraft passes 1 for isForSpellCasting when using Feedback, Mind Control,
  12. /// and Hallucination (but not when launching Nukes).
  13. /// Note: sight ranges cannot exceed 11, unless extended.
  14. /// Equivalent to getUpgradedSightRange @ 004E5B40
  15. u32 getSightRangeHook(CUnit* unit, bool isForSpellCasting) {
  16.  
  17. u32 sightRange;
  18.  
  19. //Check if the unit is a constructing building (exclude remorphing buildings)
  20. if ( unit->status & UnitStatus::GroundedBuilding &&
  21. !(unit->status & UnitStatus::Completed) &&
  22. !unit->isRemorphingBuilding()
  23. )
  24. sightRange = DEFAULT_SIGHT_RANGE;
  25. else
  26. //Check if the unit is blinded (don't bother if this is for spellcasting)
  27. if (!isForSpellCasting && unit->isBlind)
  28. sightRange = BLIND_SIGHT_RANGE;
  29. else
  30. if(unit->id < UnitId::TerranGhost || unit->id > UnitId::ProtossObserver)
  31. sightRange = units_dat::SightRange[unit->id];
  32. else {
  33.  
  34. if(
  35. unit->id == UnitId::TerranGhost &&
  36. UpgradesSc->currentLevel[unit->playerId][UpgradeId::OcularImplants] != 0
  37. )
  38. sightRange = MAX_SIGHT_RANGE;
  39. else
  40. if(
  41. unit->id == UnitId::ZergOverlord &&
  42. UpgradesSc->currentLevel[unit->playerId][UpgradeId::Antennae] != 0
  43. )
  44. sightRange = MAX_SIGHT_RANGE;
  45. else
  46. if(
  47. unit->id == UnitId::ProtossObserver &&
  48. UpgradesSc->currentLevel[unit->playerId][UpgradeId::SensorArray] != 0
  49. )
  50. sightRange = MAX_SIGHT_RANGE;
  51. else
  52. if(
  53. unit->id == UnitId::ProtossScout &&
  54. UpgradesSc->currentLevel[unit->playerId][UpgradeId::ApialSensors] != 0
  55. )
  56. sightRange = MAX_SIGHT_RANGE;
  57. else
  58. sightRange = units_dat::SightRange[unit->id];
  59.  
  60. }
  61.  
  62. return sightRange;
  63.  
  64. }
  65.  
  66. } //hooks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement