place item on map instead of in code
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
place item on map instead of in code
Hello all,
[I ask this question here because there does not seem to be any forum dedicated to maps, else tell me where it should belong and/or move the thread.]
Is it possible to have an item on the map directly (if only by modifying its text file) instead of placing it in WML code? I think at having it be an overlay as for mixed terrains (with the '^' sign in text).
Thank you,
Diniz
[I ask this question here because there does not seem to be any forum dedicated to maps, else tell me where it should belong and/or move the thread.]
Is it possible to have an item on the map directly (if only by modifying its text file) instead of placing it in WML code? I think at having it be an overlay as for mixed terrains (with the '^' sign in text).
Thank you,
Diniz
Re: place item on map instead of in code
Usually not, though it is possible to use WML to create new terrain types that look like items.
Re: place item on map instead of in code
Take a look at the brazier "embellishment' terrains (^Eb, ^Ebn) as examples, I think they do what you want. You'll still need to define what the terrain code does, but then you can add it as an overlay with the "^" on a map.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Re: place item on map instead of in code
Do you mean something as externally referenced item so you only need to call in the scenario file?
Since that is possible. Something like this in the macros:
And then in the scenario file you place it with {RING_DEFENSE 33 70}
Since that is possible. Something like this in the macros:
Code: Select all
#define PICK_UP _IMG _X _Y _VERBOSE_MSG _OBJECT_CODE_AND_ACTIONS
[event]
name=victory
[clear_variable]
name=pickups.generic_flag_{_X}_{_Y}
[/clear_variable]
[/event]
[item]
image={_IMG}
x={_X}
y={_Y}
[/item]
[event]
name=moveto
first_time_only=no
[filter]
side=1
x={_X}
y={_Y}
[/filter]
{REDRAW}
[if]
[variable]
boolean_equals=no
name=pickups.generic_flag_{_X}_{_Y}
[/variable]
[then]
[message]
speaker=unit
message={_VERBOSE_MSG}
[/message]
[message]
speaker=narrator
image=wesnoth-icon.png
message= _ "Do you want this unit to pick up this item?"
[option]
message= _ "Yes"
[command]
{_OBJECT_CODE_AND_ACTIONS}
[+object]
[+then]
# Mark object as picked-up; won't happen if the object's filter
# doesn't match primary_unit
[set_variable]
name=pickups.generic_flag_{_X}_{_Y}
value="yes"
[/set_variable]
[/then]
[/object]
[/command]
[/option]
[option]
message= _ "No"
[command]
[allow_undo]
[/allow_undo]
[/command]
[/option]
[/message]
[/then]
[/if]
[/event]
#enddef
#define RING_DEFENSE X Y
{PICK_UP (items/ring-gold.png) ({X}) ({Y})
( _ "A gold ring, and there is a inscription on it. 'May enemy attacks shatter upon you like water upon a might rock.'")
(
[object]
image=items/ring-gold.png
duration=forever
name= _ "Ring of Impregnable Defense"
description= _ "+10% defense on all terrains."
[filter]
x={X}
y={Y}
[/filter]
[then]
[remove_item]
x,y={X},{Y}
[/remove_item]
[/then]
[effect]
apply_to=defense
replace=no
[defense]
deep_water=-10%
shallow_water=-10%
flat=-10%
forest=-10%
frozen=-10%
desert=-10%
hills=-10%
mountains=-10%
village=-10%
castle=-10%
cave=-10%
fungus=-10%
[/defense]
[/effect]
[effect]
apply_to=overlay
add="overlays/armor-icon.png"
[/effect]
[/object]
)}
#enddef
Light travels much faster than sound, that's why some people seem bright until you hear them speak.
>>> MY LITTLE LAB! <<<
>>> MY LITTLE LAB! <<<
Re: place item on map instead of in code
Do you mean, although there's some WML involved, the location is chosen in the map editor instead of putting the coordinates in to the WML?
The WML on the back of picture above is:
This works in 1.14, in the map editor the labels are placed with the "player start" tool (click "Add", and then type a name that doesn't start with a number). Units then can be placed using "location_id=" instead of "x,y=".The WML on the back of picture above is:
Code: Select all
# The dwarvish treasury is accessible via a guarded rope-bridge, which will be cut
# if a non-flying unit moves on to it.
#
# For now let's just cut it when a unit gets close (when it's on the hex
# before the bridge). If the trap gets more complex, the player's unit
# should stop there anyway, and warn that there's a dwarf waiting to cut the
# bridge.
[event]
name=enter hex
# It will only modify terrain for non-flying heroes, and it makes sense to
# have the dwarf laugh again every time someone steps on this hex.
first_time_only=no
[filter]
[filter_location]
location_id=laugh_trigger
[/filter_location]
[filter_side]
team_name=Heroes
[/filter_side]
[/filter]
[if]
{SXC_CMP unit.movement_costs.unwalkable not_equals 1}
[have_unit]
[filter_location]
location_id=laughing_dwarf
[/filter_location]
role=guard
[/have_unit]
[then]
[cancel_action][/cancel_action]
[terrain]
terrain="Qxu"
location_id=trap_bridge
[/terrain]
{SXC_REDRAW_TERRAIN}
[sound]
name=dwarf-laugh.wav
[/sound]
[animate_unit]
[filter]
location_id=laughing_dwarf
[/filter]
[facing]
x,y=$x,$y
[/facing]
flag=defend
hits=no
[/animate_unit]
[/then]
[else]
[allow_undo][/allow_undo]
[/else]
[/if]
[/event]