No Movement Points
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.
- Into-Jesus
- Posts: 40
- Joined: June 17th, 2012, 8:03 pm
No Movement Points
In my campaign I want a unit to stand on a village and not move, but I want him to be able to attack if there is a unit standing next to him. I know how to use the ai_special=guardian, but that's not what I want. Can anyone help?
"The problem with Internet quotes is that you can never tell when they're true." - Ben Franklin
On Wesbreak
On Wesbreak
Re: No Movement Points
You could set the unit's
max_moves
to 0.Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
Re: No Movement Points
I have a similar question to this I was going to post to a new thread... so apologies in advance-- not trying to hijack you. (If this should be it's own thread please let me know and I can start one.)
I want to do something where a unit is "stuck" in a defensive position, has movement (to escape if necessary, but also so it has a field of vision and can spot enemy units), but at the same time will basically fight and die in it's position unless it hits a certain % of it's HP remaining and will then try to flee.
This is sort of like the Heir to the Throne scenario where you are sneaking through the Heavy Infantryman in the forest... except if they see you, or you attack, they stay in their nice cozy turret and receive the defensive bonus.
I want to do something where a unit is "stuck" in a defensive position, has movement (to escape if necessary, but also so it has a field of vision and can spot enemy units), but at the same time will basically fight and die in it's position unless it hits a certain % of it's HP remaining and will then try to flee.
This is sort of like the Heir to the Throne scenario where you are sneaking through the Heavy Infantryman in the forest... except if they see you, or you attack, they stay in their nice cozy turret and receive the defensive bonus.
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."
"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"
"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"
- Into-Jesus
- Posts: 40
- Joined: June 17th, 2012, 8:03 pm
Re: No Movement Points
If you use the tag "ai_special=guardian" as shown, that should fix your problem.
Code: Select all
[unit]
side=2
type=Walking Corpse
id=WC1
canrecruit=no
x,y=18,7
ai_special=guardian
[/unit]
"The problem with Internet quotes is that you can never tell when they're true." - Ben Franklin
On Wesbreak
On Wesbreak
Re: No Movement Points
If I understand you correctly, I'd set the moves to zero at the beginning of each turn for that. Such as this for the example of a unit on Side 2 with id 'test_unit' (untested, so it might contain typos):Into-Jesus wrote:In my campaign I want a unit to stand on a village and not move, but I want him to be able to attack if there is a unit standing next to him. I know how to use the ai_special=guardian, but that's not what I want. Can anyone help?
Code: Select all
[event]
name=side 2 turn refresh
first_time_only=no
[modify_unit]
[filter]
id=test_unit
[/filter]
moves=0
[/modify_unit]
[/event]
Again, assuming I understand what you want correctly: you could use the same code as above (vision is set according to 'max_moves', not 'moves'), but put the [modify_unit] into an [if] statement that tests for hitpoints being above a certain level. For the fleeing part, you could then add an [else] clause in which you modify the unit to set goto_x, goto_y to the location you want the unit to flee to.junoslord wrote:I want to do something where a unit is "stuck" in a defensive position, has movement (to escape if necessary, but also so it has a field of vision and can spot enemy units), but at the same time will basically fight and die in it's position unless it hits a certain % of it's HP remaining and will then try to flee.
If you want a more complex behavior (e.g. fleeing to a location as far away from enemies as possible), you could either use more complicated WML code, or write a simple AI routine in either Formula AI or Lua AI. As an example, have a look at scenario 'Guardians' in the add-on campaign 'AI Modification Demos' (you can simply choose the scenario you want to look at). None of those guardians behaves exactly as you want it, but it should show you what can be done with simple custom AI code. (And if you can describe to me exactly what you want, I'd be happy to help with the coding.)
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- Into-Jesus
- Posts: 40
- Joined: June 17th, 2012, 8:03 pm
Re: No Movement Points
I used the max_moves and that worked for what I needed. Thanks!
"The problem with Internet quotes is that you can never tell when they're true." - Ben Franklin
On Wesbreak
On Wesbreak
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: No Movement Points
However, the main issue with such approach will be that, if the unit levels up, it will be able to move again. You have two ways to fix it:Into-Jesus wrote:I used the max_moves and that worked for what I needed.
1) use a post_advance event to set again max_moves=0 after the unit advances
2) give the unit a [object]:
Code: Select all
[object]
duration=level
silent=yes
[effect]
apply_to=movement
set=0
[/effect]
[/object]
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Into-Jesus
- Posts: 40
- Joined: June 17th, 2012, 8:03 pm
Re: No Movement Points
Okay, thanks. I'll use that just in case. Thanks for the info!
"The problem with Internet quotes is that you can never tell when they're true." - Ben Franklin
On Wesbreak
On Wesbreak
Re: No Movement Points
I read somewhere that 0 movement causes 'strange infinite movement' and that to make all terrains unreachable for the unit instead, somewhere in the game macros, maybe a long time ago. Is 0 movement okay now?Elvish_Hunter wrote:...Code: Select all
[object] duration=level silent=yes [effect] apply_to=movement set=0 [/effect] [/object]
- Into-Jesus
- Posts: 40
- Joined: June 17th, 2012, 8:03 pm
Re: No Movement Points
I'm not exactly sure what you mean. Do you know which is better?
"The problem with Internet quotes is that you can never tell when they're true." - Ben Franklin
On Wesbreak
On Wesbreak
Re: No Movement Points
If the movement=0 method works, there is no reason to try to set all terrains to unreachable. I just said that in a mainline scenario, it was written that it causes 'strange, infinite movement', but it might be an old information.
- Into-Jesus
- Posts: 40
- Joined: June 17th, 2012, 8:03 pm
Re: No Movement Points
Okay, makes sense. Thanks, everyone!
"The problem with Internet quotes is that you can never tell when they're true." - Ben Franklin
On Wesbreak
On Wesbreak