Jump to content

CK2 Modding Quick Question Thread


Recommended Posts

Posted
8 hours ago, joemann said:

The event works, however the commands <wealth = price>  and <wealth = -price> gives a result of 0 and not the price calculated by the scripted effect which the console shows as one of the slave's variables.

According to the wiki a command of <wealth  = myvar> should work

Variables are a fickle thing. wealth = even more so. While you can do wealth = -50 you cannot do wealth = -price

 

the solution would be to add in a second variable at the very end of the scripted effect.

        subtract_variable = { which = buyer_price which = price }
and then do wealth = buyer_price

Since buyer_price (or any variable, for that matter) always defaults to 0 if it is not set, you'll end up with a negative number, which you can use to remove the wealth from the buyer.

Be sure to clear out all variables afterwards via

    after = {
        set_variable = { which = price value = 0 }
        set_variable = { which = buyer_price value = 0 }
    }

in the event at the very end.

 

Also note that price is also used by vanilla, so you might want to change that to something like slave_price

 

8 hours ago, joemann said:

One last question concerning the decision. I would like the ai to also sell its slaves and ideally I would like to receive offers ( like the marriage proposals you receive regularly in game)

I tried ai = yes in the first part of the decision script but that resulted in the ai immediately selling all my slaves, which was not the intention:)

Should I tinker with the factor in ai_will_do ?

Going this route will require 

        ai_check_interval = 24

in the decision pretriggers, otherwise the AI will do the decision every chance they will get. Modify the interval to your tastes (the number is in months for every check).

Posted

Thanks for your help Lockeslylcrit.

 

I made the modifications you suggested. The buyer_price does revert to a negative but the problem remains that the in the event the  commands

 

<event_target:rsl_slave_seller = { wealth = slave_price }> and <event_target:rsl_slave_buyer = { wealth = buyer_price }> are not executed. The money does not change hands but the buyer does get the slave. Good deal for him☺️

 

I include three screenshots which shows the info provided by charinfo:vlcsnap-00308.png.aa25dc29f14d0486702a3878ef45165a.pngvlcsnap-00309.png.21daad10d720546f4be707a21911376e.pngvlcsnap-00310.png.c3c97325d17fa90c11d2548433ea6cf1.png

 

I also noted that after execution of the option, the variables slave_price and buyer_price remained present in the charinfo of the characters.

 

 

What can I do more?

 

Posted

Correction. I had overlooked one variable_name which needed to be corrected. It works now. However the variables do persist in the slave after the event has been executed and the calculated price is shown not 0. I put the <after> command at the end of the event. Should that maybe  be at the end of the executed option?

 

Anyhow thanks for your advise.

 

As for the ai, I tried using different options but it keeps selling my slaves which I do not want. Maybe it is also selling other characters' slaves but so far I haven't been offered any.

So I decided to set it to off.

 

Is there any way of tapping into the marriage routine?

Posted
53 minutes ago, joemann said:

What can I do more?

Taking a longer look at the code gave me a clue

 

        event_target:rsl_slave_seller = { 
			set_variable = { which = price which = event_target:rsl_slave_target }
		}
        event_target:rsl_slave_seller = { wealth = price }            

I have never once seen a which = or a value = that targets a character. It's not present in the vanilla code, and likely will never work. That's likely why you are getting the proper slave price on rsl_slave_target but not on rsl_slave_seller, because the code cant transfer the values.

 

My suggestion is...

    immediate = {
                FROM = {
                    save_event_target_as = rsl_slave_target
                    
                }
                ROOT = {
                    save_event_target_as = rsl_slave_seller
                }
                FROMFROMFROM = {
                    save_event_target_as = rsl_slave_buyer
                }
                event_target:rsl_slave_target = { calculate_slave_sale_value = yes }
                
    }

change event_target:rsl_slave_target = { calculate_slave_sale_value = yes } to calculate_slave_sale_value = yes

 

        event_target:rsl_slave_seller = { 
			set_variable = { which = price which = event_target:rsl_slave_target }
		}
        event_target:rsl_slave_seller = { wealth = slave_price }            
        
        event_target:rsl_slave_buyer = { 
			set_variable = { which = price which = event_target:rsl_slave_target }
		}
        event_target:rsl_slave_buyer = { wealth = buyer_price }        

Delete the two set_variable lines.

 

 

Finally, change all references in the event file and scripted_effects file of slave_price and buyer_price to local_slave_price and local_buyer_price. This will allow the variable to be used only in this event chain, thus eliminating the need to clear it manually afterwards.

 

Posted

Made the changes, everything works!  Thanks a lot.

 

Now I am going to try to buy slaves on the market. I don't think a third_party_decision like the one above will work well. You would have to hand pick the potential sellers without knowing if they have slaves, since I'don't know how to pull in only those characters that have slaves. I can't find an appropriate condition to put in the potential block.

 

I will try and make a decision in the intrigue tab "visit_slave_market" and see if I can make it work through events. If it works I then might also replace the third_party_decision to sell slaves, so that selling and buying both go through the market. I will probably be back for help ?

Posted
1 hour ago, joemann said:

Now I am going to try to buy slaves on the market. I don't think a third_party_decision like the one above will work well. You would have to hand pick the potential sellers without knowing if they have slaves, since I'don't know how to pull in only those characters that have slaves. I can't find an appropriate condition to put in the potential block.

Idea:

 

Change the selling of slaves to a normal targetted_decision (no third party).

Add in a landless title (slave market) run by a slaver (new history file character). 

Move all sold slaves to that court.

Add in a third party decision to buy a slave from the market.

 

You may need to do some defines editing or coding magic to get past the 3.1.1 court limits, though.

Posted

Liked the idea and tried implementing it. Never used create_title before and find myself stuck.

 

Spoiler

#.800 Create Slave Market

province_event = {
    id = RSLS.800
    desc = RSLS800desc
    picture = slavery_female_sale1
    title = rsl_slave_sale_target
    hide_window = yes
    
    
    trigger = {
            capital_holding = {
                        has_building = rsl_slave_market_1
            }
    }
    mean_time_to_happen = {
                days = 10
    }
    immediate = {
            any_trade_route_province = {
                                    limit = {
                                            NOT = {
                                                distance = { where = ROOT value = 1000 }
                                            }
                                    }
                            create_title = {
                                        tier = COUNT
                                        name = "SLAVE_MARKET"
                                        holder = THIS
                                        custom_created = no
                                        temporary = no
                                        culture = ashkenazi
                                        adventurer = yes
                                        ruler = "SLAVE_TRADER"
                            }
            }                                        
}
        option = {
                name = rsl_OK
        }        
}

Not even sure I should be using a province_event. According to the wiki the command should be called from the home_province scope but I haven't found such a scope in the list of scopes. I am lost. ? Can someone please help?

Posted

A quick question.

 

In the following immediate block of a three party event:

 

immediate = {    
                event_target:rsl_guest_target = {
                        set_variable = { which = local_size_differential_anus  which = dick_size }
                }
                event_target:rsl_slave_target = {
                                set_variable = { which = local_size_differential_anus value = 0 }
                                change_variable = { which = local_size_differential_anus which = event_target:rsl_guest_target }
                }
                event_target:rsl_player_target = {
                            set_variable = { which = local_size_differential_pussy  which = dick_size }
                }
                event_target:rsl_slave_target = {
                                set_variable = { which = local_size_differential_pussy value = 0 }
                                change_variable = { which = local_size_differential_pussy which = event_target:rsl_player_target }
                }
     }

 

I am assuming that the first set_variable block scopes to  event_target:rsl_guest_target  and therefore automatically sets the <local_size_differential_anus> to the dick_size variable of said event_target. The same thing for the second set_variable block in this case the dick_size variable of the player_target will be used. Is this correct?

 

I was wondering if perhaps I needed to separately set a variable dick_size_player and dick_size_guest

 


                
                
                            
                        
       

Posted
2 hours ago, joemann said:

A quick question.

 

In the following immediate block of a three party event:

 

immediate = {    
                event_target:rsl_guest_target = {
                        set_variable = { which = local_size_differential_anus  which = dick_size }
                }
                event_target:rsl_slave_target = {
                                set_variable = { which = local_size_differential_anus value = 0 }
                                change_variable = { which = local_size_differential_anus which = event_target:rsl_guest_target }
                }
                event_target:rsl_player_target = {
                            set_variable = { which = local_size_differential_pussy  which = dick_size }
                }
                event_target:rsl_slave_target = {
                                set_variable = { which = local_size_differential_pussy value = 0 }
                                change_variable = { which = local_size_differential_pussy which = event_target:rsl_player_target }
                }
     }

 

I am assuming that the first set_variable block scopes to  event_target:rsl_guest_target  and therefore automatically sets the <local_size_differential_anus> to the dick_size variable of said event_target. The same thing for the second set_variable block in this case the dick_size variable of the player_target will be used. Is this correct?

 

I was wondering if perhaps I needed to separately set a variable dick_size_player and dick_size_guest

There are three kinds of variables:

 

1. Normal variables. Stored only within the scope they are used in.

2. local_ variables. Same as normal variables, but are erased when the event chain is over, like an event_target.

3. global_ variables. Stored globally and can be accessed by any scope. Will need to be cleared if you want to reuse it.

 

If you want to use a variable that can be called from any scope within the event chain, go for global_ and clear it after the event chain. Otherwise, only variables that are stored in a particular scope can be called from that scope.

Posted

In my immediate block, <dick_size> is a normal variable. Because it is stored in two different scopes and can only be called in these scopes it has a value depending on the scope it is called from. The first dick_size can have a different value than the second one The first dick_size will take the dick_size value of the guest, the second one of the player.

However if I created a variable global_dock_size it would have one single value regardless from which scope it is called

 

Have I understood this correctly?

 

 

 

 

 

 

 


                
                
                            
                        
       

Posted
8 hours ago, joemann said:

In my immediate block, <dick_size> is a normal variable. Because it is stored in two different scopes and can only be called in these scopes it has a value depending on the scope it is called from. The first dick_size can have a different value than the second one The first dick_size will take the dick_size value of the guest, the second one of the player.

However if I created a variable global_dock_size it would have one single value regardless from which scope it is called

 

Have I understood this correctly?

 

That's pertty much it.

Posted

Thanks!

 

I have another basic question on scopes in the context of a third party decision.

 

According to the wiki if you create a third party decision FROM is the decision taker (usually the player) ROOT is the target and FROMFROM is the third party.

 

In the first event that is triggered by the decision, if I want to define event_targets for the subsequent event chain, the decision taker is  FROMFROM, the target becomes FROM and the third_party FROMFROMFROM?

Posted
17 minutes ago, joemann said:

Thanks!

 

I have another basic question on scopes in the context of a third party decision.

 

According to the wiki if you create a third party decision FROM is the decision taker (usually the player) ROOT is the target and FROMFROM is the third party.

 

In the first event that is triggered by the decision, if I want to define event_targets for the subsequent event chain, the decision taker is  FROMFROM, the target becomes FROM and the third_party FROMFROMFROM?

Yes, if you're trying to figure out scopes for an event chain, it's probably best to assign the event_targets in the decision effect.

 

See: chinese_grace_offer_concubine in jd_grace_decisions.txt and event id JD.10050 in jd_grace_decision_events.txt file.

Posted

I am having a problem with a scripted effect which worked in the past and which I have slightly modified. I think it has to do with me still not understanding the variable commands (although I am not excluding a stupid mistake which I just keep reading over). 

The scripted effect is the following:

Spoiler

anal_impact_evaluation = { # after sodomy

                if = {
                    limit = {
                            check_variable = { which = local_size_differential_anus which = anus_size }  # checks that ROOT's dick_size is greater than FROM's anus_size
                            
                    }
                            subtract_variable = { which = local_size_differential_anus which = anus_size }
                }        
                        
                 # calculate FROM's new size
                        if = {
                            limit = {
                                is_variable_equal = { which = local_size_differential_anus value = 6 }
                            }
                                random_list = {
            
                                    15 = { change_variable = { which = anus_size value = 3 }
                                            set_character_flag = anus_size_increase_3
                                            set_character_flag = sodomized
                                            add_character_modifier = { name = rsl_torn_anus days = 90 }
                                            add_character_modifier = { name = rsl_pain_level_2 days = 60 }
                                    }
                                    35 = { change_variable = { which = anus_size value = 4 }
                                            set_character_flag = anus_size_increase_4
                                            set_character_flag = sodomized
                                            add_character_modifier = { name = rsl_incontinent days = 90 }
                                            add_character_modifier = { name = rsl_torn_anus days = 120 }
                                            add_character_modifier = { name = rsl_pain_level_2 days = 90 }
                                    }        
                                    45 = { change_variable = { which = anus_size value = 5 }
                                            set_character_flag = anus_size_increase_5
                                            set_character_flag = sodomized
                                            add_trait = wounded
                                            add_character_modifier = { name = rsl_incontinent days = 90 }
                                            add_character_modifier = { name = rsl_torn_anus days = 180 }
                                            add_character_modifier = { name = rsl_pain_level_2 days = 90 }
                                    }
                                    5 = { change_variable = { which = anus_size value = 6 }
                                            set_character_flag = anus_size_increase_6
                                            set_character_flag = sodomized
                                            add_trait = wounded
                                            add_character_modifier = { name = rsl_incontinent days = 120 }
                                            add_character_modifier = { name = rsl_torn_anus days = 180 }
                                            add_character_modifier = { name = rsl_pain_level_2 days = 120 }
                                    }
                                }
                                            
                        } 

 

                <I have taken out some of the intermediary "if"s>
                       
                        if = {
                            limit = {
                                is_variable_equal = { which = local_size_differential_anus value = 2 }
                            }
                                random_list = {
            
                                    5 = { change_variable = { which = anus_size value = 0 }
                                    }
                                    35 = { change_variable = { which = anus_size value = 1 }
                                            set_character_flag = anus_size_increase_1
                                            set_character_flag = sodomized
                                            add_character_modifier = { name = rsl_distended_anus days = 30 }
                                            add_character_modifier = { name = rsl_pain_level_1 days = 20 }
                                    }    
                                    45 = { change_variable = { which = anus_size value = 2}
                                            set_character_flag = anus_size_increase_2
                                            set_character_flag = sodomized
                                            add_character_modifier = { name = rsl_distended_anus days = 60 }
                                            add_character_modifier = { name = rsl_pain_level_1 days = 40 }
                                    }    
                                    15 = { change_variable = { which = anus_size value = 3 }
                                            set_character_flag = anus_size_increase_3
                                            set_character_flag = sodomized
                                            add_character_modifier = { name = rsl_torn_anus days = 60 }
                                            add_character_modifier = { name = rsl_pain_level_2 days = 40 }
                                    }    
                                }
        
                        }
                        if = {
                            limit = {
                                is_variable_equal = { which = local_size_differential_anus value = 1 }
                            }
                                random_list = {
        
                                    35 = { change_variable = { which = anus_size value = 0 }
                                    }
                                    60 = { change_variable = { which = anus_size value = 1 }
                                            set_character_flag = anus_size_increase_1
                                            set_character_flag = sodomized
                                            add_character_modifier = { name = rsl_distended_anus days = 30 }
                                            add_character_modifier = { name = rsl_pain_level_1 days = 20 }
                                    }
                                    5 = { change_variable = { which = anus_size value = 2 }
                                            set_character_flag = anus_size_increase_2
                                            set_character_flag = sodomized
                                            add_character_modifier = { name = rsl_distended_anus days = 60 }
                                            add_character_modifier = { name = rsl_pain_level_1 days = 40 }
                                    }    
            
                                }
        
                        }
                        if = {
                            limit = {
                                is_variable_equal = { which = local_size_differential_anus value = 0 }
                            }
                                    change_variable = { which = anus_size value = 0 }
                                    set_character_flag = anus_size_increase_0
                                    set_character_flag = sodomized
                        }
                        
}

When I execute the event I can see with the console command that the scripted effect is executed (character_flags are added) but it always reverts to the same effect.Probably the last <if> command.

It seems as if the local_size_differential_ anus variable always reverts to 0. But if this were true then it wouldn't pass the limit of the first <if> block, would it?

 

I suppose there is no tool that shows you the numerical value of the different variables?

 

The sequence of the variables is as follows:

 

Spoiler

In the event

 

immediate = {
    
        event_target:rapist = {
            
            set_variable = { which = local_size_differential_anus  which = dick_size }
        }
        event_target:rape_victim = {
            
            set_variable = { which = local_size_differential_anus  value = 0 }
            change_variable = { which = local_size_differential_anus which = event_target:rapist }
        }
        
    }

 

 

If  event_target:rapist has dick_size 5 and event_target:rape_victim has anus_size 1

 

The way I read the complete sequence is as follows:

 

first <set_variable> results in a local_size_differential_anus  of 5 in the scope event_target:rapist

second <set_variable> results in a event_target:rape_victim of 0 in the scope event_target:rape_victim

this variable is then changed to 5

Result is that the value of local_size_differential_anus in both scopes is now 5.

 

If we then go to the scripted_effect command, which is triggered by the event_command

<event_target:rape_victim = {
                                                                anal_impact_evaluation = yes
                                                                update_anus = yes
                                        }  > 

 

the first line of the scripted_effect checks if the local_size_differential_anus of 5 is equal or greater than the anus size of 1 (This is done in the scope event_target:rape_victim).

The second line of the scripted_effect subtracts 1 (event_target:rape_victim's anus_size) from 5 the last value of local_size_differential_anus.

I am assuming that local_size_differential_anus is now 4.

This is then compared to the values in the different <if> blocks with the variable_equal command.

 

Am I correct in my assumption that, in my example, after applying the different variable commands the final value of <local_size_differential_anus> is 4?

 

 

 

 

 

 

 

 

 

 

Posted

I also noticed that after execution of the option, the character_flags are saved in the char-info. The variable local_size_differential_anus, however, does  not show.Is that because it is a local_variable or because the event does not recognize it? All variable commands are executed within the same event.

Posted

I solved the problem. I had to delete <local> from <local_size_differential_anus>. It seems local does not last throughout the whole event. It was first set in the immediate clause and then used in the opinion block of the same event but I assume it "disappears" on executing the opinion.  The <local_size_differential_anus> was not saved in the charinfo, whereas <size_differential_anus> was .

My problem is now to get rid of it at the end of the event chain. I tried using :

 

after = { set_variable = { which = size_differential_anus value = 0 }} and  set_variable = { which = size_differential_anus value = 0 } in the opinion block of a subsequent event. In both cases the tool-tip recognizes the command but in charinfo  the variable still appears with the old value.

 

I will try using the command at the end of the event in which the variable is first used.

Posted

Been working on a mod that adds a bunch of stuff mainly for personal use, there are some changes I'd make if I posted it here (mainly making things balanced and not OP as all hell :P), but I've been having some issues with adding holy sites to a modded religion without directly editing or completely overwriting the landed_titles.txt file in the game's base directory. 

Posted
7 minutes ago, 2561642 said:

Been working on a mod that adds a bunch of stuff mainly for personal use, there are some changes I'd make if I posted it here (mainly making things balanced and not OP as all hell :P), but I've been having some issues with adding holy sites to a modded religion without directly editing or completely overwriting the landed_titles.txt file in the game's base directory. 

effect = { # if using a decision. Use immediate or option if using an event
	c_kent = {
		remove_holy_site_with_heresies = derpherpreligion
	}

	c_london = { 
		set_holy_site_with_heresies = derpherpreligion 
	}
}

 

Posted
11 minutes ago, lockeslylcrit said:

effect = { # if using a decision. Use immediate or option if using an event
	c_kent = {
		remove_holy_site_with_heresies = derpherpreligion
	}

	c_london = { 
		set_holy_site_with_heresies = derpherpreligion 
	}
}

 

Would I be using this in my own mod's text file for landed titles or somewhere like a new event meant to fire off at the start of the game? Still wrapping my head around all the arbitrary restrictions on where and how you can use certain scripting blocks.

Posted
32 minutes ago, 2561642 said:

Would I be using this in my own mod's text file for landed titles or somewhere like a new event meant to fire off at the start of the game? Still wrapping my head around all the arbitrary restrictions on where and how you can use certain scripting blocks.

you use effect in a decision, you use immediate or option in an event.

 

You can easily make an on_startup event and convert the above code appropriately

Posted
8 minutes ago, lockeslylcrit said:

you use effect in a decision, you use immediate or option in an event.

 

You can easily make an on_startup event and convert the above code appropriately

Alright! Thanks for the help!

Posted

How does the condition <is_dying> work? Does it kick in when health reaches 0 ?

 

I am trying to use it in a trigger for an event but without success.

 

Spoiler

# death under torture
character_event = {
    id = RSLCourt.5342
    desc = RSLCourt5342
    picture = dead_prisoner
    title = rsl_bungeled
    
    
    trigger = {
            event_target:rsl_victim_target = {
                                            is_dying = yes
                                            OR = {
                                                had_character_flag = { flag = resisting_ransomee days = 7 }
                                                had_character_flag = { flag = resisting_plotter days = 7 }
                                                had_character_flag = { flag = resisting_heretic days = 7 }
                                                had_character_flag = { flag = resisting_slave days = 7 }
                                                has_character_flag = resisting_ransomee
                                                has_character_flag = resisting_plotter
                                                has_character_flag = resisting_heretic
                                                has_character_flag = resisting_slave
                                            }
            }    
    }    
    option = {                        
    
            name = EVTOPT_Court_5343
            death = {
                    death_reason = rsl_death_torture
                    killer = event_target:rsl_player_target
                    
            }
            any_courtier_or_vassal = {
                                    has_minor_title = rsl_court_torturer
                                            
            }
    
            
            prestige = -15
            change_learning = -1
    }
}

I suppose the trigger should work just before the victim dies because all the stats of a dead character seem to disappear (at least in the charinfo of the console) That's why is_dying seemed very promising but it doesn't seem to work. Does anybody have any experience with this?

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...