Advertisement
maat7043

EnterPortal.txt

Feb 12th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. ;----------------------------------
  2. ; Enter Nearest Portal by maat70432/11/2014
  3. ;----------------------------------
  4. ; NAMES TO UPDATE
  5. ;
  6. #set fullfunctionname "com.company.assembleegameclient.objects:Player/ClosestPortal_" ; the full function name
  7. #set functionname "ClosestPortal_" ; the function name
  8. ;----------------------------------
  9. ; CODE
  10. ;----------------------------------
  11. trait method QName(PackageNamespace(""), $"functionname");
  12. method
  13. refid $"fullfunctionname"
  14. returns QName(PackageNamespace(""), "void")
  15. body
  16. maxstack 16
  17. localcount 16
  18. initscopedepth 16
  19. maxscopedepth 18
  20. code
  21. getlocal0
  22. pushscope
  23.  
  24. ; Set current object to null
  25. pushnull
  26. coerce QName(PackageNamespace("com.company.assembleegameclient.objects"), "GameObject")
  27. setlocal 4
  28.  
  29. ; Set considered object to null
  30. pushnull
  31. coerce QName(PackageNamespace("com.company.assembleegameclient.objects"), "GameObject")
  32. setlocal 7
  33.  
  34. ; Set current target distance to 0
  35. pushbyte 0
  36. setlocal 8
  37.  
  38. ; Set Considered Taget distance to 0
  39. pushbyte 0
  40. setlocal 9
  41.  
  42. ; used for hasnext2 function
  43. pushbyte 0
  44. setlocal 5
  45.  
  46. ; Get Array of all object within range
  47. getlex QName(PackageNamespace(""), "map_")
  48. getproperty QName(PackageNamespace(""), "goDict_")
  49. coerce_a
  50. setlocal 6
  51.  
  52. jump NEXTOBJ
  53.  
  54. L34:
  55. ; Get current gameobject.property from the Array
  56. label
  57. getlocal 6
  58. getlocal 5
  59. nextvalue
  60. coerce QName(PackageNamespace("com.company.assembleegameclient.objects"), "GameObject")
  61. dup
  62. setlocal 4
  63.  
  64. ; Use the first instance of loc4 to check to see if object is a portal
  65. getlex QName(PackageNamespace("com.company.assembleegameclient.objects"), "Portal")
  66. istypelate
  67. iffalse NEXTOBJ
  68.  
  69. ; Set XML ID of the Portal
  70. getlocal 4
  71. getproperty QName(PackageNamespace(""), "props_")
  72. getproperty QName(PackageNamespace(""), "id_")
  73. setlocal 14
  74.  
  75. ; Dungeons to avoid
  76. getlocal 14
  77. pushstring "Pirate Cave Portal"
  78. ifeq NEXTOBJ
  79.  
  80. ; Priority Dungeons
  81. getlocal 14
  82. pushstring "Ocean Trench Portal"
  83. ifeq ENTER
  84.  
  85. getlocal 14
  86. pushstring "Tomb of the Ancients Portal"
  87. ifeq ENTER
  88.  
  89. getlocal 14
  90. pushstring "Wine Cellar Portal"
  91. ifeq ENTER
  92.  
  93. ; Distance from player to portal
  94. getlex QName(PackageNamespace(""), "Math")
  95. getlocal 4
  96. getproperty QName(PackageNamespace(""), "y_")
  97. getlex QName(PackageNamespace(""), "y_")
  98. subtract
  99. dup
  100. multiply
  101. getlocal 4
  102. getproperty QName(PackageNamespace(""), "x_")
  103. getlex QName(PackageNamespace(""), "x_")
  104. subtract
  105. dup
  106. multiply
  107. add
  108. callproperty QName(PackageNamespace(""), "sqrt"), 1
  109. dup
  110. setlocal 9
  111.  
  112. ; Check to see if Current portal is null
  113. getlocal 8
  114. pushbyte 0
  115. ifeq REPLACE
  116.  
  117. ; Check to see if new distance is lower that
  118. getlocal 8
  119. getlocal 9
  120. iflt REPLACE
  121.  
  122. jump NEXTOBJ
  123.  
  124. REPLACE:
  125. getlocal 9
  126. setlocal 8
  127.  
  128. setlocal 4
  129. setlocal 7
  130.  
  131. NEXTOBJ:
  132. ; Check to see if there is more objects within range
  133. hasnext2 6, 5 ; loc6 is your object you are check against and loc5 is your enumerator variable
  134. iftrue L34
  135.  
  136. kill 6
  137. kill 5
  138.  
  139. ENTER:
  140. ; Check to see if Portal is Locked
  141. ; getlocal 7
  142. ; getproperty QName(PackageNamespace("", "#0"), "_-0Ks")
  143. ; pushtrue
  144. ; ifeq END
  145.  
  146. ; Enter Portal
  147. getlocal0
  148. getlocal 7
  149. callpropvoid QName(PackageNamespace("", "#0"), "usePortal"), 1
  150.  
  151. END:
  152. returnvoid
  153. end ; code
  154. end ; body
  155. end ; method
  156. end ; trait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement