Creating a unit which freezes the terrain beneath it?

The place to post your WML questions and answers.

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.
Post Reply
shadowhawke
Posts: 6
Joined: October 6th, 2010, 4:31 pm

Creating a unit which freezes the terrain beneath it?

Post by shadowhawke »

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
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Creating a unit which freezes the terrain beneath it?

Post by Anonymissimus »

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...)
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
shadowhawke
Posts: 6
Joined: October 6th, 2010, 4:31 pm

Re: Creating a unit which freezes the terrain beneath it?

Post by shadowhawke »

Thanks, I didn't think it was possible but I wanted to check with the masters :wink:
User avatar
Alarantalara
Art Contributor
Posts: 786
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: Creating a unit which freezes the terrain beneath it?

Post by Alarantalara »

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.

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]
Post Reply