How to make AI only terrain

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
xaero_radiance
Posts: 19
Joined: October 1st, 2005, 5:41 am

How to make AI only terrain

Post by xaero_radiance »

Okay this is the last time I'm posting this. I only hope I got the right place this time...

If I were to make terrain passable by AI units but not mine how would I do that?

So far I've been told that I can make a special movetype to walk on this new kind of terrain, but all I need to know is what file I need to change to make the game accept the new kind of movement. And if there IS a file I need to change...
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

It's problematic no matter how you do it. It depends on what else you have planned.

If you change the terrain every time a side ends its turn, it would take a long time if you have a lot of it. Do you?

Otherwise, this might be an easy solution.

Define a custom terrain as an alias of Cave Wall but with the image of the desired terrain. To do this, you will have to look at examples. Under the Burning Suns has custom terrain files. The process is too complicated for me to explain.

Then you have some side turn events to swap back and forth between the 2 terrains. Something like this...

Code: Select all

[event]
name=side turn

[if]
[variable]
name=side_number
numerical_equals=1
[/variable]

[then]
[terrain]
x=a bunch of numbers
y=a bunch of numbers
letter=x (the unpassable terrain that looks like the AI-passable terrain)
[/terrain]
[/then]

[/if]
[/event]
You make a similar event for when side_number = 2 and switch the terrain back. If you only have 2 sides it would be better to use an else statement, but with more than 2 you don't want to. [terrain] is a slow tag for lots of terrain.


An alternate method is by defining a custom terrain and altering the units' movement on it. However, it would require you to create a ton of custom units, and I don't recommend it.
Hope springs eternal.
Wesnoth acronym guide.
xaero_radiance
Posts: 19
Joined: October 1st, 2005, 5:41 am

Post by xaero_radiance »

Well the campaign I'm going to use this in is totally custom units...
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Alright, then you have options.

You still need to define a custom terrain that has the same images as the AI-passable terrain. However, I think you want to make it a canyon alias.
Then, you set the canyon movement of your AI units to 1.

Alternately you can make it a cave wall, deep water, or snow alias.
If you use snow, you also have to set the snow movement to unpassable for your friendly units.

There are some problems. The movement costs for the custom terrain will apply to the original... so the AI would be able to walk through cavewall or deep water, or your friendly units won't be able to walk on snow. Thus you should use a terrain you won't otherwise use in the campaign. Canyons should be a good pick, but again I don't know what you plan on doing.
Hope springs eternal.
Wesnoth acronym guide.
xaero_radiance
Posts: 19
Joined: October 1st, 2005, 5:41 am

Post by xaero_radiance »

I plan on a forest that has a path through the middle with undead walking around in the forest which I can't move my men onto...for my mock Dragonlance campaign...
So you're saying I can use a terrain such as canyon with the image of a forest?
And set my the AI movement on the canyon to 1
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Yes. You could also try a moveto event that fires any time someone tries to move onto the forest. It can repulse or kill them. Killing them would be much much easier. Repulsing them would require figuring out where they came from and putting them back someplace appropriate.
Hope springs eternal.
Wesnoth acronym guide.
xaero_radiance
Posts: 19
Joined: October 1st, 2005, 5:41 am

Post by xaero_radiance »

Yeah killing fits with the story actually...
okay so I change this where?

I haven't actually started making the campaign because I'm still in the process of getting the custom unit art and cfg's working the best...but when I come to the actual map part this will all be essential
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

[event]
name=moveto
first_time_only=no

[filter]
x=range of x locations
y=range of y locations
side=1
[/filter]

[kill]
x=$x1
y=$y1
[/kill]

[/event]

I'm not 100% sure about the $x1,$y1. As I understand it, they store the x,y location of the unit. Someone will correct me if it's wrong.
Hope springs eternal.
Wesnoth acronym guide.
Post Reply