Advertisement
Guest User

Untitled

a guest
Feb 4th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. //Attempts to trigger all monsters of the specified type within the specified distance to Sync fire
  2.     void TriggerSync(class<SyncEnabledMonster> targetType, double chance, int maxDist = 2048)
  3.     {
  4.         ThinkerIterator targetFinder = ThinkerIterator.Create(targetType);
  5.         SyncEnabledMonster other;
  6.         while(other = SyncEnabledMonster(targetFinder.Next()))
  7.         {
  8.             if(self == other)
  9.             {
  10.                 continue;
  11.             }
  12.             if(!self.CheckSight(other) || !BabelLib.CoarseDistanceCheck(self, other, maxDist))
  13.             {
  14.                 continue;
  15.             }
  16.             other.SyncFire(self.target, chance);
  17.         }
  18.     }
  19. ...
  20. class SyncEnabledMonster : BabelMonster
  21. {
  22.     //Triggers the monster's MissileNoSignal state if it isn't afraid or holding its state, and succeeds a roll
  23.     void SyncFire(Actor newTarget, double chance = 0)
  24.     {
  25.         if(health > 0)
  26.         {
  27.             if(!holdingState && !isAfraid)
  28.             {
  29.                 if(frandom(0.0, 100.0) <= chance)
  30.                 {
  31.                     if(newTarget != null && newTarget.GetSpecies() != self.GetSpecies())
  32.                         self.target = newTarget;
  33.                     else
  34.                         return;
  35.                     if(checksLOF && (!self.CheckIfTargetInLOS() || !self.CheckLOF()))
  36.                         return;
  37.                     if(checksLOS && !self.CheckIfTargetInLOS())
  38.                         return;
  39.                     DisplayComboEffect();
  40.                     SetState(ResolveState("MissileNoSignal"));
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement