Guest User

Untitled

a guest
Feb 18th, 2019
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class VisLinker : Actor {
  2.  
  3. // these should only be purely cosmetic (blocking/solid is ok) actors
  4. // they should not ever move
  5. static const Name classes[] = {
  6.  
  7. "AlienGrass",
  8. "PalmTree1",
  9. "GrassPatch1",
  10. "GrassPatch2",
  11. "ExplosiveBarrel",
  12. "ShortGreenColumn",
  13. "ShortRedColumn",
  14. "SkullColumn",
  15. "Stalagmite",
  16. "Stalagtite",
  17. "TallGreenColumn",
  18. "TallRedColumn",
  19. "TechPillar",
  20. "Backpack",
  21. "CellPack",
  22. "ClipBox",
  23. "Clip",
  24. "RocketAmmo",
  25. "RocketBox",
  26. "ShellBox",
  27. "Shell",
  28. "BigTree",
  29. "TorchTree",
  30. "BigDeadTree",
  31. "Firelight",
  32. "SmallFire"
  33.  
  34. };
  35.  
  36. array<Actor> actors;
  37.  
  38. bool actorsHidden;
  39.  
  40. double playerDistThreshold;
  41. double actorGrabDist;
  42. int checkDelay;
  43. int initDelay;
  44.  
  45. Default {
  46.  
  47. //$Sprite AMRKA0
  48. //$NotAngled
  49. //$Arg0 "Radius (dflt: 1024)"
  50.  
  51. -SOLID;
  52. +NOINTERACTION;
  53. +INVISIBLE;
  54. +SYNCHRONIZED;
  55.  
  56. radius 64;
  57.  
  58. }
  59.  
  60.  
  61. override void PostBeginPlay() {
  62.  
  63. self.actorGrabDist = self.args[0] == 0 ? 1024 : self.args[0];
  64. self.playerDistThreshold = self.actorGrabDist + 2400;
  65.  
  66.  
  67. if (self.tid == 0) {
  68. ChangeTid(FindUniqueTid());
  69. }
  70.  
  71. super.PostBeginPlay();
  72.  
  73. }
  74.  
  75. void Enumerate() {
  76.  
  77. self.actors.Clear();
  78.  
  79. Actor _actor;
  80.  
  81. // Some actors may have NOBLOCKMAP, this is only done once/rarely
  82. ThinkerIterator iter = ThinkerIterator.Create("Actor");
  83.  
  84. while (_actor = Actor(iter.Next())) {
  85.  
  86. if (Distance3D(_actor) <= actorGrabDist) {
  87.  
  88. for (int i = 0; i < classes.size(); i++){
  89.  
  90. if (_actor is classes[i]) {
  91. actors.Push(_actor);
  92. }
  93. }
  94.  
  95. }
  96.  
  97. }
  98.  
  99. Console.printf("VisLinker (" .. self.tid .. ") -- Enumerated " .. actors.size() .. " actors");
  100.  
  101. super.PostBeginPlay();
  102.  
  103. }
  104.  
  105. bool proxCheck () {
  106. // return true;
  107. // return false;
  108. return CheckProximity("PlayerPawn", playerDistThreshold, 1, CPXF_ANCESTOR);
  109.  
  110. }
  111.  
  112. void hide() {
  113.  
  114. Console.printf("VisLinker (" .. self.tid .. ") -- hide ");
  115.  
  116. for (int i = 0; i < actors.size(); i++) {
  117. actors[i].bINVISIBLE = true;
  118. }
  119.  
  120. actorsHidden = true;
  121.  
  122. }
  123.  
  124. void unhide() {
  125.  
  126. Console.printf("VisLinker (" .. self.tid .. ") -- unhide ");
  127.  
  128. for (int i = 0; i < actors.size(); i++) {
  129. actors[i].bINVISIBLE = false;
  130. }
  131.  
  132. actorsHidden = false;
  133.  
  134. }
  135.  
  136. void CheckVis() {
  137.  
  138. if (actorsHidden && proxCheck()) {
  139. unhide();
  140. }
  141.  
  142. else if (!actorsHidden && !proxCheck()) {
  143. hide();
  144. }
  145.  
  146. }
  147.  
  148.  
  149. States {
  150.  
  151. Spawn:
  152. TNT1 A 2;
  153. TNT1 A 0 Enumerate;
  154. Idle:
  155. // stagger checking
  156. TNT1 A random(35, 70) CheckVis;
  157. goto Idle;
  158.  
  159. }
  160.  
  161. }
RAW Paste Data