shadowm

Untitled

Sep 22nd, 2011
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1.  
  2. [event]
  3. name=preload
  4. first_time_only=no
  5.  
  6. [lua]
  7. code = <<
  8. function spawn_loyal_player_unit(type_id, loc_x, loc_y)
  9. -- Inelegant, I know, but put_unit() invokes a code path
  10. -- where animate= doesn't have a meaning.
  11. wesnoth.fire("unit", {
  12. x = loc_x,
  13. y = loc_y,
  14. side = 1,
  15. type = type_id,
  16. upkeep = "loyal",
  17. animate = true,
  18. })
  19. end
  20.  
  21. function wesnoth.wml_actions.s9_area_spawns(cfg)
  22. local num_skels = cfg.skeletons or 1
  23. local num_ghosts = cfg.ghosts or 1
  24. local locs = wesnoth.get_locations(cfg)
  25.  
  26. for i = 1, num_skels do
  27. if #locs == 0 then
  28. return
  29. end
  30. local r = safe_random(string.format("1..%d", #locs))
  31. local x, y = locs[r][1], locs[r][2]
  32. spawn_loyal_player_unit("Skeleton", x, y)
  33. table.remove(locs, r)
  34. end
  35.  
  36. for i = 1, num_ghosts do
  37. if #locs == 0 then
  38. return
  39. end
  40. local r = safe_random(string.format("1..%d", #locs))
  41. local x, y = locs[r][1], locs[r][2]
  42. spawn_loyal_player_unit("Ghost", x, y)
  43. table.remove(locs, r)
  44. end
  45. end
  46. >>
  47. [/lua]
  48. [/event]
Advertisement
Add Comment
Please, Sign In to add comment