[move_unit] exactly one hex back
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.
[move_unit] exactly one hex back
Hello,
how can I set up following: When player's units reached deep forest in my scenario, I want them to turn back and prevent them to go further to the trees. I already wrote this:
So again: I would like to return unit EXACTLY one hex back.
Any ideas, please? Thank you.
how can I set up following: When player's units reached deep forest in my scenario, I want them to turn back and prevent them to go further to the trees. I already wrote this:
Code: Select all
[event]
name=enter_hex
first_time_only=no
[filter]
side=1
x=10
y=1-10
[/filter]
[message]
speaker=unit
message= _ "We should return back to the main path."
[/message]
[move_unit]
x=10
y=1-10
#Here I don't know what I should write, because I would like to return unit EXACTLY one hex back.
to_x=
to_y=
[/move_unit]
[/event]
Any ideas, please? Thank you.
- Pentarctagon
- Project Manager
- Posts: 5565
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: [move_unit] exactly one hex back
You could use the automatically stored variables y1/y2 and x1/x2.
So maybe something like:
based on what those values should be as per the wiki.
So maybe something like:
Code: Select all
[move_unit]
x=$x1
y=$y1
to_x=$x2
to_y=$y2
[/move_unit]
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: [move_unit] exactly one hex back
Pentarctagon: Thank you It works.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [move_unit] exactly one hex back
In 1.15 the following should also work:
Basically, move the unit one space in the direction opposite the direction it's currently facing. But again, unless you patch in the capability (as I did in Black Cross), you need 1.15 for that to work.
Code: Select all
[move_unit]
x=$x1
y=$y1
dir=-$unit.facing
[/move_unit]
Re: [move_unit] exactly one hex back
That would need a check for the hex being vacant, as units can move through hexes occupied by other friendly units.
Re: [move_unit] exactly one hex back
Previously unit.facing was unsynced, is that changed now?
Re: [move_unit] exactly one hex back
Pretty sure it's still unsynced, and we should really not have synced and unsynced attributes in the same namespace, it should be something like unit.unsynced_facing, unit.unsynced_controller etc.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [move_unit] exactly one hex back
Though it may technically be unsynced, I believe you can at least rely on its value to be effectively synced after a unit has finished moving or attacking?
Re: [move_unit] exactly one hex back
It was depending on animation settings, so attacking would be one case to get it out of sync.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [move_unit] exactly one hex back
I'm pretty sure it's guaranteed to be in sync after an attack? That may not have been the case in 1.12, but I'm fairly sure it's true in 1.14 – otherwise the backstab special probably wouldn't work properly.
Re: [move_unit] exactly one hex back
Hmm yes iirc you changed it to be set before every attack, still it's not set before predictions, this probably also effects the lua wesnoth.simulate_combat function by the way leading to possible oos (although that function is _mostly_ used in the air code where it if course won't cause oos(
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: [move_unit] exactly one hex back
"air code"?gfgtdf wrote: ↑October 24th, 2019, 2:30 am Hmm yes iirc you changed it to be set before every attack, still it's not set before predictions, this probably also effects the lua wesnoth.simulate_combat function by the way leading to possible oos (although that function is _mostly_ used in the air code where it if course won't cause oos(
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [move_unit] exactly one hex back
I think he means AI code.