Vultraz

Untitled

Feb 2nd, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.89 KB | None | 0 0
  1. # TODO: refactor
  2. #
  3. # Here is the code for popping up random bandits on village
  4. # captures.
  5. [event]
  6. name=capture
  7. first_time_only=no
  8. [if]
  9. [variable]
  10. name=unit.side
  11. numerical_equals=5
  12. [/variable]
  13. [then]
  14. {CLEAR_VARIABLE cleared_$x1|_$y1|_village}
  15. [/then]
  16. [else]
  17. [if]
  18. [variable]
  19. name=cleared_$x1|_$y1|_village
  20. not_equals=yes
  21. [/variable]
  22. [then]
  23. [set_variable]
  24. name=cleared_$x1|_$y1|_village
  25. value=yes
  26. [/set_variable]
  27. # Compute the number of indigs that will pop up
  28. [if]
  29. [variable]
  30. name=unit.side
  31. numerical_equals=1
  32. [/variable]
  33. [then]
  34. # The bandit villagers hate dwarves...
  35. [set_variable]
  36. name=indigs
  37. rand=0..2
  38. [/set_variable]
  39. [/then]
  40. [else]
  41. # ...but they hate orcs much worse.
  42. [set_variable]
  43. name=indigs
  44. rand=2..5
  45. [/set_variable]
  46. [/else]
  47. [/if]
  48. # Now place the indigs
  49. [set_variable]
  50. name=indig_countdown
  51. value=$indigs
  52. [/set_variable]
  53. [while]
  54. [variable]
  55. name=indig_countdown
  56. greater_than=0
  57. [/variable]
  58. [do]
  59. [store_locations]
  60. [filter_adjacent_location]
  61. x,y=$x1,$y1
  62. [/filter_adjacent_location]
  63.  
  64. [not]
  65. [filter]
  66. [/filter]
  67. [/not]
  68.  
  69. variable=possible_indig_locations
  70. [/store_locations]
  71.  
  72. [if]
  73. [variable]
  74. name=possible_indig_locations.length
  75. greater_than=0
  76. [/variable]
  77. [then]
  78. {VARIABLE_OP random_location_index rand "1..$possible_indig_locations.length"}
  79. [set_variable]
  80. name=random_location_index
  81. sub=1
  82. [/set_variable]
  83. {RANDOM (Footpad,Thief,Thug)}
  84. [unit]
  85. type=$random
  86. side=5
  87. x,y=$possible_indig_locations[$random_location_index].x,$possible_indig_locations[$random_location_index].y
  88. generate_name=yes
  89. random_traits=yes
  90. [/unit]
  91. [/then]
  92. [/if]
  93. [set_variable]
  94. name=indig_countdown
  95. sub=1
  96. [/set_variable]
  97. [/do]
  98. [/while]
  99. {CLEAR_VARIABLE indigs_countdown}
  100. # Perform appropriate notifications
  101. [if]
  102. [variable]
  103. name=indigs
  104. greater_than=0
  105. [/variable]
  106. [then]
  107. [message]
  108. speaker=unit
  109. message= _ "The villagers are attacking us!"
  110. [/message]
  111. [if]
  112. [variable]
  113. name=indigs_sighted
  114. equals=0
  115. [/variable]
  116. [then]
  117. [message]
  118. speaker=Aiglondur
  119. message= _ "Aye, it’s still bandit country, right enough."
  120. [/message]
  121. [/then]
  122. [/if]
  123. [set_variable]
  124. name=indigs_sighted
  125. add=1
  126. [/set_variable]
  127. [/then]
  128. [else]
  129. [if]
  130. [variable]
  131. name=indigs_sighted
  132. greater_than=0
  133. [/variable]
  134. [then]
  135. [message]
  136. speaker=unit
  137. message= _ "No bandits in this village."
  138. [/message]
  139.  
  140. [allow_undo]
  141. [/allow_undo]
  142. [/then]
  143. [/if]
  144. [/else]
  145. [/if]
  146. {CLEAR_VARIABLE possible_indig_locations}
  147. {CLEAR_VARIABLE indigs}
  148. [/then]
  149.  
  150. [else]
  151. [allow_undo]
  152. [/allow_undo]
  153. [/else]
  154. [/if]
  155. [/else]
  156. [/if]
  157. [/event]
Advertisement
Add Comment
Please, Sign In to add comment