how can I make names for a specific unit type?
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.
how can I make names for a specific unit type?
I was wondering can I make my own names that are automatically given to a unit type, regardless of it's race.
Re: how can I make names for a specific unit type?
I'm guessing there's no other way than making a prerecruit unit type event which sets the name of the unit to whatever you want. However, even that won't help when you're just spawning [unit]s using random_traits=yes.nobody5 wrote:I was wondering can I make my own names that are automatically given to a unit type, regardless of it's race.
Re: how can I make names for a specific unit type?
No, you didn't understand me. I wasn't talking about variations, I was talking about the unit's name (e.g. something like 'Gwedrry').
But if you really thought what I wrote above, then please explain it to me.
Here is an example of what I was thinking:
Let's say I want to give every Knight I recruit a a name such as "Sir Darren".
I make a name list. Then I do the rest. How?
But if you really thought what I wrote above, then please explain it to me.
Here is an example of what I was thinking:
Let's say I want to give every Knight I recruit a a name such as "Sir Darren".
I make a name list. Then I do the rest. How?
Re: how can I make names for a specific unit type?
Yes, that's exactly what I was talking about.nobody5 wrote:No, you didn't understand me. I wasn't talking about variations, I was talking about the unit's name (e.g. something like 'Gwedrry').
But if you really thought what I wrote above, then please explain it to me.
Here is an example of what I was thinking:
Let's say I want to give every Knight I recruit a a name such as "Sir Darren".
I make a name list. Then I do the rest. How?
If you want to use your own list of names:
Code: Select all
[event]
name=prerecruit
first_time_only=yes
[filter]
type=Knight
[/filter]
{RANDOM "Sir Darren,Sir Diesalot,Sir Bob"}
{VARIABLE unit.name $random}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[/event]
Code: Select all
[event]
name=prerecruit
first_time_only=yes
[filter]
type=Knight
[/filter]
{VARIABLE unit.name "Sir $unit.name"}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[/event]
Re: how can I make names for a specific unit type?
Thanks, you helped a lot. It doesn't seem so hard after all.
By the way, if I wanted a "sir" title to append to the name on advancement,
I would write:
Is that right?
Note: I think 'first_time_only' should be no, because I want it to happen every time
By the way, if I wanted a "sir" title to append to the name on advancement,
I would write:
Code: Select all
[event]
name=post_advance
first_time_only=no
[filter]
type=Knight_dismounted
[/filter]
{VARIABLE unit.name "Sir $unit.name"}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[/event]
Note: I think 'first_time_only' should be no, because I want it to happen every time
Re: how can I make names for a specific unit type?
Yes, that is right. You don't need to specify find_vacant because it's no by default.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
-
- Posts: 39
- Joined: December 20th, 2007, 9:47 am
Re: how can I make names for a specific unit type?
Code: Select all
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
Re: how can I make names for a specific unit type?
I would give you a link to a thread that shows how it's useful, but you posted in one. I assume you already looked at the examples here. Could you be more specific what you don't understand?
Re: how can I make names for a specific unit type?
One way to modify an existing unit is to use an [object]. The other one, used here, is to directly edit its properties. All units are stored as WML, as tags and keys. You can open an (uncompressed) savefile and check; it's all WML, nothing more.AssassinT90 wrote:I'm wondering about why that is code useful. Already read its([unstore_unit]) effect, but couldn't understand well. Could somebody make it clear?Code: Select all
[unstore_unit] variable=unit find_vacant=no [/unstore_unit]
So, usually you use [store_unit] to store some existing unit into a variable, then change that variable, and finally use [unstore_unit] to make the game create an actual existing unit from the contents of that variable. In this case, [store_unit] isn't used because by default the primary unit associated with an event is stored in the variable called "unit".
What {VARIABLE unit.name "Sir $unit.name"} does is tells the game to replace the contents of the variable unit.name with the value of that variable preceded with "Sir ". After that, the unit data stored in the variable "unit" is identical to that of the actual unit whose advancement triggered that event except that it now has a different name. Then, [unstore_unit] tells the game to take the contents of that variable and create an actual unit on the map from it - which leads to the original unit getting eliminated because the "new" unit appears on top of it because it has the same x and y coordinates (if find_vacant=yes would be used, the "new" one would appear in an adjacent hex instead, leading to two copies of the unit on the map, only with different names).
If you'd remove the [unstore_unit], then nothing would happen, as you would have simply modified a variable and the game doesn't by itself do anything with any variable unless you tell it to.
-
- Posts: 39
- Joined: December 20th, 2007, 9:47 am
Re: how can I make names for a specific unit type?
@zookeeper, melinath:
Thank you(again)!
Thank you(again)!
Re: how can I make names for a specific unit type?
You know, that post_advance event doesn't work. Why? It's totally logical:
This would trigger when a horseman advances, but it doesn't add the 'Sir' title.
And if I use advance, then it creates weird infinite advancement that adds 'Sir' a million times.
Code: Select all
[event]
name=post_advance
first_time_only=no
[filter]
type=Horseman
[/filter]
{VARIABLE unit.name "Sir $unit.name"}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[/event]
And if I use advance, then it creates weird infinite advancement that adds 'Sir' a million times.
Re: how can I make names for a specific unit type?
You wrote:nobody5 wrote:This would trigger when a horseman advances, but it doesn't add the 'Sir' title.
And if I use advance, then it creates weird infinite advancement that adds 'Sir' a million times.
Everyone else wrote:nobody5 wrote:Is that right?
Note: I think 'first_time_only' should be no, because I want it to happen every time
Code: Select all
first_time_only=yes
Mainline Maintainer: AOI, DM, NR, TB and THoT.
UMC Maintainer: Forward They Cried, A Few Logs, A Few More Logs, Start of the War, and Battle Against Time
UMC Maintainer: Forward They Cried, A Few Logs, A Few More Logs, Start of the War, and Battle Against Time
Re: how can I make names for a specific unit type?
Now it works, but it happens only the first time! I want it to happen always!
The code:
Help meeeeeee!!!
The code:
Code: Select all
[event]
name=advance
first_time_only=yes
[filter]
type=Horseman
[/filter]
{VARIABLE unit.name "Sir $unit.name"}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[/event]
Re: how can I make names for a specific unit type?
Probably the filter applies to the unit after advancement, so if you want "Sir" to be added when advancing to a Knight, don't use type=Horseman as the filter, but type=Knight.nobody5 wrote:You know, that post_advance event doesn't work. Why? It's totally logical:
This would trigger when a horseman advances, but it doesn't add the 'Sir' title.Code: Select all
[event] name=post_advance first_time_only=no [filter] type=Horseman [/filter] {VARIABLE unit.name "Sir $unit.name"} [unstore_unit] variable=unit find_vacant=no [/unstore_unit] [/event]
Yeah, that seems to be a strange bug.nobody5 wrote:And if I use advance, then it creates weird infinite advancement that adds 'Sir' a million times.
Re: how can I make names for a specific unit type?
Nay, it has to be Horseman, otherwise nothing happens, except when a Knight advances. And who wants to bother with adding a advancing event for Knight, it already gets 'Sir' when it's recruited, so I'll get 'Sir Sir Bob'!