TreeSpawned
Chieftain
I writing a mod, where I want one of my leaderheads to only ever respond with dialogue, that is associated with him in particular, i.e. responses that have his LeaderType and not any dialogue responses that are generic to all leaders, i.e. responses without any LeaderType.
I think I almost have a solution, but I don't have any experience programming in Python and therefore i am stuck.
Searching through the Python code I found the file CvDiplomacy.py which seems to be what I am looking for.
In it there is a function called filterUserResponse. If I read correctly this method determines which of all the possible sentences is returned for a specific diplo line.
It goes through all the lines that there are and those that do not fit it's criteria are dismissed using 'continue'. And those that fit all criteria are added to a list called 'responses' in the end from which a random one is chosen.
So I am guessing all I need to programm is: 1. Check if this is the leader I want 2. Check if the line is not associated with any leader and if both those critieria are met, throw out that line with a 'continue'.
I tried it like this, but it does nothing:
if (theirPlayer.getLeaderType() == "LEADER_MURKY" and
not self.isUsed(diploInfo.getLeaderHeadTypes, i, gc.getNumLeaderHeadInfos())):
continue
'theirPlayer' is defined further up in the same function using:
theirPlayer = gc.getPlayer(self.diploScreen.getWhoTradingWith())
From what I think I have found out testing this code (I have no idea how to debug this other than trying it out in-game), I think the first condition is never met, It doesn't matter if the leader I am contacting is LEADER_MURKY or anyone else, the first line always returns false.
The second line I copied from the already existing check for the leader type. I hope I am correct in assuming this checks whether the line has any leader type.
Does anyone know what my error is? Is the return value of .getLeaderType() not a string? Am I comparing strings incorrectly? Or is it something else entirely?
I am looking forward to all of your feedback.
I think I almost have a solution, but I don't have any experience programming in Python and therefore i am stuck.
Searching through the Python code I found the file CvDiplomacy.py which seems to be what I am looking for.
In it there is a function called filterUserResponse. If I read correctly this method determines which of all the possible sentences is returned for a specific diplo line.
It goes through all the lines that there are and those that do not fit it's criteria are dismissed using 'continue'. And those that fit all criteria are added to a list called 'responses' in the end from which a random one is chosen.
So I am guessing all I need to programm is: 1. Check if this is the leader I want 2. Check if the line is not associated with any leader and if both those critieria are met, throw out that line with a 'continue'.
I tried it like this, but it does nothing:
if (theirPlayer.getLeaderType() == "LEADER_MURKY" and
not self.isUsed(diploInfo.getLeaderHeadTypes, i, gc.getNumLeaderHeadInfos())):
continue
'theirPlayer' is defined further up in the same function using:
theirPlayer = gc.getPlayer(self.diploScreen.getWhoTradingWith())
From what I think I have found out testing this code (I have no idea how to debug this other than trying it out in-game), I think the first condition is never met, It doesn't matter if the leader I am contacting is LEADER_MURKY or anyone else, the first line always returns false.
The second line I copied from the already existing check for the leader type. I hope I am correct in assuming this checks whether the line has any leader type.
Does anyone know what my error is? Is the return value of .getLeaderType() not a string? Am I comparing strings incorrectly? Or is it something else entirely?
I am looking forward to all of your feedback.