Using the location of a unit
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.
- ResExsention
- Posts: 97
- Joined: March 17th, 2018, 12:00 am
- Location: Alberta, Canada
Using the location of a unit
Hello!
I've been working on a campaign so far (Purger of Evil) and I would like to find a way to call on the location of a specific unit as a variable in a generic event (not one of those
- Store the unit and then somehow call on the coordinates of the stored unit. Don't know how to do that.
- Or use
Though nothing happens. Is this how I'm supposed to do it?
I mean, I know you can invoke
Thanks!
I've been working on a campaign so far (Purger of Evil) and I would like to find a way to call on the location of a specific unit as a variable in a generic event (not one of those
moveto
events in which $x1
$x2
would work fine, but in something like a new turn
event, where $x1
and $y1
could refer to anything. I've found out a few ways:- Store the unit and then somehow call on the coordinates of the stored unit. Don't know how to do that.
- Or use
$unitID.x
and $unitID.y
. It looks like the most promising, but it doesn't seem to be working when spawning units near the leader in a new turn with the [unit]
tag going:Code: Select all
[unit]
side=2
type=Lieutenant
id=unitID1
name="Lieutenant Lol"
canrecruit=no
x=$leaderID.x
y=$leaderID.y
{IS_LOYAL}
[/unit]
I mean, I know you can invoke
$unitID.id
or maybe type, but I don't really know if calling the preset x y variables of a unit works. Spawning units is failing already. Any ideas? If I've already solved this, please help me out here, and tell me how I figured it out. I haven't found anything in the forums relating to this kind of topic, yet...Thanks!
I am a ranger and my WML knives will implant themselves in your back.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.
Re: Using the location of a unit
The right thing is actually a combination of these: you store the unit to a variable, then useResExsention wrote: ↑August 2nd, 2018, 4:03 am - Store the unit and then somehow call on the coordinates of the stored unit. Don't know how to do that.
- Or use$unitID.x
and$unitID.y
. It looks like the most promising, but it doesn't seem to be working when spawning units near the leader in a new turn with the[unit]
tag going:
$variableName.x
to access the variable and get the coordinate.
Code: Select all
[store_unit]
[filter]
<filter by id or however you want>
[/filter]
variable=<some variable name>
[/store_unit]
[unit]
side=2
type=Lieutenant
id=unitID1
name="Lieutenant Lol"
canrecruit=no
x=$<some variable name>.x
y=$<some variable name>.y
{IS_LOYAL}
[/unit]
The last few months have been nothing but one big, painful reminder that TIMTLTW.
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
- ResExsention
- Posts: 97
- Joined: March 17th, 2018, 12:00 am
- Location: Alberta, Canada
Re: Using the location of a unit
Ahh. I get it. So this is what it should look like?
And then:
And then when I need to spawn a unit on his position:
Is that how it works? I think it is. Thanks, Samonella!
EDIT: And that's how you manipulate a unit's variables if need be, with
Is that the basic idea?
Code: Select all
[unit]
side=1
type=General
id=leaderID
name="General Hello"
canrecruit=yes
recruit="Royal Guard, Halberdier, Master Bowman"
x=50
y=50
[/unit]
Code: Select all
[store_unit]
[filter]
id=leaderID
[/filter]
variable=generalHelloVariable
[/store_unit]
Code: Select all
[unit]
side=1
type=Lieutenant
id=unitID1
name="Lieutenant Lol"
canrecruit=no
x=$generalHelloVariable.x
y=$generalHelloVariable.y
{IS_LOYAL}
[/unit]
EDIT: And that's how you manipulate a unit's variables if need be, with
[set_variable]
, right? Like maybe:
Code: Select all
[set_variable]
variable=generalHelloVariable.goto_x
value=52
[/set_variable]
[set_variable]
variable=generalHelloVariable.goto_y
value=52
[/set_variable]
I am a ranger and my WML knives will implant themselves in your back.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.
Re: Using the location of a unit
Yup, exactly right!ResExsention wrote: ↑August 2nd, 2018, 5:44 pm Is that how it works? I think it is. Thanks, Samonella!
The basic idea, yes. Two notes:ResExsention wrote: ↑August 2nd, 2018, 5:44 pm EDIT: And that's how you manipulate a unit's variables if need be, with[set_variable]
, right? Like maybe:Is that the basic idea?Code: Select all
[set_variable] variable=generalHelloVariable.goto_x value=52 [/set_variable] [set_variable] variable=generalHelloVariable.goto_y value=52 [/set_variable]
-That only changes the variable, not the actual unit. To get the changes you made back into the real game you'd have to use [unstore_unit].
-The specific example you used, goto_x/y, doesn't make ai units move anywhere, the ai does whatever it wants with those values. But yeah that's how you use [set_variable].
The last few months have been nothing but one big, painful reminder that TIMTLTW.
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
- ResExsention
- Posts: 97
- Joined: March 17th, 2018, 12:00 am
- Location: Alberta, Canada
Re: Using the location of a unit
Well then, nothing more needs to be said about this. Thanks, Samonella!
I am a ranger and my WML knives will implant themselves in your back.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Using the location of a unit
Side note: The
Or, if you want it to be loyal but not display the loyal trait, you can instead use
You still need
{IS_LOYAL}
macro doesn't make a unit loyal. It only makes it look like it's loyal. To actually make it loyal you also need the following code:Code: Select all
[modifications]
{TRAIT_LOYAL}
[/modifications]
upkeep=loyal
.You still need
{IS_LOYAL}
in both cases to add the visual indicator though.Re: Using the location of a unit
note that we are considering making upkeep=loyal a 'effect-controlled' attribute in 1.15 so it might be later to use aCeltic_Minstrel wrote: ↑August 5th, 2018, 7:40 pm Or, if you want it to be loyal but not display the loyal trait, you can instead useupkeep=loyal
.
[object]
with a apply_to=loyal effect.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.
- ResExsention
- Posts: 97
- Joined: March 17th, 2018, 12:00 am
- Location: Alberta, Canada
Re: Using the location of a unit
Yes, I know about that. I just forgot to add
Code: Select all
[modifications]
{TRAIT_LOYAL}
[/modifications]
I am a ranger and my WML knives will implant themselves in your back.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.
Creator of the abandoned campaign Royalties Forgotten and the work in progress campaign Purger of Evil.
Maintainer of Fate of a Princess.