Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # TODO: refactor
- #
- # Here is the code for popping up random bandits on village
- # captures.
- [event]
- name=capture
- first_time_only=no
- [if]
- [variable]
- name=unit.side
- numerical_equals=5
- [/variable]
- [then]
- {CLEAR_VARIABLE cleared_$x1|_$y1|_village}
- [/then]
- [else]
- [if]
- [variable]
- name=cleared_$x1|_$y1|_village
- not_equals=yes
- [/variable]
- [then]
- [set_variable]
- name=cleared_$x1|_$y1|_village
- value=yes
- [/set_variable]
- # Compute the number of indigs that will pop up
- [if]
- [variable]
- name=unit.side
- numerical_equals=1
- [/variable]
- [then]
- # The bandit villagers hate dwarves...
- [set_variable]
- name=indigs
- rand=0..2
- [/set_variable]
- [/then]
- [else]
- # ...but they hate orcs much worse.
- [set_variable]
- name=indigs
- rand=2..5
- [/set_variable]
- [/else]
- [/if]
- # Now place the indigs
- [set_variable]
- name=indig_countdown
- value=$indigs
- [/set_variable]
- [while]
- [variable]
- name=indig_countdown
- greater_than=0
- [/variable]
- [do]
- [store_locations]
- [filter_adjacent_location]
- x,y=$x1,$y1
- [/filter_adjacent_location]
- [not]
- [filter]
- [/filter]
- [/not]
- variable=possible_indig_locations
- [/store_locations]
- [if]
- [variable]
- name=possible_indig_locations.length
- greater_than=0
- [/variable]
- [then]
- {VARIABLE_OP random_location_index rand "1..$possible_indig_locations.length"}
- [set_variable]
- name=random_location_index
- sub=1
- [/set_variable]
- {RANDOM (Footpad,Thief,Thug)}
- [unit]
- type=$random
- side=5
- x,y=$possible_indig_locations[$random_location_index].x,$possible_indig_locations[$random_location_index].y
- generate_name=yes
- random_traits=yes
- [/unit]
- [/then]
- [/if]
- [set_variable]
- name=indig_countdown
- sub=1
- [/set_variable]
- [/do]
- [/while]
- {CLEAR_VARIABLE indigs_countdown}
- # Perform appropriate notifications
- [if]
- [variable]
- name=indigs
- greater_than=0
- [/variable]
- [then]
- [message]
- speaker=unit
- message= _ "The villagers are attacking us!"
- [/message]
- [if]
- [variable]
- name=indigs_sighted
- equals=0
- [/variable]
- [then]
- [message]
- speaker=Aiglondur
- message= _ "Aye, it’s still bandit country, right enough."
- [/message]
- [/then]
- [/if]
- [set_variable]
- name=indigs_sighted
- add=1
- [/set_variable]
- [/then]
- [else]
- [if]
- [variable]
- name=indigs_sighted
- greater_than=0
- [/variable]
- [then]
- [message]
- speaker=unit
- message= _ "No bandits in this village."
- [/message]
- [allow_undo]
- [/allow_undo]
- [/then]
- [/if]
- [/else]
- [/if]
- {CLEAR_VARIABLE possible_indig_locations}
- {CLEAR_VARIABLE indigs}
- [/then]
- [else]
- [allow_undo]
- [/allow_undo]
- [/else]
- [/if]
- [/else]
- [/if]
- [/event]
Advertisement
Add Comment
Please, Sign In to add comment