Creating a unit which freezes the terrain beneath it?
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.
-
- Posts: 6
- Joined: October 6th, 2010, 4:31 pm
Creating a unit which freezes the terrain beneath it?
I've been making a ice-people faction recently and I had an idea for a unit which, when it moves, the terrain it passes over becomes the "frozen" version - e.g. flats become snow, water becomes ice, etc.
Does anyone have any ideas as to how I could make this work?
I thought of using moveto events but that would only work on the tile the unit moves to, not the tiles that it moves over...
Moved to WML Workshop
-- shadowmaster
Does anyone have any ideas as to how I could make this work?
I thought of using moveto events but that would only work on the tile the unit moves to, not the tiles that it moves over...
Moved to WML Workshop
-- shadowmaster
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Creating a unit which freezes the terrain beneath it?
as for the moved-over hexes: no way - really
(for the moved-to ones, store the terrain and make a switch clause computing the new terrain...)
(for the moved-to ones, store the terrain and make a switch clause computing the new terrain...)
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 6
- Joined: October 6th, 2010, 4:31 pm
Re: Creating a unit which freezes the terrain beneath it?
Thanks, I didn't think it was possible but I wanted to check with the masters
- Alarantalara
- Art Contributor
- Posts: 787
- Joined: April 23rd, 2010, 8:17 pm
- Location: Canada
Re: Creating a unit which freezes the terrain beneath it?
It can and has been done. Check out the Terrain Artist addon, which modifies the entire path taken using Lua.
This is a copy (slightly modified to make it closer to what you need) of the code for the moveto event. You would need to replace "randterrain" with your own event to set the terrain.
This is a copy (slightly modified to make it closer to what you need) of the code for the moveto event. You would need to replace "randterrain" with your own event to set the terrain.
Code: Select all
[event]
name=moveto
first_time_only=no
[lua]
code=<<
local this = ...
local unit = wesnoth.copy_unit(wesnoth.get_units({ id = this.unit_id })[1])
unit.x = this.from_x
unit.y = this.from_y
local path = wesnoth.find_path(unit, this.to_x, this.to_y)
for i, loc in ipairs(path) do
wesnoth.set_variable("unit.x", loc[1])
wesnoth.set_variable("unit.y", loc[2])
wesnoth.fire_event("randterrain")
end
>>
[args]
unit_id=$unit.id
from_x = $x2
from_y = $y2
to_x = $x1
to_y = $y1
[/args]
[/lua]
[/event]