• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
I posted my question at the base ck2 forum, but I am posting it here as well. Thoughts?

Details:
Guide: Your first mod

Question:
Guide: Your first mod
As I just responded to you there, if you are unsure of any rule or if what you are doing is fine according to the rule then post in the User Mod rules thread that I linked you in that thread and ask your question.
 
Hello, is there a way to count the number of specific unit a player has raised?

For instance, how to count the number of raised pikemen by a player? I plan to use this counting for a special unit type only created as retinue, so it seems I can only use "the character = { any_army = {" scope => the Unit scope. However, I can't found any way to checkup what's inside, I only have found effects to modify what's inside.

What data can you extract as conditions in the Unit scope? There must be a way to check "if a player has raised 10 000 pikemen" then action.
 
So, I don't entirely get stacking modifiers, and sadly can't find much info about them in the wiki.
My question is, how do I contain them?
If I want a maximum of say 4 stacks, can I check if there are 4 in a province, and thus stop my event from layering another one on top? Similarly, can I remove individual stacks?
 
How do I define a nation to be a Merchant republic? The nations I want to be merchant republics show up as regular republics before I hit 'play', but become merchant republics after it.
 
How do I define a nation to be a Merchant republic? The nations I want to be merchant republics show up as regular republics before I hit 'play', but become merchant republics after it.

You have to give the merchant republic title holder a family palace holding. To do so, define a barony in landed_titles.txt WITHOUT making it the de jure territory of any country. And then in its history use (for the appropriate date) "holding_dynasty = X", where X is the character's dynasty.
 
You have to give the merchant republic title holder a family palace holding. To do so, define a barony in landed_titles.txt WITHOUT making it the de jure territory of any country. And then in its history use (for the appropriate date) "holding_dynasty = X", where X is the character's dynasty.
Thanks going to check it out.
 
This piece of code doesn't seem to work (it doesn't set the population size for the province), anyone has an idea why?

Code:
       any_province = {
           if = {
               limit = {
                   NOT = { check_variable = { which = population_size value = 1 } } #if the province has no historical population number set, give a portion of the number given for its de jure duchy to it
               }
               
               save_event_target_as = province_target

               county = {
                   dejure_liege_title = {
                       if = {
                           limit = {
                               check_variable = { which = population_size value = 1 }
                           }
                           
                           set_variable = { which = quantity_of_provinces value = 0 }
                               
                           any_de_jure_vassal_title = {
                               change_variable = { which = quantity_of_provinces value = 1 }
                           }
                       
                           event_target:province_target = {
                               set_variable = { which = population_size which = PREV }
                               set_variable = { which = quantity_of_provinces which = PREV }
                               divide_variable = { which = population_size which = quantity_of_provinces }
                               set_variable = { which = quantity_of_provinces value = 0 }
                           }
                           
                           set_variable = { which = quantity_of_provinces value = 0 }
                       }
                   }
               }
           }
        }
 
This piece of code doesn't seem to work (it doesn't set the population size for the province), anyone has an idea why?

Code:
       any_province = {
           if = {
               limit = {
                   NOT = { check_variable = { which = population_size value = 1 } } #if the province has no historical population number set, give a portion of the number given for its de jure duchy to it
               }
              
               save_event_target_as = province_target

               county = {
                   dejure_liege_title = {
                       if = {
                           limit = {
                               check_variable = { which = population_size value = 1 }
                           }
                          
                           set_variable = { which = quantity_of_provinces value = 0 }
                              
                           any_de_jure_vassal_title = {
                               change_variable = { which = quantity_of_provinces value = 1 }
                           }
                      
                           event_target:province_target = {
                               set_variable = { which = population_size which = PREV }
                               set_variable = { which = quantity_of_provinces which = PREV }
                               divide_variable = { which = population_size which = quantity_of_provinces }
                               set_variable = { which = quantity_of_provinces value = 0 }
                           }
                          
                           set_variable = { which = quantity_of_provinces value = 0 }
                       }
                   }
               }
           }
        }

I'm not sure about it, but your scope sequence is "any province" (GLOBAL -> PROVINCE) then "county " (HOLDING -> COUNTY). Don't you need the "any province holding" link (PROVINCE -> HOLDING) ?
 
I'm not sure about it, but your scope sequence is "any province" (GLOBAL -> PROVINCE) then "county " (HOLDING -> COUNTY). Don't you need the "any province holding" link (PROVINCE -> HOLDING) ?

I meant to scope to the province's corresponding county. According to the wiki page on scopes it should work for provinces; do you think it doesn't work that way?
 
From the wiki:

1920px-Scopes_modding_quickcard.png


According to this picture, you can only link "county" with a holding and not a province. But it's true that the wiki text says it can be linked from the province scope directly. That's a contradiction... What about trying the picture configuration and tell me if it worked?
 
From the wiki:

1920px-Scopes_modding_quickcard.png


According to this picture, you can only link "county" with a holding and not a province. But it's true that the wiki text says it can be linked from the province scope directly. That's a contradiction... What about trying the picture configuration and tell me if it worked?

I've looked for and found many instances in vanilla of "county" being used from the province scope (i.e. in byzantine_events.txt), so I don't think that's it...

Actually, I've found the error now. I was increasing "quantity_of_provinces" for each of the duchy's counties, instead of for the duchy itself, making the population be divided by zero later on. This is the ammended code:

Code:
                           any_direct_de_jure_vassal_title = {
                               dejure_liege_title = {
                                   change_variable = { which = quantity_of_provinces value = 1 }
                               }
                           }

Unfortunately however, I have hit a further stumbling block. If the duchy has a population of over 4 million, then the population variable doesn't get applied properly to the provinces. If the duchy's population is something like 300,000 it works fine though. So it seems like I've hit a maximum limit to how large a variable can be?

Since variables use three decimals, then probably their maximum limit is 2,147,483.647 (they are probably just integers with the three last numbers appearing as decimals).

I suppose I could use thousands of people for the variable instead, though that isn't as appealing, visually.

Thanks for the help with this issue, @Attila2131 :)
 
Last edited:
Unfortunately however, I have hit a further stumbling block. If the duchy has a population of over 4 million, then the population variable doesn't get applied properly to the provinces. If the duchy's population is something like 300,000 it works fine though. So it seems like I've hit a maximum limit to how large a variable can be?

Since variables use three decimals, then probably their maximum limit is 2,147,483.647 (they are probably just integers with the three last numbers appearing as decimals).

I suppose I could use thousands of people for the variable instead, though that isn't as appealing, visually.

Thanks for the help with this issue, @Attila2131 :)
Reasonable compromise: You could use thousands of people in the variable, but display it with an extra ",000".
 
I have this event :
Code:
character_event = {
 id = TestEvent.2
 hide_window = yes
 is_triggered_only = yes
 trigger = {
  always = yes
 }
 option = {
  capital_scope = {
   ROOT = {
    spawn_unit = {
     owner = ROOT
     province = PREV
     home = PREV
     match_character = ROOT
     match_mult = 0.50
     attrition = 1.0
    }
   }
  }
 }
}

which was based on this vanilla event:
Code:
# Faction Revolt - Great numbers of Rebels flock to your banner
character_event = {
 id = 45000
 desc = "EVTDESC45000"
 picture = "GFX_evt_battle"
 border = "GFX_event_normal_frame_war"
 is_triggered_only = yes
 trigger = {
  war_with = FROM
 }
 option = {
  name = "EXCELLENT"
 
  hidden_tooltip = {
   FROM = {
    character_event = { id = 45001 }
   }
  }
 
  capital_scope = {
   tooltip = {
    ROOT = {
     spawn_unit = {
      province = PREV
      owner = ROOT
      match_character = FROM
      match_mult = 0.05
      attrition = 1.0
     }

The problem is that no troops spawn when it fires. Anyone know what might be wrong?
 
Run the Validator on your events. I suspect that the reason it can't find the event is that the game can't recognize it as a valid event, due to stray brackets or an unrecognized command.
I've finally tried the Validator on this one and nothing came up. This is so frustrating ^^. I've tried to create a new event, similar, and when i tried to cheat-run those two event, the game says there's not event responding to the ID 100000003 or 100000004..
 
Reasonable compromise: You could use thousands of people in the variable, but display it with an extra ",000".

I haven't even been able to get the variable to show properly outside of building requirements... which cannot be changed in their format on a per-variable basis, in any case. But thanks anyway :)

I have this event :
Code:
character_event = {
 id = TestEvent.2
 hide_window = yes
 is_triggered_only = yes
 trigger = {
  always = yes
 }
 option = {
  capital_scope = {
   ROOT = {
    spawn_unit = {
     owner = ROOT
     province = PREV
     home = PREV
     match_character = ROOT
     match_mult = 0.50
     attrition = 1.0
    }
   }
  }
 }
}

which was based on this vanilla event:
Code:
# Faction Revolt - Great numbers of Rebels flock to your banner
character_event = {
 id = 45000
 desc = "EVTDESC45000"
 picture = "GFX_evt_battle"
 border = "GFX_event_normal_frame_war"
 is_triggered_only = yes
 trigger = {
  war_with = FROM
 }
 option = {
  name = "EXCELLENT"
 
  hidden_tooltip = {
   FROM = {
    character_event = { id = 45001 }
   }
  }
 
  capital_scope = {
   tooltip = {
    ROOT = {
     spawn_unit = {
      province = PREV
      owner = ROOT
      match_character = FROM
      match_mult = 0.05
      attrition = 1.0
     }

The problem is that no troops spawn when it fires. Anyone know what might be wrong?

I'm not sure if that's the origin of your problem, but you should use "immediate" instead of "option" for events with a hidden window.
 
Can you modify vassalization/marriage?

I want to change the parameters for which the targets consider your offer a bit,
I think yes, but you'll have to override existing conditions (just adding new won't do, IA will go for vanilla). That means "replace path" concerned with all the files inside and modify the conditions to add your own.
 
Reworking marriages/etc. is doable, but not recommended. Implementing proper AI logic for making and accepting such interactions is not trivial (as knowing the exact reasoning it uses now is rather difficult), nor is making it work without hurting performance a lot if you want the AI to use this system (which it has to do if you want it to be using the same calculations when marrying other AI characters as it would do if you use a modified system).
 
Does any one know why this would be happening, the issue seems to be the fact that I've changed the saxongfx's headgear to a personally made one for middle era.

http://i.imgur.com/u7rV82O.png


included are the relevant bits (it only messes up when I change the headgear and clothes and only when I click on characters with theocracies). It's a very strange bug as it effects literally everyone who uses the headgear and clothes that I make. It's an altered saxon headgear and clothes file with only the Emperor crown and the military headgear changed. It looks like so:

http://i.imgur.com/Wu3nn93.png

Code:
    portraitType = {
        name = "PORTRAIT_saxongfx_male"
        effectFile = "gfx/FX/portrait.lua"
        layer = { # GFX_TYPE:[d|p]INDEX:COLOR_LINK:DONT_REFRESH_IF_VALID:CULTURE_INDEX
            "GFX_character_background:p0"
            "GFX_norse_male_clothes_behind_christian:p3:c0"
            "GFX_norse_male_headgear_behind_christian:p5:c1"
            "GFX_saxon_male_hair_behind:p1:h:y"
            "GFX_norse_male_beard_behind_christian:p4:o-2x2:h:y"
            "GFX_english_male_base:p2"
            "GFX_english_male_neck:d0"
            "GFX_english_male_cheeks:d4"
            "GFX_english_male_chin:d1"
            "GFX_english_male_mouth:d2"
            "GFX_saxon_male_eyes:d6:o26x30"
            "GFX_english_male_eyes2:d6:e:o-2x0"
            "GFX_english_male_nose:d3"
            "GFX_character_scars:p7:y"
            "GFX_character_reddots:p8"
            "GFX_character_boils:p9"
            "GFX_character_blinded_eyes:p10"
            "GFX_character_eyepatch:p13:y:o30x63"
            "GFX_english_male_ear:d7"  
            "GFX_norse_male_clothes_christian:p3:c2"
            "GFX_norse_male_beard_christian:p4:o-2x2:h:y"
               "GFX_saxon_male_hair:p1:h:y"
            "GFX_character_mask:p12:y:o40x45"
            "GFX_empty:p3:c4"
            "GFX_norse_male_clothes_infront_christian:p3:c4"
            "GFX_norse_male_headgear_christian:p5:c5"
            "GFX_character_imprisoned:p6"
            "GFX_player_overlay:p11"
        }
 
Are province events with high MTTH checked less often than province events with low MTTH?