Vultraz

Untitled

Sep 13th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. #define APPLY_EXTRA_AMLA_EFFECT _AMLA_ID _ACTIONS
  2. [event]
  3. id="post_advance_" + {_AMLA_ID}
  4. name=post advance
  5. first_time_only=no
  6. [filter]
  7. side=1
  8. role=hero
  9. [/filter]
  10.  
  11. #[store_amlas]
  12. # id=$unit.id
  13. # variable=temp_advancements
  14. #[/store_amlas]
  15.  
  16. {VARIABLE temp_event_id ("post_advance_" + {_AMLA_ID})}
  17.  
  18. # Debug code for manual firing
  19. #[apply_amlas]
  20. # id=Elynia
  21. # [advance]
  22. # id={_AMLA_ID}
  23. # [/advance]
  24. #[/apply_amlas]
  25.  
  26. #[store_unit]
  27. # [filter]
  28. # id=Elynia
  29. # [/filter]
  30. # variable=unit
  31. #[/store_unit]
  32.  
  33. {FOREACH unit.modifications.advance i}
  34. [if]
  35. {VARIABLE_LEXICAL_EQUALS unit.modifications.advance[$i].id {_AMLA_ID}}
  36. #{VARIABLE_BOOLEAN_NOT_EQUALS unit.variables.actions_executed_${_AMLA_ID}| yes}
  37. [then]
  38. #{VARIABLE unit.variables.actions_executed_${_AMLA_ID}| yes}
  39.  
  40. #[lua]
  41. # code = <<
  42. # local set, get = wesnoth.set_variable, wesnoth.get_variable
  43. # set("k", select(2, helper.get_child(get("unit"), "event", get("temp_event_id"))) - 1)
  44. # >>
  45. #[/lua]
  46.  
  47. {VARIABLE k 0}
  48. [while]
  49. {VARIABLE_NUMERICAL_LESS_THAN k $unit.event.length}
  50. {VARIABLE_NUMERICAL_NOT_EQUALS unit.event[$k].id $temp_event_id}
  51. [do]
  52. {VARIABLE_INC k 1}
  53. [/do]
  54. [/while]
  55.  
  56. #{BUG_ON ({VARIABLE_NUMERICAL_EQUALS k $unit.event.length})
  57. #("unit does not carry the amla command controller event!")}
  58.  
  59. {CLEAR_VARIABLE unit.event[$k],k}
  60.  
  61. # Unstore unit before executing actions
  62. [unstore_unit]
  63. variable=unit
  64. find_vacant=no
  65. [/unstore_unit]
  66.  
  67. {_ACTIONS}
  68.  
  69. # Remove this event so it won't trigger again on next advance
  70. [event]
  71. id=$temp_event_id
  72. remove=yes
  73. [/event]
  74.  
  75. {LOG_NX_DBG ("Post-advance commands applied for AMLA '" + {_AMLA_ID} + "'")}
  76. [/then]
  77. [/if]
  78. {NEXT i}
  79.  
  80. {CLEAR_VARIABLE temp_event_id}
  81. [/event]
  82. #enddef
Advertisement
Add Comment
Please, Sign In to add comment