Guest User

Untitled

a guest
Jan 23rd, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.15 KB | None | 0 0
  1. #textdomain wesnoth-NX-RPG
  2.  
  3. #------------------------------------------------------------
  4. #This macro initiates the roles necessary for the death event
  5. #to work.
  6. #------------------------------------------------------------
  7. #define NX_ROLE_INIT
  8. [lua]
  9. code = << for role_counter_b = 6, 9 do
  10. wesnoth.wml_actions.role( { side = role_counter_b, canrecruit = "yes", role = "boss" } )- 1
  11. end
  12. for role_counter_p = 1, 5 do
  13. wesnoth.wml_actions.role( { side = role_counter_p, canrecruit = "yes", role = "player" } )
  14. end
  15. >>
  16. [/lua]
  17. [event]
  18. name=prerecruit
  19. [filter]
  20. side=6,7,8,9
  21. [/filter]
  22. [role]
  23. role=recruit
  24. [/role]
  25. [/event]
  26. #enddef
  27.  
  28. #------------------------------------------------------------
  29. #These macros and for initiating variables used in the player
  30. #death events, such as the number of bosses present, and which
  31. #ones are alive at a current time.
  32. #------------------------------------------------------------
  33. #define NX_PLAYER_MINIBOSS_CHECK SIDE
  34. [store_unit]
  35. [filter]
  36. side={SIDE}
  37. canrecruit=yes
  38. [/filter]
  39. variable=role_check
  40. [/store_unit]
  41.  
  42. {IF_VAR role_check.role equals miniboss (
  43. [then]
  44. {TELEPORT_UNIT (
  45. side={SIDE}
  46. canrecruit=yes
  47. ) $miniboss_location.x| $miniboss_location.y|}
  48. [/then]
  49. )}
  50.  
  51. [unstore_unit]
  52. variable=role_check
  53. [/unstore_unit]
  54.  
  55. {CLEAR_VARIABLE role_check}
  56. #enddef
  57.  
  58. #define NX_PLAYERS_PRESENT_CHECK SIDE
  59. [if]
  60. [have_unit]
  61. side={SIDE}
  62. canrecruit=yes
  63. [/have_unit]
  64. [then]
  65. {VARIABLE player[{SIDE}].side.original {SIDE}}
  66. {VARIABLE player[{SIDE}].side.new O}
  67. {VARIABLE_OP players_ingame add 1}
  68. [/then]
  69. [/if]
  70. #enddef
  71.  
  72. #define NX_DEATHS_VAR_INIT
  73. [event]
  74. name=start
  75. {VARIABLE boss_6_present no}
  76. {VARIABLE boss_7_present no}
  77. {VARIABLE boss_8_present no}
  78. {VARIABLE boss_9_present no}
  79.  
  80. {VARIABLE unlock_points_1 0}
  81. {VARIABLE unlock_points_2 0}
  82. {VARIABLE unlock_points_3 0}
  83. {VARIABLE unlock_points_4 0}
  84. {VARIABLE unlock_points_5 0}
  85.  
  86. {VARIABLE players_ingame 0}
  87. {VARIABLE brutal 0}
  88. {VARIABLE cornucopia 0}
  89. {VARIABLE killbonus_0_0 5}
  90. {VARIABLE killbonus_0_1 10}
  91. {VARIABLE killbonus_0_2 15}
  92. {VARIABLE killbonus_0_3 20}
  93. {VARIABLE killbonus_0_4 25}
  94. {VARIABLE killbonus_0_5 30}
  95. {VARIABLE killbonus_1_0 10}
  96. {VARIABLE killbonus_1_1 20}
  97. {VARIABLE killbonus_1_2 30}
  98. {VARIABLE killbonus_1_3 40}
  99. {VARIABLE killbonus_1_4 50}
  100. {VARIABLE killbonus_1_5 60}
  101. {VARIABLE killbonus_2_0 15}
  102. {VARIABLE killbonus_2_1 30}
  103. {VARIABLE killbonus_2_2 45}
  104. {VARIABLE killbonus_2_3 60}
  105. {VARIABLE killbonus_2_4 75}
  106. {VARIABLE killbonus_2_5 90}
  107.  
  108. # In order that these player_check variable not be changed to
  109. # default settings they can't be used here. Call them once in
  110. # a start event in the first scenario.
  111.  
  112. [lua]
  113. code = <<
  114. local total_bosses = 0
  115. local current_bosses = 0
  116. for boss_side = 6, 10 do
  117. local result = wesnoth.eval_conditional {
  118. { "have_unit", { canrecruit = "true", side = boss_side } }
  119. }
  120. if result == true then
  121. total_bosses = total_bosses + 1
  122. current_bosses = current_bosses + 1
  123. wesnoth.wml_actions.store_starting_location( { side = "boss_side", variable = "boss_location_" .. boss_side } )
  124. wesnoth.set_variable( string.format( "boss_%d_present", boss_side), true )
  125. end
  126. end
  127. wesnoth.set_variable( "total_bosses_present", total_bosses )
  128. wesnoth.set_variable( "current_bosses_present", current_bosses )
  129. >>
  130. [/lua]
  131.  
  132. # Checks if any player is a miniboss. If so, they are teleported
  133. # to the miniboss starting location.
  134.  
  135. {NX_PLAYER_MINIBOSS_CHECK 1}
  136. {NX_PLAYER_MINIBOSS_CHECK 2}
  137. {NX_PLAYER_MINIBOSS_CHECK 3}
  138. {NX_PLAYER_MINIBOSS_CHECK 4}
  139. {NX_PLAYER_MINIBOSS_CHECK 5}
  140. [/event]
  141. #enddef
  142.  
  143. #------------------------------------------------------------
  144. # This macro is used to make a unit, change its team, and heal
  145. # it. It is used in the death event macro.
  146. #------------------------------------------------------------
  147. #define NX_UNIT_SIDE_SWICH SIDE_TO_BE X Y ROLE TEAM_NAME
  148. [store_unit]
  149. [filter]
  150. x,y=$x1|,$y1|
  151. [/filter]
  152. variable=unit_died
  153. [/store_unit]
  154.  
  155. [unit]
  156. x,y={X},{Y}
  157. type=$unit_died.type|
  158. side={SIDE_TO_BE}
  159. name=$unit_died.name|
  160. role={ROLE}
  161. moves=$player_died.moves|
  162. hitpoints=$player_died.max_hitpoints|
  163. canrecruit=yes
  164. controller=human
  165. [/unit]
  166.  
  167. [modify_side]
  168. side=$unit_died.side|
  169. team_name={TEAM_NAME}
  170. [/modify_side]
  171.  
  172. [heal_unit]
  173. [filter]
  174. role={ROLE}
  175. [/filter]
  176. amount=full
  177. [/heal_unit]
  178.  
  179. [unstore_unit]
  180. variable=unit_died
  181. [/unstore_unit]
  182.  
  183. {CLEAR_VARIABLE unit_died}
  184. #enddef
  185.  
  186. #------------------------------------------------------------
  187. # The first macro is to shorten the code in the following one.
  188. # The second macro is designed to handle a unit's death. It checks
  189. # weather that unit was a player or an enemy and executes certain
  190. # actions based on the result.
  191. #------------------------------------------------------------
  192. #define NX_PLAYER_NOT_PRESENT_CHECK SIDE
  193. [if]
  194. [not]
  195. [have_unit]
  196. side={SIDE}
  197. canrecrunit=yes
  198. role=player
  199. #[filter_wml]
  200. # team_name=$player_team_name|
  201. #[/filter_wml]
  202. [/have_unit]
  203. [/not]
  204. [then]
  205. {VARIABLE player_{SIDE}_present no}
  206. [/then]
  207. [/if]
  208. #enddef
  209.  
  210. # Main unit death macros
  211. #define NX_UNIT_DEATHS
  212. [event]
  213. name=die
  214. first_time_only=no
  215. [filter]
  216. side=1,2,3,4,5
  217. [/filter]
  218.  
  219. [store_unit]
  220. [filter]
  221. x,y=$x1|,$y1|
  222. [/filter]
  223. variable=victim
  224. [/store_unit]
  225. [store_unit]
  226. [filter]
  227. x,y=$x2|,$y2|
  228. [/filter]
  229. variable=killer
  230. [/store_unit]
  231. [store_locations]
  232. [filter]
  233. side=$victim.side
  234. [/filter]
  235. variable=player_location_$victim.side|
  236. [/store_locations]
  237.  
  238. {VARIABLE_OP brutal add 30}
  239.  
  240. [if]
  241. [have_unit]
  242. canrecruit=yes
  243. role=player
  244. [not]
  245. side=$victim.side
  246. [/not]
  247. [/have_unit]
  248. [then]
  249. {VARIABLE_OP message_id rand 1..7}
  250. [switch]
  251. variable=message_id
  252. [case]
  253. value=1
  254.  
  255. [message]
  256. side=$victim.side
  257. message= _ "Augh...no...I cannot...the..darkness will...take..meeeee..."
  258. [/message]
  259. [/case]
  260. [case]
  261. value=2
  262.  
  263. [message]
  264. side=$victim.side
  265. message= _ "Get away from me you foul!...arghh...<i>(groan)</i>"
  266. [/message]
  267. [/case]
  268. [case]
  269. value=3
  270.  
  271. [message]
  272. side=$victim.side
  273. message= _ "I have...failed..."
  274. [/message]
  275. [/case]
  276. [case]
  277. value=4
  278.  
  279. [message]
  280. side=$victim.side
  281. message= _ "Save...me...I..<i>(groan)</i>...find the...answers!"
  282. [/message]
  283. [/case]
  284. [case]
  285. value=5
  286.  
  287. [message]
  288. side=$victim.side
  289. message= _ "NO! We are so close! We cannot fail now..."
  290. [/message]
  291. [/case]
  292. [case]
  293. value=6
  294.  
  295. [message]
  296. side=$victim.side
  297. message= _ "The shadows...they call to me...I will..fall..good luck..."
  298. [/message]
  299. [/case]
  300. [case]
  301. value=7
  302.  
  303. [message]
  304. side=$victim.side
  305. message= _ "Fight on...friends...we can still...beat our enemy!"
  306. [/message]
  307. [/case]
  308. [/switch]
  309. {IF_VAR current_bosses_present equals $total_bosses_present| (
  310. [then]
  311. [sound]
  312. name=dragonstick.ogg
  313. [/sound]
  314. [print]
  315. text= _ "$unit.name| REVIVED AS MINI-BOSS"
  316. size=35
  317. duration=500
  318. red,green,blue=255,0,0
  319. [/print]
  320. {VARIABLE player[$victim.side|].side.new $victim.side|}
  321. {NX_UNIT_SIDE_SWICH $unit.side $miniboss_location.x $miniboss_location.y playermb $enemy_team_name|}
  322. [/then]
  323. [else]
  324. {IF_VAR current_bosses_present not_equals $total_bosses_present| (
  325. [then]
  326. [sound]
  327. name=dragonstick.ogg
  328. [/sound]
  329. [print]
  330. text= _ "$unit.name| REVIVED AS BOSS"
  331. size=35
  332. duration=500
  333. red,green,blue=255,0,0
  334. [/print]
  335.  
  336. {IF_VAR boss_6_present equals no (
  337. [then]
  338. {VARIABLE player[$victim.side|].side.new 6}
  339. {VARIABLE player_to_change $side_number}
  340. {NX_UNIT_SIDE_SWICH 6 $boss_location_6.x| $boss_location_6.y| playerb $enemy_team_name|}
  341. [/then]
  342. [else]
  343. {IF_VAR boss_7_present equals no (
  344. [then]
  345. {VARIABLE player[$victim.side|].side.new 7}
  346. {VARIABLE player_to_change $side_number}
  347. {NX_UNIT_SIDE_SWICH 7 $boss_location_7.x| $boss_location_7.y| playerb $enemy_team_name|}
  348. [/then]
  349. [else]
  350. {IF_VAR boss_8_present equals no (
  351. [then]
  352. {VARIABLE player[$victim.side|].side.new 8}
  353. {VARIABLE player_to_change $side_number}
  354. {NX_UNIT_SIDE_SWICH 8 $boss_location_8.x| $boss_location_8.y| playerb $enemy_team_name|}
  355. [/then]
  356. [else]
  357. {IF_VAR boss_9_present equals no (
  358. [then]
  359. {VARIABLE player[$victim.side|].side.new 9}
  360. {VARIABLE player_to_change $side_number}
  361. {NX_UNIT_SIDE_SWICH 9 $boss_location_9.x| $boss_location_9.y| playerb $enemy_team_name|}
  362. [/then]
  363. )}
  364. [/else]
  365. )}
  366. [/else]
  367. )}
  368. [/else]
  369. )}
  370. [/then]
  371. )}
  372. [/else]
  373. )}
  374. [/then]
  375. [else]
  376. [if]
  377. [not]
  378. [have_unit]
  379. canrecruit=yes
  380. role=player
  381. [not]
  382. side=$victim.side
  383. [/not]
  384. [/have_unit]
  385. [/not]
  386. [then]
  387. [message]
  388. side=$victim.side
  389. message= _ "I..am alone...My friends...they have fallen...and now...never will we discover...the truth...<i>(augh)</i>"
  390. [/message]
  391. [endlevel]
  392. result=defeat
  393. [/endlevel]
  394. [/then]
  395. [/if]
  396. [/else]
  397. [/if]
  398.  
  399. [unstore_unit]
  400. variable=killer
  401. [/unstore_unit]
  402. [unstore_unit]
  403. variable=victim
  404. [/unstore_unit]
  405.  
  406. {CLEAR_VARIABLE killer}
  407. {CLEAR_VARIABLE victim}
  408. [/event]
  409.  
  410. [event]
  411. name=die
  412. [filter]
  413. side=6,7,8,9
  414. [store_unit]
  415. [filter]
  416. x,y=$x1|,$y1|
  417. [/filter]
  418. variable=victim
  419. [/store_unit]
  420. [store_unit]
  421. [filter]
  422. x,y=$x2|,$y2|
  423. [/filter]
  424. variable=killer
  425. [/store_unit]
  426.  
  427. [if]
  428. {SXCON victim.type equals "Gate"}
  429. [then]
  430. [store_locations]
  431. x,y=$x1,$y1
  432. variable=door_tile_store
  433. [/store_locations]
  434.  
  435. [if]
  436. [variable]
  437. name=door_tile_store[0].terrain
  438. equals="^Ng/"
  439. [/variable]
  440. [or]
  441. [variable]
  442. name=door_tile_store[0].terrain
  443. equals="^Ng\"
  444. [/variable]
  445. [/or]
  446. [then]
  447. [set_variables]
  448. name=door_tile_info
  449. mode=replace
  450. [split]
  451. list="$door_tile_store.terrain"
  452. separator="^"
  453. [/split]
  454. [/set_variables]
  455.  
  456. [terrain]
  457. x,y=$x1,$y1
  458. terrain="$door_tile_info[0].value" # wmllint: ignore
  459. layer=both
  460. [/terrain]
  461.  
  462. [redraw]
  463. side=1
  464. [/redraw]
  465.  
  466. {CLEAR_VARIABLE door_tile_info}
  467. [/then]
  468. [/if]
  469. {CLEAR_VARIABLE door_tile_store}
  470. [/then]
  471. [/if]
  472.  
  473. [if]
  474. {SXCON victim.role equals playermb}
  475. [or]
  476. {SXCON victim.role equals playerb}
  477. [/or]
  478. [then]
  479. {NX_PLAYER_NOT_PRESENT_CHECK 1}
  480. {NX_PLAYER_NOT_PRESENT_CHECK 2}
  481. {NX_PLAYER_NOT_PRESENT_CHECK 3}
  482. {NX_PLAYER_NOT_PRESENT_CHECK 4}
  483. {NX_PLAYER_NOT_PRESENT_CHECK 5}
  484.  
  485. [if]
  486. [variable]
  487. name=player_1_present
  488. equals=no
  489. [/variable]
  490. [and]
  491. [variable]
  492. name=victim.side
  493. equals=$player[1].side.new|
  494. [/variable]
  495. [/and]
  496. [then]
  497. {NX_UNIT_SIDE_SWICH $player[1].side.original| $player_location_1.x| $player_location_1.y| player $player_team_name|}
  498. [/then]
  499. [else]
  500. [if]
  501. [variable]
  502. name=player_2_present
  503. equals=no
  504. [/variable]
  505. [and]
  506. [variable]
  507. name=victim.side
  508. equals=$player[2].side.new|
  509. [/variable]
  510. [/and]
  511. [then]
  512. {NX_UNIT_SIDE_SWICH $player[2].side.original| $player_location_2.x| $player_location_2.y| player $player_team_name|}
  513. [/then]
  514. [else]
  515. [if]
  516. [variable]
  517. name=player_3_present
  518. equals=no
  519. [/variable]
  520. [and]
  521. [variable]
  522. name=victim.side
  523. equals=$player[3].side.new|
  524. [/variable]
  525. [/and]
  526. [then]
  527. {NX_UNIT_SIDE_SWICH $player[3].side.original| $player_location_3.x| $player_location_3.y| player $player_team_name|}
  528. [/then]
  529. [else]
  530. [if]
  531. [variable]
  532. name=player_4_present
  533. equals=no
  534. [/variable]
  535. [and]
  536. [variable]
  537. name=victim.side
  538. equals=$player[4].side.new|
  539. [/variable]
  540. [/and]
  541. [then]
  542. {NX_UNIT_SIDE_SWICH $player[4].side.original| $player_location_4.x| $player_location_4.y| player $player_team_name|}
  543. [/then]
  544. [else]
  545. [if]
  546. [variable]
  547. name=player_5_present
  548. equals=no
  549. [/variable]
  550. [and]
  551. [variable]
  552. name=victim.side
  553. equals=$player[5].side.new|
  554. [/variable]
  555. [/and]
  556. [then]
  557. {NX_UNIT_SIDE_SWICH $player[5].side.original $player_location_5.x| $player_location_5.y| player $player_team_name|}
  558. [/then]
  559. [/if]
  560. [/else]
  561. [/if]
  562. [/else]
  563. [/if]
  564. [/else]
  565. [/if]
  566. [/else]
  567. [/if]
  568. [/then]
  569. [/if]
  570.  
  571. [switch]
  572. variable=victim.role
  573. [case]
  574. value="boss", "miniboss"
  575.  
  576. {VARIABLE isHero 2}
  577. [/case]
  578. [case]
  579. value="guard"
  580.  
  581. {VARIABLE isHero 1}
  582. [/case]
  583. [case]
  584. value="recruit"
  585.  
  586. {VARIABLE isHero 0}
  587. {VARIABLE_OP recruits_$victim.side| sub 1}
  588. [/case]
  589. [/switch]
  590.  
  591. {VARIABLE bonus $killbonus_$isHero|_$victim.level|}
  592. {VARIABLE points $victim.level}
  593.  
  594. {IF_VAR cornucopia equals 1 (
  595. [then]
  596. {VARIABLE_OP bonus multiply 1.2}
  597. {VARIABLE_OP points multiply 1.2}
  598. [/then]
  599. )}
  600.  
  601. {VARIABLE killer.moves 4}
  602.  
  603. {IF_VAR boosts_$side_number greater_than 1 (
  604. [then]
  605. {VARIABLE_OP killer.moves add 1}
  606. [/then]
  607. )}
  608.  
  609. {VARIABLE killer.attacks_left 1}
  610. {VARIABLE killer.status.slowed no}
  611.  
  612. {VARIABLE i 1}
  613.  
  614. [while]
  615. [variable]
  616. name=i
  617. less_than_equal_to=5
  618. [/variable]
  619. [do]
  620. [if]
  621. [have_unit]
  622. side=$i|
  623. canrecruit=yes
  624. [filter_side]
  625. team_name=$player_team_name|
  626. [/filter_side]
  627. [/have_unit]
  628. [then]
  629. [gold]
  630. amount=$bonus|
  631. side=$i|
  632. [/gold]
  633. [floating_text]
  634. [filter]
  635. side=$i|
  636. role=player
  637. [/filter]
  638. text="<span color='#e1e119'>$bonus|</span>"
  639. [/floating_text]
  640.  
  641. {VARIABLE_OP income_$i| add $bonus}
  642. [/then]
  643. [/if]
  644.  
  645. [sound]
  646. name=gold.ogg
  647. [/sound]
  648.  
  649. [floating_text]
  650. [filter]
  651. side=$killer.side|
  652. [/filter]
  653. text="<span color='#e1e119'>$points|</span>"
  654. [/floating_text]
  655. {VARIABLE_OP unlock_points_$side_number add $points|}
  656.  
  657. [sound]
  658. name=magic-holy-1.ogg
  659. [/sound]
  660.  
  661. {VARIABLE_OP i add 1}
  662. [/do]
  663. [/while]
  664. [unstore_unit]
  665. variable=killer
  666. [/unstore_unit]
  667. [unstore_unit]
  668. variable=victim
  669. [/unstore_unit]
  670.  
  671. {CLEAR_VARIABLE i}
  672. {CLEAR_VARIABLE isHero}
  673. {CLEAR_VARIABLE killer}
  674. {CLEAR_VARIABLE victim}
  675. [/event]
  676. #enddef
  677.  
  678. #NOTES:
  679. #Some variables such as $miniboss_location are unique to each scenario
  680. #and therefore should be initiated are the beginning of each one and
  681. #likewise cleared at the end of each.
  682.  
  683. #Fix problem with scenario beginning boss/mini-boss checks. If a scenario
  684. #has the boss a player became in the previous scenario, then we'll have to
  685. #get rid of the original one. Likewise if there is no starting position for
  686. #the side a player is attempting to replace.
Add Comment
Please, Sign In to add comment