[HELP] Trying to make the player character and rulers able to be a knight

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

Nocan

Corporal
31 Badges
Jun 9, 2015
40
30
  • Crusader Kings II: Charlemagne
  • Europa Universalis IV: Res Publica
  • Magicka
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Way of Life
  • Crusader Kings III
  • Prison Architect: Psych Ward
  • Prison Architect
  • Imperator: Rome
  • Crusader Kings II: Holy Fury
  • Cities: Skylines - Parklife
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Monks and Mystics
  • Crusader Kings II: Reapers Due
  • Crusader Kings II: Conclave
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: El Dorado
  • Cities: Skylines
  • War of the Roses
  • Europa Universalis IV
As the title says, I'm trying to make the player character, and all rulers/army owners, eligibe to be a knight. Wanting the character to show up in the knights list and to be able to be a knight in their own army. If I'm not mistaken, in vanilla a knight can also be the commander of the army and thereby take part in battles; want this for the army owner / player.

Code:
can_be_knight_trigger = {
    OR = {
        AND = {
            can_be_warrior_trigger = { ARMY_OWNER = $ARMY_OWNER$ }
            NOR = {
                AND = {
                    has_trait = devoted
                    faith = {
                        NOT = {
                            has_doctrine_parameter = clergy_can_fight
                        }
                    }
                }
                AND = {
                    is_clergy = yes
                    faith = {
                        NOT = {
                            has_doctrine_parameter = clergy_can_fight
                        }
                    }
                }
                has_trait = blind
            }
            is_ai = yes
        }
        is_player = yes
    }
}

This is how I tried to do it; basically the original code or is_player = yes. First thing I tried doing was to simply remove is_ai = yes from the original code.

All help is appreciated!
 
If you comment out the line is_ai = yes in can_be_knight_trigger - then in the game itself, as a vassal, you can be a knight in the army of liege.
It seems that the very possibility of being a combat unit in the army which is controlled by the player in the game engine is not provided.

Update:
Okay, if in --- common\scripted_rules\00_rules.txt
we will replace

Code:
can_be_knight = {
    trigger_if = {
        limit = {
            OR = {
                is_landed = no
                root = root.court_owner
            }
            NOT = { exists = liege }
        }
        can_be_knight_trigger = { ARMY_OWNER = root.court_owner }
    }
    trigger_else = {
        can_be_knight_trigger = { ARMY_OWNER = liege }
    }
}

to

Code:
can_be_knight = {
}

Then absolutely all characters, without the can_be_knight_trigger check, can be knights.
This means that "can_be_knight" is being applied elsewhere. But in the game files this is only found in "Crusader Kings III\binaries\ck3.exe" and "Crusader Kings III\common\scripted_rules\00_rules.txt"

This means that the "can_be_knight" check occurs in the closed part of the game code. But there is no check for the character who owns the army (player or AI).

If it is possible to apply 00_rulers.txt as an effect inside events or something else, then we can apply it. But is it possible?

Code:
#immediate to root
trigger = {
    is_ai = no
}
immediate = {
    can_be_knight
}
 
Last edited:
  • 4
Reactions:
Perhaps there is also a "knight_list" where we can add the character of the owner of the army without any checks.
For example, the gui clearly uses some kind of "can_be_knight_list" to display our knights. This list also contains guests who can become our knights.
But as far as I understand, the scope of any list is limited to "trigger \ event \ a piece of code where list was defined". Or not?
 
Only knights list I've found so far is the gui one; may be able to find some useful information through that though I did not see where it picks characters from.

Could maybe "Character.IsKnightForced" be used somehow? And could we find " datacontext = "[KnightsView.GetMilitaryView]" "?

Edit: Could we could use the same effect as is applied when forcing a character to be a knight on the player?
 
Last edited:
Only knights list I've found so far is the gui one; may be able to find some useful information through that though I did not see where it picks characters from.

Could maybe "Character.IsKnightForced" be used somehow? And could we find " datacontext = "[KnightsView.GetMilitaryView]" "?

datacontext = "[KnightsView.GetMilitaryView]" - I suppose this is a pointer from which gui to render. And "GET view" indicates that you need to take the interface window.

datamodel = "[MilitaryView.GetKnights]" - But this already looks like iterating over a list. GET indicates that it takes all knights from - "some list".

But where is it and how to work with it ... I did not find anything.

"Character.IsKnightForced" may be applied if we add our character to the "scrollbox" and not only from some "knight_list" that it iterates over.

Edit: Could we could use the same effect as is applied when forcing a character to be a knight on the player?
We must try to find out. But I guess it just creates a priority queue inside "knight_list" for adding knights when we raise an army.
 
Last edited:
Not finding any useful mentions of knights at all in the game files.
Quite likely that all the stuff we've not been able to locate is hardcoded.
Posted about it in the suggestions forum to atleast hopefully bring it to dev attention.
 
  • 1Like
Reactions:
If we remove "can_be_knight" from "common\scripted_rules\00_rules.txt", then the error log will write to us -
"[02:34:51] [jomini_scripted_rule.cpp: 104]: No script rule defined for 'can_be_knight'. If you want 'always true ', just define an empty script rule by that name. "

Ck3.exe has an indication of "D:\jenkins\workspace\titus\cw\jomini\modules\script_system\source\jomini_scripted_rule.cpp"
If change the code there, then everything will work out.

In general, the necessary functionality cannot be added in the form of a mod. For now.
 
Last edited:
  • 1
Reactions:
Hi, i found a way.
20201010155947_1.jpg
 
Chatted with JUANQUI_CH on private message and he sent the code (I've only changed formatting):

Code:
##### Written by JUANQUI_CH #####

--------i edited character triggers in trigger localization :
is_knight = {
    global = IS_A_KNIGHT_TRIGGER
    first = I_AM_IN_AN_ARMY
    third = CHARACTER_IS_IN_AN_ARMY
}

is_knight_of = {
    global = IS_A_KNIGHT_OF_CHARACTER_TRIGGER
}
--------i added the flag player_knight with one event, in that event i added an option to remove or add that flag.
---------i edited war and peace triggers in scripted triggers :
can_be_warrior_trigger = {
    is_adult = yes
    is_imprisoned = no
    can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = $ARMY_OWNER$ }
    NOT = {
        has_trait = incapable
    }
    #trigger_else = { has_character_flag = player_knight }
}

can_be_knight_trigger = {
    can_be_warrior_trigger = { ARMY_OWNER = $ARMY_OWNER$ }
    NOR = {
        AND = {
            has_trait = devoted
            faith = {
                NOT = {
                    has_doctrine_parameter = clergy_can_fight
                }
            }
        }
        AND = {
            is_clergy = yes
            faith = {
                NOT = {
                    has_doctrine_parameter = clergy_can_fight
                }
            }
        }
        AND = {
            is_ai = no
            NOT = {
                has_character_flag = player_knight
            }
        }
        has_trait = blind
    }
    #is_ai = yes
}
--------A this point your liege will be able to use you as a knight, but you cant be a knight in your army. so i discovered that if you edit the save and under your character id you edit the ´court_data´ with: ´ employer = your charcter id´ you will appear on the knights tab. i dont know much about modding but you have to find a way to make yourself your own courtier so you dont have to be editing your saves with every character.

As he says in the end, if we could make the player a courtier in their own court, employed by themself, they could function as knights without needing to edit save files.
I've not tried it yet. Immediate thoughts would be that making the player their own courtier could have side effects.
 
Okay tested it a bit. Instead of writing an event to add the character_flag player_knight, I wrote the trigger out as it was more for being a knight for your liege:
Code:
can_be_knight_trigger = {
    can_be_warrior_trigger = { ARMY_OWNER = $ARMY_OWNER$ }
    NOR = {
        AND = {
            has_trait = devoted
            faith = {
                NOT = {
                    has_doctrine_parameter = clergy_can_fight
                }
            }
        }
        AND = {
            is_clergy = yes
            faith = {
                NOT = {
                    has_doctrine_parameter = clergy_can_fight
                }
            }
        }
        #AND = {
        #    is_ai = no
        #    NOT = {
        #        has_character_flag = player_knight
        #    }
        #}
        has_trait = blind
    }
    #is_ai = yes
}
I then started a game and edited the save file to make the player their own employer. As JUAN showed this made him show up in the knight tab and kill troops in battle!
Player character also duelled, though this lacked localisation; for example, wounding an enemy showed: "knight_wounded_by_enemy_enemy_player". Seems the devs didn't fill this in, should be doable. (EDIT: Play-testing the current version a bit now. Noticed that you show up twice when picking a commander for yout army. Guessing it's because you're both the ruler and a courtier; minor bug. EDIT 2: you also seem able to be your own councillor since you're technicly a courtier)

Juan also pointed out the Player can be Knight mod by Foxador which is where he got the triggers.

The problem both we and Foxador then face is writing something that makes the player their own courtier without save editing. If that could be done all left for this to be functioning perfectly is localisation and a character decision allowing yourself to be a knight for your liege.
 
Last edited:
  • 3Like
Reactions: