Anyone know how to make an AI unit stand still?
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.
- Bob_The_Mighty
- Posts: 875
- Joined: July 13th, 2006, 1:15 pm
Anyone know how to make an AI unit stand still?
I'm making a multiplayer scenario and all i want is a computer-controlled unit to stay where it is when the players approach (thus luring them into a trap).
I've tried using the effect tag to reduce it's movement to zero, but i can't seem to get it right. The unit just keeps running into combat.
Can anyone help? An explantion of the effect tag might be useful even if that is not how to do it.
I've tried using the effect tag to reduce it's movement to zero, but i can't seem to get it right. The unit just keeps running into combat.
Can anyone help? An explantion of the effect tag might be useful even if that is not how to do it.
I would have to test it, but you can create the unit, change its movement costs to 99 for all terrains, then change them back to normal when you want it to move.
Code: Select all
[event]
name=start
[unit]
type=Orcish Grunt
x,y=10,10
side=2
[/unit]
[store_unit]
variable=stationary_store
[filter]
x,y=10,10
[/filter]
[/store_unit]
{VARIABLE stationary_store.movement_costs.grassland 99}
{VARIABLE stationary_store.movement_costs.hills 99}
{VARIABLE stationary_store.movement_costs.mountains 99}
...etc... for every terrain around it
[unstore_unit]
variable=stationary_store
[/unstore_unit]
[/event]
[event]
name=moveto
[filter]
side=1
x=5-15
y=5-15
[/filter]
[store_unit]
variable=stationary_store
[filter]
x,y=10,10
[/filter]
[/store_unit]
{VARIABLE stationary_store.movement_costs.grassland 1}
{VARIABLE stationary_store.movement_costs.hills 1}
{VARIABLE stationary_store.movement_costs.mountains 2}
...etc... for every terrain around it
[unstore_unit]
variable=stationary_store
[/unstore_unit]
[/event]
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
- Bob_The_Mighty
- Posts: 875
- Joined: July 13th, 2006, 1:15 pm
Thanks for the speedy reply but that doesn't work. At least not for me.
(maybe I've done something wrong elsewhere).
Is it possible to set movement to zero?
Could someone give me an example of an effect tag, with some indication of where it should be placed? (i.e. inside the unit tag or what?)
Thanks.
(maybe I've done something wrong elsewhere).
Is it possible to set movement to zero?
Could someone give me an example of an effect tag, with some indication of where it should be placed? (i.e. inside the unit tag or what?)
Thanks.
- Ken_Oh
- Moderator Emeritus
- Posts: 2178
- Joined: February 6th, 2006, 4:03 am
- Location: Baltimore, Maryland, USA
Yeah, setting its movement points to zero is easy. Here's one example:
The above will set a unit at coords 10,10 to 0 movement points at the beginning of each side's turn (you can set it so it's only on the side it needs to be, but I didn't want to complicate the code).
Things can get a little more lengthy if you don't want the unit to move only for a few turns, but don't hesitate to ask if you can't figure it out.
Code: Select all
[event]
name=side turn
first_time_only=no
{MODIFY_UNIT x,y=10,10 moves 0}
[/event]
Things can get a little more lengthy if you don't want the unit to move only for a few turns, but don't hesitate to ask if you can't figure it out.
Since it is an AI side unit, you probably need to use name=ai turn instead of name=side turn. Otherwise, this one should work nicely (assuming that you're running a relatively new version, of course).Ken Oh wrote:Code: Select all
[event] name=side turn first_time_only=no {MODIFY_UNIT x,y=10,10 moves 0} [/event]
try this. the wose will not move untill he can attack a players unit.
really ugly, if standing in a forest!
(side 7 must be ai controlled.)
really ugly, if standing in a forest!
(side 7 must be ai controlled.)
Code: Select all
[unit]
type=Wose
generate_description=yes
x=12
y=13
side=7
ai_special=guardian
[/unit]
no borders, no nation
- Bob_The_Mighty
- Posts: 875
- Joined: July 13th, 2006, 1:15 pm
This doesn't work either, for some reason.Ken Oh wrote:Code: Select all
[event] name=side turn first_time_only=no {MODIFY_UNIT x,y=10,10 moves 0} [/event]
I've tried using both 'ai turn' and 'side turn', but the bloody bandit keep charging!
Any ideas?
I just heard that ai side turns were somehow broken in MP scenarios, meaning that still in 1.1.7 they won't work (in MP scenarios). This might explain the trouble you're having...have you tested by playing a local or a network game? If for some reason (unlikely, but you never know...) you haven't tried a local one (hotseat or vs ai), then I suggest you do so.
It might indeed be best to post the whole scenario at this point.
It might indeed be best to post the whole scenario at this point.
zookeeper - true, but that C++ bug only affects the remote players. (by the way, that bug is fixed in svn, as well as in the EXE yogi bear provided in the DotM thread). Anyways, since this task only affects AI behavior, it shouldn't generate OOS.
The WML problem here is that side turn events fire before moves are restored from the last turn. The easiest way to force the unit to stand still is to give the unit a silent object that sets its movement to 0. Depending on what you are trying to acheive, the "ai_guardian" solution may suit your needs as well.
The WML problem here is that side turn events fire before moves are restored from the last turn. The easiest way to force the unit to stand still is to give the unit a silent object that sets its movement to 0. Depending on what you are trying to acheive, the "ai_guardian" solution may suit your needs as well.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
this works for me.
Code: Select all
[object]
silent=yes
[filter]
#your filter here
[filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
grassland=99
shallow_water=99
#more terrains here
[/movement_costs]
[/effect]
[/object]
Oh, yeah, that's the fancy way to do it. The advantage is that he will still show normal movement points in the status window. Thanks, Swordy.Swordy wrote:this works for me.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- Bob_The_Mighty
- Posts: 875
- Joined: July 13th, 2006, 1:15 pm
Thanks again for your help.
I've tried all the suggestions here, and still no joy.
Where should swordy's silent object bit go? On it's own, or in a seperate event? If so, what sort of event?
I have also tried doing the same thing in a test scenario, where there is not much else going on. But none of the suggestions work.
Is it because I'm using the 1.0.2 version?
Or some percularity with multiplayer mode?
Hmmm.
I've tried all the suggestions here, and still no joy.
Where should swordy's silent object bit go? On it's own, or in a seperate event? If so, what sort of event?
I have also tried doing the same thing in a test scenario, where there is not much else going on. But none of the suggestions work.
Is it because I'm using the 1.0.2 version?
Or some percularity with multiplayer mode?
Hmmm.
Umm, yes. 1.0.2 has nearly nowhere the same capabilities in terms of altering units than the development (and nearly done stable 1.2) have. Most advice you will get on the forums assume that you are working with the development version. If not, maybe state that fact.Bob_The_Mighty wrote:I've tried all the suggestions here, and still no joy.
Is it because I'm using the 1.0.2 version?
Try some Multiplayer Scenarios / Campaigns
Oh sorry, I assumed you were using 1.1.7.
I strongly suggest you get the development version, since you're a campaign/scenario maker. There are lots of WML changes in the development version and we're so close to the release of new stable version (1.2). So you need to keep up!
And my [object] should go in an [event] tag. For example, if you want the AI unit to stand still from the beginning of the game, you can do it in a start event:
I strongly suggest you get the development version, since you're a campaign/scenario maker. There are lots of WML changes in the development version and we're so close to the release of new stable version (1.2). So you need to keep up!

And my [object] should go in an [event] tag. For example, if you want the AI unit to stand still from the beginning of the game, you can do it in a start event:
Code: Select all
[event]
name=start
[object]
...
[/object]
[/event]