Rewrote the village bandit code.

This commit is contained in:
Lari Nieminen 2008-12-20 09:47:25 +00:00
parent 20454f5e7c
commit 01c6d802d7

View File

@ -86,17 +86,6 @@
[/ai]
[/side]
#define TRAPMAN TYPE
[unit]
type={TYPE}
side=4
x=$x1
y=$y1
generate_name=yes
random_traits=yes
[/unit]
#enddef
[event]
name=prestart
@ -130,10 +119,7 @@
[event]
name=start
[set_variable]
name=trapdiff
value=1
[/set_variable]
[recall]
id=Dacyn
[/recall]
@ -192,116 +178,255 @@
name=shodranoshown
value=no
[/set_variable]
# mark half of the villages as containing bandits
[store_locations]
terrain=*^V*
variable=all_villages
[/store_locations]
{VARIABLE num_of_bandit_villages $all_villages.length}
{VARIABLE_OP num_of_bandit_villages divide 2}
{REPEAT $num_of_bandit_villages (
{VARIABLE_OP bandit_village_i rand "1..$all_villages.length"}
{VARIABLE_OP bandit_village_i add -1}
[store_locations]
x,y=$all_villages[$bandit_village_i].x,$all_villages[$bandit_village_i].y
[or]
find_in=bandit_villages
[/or]
variable=bandit_villages
[/store_locations]
[store_locations]
find_in=all_villages
[not]
x,y=$all_villages[$bandit_village_i].x,$all_villages[$bandit_village_i].y
[/not]
variable=all_villages
[/store_locations]
)}
{CLEAR_VARIABLE all_villages,bandit_village_i}
[/event]
[event]
name=capture
first_time_only=no
#creates random enemies when you flag a village
[filter]
side=1
[filter_location]
find_in=bandit_villages
[/filter_location]
[/filter]
[store_locations]
find_in=bandit_villages
[not]
x,y=$x1,$y1
[/not]
variable=bandit_villages
[/store_locations]
[store_locations]
x,y=$x1,$y1
[or]
find_in=cleared_villages
[/or]
variable=cleared_villages
[/store_locations]
{VARIABLE_OP bandit_villages_visited add 1}
[message]
speaker=unit
message= _ "They're here!"
[/message]
# 50% chance that the number of bandits will be 1..4 instead of 1..3
{RANDOM 3..4}
{RANDOM 1..$random}
{REPEAT $random (
#ifdef EASY
{VARIABLE_OP new_bandit_type rand "Footpad,Footpad,Poacher,Poacher,Thug,Thug,Thug,Thug,Thief,Thief,Thief,Thief"}
#else
{VARIABLE_OP new_bandit_type rand "Footpad,Footpad,Poacher,Poacher,Thug,Thug,Thug,Thug,Thief,Thief,Thief,Thief,Rogue,Bandit,Outlaw"}
#endif
[store_locations]
[not]
[filter]
[/filter]
[/not]
[and]
x,y=$x1,$y1
radius=1
[/and]
variable=new_bandit_locations
[/store_locations]
[if]
[variable]
name=new_bandit_locations.length
less_than=1
[/variable]
[then]
[store_locations]
[not]
[filter]
[/filter]
[/not]
[and]
x,y=$x1,$y1
radius=2
[/and]
variable=new_bandit_locations
[/store_locations]
[/then]
[/if]
{VARIABLE_OP loc_i rand "1..$new_bandit_locations.length"}
{VARIABLE_OP loc_i add -1}
[move_unit_fake]
x=$x1|,$new_bandit_locations[$loc_i].x
y=$y1|,$new_bandit_locations[$loc_i].y
type=$new_bandit_type
side=4
[/move_unit_fake]
[unit]
x,y=$new_bandit_locations[$loc_i].x,$new_bandit_locations[$loc_i].y
type=$new_bandit_type
side=4
random_traits=yes
generate_name=yes
upkeep=loyal
[/unit]
)}
# the chance of shodano appearing is 100% divided by the number of
# uninvestigated bandit villages remaining, except that it can't happen
# in the first two bandit villages found and is forced to happen not
# later than in the second last bandit village visited
{VARIABLE chance_of_shodano 100}
{VARIABLE_OP chance_of_shodano divide $bandit_villages.length}
{RANDOM "0..100"}
[if]
[and]
[variable]
name=random
less_than=$chance_of_shodano
[/variable]
[or]
[variable]
name=bandit_villages.length
less_than=3
[/variable]
[/or]
[/and]
[variable]
name=shodrano_killed
not_equals=yes
name=bandit_villages_visited
greater_than=2
[/variable]
[then]
{RANDOM 0..10}
[if]
[variable]
name=random
less_than=$trapdiff
[/variable]
[then]
[set_variable]
name=numban
#ifdef EASY
random=0..3
#endif
#ifdef NORMAL
random=1..4
#endif
#ifdef HARD
random=2..5
#endif
[/set_variable]
[set_variable]
name=numban
add=$trapdiff
[/set_variable]
[while]
[variable]
name=numban
greater_than=0
[/variable]
[do]
{RANDOM Footpad,Thug,Thief,Poacher,Thug,Thief,Footpad,Thug,Thief,Poacher,Thug,Thief,Rogue,Bandit}
{TRAPMAN $random}
[set_variable]
name=numban
add=-2
[/set_variable]
[/do]
[/while]
{CLEAR_VARIABLE numban}
[message]
speaker=unit
message= _ "They're here!"
[/message]
#decides if the badguy leader appears
#badguy leader has less chance of appearing early on. (as in 0% chance for first 5 villages. :P)
{RANDOM 4..10}
[if]
[variable]
name=random
greater_than_equal_to=$trapdiff
[/variable]
[or]
[variable]
name=shodranoshown
equals=yes
[/variable]
[/or]
[else]
[unit]
type=Assassin
side=4
x=$x1
y=$y1
id=Shodrano
name= _ "Shodrano"
[/unit]
[set_variable]
name=shodranoshown
value=yes
[/set_variable]
[message]
speaker=Shodrano
message= _ "So, you have found my hiding place. Very well, I guess I will have to kill you!"
[/message]
[message]
speaker=Owaec
message= _ "That's the bandit leader! Kill him, and we will have fulfilled our duty!"
[/message]
[/else]
[/if]
[/then]
[else]
[message]
speaker=unit
message= _ "No outlaws in this village."
[/message]
[/else]
[/if]
[set_variable]
name=trapdiff
add=1
[/set_variable]
[store_locations]
[not]
[filter]
[/filter]
[/not]
[and]
x,y=$x1,$y1
radius=2
[/and]
variable=new_bandit_locations
[/store_locations]
{VARIABLE_OP loc_i rand "1..$new_bandit_locations.length"}
{VARIABLE_OP loc_i add -1}
[move_unit_fake]
x=$x1|,$new_bandit_locations[$loc_i].x
y=$y1|,$new_bandit_locations[$loc_i].y
type=Assassin
side=4
[/move_unit_fake]
[unit]
x,y=$new_bandit_locations[$loc_i].x,$new_bandit_locations[$loc_i].y
type=Assassin
side=4
id=Shodrano
name= _ "Shodrano"
canrecruit=yes
[/unit]
[message]
speaker=Shodrano
message= _ "So, you have found my hiding place. Very well, I guess I will have to kill you!"
[/message]
[message]
speaker=Owaec
message= _ "That's the bandit leader! Kill him, and we will have fulfilled our duty!"
[/message]
[/then]
[/if]
{CLEAR_VARIABLE new_bandit_type,new_bandit_locations}
[/event]
[event]
name=capture
first_time_only=no
[filter]
side=1
[filter_location]
[not]
find_in=bandit_villages
[/not]
[not]
find_in=cleared_villages
[/not]
[/filter_location]
[/filter]
[store_locations]
x,y=$x1,$y1
[or]
find_in=cleared_villages
[/or]
variable=cleared_villages
[/store_locations]
[message]
speaker=unit
message= _ "No outlaws in this village."
[/message]
[/event]
[event]
@ -446,6 +571,12 @@
[/if]
[/event]
[event]
name=victory
{CLEAR_VARIABLE bandit_villages,cleared_villages,bandit_villages_visited}
[/event]
#eternal holy water!
[item]
x=2