Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #textdomain wesnoth-NX-RPG
- #------------------------------------------------------------
- #This macro initiates the roles necessary for the death event
- #to work.
- #------------------------------------------------------------
- #define NX_ROLE_INIT
- [lua]
- code = << for role_counter_b = 6, 9 do
- wesnoth.wml_actions.role( { side = role_counter_b, canrecruit = "yes", role = "boss" } )- 1
- end
- for role_counter_p = 1, 5 do
- wesnoth.wml_actions.role( { side = role_counter_p, canrecruit = "yes", role = "player" } )
- end
- >>
- [/lua]
- [event]
- name=prerecruit
- [filter]
- side=6,7,8,9
- [/filter]
- [role]
- role=recruit
- [/role]
- [/event]
- #enddef
- #------------------------------------------------------------
- #These macros and for initiating variables used in the player
- #death events, such as the number of bosses present, and which
- #ones are alive at a current time.
- #------------------------------------------------------------
- #define NX_PLAYER_MINIBOSS_CHECK SIDE
- [store_unit]
- [filter]
- side={SIDE}
- canrecruit=yes
- [/filter]
- variable=role_check
- [/store_unit]
- {IF_VAR role_check.role equals miniboss (
- [then]
- {TELEPORT_UNIT (
- side={SIDE}
- canrecruit=yes
- ) $miniboss_location.x| $miniboss_location.y|}
- [/then]
- )}
- [unstore_unit]
- variable=role_check
- [/unstore_unit]
- {CLEAR_VARIABLE role_check}
- #enddef
- #define NX_PLAYERS_PRESENT_CHECK SIDE
- [if]
- [have_unit]
- side={SIDE}
- canrecruit=yes
- [/have_unit]
- [then]
- {VARIABLE player[{SIDE}].side.original {SIDE}}
- {VARIABLE player[{SIDE}].side.new O}
- {VARIABLE_OP players_ingame add 1}
- [/then]
- [/if]
- #enddef
- #define NX_DEATHS_VAR_INIT
- [event]
- name=start
- {VARIABLE boss_6_present no}
- {VARIABLE boss_7_present no}
- {VARIABLE boss_8_present no}
- {VARIABLE boss_9_present no}
- {VARIABLE unlock_points_1 0}
- {VARIABLE unlock_points_2 0}
- {VARIABLE unlock_points_3 0}
- {VARIABLE unlock_points_4 0}
- {VARIABLE unlock_points_5 0}
- {VARIABLE players_ingame 0}
- {VARIABLE brutal 0}
- {VARIABLE cornucopia 0}
- {VARIABLE killbonus_0_0 5}
- {VARIABLE killbonus_0_1 10}
- {VARIABLE killbonus_0_2 15}
- {VARIABLE killbonus_0_3 20}
- {VARIABLE killbonus_0_4 25}
- {VARIABLE killbonus_0_5 30}
- {VARIABLE killbonus_1_0 10}
- {VARIABLE killbonus_1_1 20}
- {VARIABLE killbonus_1_2 30}
- {VARIABLE killbonus_1_3 40}
- {VARIABLE killbonus_1_4 50}
- {VARIABLE killbonus_1_5 60}
- {VARIABLE killbonus_2_0 15}
- {VARIABLE killbonus_2_1 30}
- {VARIABLE killbonus_2_2 45}
- {VARIABLE killbonus_2_3 60}
- {VARIABLE killbonus_2_4 75}
- {VARIABLE killbonus_2_5 90}
- # In order that these player_check variable not be changed to
- # default settings they can't be used here. Call them once in
- # a start event in the first scenario.
- [lua]
- code = <<
- local total_bosses = 0
- local current_bosses = 0
- for boss_side = 6, 10 do
- local result = wesnoth.eval_conditional {
- { "have_unit", { canrecruit = "true", side = boss_side } }
- }
- if result == true then
- total_bosses = total_bosses + 1
- current_bosses = current_bosses + 1
- wesnoth.wml_actions.store_starting_location( { side = "boss_side", variable = "boss_location_" .. boss_side } )
- wesnoth.set_variable( string.format( "boss_%d_present", boss_side), true )
- end
- end
- wesnoth.set_variable( "total_bosses_present", total_bosses )
- wesnoth.set_variable( "current_bosses_present", current_bosses )
- >>
- [/lua]
- # Checks if any player is a miniboss. If so, they are teleported
- # to the miniboss starting location.
- {NX_PLAYER_MINIBOSS_CHECK 1}
- {NX_PLAYER_MINIBOSS_CHECK 2}
- {NX_PLAYER_MINIBOSS_CHECK 3}
- {NX_PLAYER_MINIBOSS_CHECK 4}
- {NX_PLAYER_MINIBOSS_CHECK 5}
- [/event]
- #enddef
- #------------------------------------------------------------
- # This macro is used to make a unit, change its team, and heal
- # it. It is used in the death event macro.
- #------------------------------------------------------------
- #define NX_UNIT_SIDE_SWICH SIDE_TO_BE X Y ROLE TEAM_NAME
- [store_unit]
- [filter]
- x,y=$x1|,$y1|
- [/filter]
- variable=unit_died
- [/store_unit]
- [unit]
- x,y={X},{Y}
- type=$unit_died.type|
- side={SIDE_TO_BE}
- name=$unit_died.name|
- role={ROLE}
- moves=$player_died.moves|
- hitpoints=$player_died.max_hitpoints|
- canrecruit=yes
- controller=human
- [/unit]
- [modify_side]
- side=$unit_died.side|
- team_name={TEAM_NAME}
- [/modify_side]
- [heal_unit]
- [filter]
- role={ROLE}
- [/filter]
- amount=full
- [/heal_unit]
- [unstore_unit]
- variable=unit_died
- [/unstore_unit]
- {CLEAR_VARIABLE unit_died}
- #enddef
- #------------------------------------------------------------
- # The first macro is to shorten the code in the following one.
- # The second macro is designed to handle a unit's death. It checks
- # weather that unit was a player or an enemy and executes certain
- # actions based on the result.
- #------------------------------------------------------------
- #define NX_PLAYER_NOT_PRESENT_CHECK SIDE
- [if]
- [not]
- [have_unit]
- side={SIDE}
- canrecrunit=yes
- role=player
- #[filter_wml]
- # team_name=$player_team_name|
- #[/filter_wml]
- [/have_unit]
- [/not]
- [then]
- {VARIABLE player_{SIDE}_present no}
- [/then]
- [/if]
- #enddef
- # Main unit death macros
- #define NX_UNIT_DEATHS
- [event]
- name=die
- first_time_only=no
- [filter]
- side=1,2,3,4,5
- [/filter]
- [store_unit]
- [filter]
- x,y=$x1|,$y1|
- [/filter]
- variable=victim
- [/store_unit]
- [store_unit]
- [filter]
- x,y=$x2|,$y2|
- [/filter]
- variable=killer
- [/store_unit]
- [store_locations]
- [filter]
- side=$victim.side
- [/filter]
- variable=player_location_$victim.side|
- [/store_locations]
- {VARIABLE_OP brutal add 30}
- [if]
- [have_unit]
- canrecruit=yes
- role=player
- [not]
- side=$victim.side
- [/not]
- [/have_unit]
- [then]
- {VARIABLE_OP message_id rand 1..7}
- [switch]
- variable=message_id
- [case]
- value=1
- [message]
- side=$victim.side
- message= _ "Augh...no...I cannot...the..darkness will...take..meeeee..."
- [/message]
- [/case]
- [case]
- value=2
- [message]
- side=$victim.side
- message= _ "Get away from me you foul!...arghh...<i>(groan)</i>"
- [/message]
- [/case]
- [case]
- value=3
- [message]
- side=$victim.side
- message= _ "I have...failed..."
- [/message]
- [/case]
- [case]
- value=4
- [message]
- side=$victim.side
- message= _ "Save...me...I..<i>(groan)</i>...find the...answers!"
- [/message]
- [/case]
- [case]
- value=5
- [message]
- side=$victim.side
- message= _ "NO! We are so close! We cannot fail now..."
- [/message]
- [/case]
- [case]
- value=6
- [message]
- side=$victim.side
- message= _ "The shadows...they call to me...I will..fall..good luck..."
- [/message]
- [/case]
- [case]
- value=7
- [message]
- side=$victim.side
- message= _ "Fight on...friends...we can still...beat our enemy!"
- [/message]
- [/case]
- [/switch]
- {IF_VAR current_bosses_present equals $total_bosses_present| (
- [then]
- [sound]
- name=dragonstick.ogg
- [/sound]
- [print]
- text= _ "$unit.name| REVIVED AS MINI-BOSS"
- size=35
- duration=500
- red,green,blue=255,0,0
- [/print]
- {VARIABLE player[$victim.side|].side.new $victim.side|}
- {NX_UNIT_SIDE_SWICH $unit.side $miniboss_location.x $miniboss_location.y playermb $enemy_team_name|}
- [/then]
- [else]
- {IF_VAR current_bosses_present not_equals $total_bosses_present| (
- [then]
- [sound]
- name=dragonstick.ogg
- [/sound]
- [print]
- text= _ "$unit.name| REVIVED AS BOSS"
- size=35
- duration=500
- red,green,blue=255,0,0
- [/print]
- {IF_VAR boss_6_present equals no (
- [then]
- {VARIABLE player[$victim.side|].side.new 6}
- {VARIABLE player_to_change $side_number}
- {NX_UNIT_SIDE_SWICH 6 $boss_location_6.x| $boss_location_6.y| playerb $enemy_team_name|}
- [/then]
- [else]
- {IF_VAR boss_7_present equals no (
- [then]
- {VARIABLE player[$victim.side|].side.new 7}
- {VARIABLE player_to_change $side_number}
- {NX_UNIT_SIDE_SWICH 7 $boss_location_7.x| $boss_location_7.y| playerb $enemy_team_name|}
- [/then]
- [else]
- {IF_VAR boss_8_present equals no (
- [then]
- {VARIABLE player[$victim.side|].side.new 8}
- {VARIABLE player_to_change $side_number}
- {NX_UNIT_SIDE_SWICH 8 $boss_location_8.x| $boss_location_8.y| playerb $enemy_team_name|}
- [/then]
- [else]
- {IF_VAR boss_9_present equals no (
- [then]
- {VARIABLE player[$victim.side|].side.new 9}
- {VARIABLE player_to_change $side_number}
- {NX_UNIT_SIDE_SWICH 9 $boss_location_9.x| $boss_location_9.y| playerb $enemy_team_name|}
- [/then]
- )}
- [/else]
- )}
- [/else]
- )}
- [/else]
- )}
- [/then]
- )}
- [/else]
- )}
- [/then]
- [else]
- [if]
- [not]
- [have_unit]
- canrecruit=yes
- role=player
- [not]
- side=$victim.side
- [/not]
- [/have_unit]
- [/not]
- [then]
- [message]
- side=$victim.side
- message= _ "I..am alone...My friends...they have fallen...and now...never will we discover...the truth...<i>(augh)</i>"
- [/message]
- [endlevel]
- result=defeat
- [/endlevel]
- [/then]
- [/if]
- [/else]
- [/if]
- [unstore_unit]
- variable=killer
- [/unstore_unit]
- [unstore_unit]
- variable=victim
- [/unstore_unit]
- {CLEAR_VARIABLE killer}
- {CLEAR_VARIABLE victim}
- [/event]
- [event]
- name=die
- [filter]
- side=6,7,8,9
- [store_unit]
- [filter]
- x,y=$x1|,$y1|
- [/filter]
- variable=victim
- [/store_unit]
- [store_unit]
- [filter]
- x,y=$x2|,$y2|
- [/filter]
- variable=killer
- [/store_unit]
- [if]
- {SXCON victim.type equals "Gate"}
- [then]
- [store_locations]
- x,y=$x1,$y1
- variable=door_tile_store
- [/store_locations]
- [if]
- [variable]
- name=door_tile_store[0].terrain
- equals="^Ng/"
- [/variable]
- [or]
- [variable]
- name=door_tile_store[0].terrain
- equals="^Ng\"
- [/variable]
- [/or]
- [then]
- [set_variables]
- name=door_tile_info
- mode=replace
- [split]
- list="$door_tile_store.terrain"
- separator="^"
- [/split]
- [/set_variables]
- [terrain]
- x,y=$x1,$y1
- terrain="$door_tile_info[0].value" # wmllint: ignore
- layer=both
- [/terrain]
- [redraw]
- side=1
- [/redraw]
- {CLEAR_VARIABLE door_tile_info}
- [/then]
- [/if]
- {CLEAR_VARIABLE door_tile_store}
- [/then]
- [/if]
- [if]
- {SXCON victim.role equals playermb}
- [or]
- {SXCON victim.role equals playerb}
- [/or]
- [then]
- {NX_PLAYER_NOT_PRESENT_CHECK 1}
- {NX_PLAYER_NOT_PRESENT_CHECK 2}
- {NX_PLAYER_NOT_PRESENT_CHECK 3}
- {NX_PLAYER_NOT_PRESENT_CHECK 4}
- {NX_PLAYER_NOT_PRESENT_CHECK 5}
- [if]
- [variable]
- name=player_1_present
- equals=no
- [/variable]
- [and]
- [variable]
- name=victim.side
- equals=$player[1].side.new|
- [/variable]
- [/and]
- [then]
- {NX_UNIT_SIDE_SWICH $player[1].side.original| $player_location_1.x| $player_location_1.y| player $player_team_name|}
- [/then]
- [else]
- [if]
- [variable]
- name=player_2_present
- equals=no
- [/variable]
- [and]
- [variable]
- name=victim.side
- equals=$player[2].side.new|
- [/variable]
- [/and]
- [then]
- {NX_UNIT_SIDE_SWICH $player[2].side.original| $player_location_2.x| $player_location_2.y| player $player_team_name|}
- [/then]
- [else]
- [if]
- [variable]
- name=player_3_present
- equals=no
- [/variable]
- [and]
- [variable]
- name=victim.side
- equals=$player[3].side.new|
- [/variable]
- [/and]
- [then]
- {NX_UNIT_SIDE_SWICH $player[3].side.original| $player_location_3.x| $player_location_3.y| player $player_team_name|}
- [/then]
- [else]
- [if]
- [variable]
- name=player_4_present
- equals=no
- [/variable]
- [and]
- [variable]
- name=victim.side
- equals=$player[4].side.new|
- [/variable]
- [/and]
- [then]
- {NX_UNIT_SIDE_SWICH $player[4].side.original| $player_location_4.x| $player_location_4.y| player $player_team_name|}
- [/then]
- [else]
- [if]
- [variable]
- name=player_5_present
- equals=no
- [/variable]
- [and]
- [variable]
- name=victim.side
- equals=$player[5].side.new|
- [/variable]
- [/and]
- [then]
- {NX_UNIT_SIDE_SWICH $player[5].side.original $player_location_5.x| $player_location_5.y| player $player_team_name|}
- [/then]
- [/if]
- [/else]
- [/if]
- [/else]
- [/if]
- [/else]
- [/if]
- [/else]
- [/if]
- [/then]
- [/if]
- [switch]
- variable=victim.role
- [case]
- value="boss", "miniboss"
- {VARIABLE isHero 2}
- [/case]
- [case]
- value="guard"
- {VARIABLE isHero 1}
- [/case]
- [case]
- value="recruit"
- {VARIABLE isHero 0}
- {VARIABLE_OP recruits_$victim.side| sub 1}
- [/case]
- [/switch]
- {VARIABLE bonus $killbonus_$isHero|_$victim.level|}
- {VARIABLE points $victim.level}
- {IF_VAR cornucopia equals 1 (
- [then]
- {VARIABLE_OP bonus multiply 1.2}
- {VARIABLE_OP points multiply 1.2}
- [/then]
- )}
- {VARIABLE killer.moves 4}
- {IF_VAR boosts_$side_number greater_than 1 (
- [then]
- {VARIABLE_OP killer.moves add 1}
- [/then]
- )}
- {VARIABLE killer.attacks_left 1}
- {VARIABLE killer.status.slowed no}
- {VARIABLE i 1}
- [while]
- [variable]
- name=i
- less_than_equal_to=5
- [/variable]
- [do]
- [if]
- [have_unit]
- side=$i|
- canrecruit=yes
- [filter_side]
- team_name=$player_team_name|
- [/filter_side]
- [/have_unit]
- [then]
- [gold]
- amount=$bonus|
- side=$i|
- [/gold]
- [floating_text]
- [filter]
- side=$i|
- role=player
- [/filter]
- text="<span color='#e1e119'>$bonus|</span>"
- [/floating_text]
- {VARIABLE_OP income_$i| add $bonus}
- [/then]
- [/if]
- [sound]
- name=gold.ogg
- [/sound]
- [floating_text]
- [filter]
- side=$killer.side|
- [/filter]
- text="<span color='#e1e119'>$points|</span>"
- [/floating_text]
- {VARIABLE_OP unlock_points_$side_number add $points|}
- [sound]
- name=magic-holy-1.ogg
- [/sound]
- {VARIABLE_OP i add 1}
- [/do]
- [/while]
- [unstore_unit]
- variable=killer
- [/unstore_unit]
- [unstore_unit]
- variable=victim
- [/unstore_unit]
- {CLEAR_VARIABLE i}
- {CLEAR_VARIABLE isHero}
- {CLEAR_VARIABLE killer}
- {CLEAR_VARIABLE victim}
- [/event]
- #enddef
- #NOTES:
- #Some variables such as $miniboss_location are unique to each scenario
- #and therefore should be initiated are the beginning of each one and
- #likewise cleared at the end of each.
- #Fix problem with scenario beginning boss/mini-boss checks. If a scenario
- #has the boss a player became in the previous scenario, then we'll have to
- #get rid of the original one. Likewise if there is no starting position for
- #the side a player is attempting to replace.
Add Comment
Please, Sign In to add comment