Skip to content

Commit

Permalink
clenaup DW scenario9 scorpion placement code.
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed Dec 21, 2015
1 parent 13aef0a commit 203f7b0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 89 deletions.
119 changes: 30 additions & 89 deletions data/campaigns/Dead_Water/scenarios/09_The_Mage.cfg
Expand Up @@ -103,88 +103,35 @@
side=2
[/unit]
#endif

# Put in a bunch of scorpions. The number of them depends on
# the difficulty:
[set_variable]
name=number_of_scorpions
#ifdef EASY
value=10
#endif
#ifdef NORMAL
value=13
#endif
#ifdef HARD
value=16
#endif
#ifdef NIGHTMARE
value=19
#endif
[/set_variable]

# The location starts out with a code meaning "find another location"
[set_variable]
name=scorp_x
value=-999
[/set_variable]

# Put a scorpion in a random location with some
# constraints. (If the same location gets chosen a second
# time, the new scorpion at that location could get forced
# into an impossible spot. That’s OK because it would only be off
# by one hex, and it will have been able to move by the time the
# player sees it.)
{REPEAT $number_of_scorpions (
# While x and y don't correspond to a good location...
[while]
[variable]
name=scorp_x
equals=-999
[/variable]
[or]
[have_location]
x=$scorp_x
y=$scorp_y
terrain=Qx*,W* # In water or a chasm

[or]
terrain=K*
[and]
x=$scorp_x
y=$scorp_y
radius=8 # Too close to the player’s keep
[/and]
[/or]
[/have_location]
[/or]
[do]
# ...pick a random location x and y
{RANDOM 1..18}
[set_variable]
name=scorp_x
value=$random
[/set_variable]
{RANDOM 1..24}
[set_variable]
name=scorp_y
value=$random
[/set_variable]
[/do]
[/while]

[unit]
type=Giant Scorpion
x=$scorp_x
y=$scorp_y
side=2
[/unit]

# Code to tell the while loop to find another location
[set_variable]
name=scorp_x
value=-999
[/set_variable]
)}
[random_placement]
{QUANTITY4 num_items 10 13 16 19}
variable=scorp
[filter_location]
include_borders=no
[not]
# In water or a chasm
terrain=Qx*,W*
[/not]
[not]
# Too close to the player’s keep
terrain=K*
radius=8
[/not]
[not]
# Ocupied by spiders.
[filter]
[/filter]
[/not]
[/filter_location]
[command]
[unit]
type=Giant Scorpion
x=$scorp.x
y=$scorp.y
side=2
[/unit]
[/command]
[/random_placement]
[/event]

[event]
Expand Down Expand Up @@ -512,13 +459,7 @@
[/message]

[clear_variable]
name=scorp_x
[/clear_variable]
[clear_variable]
name=scorp_y
[/clear_variable]
[clear_variable]
name=number_of_scorpions
name=scorp
[/clear_variable]
[clear_variable]
name=time_of_day
Expand Down
1 change: 1 addition & 0 deletions data/lua/wml-tags.lua
Expand Up @@ -1647,6 +1647,7 @@ wesnoth.wml_actions.random_placement = function(cfg)
local dist_le = nil

local parsed = helper.shallow_parsed(cfg)
-- TODO: In most cases this tag is used to place units, so maybe make include_borders=no the default for [filter_location]?
local filter = helper.get_child(parsed, "filter_location") or {}
local command = helper.get_child(parsed, "command") or helper.wml_error("[random_placement] missing required [command] subtag")
local distance = cfg.min_distance or 0
Expand Down

0 comments on commit 203f7b0

Please sign in to comment.