T S2: refactor/rewrite part 5

This commit is contained in:
Charles Dang 2015-01-15 21:34:50 +11:00
parent 70f560c116
commit fe29dee1a9
2 changed files with 100 additions and 203 deletions

View File

@ -79,6 +79,14 @@
[event]
name=prestart
{VARIABLE lhpu_msg_i 0}
{VARIABLE low_hp_unit_message[0].value ( _ "I hope I have a chance to retreat after this!")}
{VARIABLE low_hp_unit_message[1].value ( _ "One lucky attack by an Orcish Grunt, and Im done for!")}
{VARIABLE low_hp_unit_message[2].value ( _ "Ouch! I could make use of some healing in a village.")}
{VARIABLE low_hp_unit_message[3].value ( _ "I had better retreat, before I get caught out with such low health!")}
[objectives]
side=1
[objective]
@ -598,18 +606,81 @@
[/event]
[event]
name=moveto
name=attack_end
[filter]
side=1
[not]
id=student
[/not]
[/filter]
[filter_condition]
[variable]
name=unit.hitpoints
less_than=19
[/variable]
[variable]
name=unit.hitpoints
greater_than=0
[/variable]
[/filter_condition]
[fire_event]
name=warn_about_units_with_low_health
[primary_unit]
id=$unit.id
[/primary_unit]
[/fire_event]
[/event]
[event]
name=warn_about_units_with_low_health
[message]
speaker=unit
message="$low_hp_unit_message[$lhpu_msg_i].value"
[/message]
{VARIABLE_OP lhpu_msg_i add 1}
[if]
[variable]
name=lhpu_msg_i
equals=3
[/variable]
[then]
{VARIABLE lhpu_msg_i 0}
[/then]
[/if]
[message]
speaker=Galdrad
message= _ "That unit is about one kill (8 experience points) away from gaining a level! Do not let it die!"
[show_if]
[variable]
name=unit.experience
greater_than=$($unit.max_experience - 8)
[/variable]
[/show_if]
[/message]
[/event]
[event]
name=capture
[filter]
id=Thrag
x=5,14,19
y=19,19,23
[/filter]
[filter_condition]
[variable]
name=turn_number
greater_than=1
[/variable]
[/filter_condition]
{TALK_ABOUT Thrag (_"Their leader has moved into that village! Hes not as stupid as I thought. The village heals him each turn and provides good defense.")}
[/event]
[event]
name=moveto
name=capture
[filter]
side=2
x=11,6,11
@ -635,56 +706,17 @@
[event]
name=attack_end
first_time_only=no
[store_unit]
variable=attacker
[filter]
x,y=$x1,$y1
[/filter]
[/store_unit]
[store_unit]
variable=defender
[filter]
x,y=$x2,$y2
[/filter]
[/store_unit]
{DEFENDER_INJURED defender}
{IMPORTANT_UNIT attacker}
[if]
[filter_second]
id=Thrag
[/filter_second]
[filter_condition]
[variable]
name=attacker.id
equals=Thrag
[/variable]
[variable]
name=attacker.hitpoints
name=second_unit.hitpoints
less_than=21
[/variable]
{NUMEQ talk_about_killing_thrag 0}
[then]
{VARIABLE talk_about_killing_thrag 1}
{TALK_ABOUT Thrag (_"You are close to killing their leader! The unit who finishes him will gain 16 experience points because he is second level. Choose your attacking unit carefully!")}
[/then]
[/if]
[/filter_condition]
[if]
[variable]
name=defender.id
equals=Thrag
[/variable]
[variable]
name=defender.hitpoints
less_than=21
[/variable]
{NUMEQ talk_about_killing_thrag 0}
[then]
{VARIABLE talk_about_killing_thrag 1}
{TALK_ABOUT Thrag (_"You are close to killing their leader! The unit who finishes him will gain 16 experience points because he is second level. Choose your attacking unit carefully!")}
[/then]
[/if]
{CLEAR_VARIABLE attacker}
{CLEAR_VARIABLE defender}
{TALK_ABOUT Thrag (_"You are close to killing their leader! The unit who finishes him will gain 16 experience points because he is second level. Choose your attacking unit carefully!")}
[/event]
[event]
@ -712,10 +744,16 @@
equals=male
[/variable]
[then]
{TEACHER (_"We will miss $unit.name| because he had $unit.experience experience points. He would have advanced to second level soon.")}
[message]
speaker=Galdrad
message= _ "We will miss $unit.name| because he had $unit.experience experience points. He would have advanced to second level soon."
[/message]
[/then]
[else]
{TEACHER (_"We will miss $unit.name| because she had $unit.experience experience points. She would have advanced to second level soon.")}
[message]
speaker=Galdrad
message= _ "We will miss $unit.name| because she had $unit.experience experience points. She would have advanced to second level soon."
[/message]
[/else]
[/if]
[/then]
@ -731,10 +769,16 @@
equals=male
[/variable]
[then]
{TEACHER (_"We will miss $unit.name|, but at least he was not one of our experienced troops!")}
[message]
speaker=Galdrad
message= _ "We will miss $unit.name|, but at least he was not one of our experienced troops!"
[/message]
[/then]
[else]
{TEACHER (_"We will miss $unit.name|, but at least she was not one of our experienced troops!")}
[message]
speaker=Galdrad
message= _ "We will miss $unit.name|, but at least she was not one of our experienced troops!"
[/message]
[/else]
[/if]
[/then]
@ -878,5 +922,7 @@
speaker=Galdrad
message= _ "You have beaten the orcs! You may want to try some novice-level campaigns next, such as: <i>The South Guard</i>, <i>An Orcish Incursion</i>, <i>A Tale of Two Brothers</i>, or <i>Heir to the Throne</i>. <i>The South Guard</i> was specifically designed as a beginners campaign. Konrad, Lisar and Delfador are characters from <i>Heir to the Throne</i>. You can also refer to the in-game help browser if you ever need to refresh your memory on gameplay mechanics."
[/message]
{CLEAR_VARIABLE low_hp_unit_message,lhpu_msg_i}
[/event]
[/tutorial]

View File

@ -29,20 +29,6 @@
[/print]
#enddef
#define NUMEQ VAR VALUE
[variable]
name={VAR}
numerical_equals={VALUE}
[/variable]
#enddef
#define BOOLEQ VAR VALUE
[variable]
name={VAR}
boolean_equals={VALUE}
[/variable]
#enddef
#define GENDER MALE_WML FEMALE_WML
[if]
[have_unit]
@ -58,13 +44,6 @@
[/if]
#enddef
#define TEACHER MESSAGE_TEXT
[message]
speaker=Galdrad
message={MESSAGE_TEXT}
[/message]
#enddef
# TODO: decide to use or not
#define NARRATOR CAPTION_TEXT MESSAGE_TEXT
[message]
@ -98,14 +77,6 @@
[/message]
#enddef
#define TALK_NO_MOVE MESSAGE_TEXT
[message]
speaker=Galdrad
scroll=no
message={MESSAGE_TEXT}
[/message]
#enddef
#define TALK_ABOUT_LOC POSITION MESSAGE_TEXT
[scroll_to]
x,y={POSITION}
@ -123,123 +94,3 @@
<big>Click a mouse button or press the spacebar to continue...</big>"
# Note: we would not like the user to "press any key" (for example, Esc)
#enddef
#define IMPORTANT_UNIT NAME
[if]
[variable]
name={NAME}.experience
greater_than=$(${NAME}.max_experience - 8)
[/variable]
[then]
{VARIABLE commented 0}
{FOREACH galdrad_comments i}
[if]
[variable]
name=galdrad_comments[$i].id
equals=${NAME}.id
[/variable]
[then]
{VARIABLE commented 1}
[/then]
[/if]
{NEXT i}
{CLEAR_VARIABLE i}
[if]
{NUMEQ commented 0}
[then]
[store_unit]
[filter]
id=${NAME}.id
[/filter]
variable=galdrad_comments
mode=append
[/store_unit]
{TEACHER (_"That unit is about one kill (8 experience points) away from gaining a level! Do not let it die!")}
[/then]
[/if]
{CLEAR_VARIABLE commented}
[/then]
[/if]
{CLEAR_VARIABLE is_intelligent}
#enddef
#define DEFENDER_INJURED NAME
[if]
{NUMEQ {NAME}.side 1}
[variable]
name={NAME}.hitpoints
less_than=19
[/variable]
[variable]
name={NAME}.hitpoints
greater_than=0
[/variable]
[then]
{VARIABLE complained 0}
# FIXME: If same unit gets attacked twice in same turn, this
# does not seem to find it the second time. Some internal bug?
{FOREACH unit_complained i}
[if]
[variable]
name=unit_complained[$i].id
equals=${NAME}.id
[/variable]
[then]
{VARIABLE complained 1}
[/then]
[/if]
{NEXT i}
[if]
{NUMEQ complained 0}
[then]
[store_unit]
[filter]
id=${NAME}.id
[/filter]
variable=unit_complained
mode=append
[/store_unit]
[if]
{NUMEQ complain_msg 2}
[then]
[message]
speaker=second_unit
message= _"I hope I have a chance to retreat after this!"
[/message]
{VARIABLE_OP complain_msg add 1}
[/then]
[/if]
[if]
{NUMEQ complain_msg 1}
[then]
[message]
speaker=second_unit
message= _"One lucky attack by an Orcish Grunt, and Im done for!"
[/message]
{VARIABLE_OP complain_msg add 1}
[/then]
[/if]
[if]
{NUMEQ complain_msg 0}
[then]
[message]
speaker=second_unit
message= _"Ouch! I could make use of some healing in a village."
[/message]
{VARIABLE_OP complain_msg add 1}
[/then]
[/if]
[/then]
[/if]
{CLEAR_VARIABLE i}
{CLEAR_VARIABLE complained}
{IMPORTANT_UNIT {NAME}}
[/then]
[/if]
#enddef