How to prevent AI from moving?
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: 22
- Joined: October 25th, 2013, 1:44 am
How to prevent AI from moving?
How would I go about preventing the AI from moving whatsoever? I have figured out how to do this with the AI leader, but not with the AI units.
Re: How to prevent AI from moving?
One way you could do it is by giving all the AI units you don't want to move an [object] which sets their move to 0.
"There are two kinds of old men in the world. The kind who didn't go to war and who say that they should have lived fast died young and left a handsome corpse and the old men who did go to war and who say that there is no such thing as a handsome corpse."
-
- Posts: 22
- Joined: October 25th, 2013, 1:44 am
Re: How to prevent AI from moving?
Ok, I tried that, and I'm pretty sure my coding isn't correct:
Edit:
I changed the code to:
It doesn't work either.
Code: Select all
[modifications]
[object]
[effect]
movement_set=0
[/effect]
[/object]
[/modifications]
I changed the code to:
Code: Select all
[modifications]
[object]
[effect]
apply_to=movement
set=0
[/effect]
[/object]
[/modifications]
Re: How to prevent AI from moving?
Code: Select all
[status]
guardian=yes
[/status]
Re: How to prevent AI from moving?
I disclaim having any major knowledge of AiWML, but, theoretically, including…
…in the relevant
Code: Select all
[ai]
[avoid][/avoid]
[/ai]
[side]
tag should forbid that side’s AI from moving any units anywhere, except for its leader, who you say you have already prevented from moving.Re: How to prevent AI from moving?
One simple method:
You can add a [filter_condition] if you don't want it to always be active.
Code: Select all
[event]
name=side 2 turn refresh
first_time_only=no
{MODIFY_UNIT side=2 moves 0}
[/event]
-
- Posts: 22
- Joined: October 25th, 2013, 1:44 am
Re: How to prevent AI from moving?
Thank you all for your suggestions. I will try those, and see if they work with what I am attempting to do.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: How to prevent AI from moving?
The easiest method is setting [side]controller= to null. It can be switched back and forth by [modify_side]controller=, and doesn't need a side turn event to run and modify unit movement points on every turn. However, setting controller=null makes the engine ignore any side turn (and similar) events for the particular side, so don't be surprised that they aren't fired if you have any.
[side][ai]ai_algorithm=idle_ai works, but cannot be modified, due to a bug.
A third pseudo-method is to take away all gold an income and/or the recruit list The remaining leader will just sit in his keep and do nothing, with the default ai.
[side][ai]ai_algorithm=idle_ai works, but cannot be modified, due to a bug.
A third pseudo-method is to take away all gold an income and/or the recruit list The remaining leader will just sit in his keep and do nothing, with the default ai.
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: 22
- Joined: October 25th, 2013, 1:44 am
Re: How to prevent AI from moving?
Well, the AI has units, and I have prevented the leader from moving; I just need the units to stand still until an event is fired that will make them aggressive and let them move.
- Bob_The_Mighty
- Posts: 870
- Joined: July 13th, 2006, 1:15 pm
Re: How to prevent AI from moving?
I had this same problem once. As it happens, it was my first forum post. I wanted to keep Ivan The Blackheart, a bandit in Fall of Trent, from moving until the players got near. Amusingly, zookeeper offered the same solution as he's done here. However, the method I ended up using was to make Ivan unable to move on any of the surrounding terrain.
You can then reallow movement with this:
You can always put more terrain types inside the [movement_costs] tag. If you don't want to worry about their surrounding terrain, you can prevent them from moving on all possible terrain types.
Hope that helps.
Code: Select all
[object]
silent=yes
duration=forever
[filter]
name="Ivan The Blackheart"
[/filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
flat={UNREACHABLE}
[/movement_costs]
[/effect]
[/object]
Code: Select all
[object]
silent=yes
duration=forever
[filter]
name="Ivan The Blackheart"
[/filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
flat=1
[/movement_costs]
[/effect]
[/object]
Code: Select all
[object]
silent=yes
duration=forever
[filter]
whatever=whatever
[/filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
deep_water={UNREACHABLE}
shallow_water={UNREACHABLE}
reef={UNREACHABLE}
swamp_water={UNREACHABLE}
flat={UNREACHABLE}
castle={UNREACHABLE}
sand={UNREACHABLE}
forest={UNREACHABLE}
hills={UNREACHABLE}
mountains={UNREACHABLE}
village={UNREACHABLE}
cave={UNREACHABLE}
frozen={UNREACHABLE}
unwalkable={UNREACHABLE}
impassable={UNREACHABLE}
fungus={UNREACHABLE}
[/movement_costs]
[/effect]
[/object]
My current projects:
MP pirate campaign: The Altaz Mariners
RPG sequel: Return to Trent
MP stealth campaign: Den of Thieves
MP pirate campaign: The Altaz Mariners
RPG sequel: Return to Trent
MP stealth campaign: Den of Thieves
-
- Posts: 22
- Joined: October 25th, 2013, 1:44 am
Re: How to prevent AI from moving?
Ok, the [side] controller=null method will not work. It doesn't spawn the leader, and like was said, none of the events involving the side fire. I'll try the object method again.
Edit:
The object method still didn't work.
Edit:
The object method still didn't work.
Code: Select all
[unit]
type=Villager
id=Eostysu
name=_"Eostysu"
x=17
y=14
side=2
random_traits=no
[modifications]
[object]
silent=yes
duration=forever
[filter]
id=Eostysu
[/filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
deep_water={UNREACHABLE}
shallow_water={UNREACHABLE}
reef={UNREACHABLE}
swamp_water={UNREACHABLE}
flat={UNREACHABLE}
castle={UNREACHABLE}
sand={UNREACHABLE}
forest={UNREACHABLE}
hills={UNREACHABLE}
mountains={UNREACHABLE}
village={UNREACHABLE}
cave={UNREACHABLE}
frozen={UNREACHABLE}
unwalkable={UNREACHABLE}
impassable={UNREACHABLE}
fungus={UNREACHABLE}
[/movement_costs]
[/effect]
[/object]
{TRAIT_LOYAL}
[/modifications]
{IS_LOYAL}
[/unit]
Re: How to prevent AI from moving?
Yes, with controller=null you have to spam the leader by hand with [unit]canrecruit=yes.
Did setting the moves of all side units to zero in a turn refresh event not work?
Another alternative, you can end the ai turn as soon it starts
Add an filter_condition if it should not fire all the time.
Did setting the moves of all side units to zero in a turn refresh event not work?
Another alternative, you can end the ai turn as soon it starts
Code: Select all
[event]
name=side 2 turn
first_time_only=no
[end_turn][/end_turn]
[/event]