Page 1 of 5 12345 LastLast
Results 1 to 20 of 85

Thread: Unique Names (and avoiding labels)

  1. #1
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Unique Names (and avoiding labels)

    This explains how to spawn characters with guaranteed-to-be-unique names using a hidden faction. That is, the hidden faction is just an intermediate step: the characters are then transferred to the faction of your choosing.

    Why?
    • Names are randomly reused by the game. You might want a special name for a special character (e.g. "The Fool of Venice") but there is no way to stop the game from giving that name to any number of other characters in the faction.
    • Limitations of labels:
      • It is not possible to spawn a Named Character with the same label twice, including using random_name. Even if the first spawned character no longer exists. This seriously restricts label reuse.
      • Agents can not have labels. This renders controlling spawned agents with script useless; you could control them with their name instead but how can you be sure that the script will not be controlling another character with the same name instead? You can't.
        UPDATE: There is a way to spawn agents with labels: see this post and a few after it for the discussion. However, note that the agent dies upon a game reload, so the practical applications are quite limited.

    To do this you will need a free faction slot. If you already have 31 factions then either sacrifice one or stop reading.

    The trick is to create a faction which contains unique character names: names that do not belong to any other faction. Characters are spawned into this faction and then the entire faction is given to the target faction; transferring the character(s) in the process.
    • This happens so fast that you never see the characters on the map under the hidden faction's banner; they appear to be spawning directly into the target faction.
    • They keep the name that you spawned them with, even though that name does not belong to the target faction.
    • You can now use this name to control the character with script; no need for labels! The name is guaranteed to be unique because 1) only this hidden faction has them, and 2) the hidden faction is not on the map so the game will not be spawning characters for it. Of course, if you use this method to spawn two characters with the same name then the uniqueness is lost.
    • The method can be used as many times as you like, even within the same turn. But see "Limitations" regarding using it in quick succession.
    • No "faction emerges/destroyed" messages as a result of this hidden faction (briefly) coming into being.

    All character types are possible except princesses.

    Initially there is some effort required to set up the hidden faction. But it only needs to be done once; after that the actual spawning steps are very simple.

    Creating the hidden faction
    Steps

    Download Attached to this post is a zip of the modified files as described in this section, taken from - and therefore only compatible with - Kingdoms Grand Campaign.

    The "spA", "spB", etc. names have been included instead of the "spawnpool_male/female" ones. Its religion is set to "heretic" instead of "catholic" to avoid being visible in the Pope scroll: see "Priests & Imams" regarding spawning religious characters.

    e.g. You could add these files to a fresh Bare_Geomod Kingdoms mod, replacing the ones there.

    This faction never appears on the map so we can skip a few steps that would usually be needed for adding a faction from scratch. If your mod already has an unused faction then even better; slightly adjusting that instead of making a new one will save some effort.

    These are the steps needed for making a new one from scratch.

    I am naming this faction "Spawn Pool" (spawnpool). The name is not important; it does not appear in the game.

    descr_strat.txt
    Insert this just before the "faction slave" entry:
    Code:
    faction    spawnpool, balanced smith
    ai_label        default
    dead_until_resurrected
    denari    0
    denari_kings_purse    0
    Add it to the nonplayable list at the top of the file:
    Code:
    nonplayable
        papal_states
        aztecs
        mongols
        timurids
        spawnpool
        slave
    end


    descr_sm_factions.txt
    Add this to the file:
    Code:
    faction                        spawnpool
    culture                        northern_european
    religion                    catholic
    symbol                        models_strat/symbol_saxons.cas
    rebel_symbol                    models_strat/symbol_rebels.CAS
    primary_colour                    red 0, green 0, blue 0
    secondary_colour                red 255, green 210, blue 0
    loading_logo                    loading_screen/symbols/symbol128_hre.tga
    standard_index                    21
    logo_index                    FACTION_LOGO_SAXONS
    small_logo_index                SMALL_FACTION_LOGO_SPAWNPOOL
    triumph_value                    5
    custom_battle_availability            no
    can_sap                        no
    prefers_naval_invasions                no
    can_have_princess                yes
    has_family_tree                    yes
    Here I just copy-pasted the Saxons entry and changed a few things.

    culture: this will affect the portraits. See Limitations below.

    religion: this will affect whether you can spawn priests/imams. See Priests & Imams below.

    primary_colour and small_logo_index: see Faction Rankings below.

    has_family_tree: if "no" then this faction will appear - and remain - in the factions lists of the Diplomacy scroll. (Thanks Gigantus.)


    expanded.txt
    Add this entry:
    Code:
    {SPAWNPOOL}Spawn Pool


    descr_win_conditions.txt
    Add this entry:
    Code:
    spawnpool
    hold_regions
    take_regions 100
    short_campaign hold_regions
    take_regions 80


    shared.sd.xml
    Add this entry to the end of the sprites list:
    Code:
    <sprite index="???" name="SMALL_FACTION_LOGO_SPAWNPOOL" page="0" left="234" right="234" top="207" bottom="207" x_offset="0" y_offset="0" alpha="1" cursor="0"/>
    ...where ??? = the next index in the sequence.

    Also add one to the sprite count:
    Code:
    <sprites count="339"> 
    (This number is an example only. Just add one to whatever is there now.)


    descr_character.txt
    The models themselves are not important because they'll never be seen on the map. But they need to be defined for this faction otherwise the spawn fails.

    So add an entry for each character type. You can just copy-paste another faction's. Here is a sample...

    Code:
    type            named character
    
    ...
    
    faction            timurids
    dictionary        2
    strat_model        islamic_general
    battle_model    Eastern_General
    battle_equip    gladius, chainmail shirt helmet and rectangular shield
    
    faction            spawnpool
    dictionary        2
    strat_model        islamic_general
    battle_model    Eastern_General
    battle_equip    gladius, chainmail shirt helmet and rectangular shield
    
    
    ...
    
    type            priest
    
    ...
    
    faction            timurids
    dictionary        2
    strat_model        muslim_iman        ; default model
    strat_model        muslim_iman        ; medium level priest
    strat_model        muslim_iman        ; advanced priest
    
    faction            spawnpool
    dictionary        2
    strat_model        muslim_iman        ; default model
    ;(no need for higher levels)
    
    
    ...


    descr_names.txt and names.txt
    The names themselves we'll be adding as needed. For now just create a place to put them in descr_names.txt. Add this:

    Code:
    faction: spawnpool
    
        characters
            spawnpool_male
            
    
        women
            spawnpool_female
    And add those names to names.txt:
    Code:
    {spawnpool_male}spawnpool_male
    {spawnpool_female}spawnpool_female
    These two names are just placeholders. You can remove them later once you start putting in real names to use.


    Faction Rankings

    A few of these steps are purely to avoid this hidden faction appearing on the Faction Rankings scroll after a spawn. It is still there but virtually hidden.

    • SMALL_FACTION_LOGO_SPAWNPOOL is the faction icon to use. But shared.sd.xml is setting its width and height to 0 (left=right, top=bottom) to hide it.
    • Putting the faction just before "slave" in descr_strat.txt forces the icon to be last in this scroll. If you don't do this then there will be a gap where this (hidden) icon should be.
    • Setting the primary_colour to 0,0,0 (black) in descr_strat makes the graph line black for this faction. This faction will always have zero regions, money, population etc. so all of its graph lines will be along the zero axis. Making it black helps it blend into the axis, making it far less noticeable.



    Spawning
    Okay, now that we have our spawning faction, let's spawn...

    First, some things to note and watch out for:
    1. When I say "general" I mean in terms of how spawn_army uses it. i.e. Just a 'regular' general; a captain. As opposed to a "named character".
    2. See the "Bodyguards" section below regarding the bodyguard that is received by Named Characters.
    3. Named Character label, direction and hero ability remain after the transfer. battle_model too but see Limitations below.
    4. When spawning units (in armies, fleets and as general bodyguards) you might need to add that unit to the hidden faction's roster in export_descr_unit.txt. In the past I found this to be a critical step (spawn/transfer fails without it) but while experimenting for this tutorial I found that I didn't need to. Strange. If you find that units/generals/admirals are not appearing then try adding spawnpool to the list of ownerships for the units.
    5. give_everything_to_faction must immediately follow the spawns. Putting it in a different monitor - or even putting a wait before it in the same monitor - doesn't work; the Named Character turns rebel and the other characters disappear.
    6. Sometimes traits go missing during the transfer. Give them to the character after the transfer instead.
      • gsthoed has reported that this might only apply to traits with Level effects.
      • Normally a trait/anc can't be given to a character (via spawn_army "traits" line or give_trait/ancillary commands) if his faction is on the trait/anc's ExcludeCultures list. However, if spawnpool is not on that list then a trait/anc can be given to him while still in the spawnpool faction; after the transfer he will still have it even if the target faction is on the ExcludeCultures list.
    7. Spawning just agents fails; they remain in the spawning faction. An extra step is need to make this work: see "Spawn just agents" below.


    In these examples spawnpool is my hidden faction and I am transferring to england.

    Also, I have added some names:
    Spoiler Alert, click show to read: 
    Code:
    faction: spawnpool
    
        characters
            spA
            spB
            spC
            spD
            spE
            spF
            spG
            spH
            spI
            spJ
            
    
        women
            spW
            spZ
    Code:
    {spA}spA
    {spB}spB
    {spC}spC
    {spD}spD
    {spE}spE
    {spF}spF
    {spG}spG
    {spH}spH
    {spI}spI
    {spJ}spJ
    {spW}spW
    {spZ}spZ
    Name them whatever you like, so long as they are unique to this faction. For demonstration purposes the in-game names are the same as the internal ones in these examples (e.g. {spA}spA). Use whatever real in-game names you need. And never use numbers in the internal names (e.g. {sp1}) as this causes problems (always, not just with this method).

    Spawn a Named Character
    Code:
      spawn_army
        faction spawnpool
        character  spA, named character, age 18, x 96, y 145, direction S
        unit Peasants    exp 0 armour 0 weapon_lvl 0    
        unit Sherwood Archers    exp 0 armour 0 weapon_lvl 0    
      end      
    
      give_everything_to_faction spawnpool england false
    
      ;give him his traits
      console_command give_trait spA GoodCommander 1
      console_command give_trait spA Sobriety 2
    That's all there is to it! It's just a regular spawn_army followed immediately by a give_everything_to_faction. And give him his traits after the transfer instead of within the spawn_army.

    In this example I have given him a unit in his army (Sherwood Archers). This is not required.

    If you find that units are not being transferred (as mentioned above) and you don't wish to add them to spawnpool's roster then you can do this instead:

    Code:
      spawn_army
        faction spawnpool
        character  spA, named character, age 18, x 96, y 145, direction S
        unit Peasants    exp 0 armour 0 weapon_lvl 0    
        unit Sherwood Archers    exp 0 armour 0 weapon_lvl 0    
      end      
      give_everything_to_faction spawnpool england false
    
      create_unit spA, Sherwood Archers, num 1, exp 0, arm 0, wep 0

    Spawn other things

    In this example I am spawning all character types:
    • Named Character (without an army)
    • General (with army)
    • Admiral (with fleet)
    • Spy
    • Assassin
    • Diplomat
    • Merchant
    • Priest
    • Heretic
    • Inquisitor
    • Princess (fails)
    • Witch

    Strat map models must exist for both the spawn faction and the target faction (descr_character.txt).

    Code:
      ;Named Character
      spawn_army
        faction spawnpool
        character  spA, named character, age 18, x 96, y 145, direction S
        unit Peasants  exp 0 armour 0 weapon_lvl 0    
      end      
      
      ;General
      spawn_army
        faction spawnpool
        character  spB, general, age 18, x 97, y 145, direction S
        unit Sherwood Archers    exp 0 armour 0 weapon_lvl 0    
        unit Peasants    exp 0 armour 0 weapon_lvl 0    
        unit Peasants    exp 0 armour 0 weapon_lvl 0    
        unit Peasants    exp 0 armour 0 weapon_lvl 0    
        unit Peasants    exp 0 armour 0 weapon_lvl 0    
      end     
    
      ;Admiral
      spawn_army
        faction spawnpool
        character  spC, admiral, age 18, x 102 y 141, direction S
        unit cog    exp 0 armour 0 weapon_lvl 0    
        unit cog    exp 0 armour 0 weapon_lvl 0    
      end     
    
      ;Agents    
      spawn_character spawnpool, spD, spy, age 18, x 98, y 145
      spawn_character spawnpool, spE, assassin, age 18, x 99, y 145
      spawn_character spawnpool, spF, diplomat, age 18, x 100, y 145
      spawn_character spawnpool, spG, merchant, age 18, x 101, y 145
      spawn_character spawnpool, spH, priest, age 18, x 102, y 145
      spawn_character spawnpool, spI, heretic, age 18, x 103, y 143
      spawn_character spawnpool, spJ, inquisitor, age 18, x 104, y 143
      spawn_character spawnpool, spW, princess, age 18, x 105, y 143
      spawn_character spawnpool, spZ, witch, age 18, x 106, y 143
    
      give_everything_to_faction spawnpool england false
    Here's the result:
    Spoiler Alert, click show to read: 
    Note the gap where the princess should have been. Alas.

    Spawn just agents

    If you try this without including a named character, general or admiral in the transfer then the spawned agents are not transferred. They remain in the spawning faction. (NOTE: not always. Sometimes it works but probably best to follow these steps just in case.)

    If you need to spawn just agent(s) without any named character, general or admiral then simply include a named character and kill him after the transfer.

    Code:
      ;Named Character (temporary)
      spawn_army
        faction spawnpool
        character  spA, named character, age 18, x 96, y 145
        unit Peasants  exp 0 armour 0 weapon_lvl 0    
      end      
      
      ;Agents    
      spawn_character spawnpool, spD, spy, age 18, x 98, y 145
      spawn_character spawnpool, spE, assassin, age 18, x 99, y 145
      spawn_character spawnpool, spF, diplomat, age 18, x 100, y 145
      spawn_character spawnpool, spG, merchant, age 18, x 101, y 145
      spawn_character spawnpool, spH, priest, age 18, x 102, y 145
      spawn_character spawnpool, spI, heretic, age 18, x 103, y 143
      spawn_character spawnpool, spJ, inquisitor, age 18, x 104, y 143
      spawn_character spawnpool, spW, princess, age 18, x 105, y 143
      spawn_character spawnpool, spZ, witch, age 18, x 106, y 143
    
      give_everything_to_faction spawnpool england false
        
      ;kill the named character now that the agents have been transferred
      kill_character spA
    The named character will be visible for the time between spawn_army and give_everything_to_faction; a fraction of a second. To prevent this, set his x,y coordinates to be somewhere out of view. e.g. A corner of the map.


    Bodyguards
    The bodyguard received by a Named Character depends on whether any units in the spawn_army have the general_unit attribute.

    No general_unit : replaced by default bodyguard
    If no unit in the spawn_army has the general_unit attribute then, after the transfer, the first unit is replaced by the faction's default bodyguard unit. That is, the first unit in export_descr_units.txt with the general_unit attribute for that faction.

    For example, none of these units have the general_unit attribute...
    Code:
    spawn_army
      faction spawnpool
      character  spA, named character, age 18, x 95, y 145
      unit Peasants    exp 0 armour 0 weapon_lvl 0    
      unit Sherwood Archers    exp 0 armour 0 weapon_lvl 0    
      unit English Knights    exp 0 armour 0 weapon_lvl 0    
    end
    Normally the Peasants unit would become the bodyguard (in fact they will be while still in the spawnpool faction). But after the transfer to England they will be replaced with England's default bodyguard: "General's Bodyguard" ("NE Bodyguard", cavalry).

    A general_unit : becomes unique bodyguard
    If a unit in the spawn_army has the general_unit attribute then, after the transfer, that unit will become the bodyguard. It does NOT need to be the first unit in the spawn_army.

    For example, if Sherwood Archers were given the general_unit attribute...
    Code:
    spawn_army
      faction spawnpool
      character  spA, named character, age 18, x 95, y 145
      unit Peasants    exp 0 armour 0 weapon_lvl 0    
      unit Sherwood Archers    exp 0 armour 0 weapon_lvl 0    ; <-- general_unit
      unit English Knights    exp 0 armour 0 weapon_lvl 0    
    end
    ...then after the transfer the Named Character will have Sherwood Archers as his bodyguard, plus Peasants and English Knights in his army. Even if Sherwood Archers are NOT the default bodyguard for this faction. i.e. Even though "General's Bodyguard" is still higher in the EDU with the general_unit attribute, this unit is NOT replaced-in as the bodyguard in this case.

    If more than one unit in the spawn_army has the attribute then the first of them becomes the bodyguard.

    (This behaviour is not exclusive to this transfer method. If I spawn that army directly into the England faction then I get the same result.)

    Custom Unique Bodyguards
    If the above situations can't give you the unique bodyguard you need then there's another way: send_character_off_map.

    After the transfer, send the Named Character off map and bring him back again with a different unit in the spawn_army. The unit does NOT need to be a general_unit.

    For example, Heavy Bill Militia is not a general_unit...
    Code:
    spawn_army
      faction spawnpool
      character  spA, named character, age 18, x 95, y 145
      unit NE Bodyguard    exp 0 armour 0 weapon_lvl 0 ;<-- temporary; use any unit
    end
    give_everything_to_faction spawnpool england false
    
    send_character_off_map spA
    spawn_army
      faction england
      character  spA, named character, x 95, y 145
      unit Heavy Bill Militia    exp 0 armour 0 weapon_lvl 0    
    end
    ...but it will now be the bodyguard for this character. No transferring is going on here (note the "england" faction); this is pure off-map-and-back-again stuff that could be used for any character, any time.

    However, a side effect of send_character_off_map is that he can end up with a "dead" portrait when he is brought back. This doesn't happen if he is in a settlement (or fort?) when the send_character_off_map is done. Also, I just realised, it doesn't seem to happen if he has other units in his army. So three ways to avoid the dead portrait are:
    1. Before the send_character_off_map move him into a settlement. Not necessarily an easy thing to script as it will need to be a settlement owned by his faction and have room to receive him; two things that can probably be assumed to be true only at the start of the campaign.
    2. Include one or more other units in the first spawn (from the spawn pool faction). But these units will remain behind when he is sent off map.
    3. Give him a custom portrait and replace the "dead" image with a living one.

    WARNING:
    This "dead" side effect prevents send_character_off_map from working more than once per Unique Name character. If he is sent off map and brought back a second time then he ends up with a blank name. Or rather, he is sent off map and a new character is spawned in his place, with a blank name because the unique name does not belong to this faction (england in the above example). Apparently because send_character_off_map can't be used with what the game thinks is a dead character, so subsequent send_character_off_map's fail. Even if he is killed and recreated in between! For example:
    1) Spawn into spawnpool
    2) Transfer to england
    3) Send off map and back again --> fine
    4) Kill
    5) Spawn into spawnpool
    6) Transfer to england
    7) Send off map and back again --> fail

    UPDATE: WARNING: the rest of this section appears to be false. I can't remember if I ever tested it but findings in this thread, including my own subsequent tests, show that the following solution does not work. It seems that a unique name character cannot be brought back from off-map more than once.

    A solution is to ensure that he has at least one other unit in his army before sending him off map. Use a unit that his faction cannot possibly own normally, then create-and-destroy it around the send_off_map:

    Code:
    create_unit spA, dummy_unit, num 1, exp 0, arm 0, wep 0   
    send_character_off_map spA
    destroy_units sicily dummy_unit
    Alternatively, it seems that if the first spawn (into spawnpool) is done on water (sea) then any extra units in his army simply disappear when he is sent off map. So instead of the previous solution, simply add one unit (of any type) to his army during the first spawn and use a sea tile as the spawn location. Then use the proper location during the second spawn (back from off-map). Just make sure there isn't a ship of his faction on that water tile otherwise the extra unit will spawn into and remain in the ship.


    Priests & Imams
    If you need to spawn a priest then the spawn faction's religion must be catholic. For an imam it must be islam. Otherwise he dies after the transfer.

    This would mean that you can't use the same spawn faction for spawning priests for catholic factions and imams for muslim ones; you would need two spawning factions in this case. BUT, by temporarily changing the spawnpool's religion it is possible.

    For example, here spawnpool's religion is catholic and I need to spawn an Imam for The Turks and a Priest for England...

    (The usual rules apply: to spawn just an agent we need to also spawn a named character, who is killed off after the transfer.)
    Code:
      ;Imam for The Turks...
        
      ;Named Character (temporary)
      spawn_army
        faction spawnpool
        character  spA, named character, age 18, x 96, y 145
        unit Peasants  exp 0 armour 0 weapon_lvl 0    
      end    
    
      ;change the religion
      set_religion spawnpool islam  
      
      ;Imam    
      spawn_character spawnpool, spB, priest, age 18, x 102, y 145
    
      give_everything_to_faction spawnpool turks false
        
      kill_character spA
        
      ;change the religion back 
      set_religion spawnpool catholic
      
        
      ;Priest for England...
        
      ;Named Character (temporary)
      spawn_army
        faction spawnpool
        character  spC, named character, age 18, x 96, y 145
        unit Peasants  exp 0 armour 0 weapon_lvl 0    
      end    
    
      ;(religion is already catholic)
      
      ;Priest    
      spawn_character spawnpool, spD, priest, age 18, x 103, y 145
    
      give_everything_to_faction spawnpool england false
        
      kill_character spC
    Note that I am using different names for the two named characters (spA & spC). See "Limitations" regarding successive spawns.

    WARNING: having this faction defined as "catholic" will make it visible on the Pope scroll. To avoid this set it to something else in descr_sm_factions.txt; if you need to spawn catholic priests then use the temporary religion switch described above.


    Limitations
    There are some limitations...

    Portraits
    The portraits of characters will be according to the culture of the spawn faction (descr_sm_factions.txt). i.e. The portraits will be taken from the spawning faction's culture, not the target faction's culture. Even after a save-reload these portraits will remain.

    The religion-portrait-subfolder trick* works with the spawn faction. So by making the spawn faction a different religion to any other faction that shares the same culture you can at least have different portraits for agents spawned via this unique name method.
    * See "Religion" in Gigantus' tutorial. I thought it only worked for priests but no: all character types.

    I was hoping to use this to create various portraits, providing a small number of custom portraits for agents. e.g. Set it up such that the spawn faction's culture has different portraits under different religions and set that faction's religion to the one that matches the desired portrait prior to the spawn+give_everything (see "Priests & Imams" above). However, as soon as the spawn faction is switched to another religion the character will get that new religion's portrait when you save-reload. It seems that the game remembers which faction this character originally came from (spawnpool) and updates his portrait when that faction changes religion (after a reload). So in reality this isn't going to work long term; at least, not if the character is still alive when the next religion switch happens.

    Of course, named characters can be given a custom portrait in the spawn_army..character line which remains after the transfer. Apparently priests can be given custom portraits in descr_strat.txt but it doesn't work in campaign_script.txt so no help here.

    battle_model
    Giving a battle_model to a named character in the spawn_army..character line works. But only if it matches the mounted/unmounted nature of the bodyguard. i.e. If the bodyguard is cavalry then only a mounted model will work. If it is infantry then only an unmounted model will work.

    UPDATE: no, this does not appear to work. I remember testing it to reach the above conclusions but I can't remember how I tested it and everything I have tried since fails. Either my original testing procedure was flawed or it included some step that I haven't been doing this time around.

    UPDATE: yes it does work! This entry is needed in the <display> section of descr_campaign_db.xml: <clear_battle_models_on_new_faction bool="false"/>.
    Thanks Gigantus. That setting was previously unknown to me so I highly doubt that that's how I managed to get it working before.

    Princesses
    I don't know why princesses don't work. Perhaps princesses need to be in the family tree so they can't just be given to another faction.

    General/Admirals
    Although these characters spawn with the name that you gave them, there is no guarantee that this character name will remain on the map. As soon as the the player or the AI begins splitting/merging armies/fleets or moving armies into settlements then the character can lose his name; replaced by a random one.

    If you need to spawn a general/admiral and control him then make no assumptions about this name being in existence after the spawning took place. i.e. Immediately after the spawn - in the monitor that spawned him - is safe; beyond that... who knows?

    Successive Spawns - it can fail
    If this method is done in quick succession then it can fail. This seems to happen when the same named character is used as the temporary 'leader' character: even though the first transfer kills him before the second spawn+transfer is attempted, the game doesn't see him as being dead yet (I think). As a result the second transfer might behave strangely, e.g. agents not transferred, the temporary named character is still alive, etc.

    See the "Priests & Imams" script as an example. It is doing two spawn+transfer+kill in quick succession.

    To avoid this use different names for the temporary named characters, as the Priest & Imam script has done.

    Alternatively, putting a campaign_wait between the two attempts might help. It might also depend on whether the temporary character is visible (outside FOW) at the time - if he's visible then he goes through the death animation so he dies slower (I think).

    Faction Leader/Heir
    I suspect that spawned named characters can not become faction leader/heir, at least for teutonic tree factions. I don't think that I have tested normal family tree factions - any confirmation there would be helpful.

    This was tested on a teutonic faction, killing off leaders/heirs/named_characters and waiting for the adoptions to happen. Happen they did but never to my unique-name character, even if he was the only character to offer it to. As soon as another character was spawned (normally, not unique-name) then that character was offered adoption, suggesting that an adoption offer was always on the cards but my character was not eligible.

    I don't know why this would be. Possibly because they originally came from another faction? Or that the game still sees them as somehow belonging to that faction? Or perhaps simply because his name is not in the faction list. If any of those reasons are correct then I'd say that it is not just a teutonic limitation.

    UPDATE: for family tree factions (i.e. non-teutonic) Man of the Hour adoption offers do occur. i.e. He can become part of the family tree and therefore heir and leader too.

    slave Agents
    This doesn't seem to work for creating slave faction agents. From what I can tell the problem lies in give_everything_to_faction: agents are killed during the handover if the to-faction is slave.

    This appears to be built-in (hardcoded) behaviour of the command, not just when using it with an 'emerging' faction such as spawnpool. e.g. Spawn a merchant into a normal faction, via normal means, then give that faction to the slaves: he dies. Give the faction to another faction instead and he lives. (This was tested with merchants as a valid slave agent type; spawning one directly into the slave faction worked just fine.)

    I don't know if it applies to all agents - I did not test them all. Named characters and generals do work okay.


    I have used this myself in a few submods, mainly as a means to bypass the label limitations. Being able to create names that the game will never reuse is a bonus.

    Hopefully this will be of use to others.

    (Thanks to TNZ for the original suggestion.)

    NOTE: I have only tried this with Kingdoms. I don't know if it works with M2TW.

    Attachment: please see the start of the "Creating the hidden faction" section for details of what this is.
    Last edited by Withwnar; May 25, 2018 at 11:44 PM.

  2. #2
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    Here is an example of this in action...

    Rammas Echor Passage (there's a video demo)

    I needed to be able to repeatedly spawn a named character and use script to: respond to him being selected, kill him, reposition him, test that he didn't already exist, etc.. Because it wasn't just a one-off spawn and he needed to be a named character (not a "general") I couldn't use a label; "label already exists!" errors.

    As a bonus, because I am using this technique, I could give him a special name (e.g. "Guide of the Eastern Gate") without fear of this name ever being used by the game for another character. Although in this case I could have just added "Guide" as a name for all factions and used a trait to give him the "of the Eastern Gate" epithet. But I didn't really want "Guide" to be used as other character names; it is a very poor name for some factions in this mod.
    Last edited by Withwnar; October 02, 2011 at 02:28 AM.

  3. #3
    Emperor of Hell's Avatar SPA-NED 1-5
    Join Date
    Jul 2011
    Location
    Netherlands
    Posts
    5,747

    Default Re: Unique Names (and avoiding labels)

    Good tutorial +rep
    One question could you spawn on this way imams for catholic nations and priests for islam nations?

  4. #4
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    Thanks.

    Good question: priests are a special case. Yes, but you will need two spawning factions:
    1) A catholic one for spawning priests for catholic factions
    2) An islam one for spawning imams for islam factions

    In the OP example if I make spawnpool the islam religion and I try to spawn a priest for England then he dies. If it is catholic and I spawn a priest for the Turks then he dies.

    Imams are just essentially priests. You spawn them with "spawn_character ... priest". But the game treats them differently according to the faction religion; all of the pope/cardinal stuff for priests and the Jihad ability for imams. I suspect that it is this that is causing the deaths.

    EDIT: two spawning factions are not required: use set_religion. The OP has been updated with this info.
    Last edited by Withwnar; December 28, 2011 at 04:40 AM.

  5. #5

    Default Re: Unique Names (and avoiding labels)

    Brilliant This solves more problems for me than I even care to count +rep

  6. #6

    Default Re: Unique Names (and avoiding labels)

    Excellent! + rep

    Luck is the residue of design ~ Milton

  7. #7
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,681
    Blog Entries
    35

    Default Re: Unique Names (and avoiding labels)

    I am having a bit of a problem with the names: they just don't stick - my named_character that I am trying to spawn hasn't got any name at all. So I ended up using a label again to use 'create_unit'.

    Code:
            faction_emerge malta malta 1 85.0 100.0 1.2 town false malta_leader1 maltaleader 30
        
        spawn_army    
                    faction malta                        
                character    Ferdinand1 von_Spanien1, named character, age 38, x 233, y 126, label angriff1, direction E
                traits GoodCommander 2
                    unit        1648 Bodyguard        exp 1 armour 0 weapon_lvl 0    
            end
    
            give_everything_to_faction malta hre false
    
            create_unit angriff1, Kroaten, num 1, exp 0, arm 0, wep 0
    Initially I had the label as the name (angriff1), but as I said, the name wasn't given in-game and the create_unit script part failed. The name entries are present in descr_names (malta section) and in text\names.

    Edit: utterly weird - I removed the numbers (script and all other files) in the names and it worked. Guess I will need to do alphabetically, not numerical.
    Last edited by Gigantus; October 09, 2011 at 07:00 AM.










  8. #8
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    I have found that the engine doesn't like numbers in names. I think that internally it 'reserves' numerical names for labels. Likewise it doesn't like you using labels without numbers - a log warning appears I believe.

  9. #9
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,681
    Blog Entries
    35

    Default Re: Unique Names (and avoiding labels)

    I think I am going to keep the label anyhow, this is going to be for scripted battles with historical characters (that are already present in the game). That way I can easily kill the 'stand in' after the battle and don't have to write a monitor for each new stand in character.










  10. #10
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    So long as you're not ever spawning the same name+label combination twice; that fails. Although I'm not 100% sure it fails if you're spawning from this emerging faction. I have never used labels on my spawnpool characters.

    I might add a comment about this number-in-names problem to the OP. It is not exclusive to this Unique Names method but worth mentioning anyway.

  11. #11
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,681
    Blog Entries
    35

    Default Re: Unique Names (and avoiding labels)

    The labels get carried forward. So do direction and hero abilities.
    The names used are always different, so I shouldn't have a problem there, but even then I don't expect a problem as I do the 'if I_CharacterExists [label]' routine.










  12. #12
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    Aha! I was wondering about hero abilities. That's good to hear. I must try battle models too.

    Thanks, I'll add those to the OP.

  13. #13
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Unique Names (and avoiding labels)

    I got something to add to this,

    If you use this method the characters bodyguard will always be the first in the EDU of the faction you are giving the character too.

    Ex:
    If the unit in red is not the first general in the EDU for spain, a new unit(the highest in EDU) will be selected to be the characters bodyguard. So it is not possible(as of now) for the character to have unique bodyguards...
    Code:
    faction_emerge hungary timurids 1 85.0 100.0 1.2 town false hungary_leader TestA 30
        spawn_army
         faction hungary    
         character TestA, named character, age 28, x 204, y 27
         traits LoyaltyStarter 1, GoodCommander 2, ReligionStarter 1
         unit  Corsair   exp 1 armour 0 weapon_lvl 0
        end
        give_everything_to_faction hungary spain false

  14. #14
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,681
    Blog Entries
    35

    Default Re: Unique Names (and avoiding labels)

    Observation: it is not necessary to use the 'faction_emergent' line - it works perfectly fine without it.










  15. #15
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    Quote Originally Posted by Moneybags14 View Post
    If you use this method the characters bodyguard will always be the first in the EDU of the faction you are giving the character too. ... So it is not possible(as of now) for the character to have unique bodyguards
    No unique bodyguards; unfortunately this is true.
    (OP updated regarding bodyguards.)

    Quote Originally Posted by Gigantus View Post
    Observation: it is not necessary to use the 'faction_emergent' line - it works perfectly fine without it.
    Good to know. Thanks, I'll update the OP.
    Last edited by Withwnar; October 23, 2011 at 10:28 AM.

  16. #16
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    I have updated the OP with new findings:
    • battle_model does work (see Limitations)
    • added instructions for spawning just agents
    • removed all mention of the faction_emerge command and added mention of label, direction and hero_ability (thanks Gigantus)



    Last edited by Withwnar; October 23, 2011 at 10:28 AM.

  17. #17
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default Re: Unique Names (and avoiding labels)

    just an observation, both named characters and agents can have custom portraits, even captains i guess; the exception are admirals

    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

  18. #18
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,681
    Blog Entries
    35

    Default Re: Unique Names (and avoiding labels)

    It will be rather pointless to give generals or admirals a custom portrait as it changes when the stack composition changes. But it might be possible.










  19. #19
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    Agents? It's been a while since I tried but I never had any luck. Does spawn_character take a portrait parameter?

    EDIT: I tried again and I get the "Unrecognised character data string (portrait)" error. "portrait" works in descr_strat but not with spawn_character as far as I know.

    I also tried with captains and admirals: no luck with spawn_character. Strangely, the admiral ends up with no portrait at all. The captain ends up with a standard portrait.
    Last edited by Withwnar; October 16, 2011 at 12:51 AM.

  20. #20
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Unique Names (and avoiding labels)

    I have some new findings regarding unique bodyguards: any unit can be used.

    OP updated.

Page 1 of 5 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •