Jump to content

CK2 Modding Quick Question Thread


Recommended Posts

Yeah, I reckon unbalanced brackets are one of the most common errors when starting modding CK2. If you don't do i yet, I'd advise to use the Validator, since that it's pretty good at warning early on when you have those kind of problems in your code.

 

And please, enough with the cumpliments, you're making me blush haha

Link to comment

Just having a fucking vent,

Ugh the  limited nature of this engine is really pissing me off.  SIMPLE variables are so convoluted it's unbelievable.

check_variable = { which = global_ISTbktot value = 3 }

That is NOT equal to 4, It should be checking if it's equal to 3, it's right there in the fucking 1 line sentence " =3 "

4 is greater than  3, not equal to it. Jesus fucking christ....

 

i'M GONNNA GO HAVE TO LEARN MODIFIERS (AS IN WEIGHT FACTORS).

 

---------

Edit: Some time later

 

Ah well modifiers were much more straightforward :)

And being straight maths, not even Paradox have found a way to make them screwy, :shy:  yay. :heart:

Link to comment

EDIT. deleted question, I fixed it 3 huge workarounds. Long n the short of it is an event fires EVERYTHING off at once, not sequentially. Stupid language.

What are you experiencing? The execution within an event is pretty much sequential. Only more concoluted behaviour is when there's an event called in the middle of another and the second event has options, I think.

Link to comment

Well I had 4 IF statements in a row -

 

 

IF   X =4

Then

Set A = 4

Set Y = 1

 

If X  = 3

and Y does NOT = 1

Then

Set A  =3

Set Y = 1

 

If X  = 2

and Y does NOT = 1

Then

Set A =2

Set Y = 1

 

If X  = 1

and Y does NOT = 1

Then

Set A = 1

Set Y = 1

 

 

Something like that. The object being, to only set A ONCE- which would turn Y on, the rest would see  Y was on, and thus not run. The problem was it's run fine 1st time, but on subsequent runs, All the If seemed to run at the same time, in that if X was 3 then the last 3 would all set A, as all were immediately true. It's over slimplified here, but it made NO sense i swear- 1st run was perfect, subsequent runs not ( all variables (bar X ) set to 0 in a prior event ofc).

 

Anyhoo are you telling me If i have

IF = {
        Limit = {
                    check_variable = { which = global_ISTbktotal value == 3 }
       }     
                   add_trait proud
 }

In that case proud would ONLY get added if global_ISTbktotal was 3, not 2 or 4?

Because that'd be incredibly bloody handy! And admittedly is pretty common in scripting language and I should've already tried :s

Link to comment

Well I had 4 IF statements in a row -

 

 

IF   X =4

Then

Set A = 4

Set Y = 1

 

If X  = 3

and Y does NOT = 1

Then

Set A  =3

Set Y = 1

 

If X  = 2

and Y does NOT = 1

Then

Set A =2

Set Y = 1

 

If X  = 1

and Y does NOT = 1

Then

Set A = 1

Set Y = 1

 

 

Something like that. The object being, to only set A ONCE- which would turn Y on, the rest would see  Y was on, and thus not run. The problem was it's run fine 1st time, but on subsequent runs, All the If seemed to run at the same time, in that if X was 3 then the last 3 would all set A, as all were immediately true. It's over slimplified here, but it made NO sense i swear- 1st run was perfect, subsequent runs not ( all variables (bar X ) set to 0 in a prior event ofc).

 

Anyhoo are you telling me If i have

IF = {
        Limit = {
                    check_variable = { which = global_ISTbktotal value == 3 }
       }     
                   add_trait proud
 }

In that case proud would ONLY get added if global_ISTbktotal was 3, not 2 or 4?

Because that'd be incredibly bloody handy! And admittedly is pretty common in scripting language and I should've already tried :s

 

I'm not sure if that syntax would work, but you CAN use 

if = {
  limit = {
    is_variable_equal = { which = global_ISTbktotal value = 3 }
  }
  add_trait = proud
}
 

to add the trait proud ONLY if the variable is exactly 3. 

 

BTW, your spoiler can be greatly simplified, I think.

You can do just

 

set A = X

set Y = 1

 

which would be 

set_variable = { which = varA which = varX } #first which is the variable being set, second one is the variable from which we copy the value. We would grab the two variables from the same scope (object) -order is important!.
set_variable = { which = varY value = 1 } #note that if you use direct numeric values you use "value" but when you use other variables you use another "which".

If X is stored on a different scope from the current one you can even do:

set_variable = { which = varA which = varX which = <another right-hand-scope } #first which is the variable being set, second one is the variable from which we copy the value. We would grab the two variables from the same scope (object), third which is a right-hand scope such as ROOT, FROM, or an event target. This means "set varA in the current scope to the value varX has in <another right-hand-scope).
set_variable = { which = varY value = 1 } #note that if you direct numeric values you use "value" but when you use other variables you use another "which".
 

 

Link to comment

That's some good variable stuff man, reads sensible thanks. That is_variable_equal = EXACTLY what i was looking for. :D

 

I'd like your input on the best way to achieve something if that's cool.

 

 

Basically a slave breaking system. Once a slave reaches 0 martial, they break.

1 Breaking session a month, and it reduces their martial by 1 - but not permanently hopefully.

What I'm struggling with is a way of tracking the martial debuff.

(WITHOUT permanent variables - a game save might see 100's of slaves broken during its course- hard to track!)

 

 

A modifier in common/event_modifiers when applied, didn't alter their stats.

 

So what I'm currently looking at is adding a trait(1) [-1 martial] on initial session.

The subsequent sessions check if they have trait(1), if so remove and add trait (2) [-2 martial], if they have trait(2), if so adds trait (3) [-3 martial] and so on, until complete.

 

Is there a better way than this you know?

Link to comment

Honestly, I feel like having a custom character vsriable to track "willpower", "resistence" or whatever you want to call it. It'd save you some headaches and some code lines.Also any other trait/modifier changing martial would affect how "broken" the slave is (so getting the +2 axe artifact would make a character more diffixult to break... Is that sensible? Dunno).

 

My gut feeling is that there would bot be much memory difference between a character having a trait and having a custom variable, anyway. Like, 64 bits per character, I'd wager (one uint32 for the id of the variable, another for the value) vs a trait that is internally tracked also as an int (maybe a short?).

Link to comment

Also any other trait/modifier changing martial would affect how "broken" the slave is

 

This is desirable behavior, so that's cool. Breaking may involve removing 'stubborn' traits that would/should make the full process easier :) I shall go with the traits, thank you.

 

I have a mild question, no urgency, but I have sell slave option that looks at traits

	if = {
			limit = {
				FROMFROM = { from_ruler_dynasty = yes }
			}
			   wealth = 22
			   custom_tooltip = {text = dyn_slave }
		}
	if = {
            limit = {
			FROMFROM ={  trait = fair }} 
            wealth = 8
			 custom_tooltip = { text = fair }
            }

The mouse over looks like

 Dynastied slaves fetch more

Gold 22

Attractive

Gold 8

trait 3

gold 10

trait 4

gold 10

 

i like the traits showing, and know I can hide the tooltip for each wealth. But is there a 'proper' way to add and show the total wealth, ie 50 gold?

 

My easy solution is if a  condition returns true add wealth value to a variable, and add that as tooltip at the end, which seems like a perfectly fine way to achieve what I want. I was just interested if there was some cleverer shortcut to achieve this, as the code already has the 4 values, is there a more streamlined way to tally them up and show the player a total?

Link to comment

There is a more concoluted way right now, whoxh would involve more conditionals, one for each xombination, ( if A, B, C, do X, if notA, B and C, do Y, and so on, up to 8 consitionals), so I wouldn't do that. Your approach woth the variable seems more sensible.

 

After 2.8 hits, you'll be able to judt give values to a local variable and then give the value of that variable in gold as in wealth = my_custom_variable, but for now, that's what you've got.

Link to comment

Fair enough, thank you!

 

I have one more problem (of the ones I can anticipate - I may just be dumb and find more :P ) So this should be the last ''what if?'' I trouble you with :)

 

I'm using a targeted decision to assign  5 NPC's a flag, eg: character_flag_XYZ.

 

What I want is an "event" (by that I mean just ANY way)  that then finds these 5 NPC's with character_flag_XYZ, and allows me to apply an opinion modifier.

 

Basically like hosting a party, invite some people - host party- people get enjoyed party opinion modifier. I've literally no idea where to start on achieving this. Your help would be appreciated please and thank you.

Link to comment

I thought of another question is there a quick way to use someone base stat as a per point modifier?

modifier = {
 factor = 0.05
 martial= from
}

martial = from does not work, I thought of asigning a variable to each point of martial and checking against it - which would work, but figured there would be a shorthand to use a characters base stat a per point modifier. eg in the above code, a from with martial of  10 would generate a factor of 0.50.

Link to comment

Fair enough, thank you!

 

I have one more problem (of the ones I can anticipate - I may just be dumb and find more :P ) So this should be the last ''what if?'' I trouble you with :)

 

I'm using a targeted decision to assign  5 NPC's a flag, eg: character_flag_XYZ.

 

What I want is an "event" (by that I mean just ANY way)  that then finds these 5 NPC's with character_flag_XYZ, and allows me to apply an opinion modifier.

 

Basically like hosting a party, invite some people - host party- people get enjoyed party opinion modifier. I've literally no idea where to start on achieving this. Your help would be appreciated please and thank you.

 

You've hit one of the biggest limitations of ck2script: creating (a substitute for) list/arrays/collections. There's a few approaches you could take here.

 

1) Instead of flags use 5 different global event targets (say xyz_1, xyz_2, and so on). Problem is, this asumes only one character can do this thing at a time (if two characters are using this decision to invite people to their own party, then the global targets the first set will be overriden by the second).

 

2) Note that non-global event targets cannot be used since each decision will start its own event chain and thus each target would only be accesible within its event chain. 

What you COULD do is try to run the separate event chains in parallel. So you time the events so that the five selected characters get each in their own event chain the opinion boost at the same time you get your party event, though that may require some careful plannng.

 

3) The brute force process: use flags as normal and then to retrieve the characters with the flags do

 

any_character = {
  limit = { has_character_flag = your_flag }
  <do stuff>
}

The problem with this is it literally checks every living person in the game askng them if they have the flag, that can be pretty cpu-intensive. If you know things about the people you are allowing to invite, then maybe you could use a less intensive scope. For example, if you only can invite people within your realm use any_realm_character and so on.

 

4) The best solution regarding efficiency vs. sophisticated planning I know of relies on opinion targets.  There is a useful scope any_opinion_modifier_target that scopes to any character the enclosing scope has an opinion modifier towards, IIRC. In normal cases, that would be always just a few dozens characters, which would be much faster. So you would define an opinion_modifier for the task and give that opinion modifier instead of flags with the decision, then use any_opinion_modifier_target, limiting to the relevan modifier. Sorry that I cannot extend more on this right now.

 

I thought of another question is there a quick way to use someone base stat as a per point modifier?

modifier = {
 factor = 0.05
 martial= from
}

martial = from does not work, I thought of asigning a variable to each point of martial and checking against it - which would work, but figured there would be a shorthand to use a characters base stat a per point modifier. eg in the above code, a from with martial of  10 would generate a factor of 0.50.

 

Look up the attribute_diff condition in the Conditions page in ckiiwiki, That'll do exatly what you want here.

Link to comment

I appreciate you taking the time to outline all of that out for me, thank you.

It may take me a fair few reads to wrap my head around some of your methods, you may be giving me too much credit :P.

 

Looking at number 3

any_character = {
only_playable
   If = {
         limit = { has_character_flag = your_flag }
  <do stuff>
   }
}

Is there any reason that would not work?

The invites only go to people with in "only_playable" so can I double filter it like that?

 

Link to comment

Then it ahould be

any_playable_character = {
  limit = { has_character_flag = your_flag }
  <do stuff>
}

 

Well that makes sense. Duh. Thanks a bunch man.

 

Just an edit rather than double posting to say things are going really well!! Which is nice. :)

Slow, but steady progress, and massively rapid compared to before your help :)

Link to comment

Is there any (not too complicated) way to branch/fork an event? I'm looking at having the event that fires as the result of a decision (i.e. a triggered event) give slightly different results depending on the character's religious group (either branch within the event, or call one of a set of slightly different events).

 

It would be easy enough to do this for a MTTH event -- I'd just create a set of near-identical events, each with a different religious trigger. I don't know however how to do this for a triggered event.

 

The differences are more color/immersion than game-critical, so its no biggy if I can't do it. But I thought I'd inquire.

 

ADDENDUM: in investigating on-action events, I seem to have answered my own question: the syntax is:

 

if = { limit = {<something>} <something-else>}

I'll try this, and see if it works.

Link to comment

OK i have a problem that is a little unusual

FromFromFrom= {
     random_list = {
		49 = {	  character_event = { id = IST.0139 }   }
		49 = {    character_event = { id = IST.0149 }   }
		2 = {     character_event = { id = IST.0169 }   } 
     }
}

Only 0139 ever triggers, obviously seeing  0169 would be rare, but  0149 NEVER pops up. What about random_list am I getting wrong please?

Link to comment

I figured out the issue all by myself! :D

 

 

The issue was me being a fucking tard :(.

 

I was looking REALLY hard at double checking all my events and decisions .txt files. Meticulously, over and over. Following chains, triggers, brackets and formatting. Repeatedly.

 

...

 

In my localisation file, I had cut n pasted into 0149 the same text and options as 0139. So I could not see any difference when one popped or the other. :dodgy:

Fucking noob, sorry for bothering you!

 

Other than idiocy, things are going well for now, no issues on the horizon, still yet to try to implement the invite thing though. We will see eh?




			
		
Link to comment

 

I figured out the issue all by myself! :D

 

 

The issue was me being a fucking tard :(.

 

I was looking REALLY hard at double checking all my events and decisions .txt files. Meticulously, over and over. Following chains, triggers, brackets and formatting. Repeatedly.

 

...

 

In my localisation file, I had cut n pasted into 0149 the same text and options as 0139. So I could not see any difference when one popped or the other. :dodgy:

Fucking noob, sorry for bothering you!

 

Other than idiocy, things are going well for now, no issues on the horizon, still yet to try to implement the invite thing though. We will see eh?


I've done that repeatedly -- to the extent that I now go back and do a search for the event number of the copied event, to make sure that I've overwritten that number for all events except the original. :)

Can anybody tell me what the opinion modifier for the Indian group of religions is? I've found a couple of places that claim that it's "indian_opinion", but that is clearly wrong as (i) it is rejected by the Validator & (ii) it is ineffective in practice.

 

ADDENDUM: Again, answered my own question -- if by pure guesswork. It is in fact "indian_group_opinion". Which seem somewhat counter-intuitive -- as otherwise the "group" is only explicit where there's both a group and an individual religion of the same name (so that you need to differentiate).

Link to comment

In general, it's <tag>_opinion where <tag> is the name of a culture, culture group, religion or religion group. However, if adding xustom cultures or religions (or repectively, groups, you need to have an entry in a text file in common/modifier_definitions/

Link to comment

sigh...

I'm having some issue with variables, this is the wikis advice

ROOT = {
  export_to_variable = { which = global_trainstew value = stewardship who = FROM }
}

Add to display it I'm trying

[global_trainstew.GetName] [global_trainstew.GetValue]

But everything is blank. :-/

 

What I want to do, Is put the stewardship value of the person I right-CLICK ON in the variable, and then have that variable + value display  in a window. I'd much appreciate this clearing up please.

 

 

Link to comment

This may not be a "quick question", but I'll try asking it here anyway. I'm working on a submod for Dark World (adds a few more racial traits, a few decisions & subsidiary event for recruiting supernatural courtiers, and a small number of on_birth events for some crossbreeds, all under its own event namespace). No religion-modding whatsoever however.

 

I have discovered that it somehow breaks the Pagan Reformation. You can reform, but you don't get event 670 (which converts large numbers of provinces and characters to the reformed religion) -- although this event does fire manually from the console -- so it isn't a case of one event namespace overwriting another. And although post-reform you can 'Demand Conversion' of your subjects, the decision now doesn't do anything.

 

This is a rather serious bug -- but I've really no idea how to track it down -- as my mod appears to be interfering with something hardwired in the game.

 

ADDENDUM: thinking about it in the shower, lacking any flash of insight, the best thing might be to 'brute force' debug it by simply deleting it chunk by chunk, until Reformation starts working again.

 

ADDENDUM2: and the answer is: the on_action events (the first 'chunk' I eliminated). Further investigation found that the culprit was my 'on_actions' definition file, which replicated the name of its vanilla equivalent, and thus overwrote it.

 

I need to tattoo on my forehead: don't reuse any file name, unless you wish to completely overwrite it.

 

Which reminds me of another question: (i) how do I set it up so that my submod loads after the DW main-mod -- so that I can (reliably) overwrite one or two things (rather than taking the luck of the draw)? And (ii), do I need to copy and modify the whole file (with identical filename so that the whole file overwrites), or can I simply include the modifications in a new-named file so that only the new contents overwrites (currently, I only need to modify a single racial trait to add an opposite in for one of the new traits I'm introducing)?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use