Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [event]
- name=preload
- first_time_only=no
- [lua]
- code = <<
- function spawn_loyal_player_unit(type_id, loc_x, loc_y)
- -- Inelegant, I know, but put_unit() invokes a code path
- -- where animate= doesn't have a meaning.
- wesnoth.fire("unit", {
- x = loc_x,
- y = loc_y,
- side = 1,
- type = type_id,
- upkeep = "loyal",
- animate = true,
- })
- end
- function wesnoth.wml_actions.s9_area_spawns(cfg)
- local num_skels = cfg.skeletons or 1
- local num_ghosts = cfg.ghosts or 1
- local locs = wesnoth.get_locations(cfg)
- for i = 1, num_skels do
- if #locs == 0 then
- return
- end
- local r = safe_random(string.format("1..%d", #locs))
- local x, y = locs[r][1], locs[r][2]
- spawn_loyal_player_unit("Skeleton", x, y)
- table.remove(locs, r)
- end
- for i = 1, num_ghosts do
- if #locs == 0 then
- return
- end
- local r = safe_random(string.format("1..%d", #locs))
- local x, y = locs[r][1], locs[r][2]
- spawn_loyal_player_unit("Ghost", x, y)
- table.remove(locs, r)
- end
- end
- >>
- [/lua]
- [/event]
Advertisement
Add Comment
Please, Sign In to add comment