Results 1 to 20 of 20

Thread: Crusade/Jihad AI target limitation? - SOLVED

  1. #1
    Ngugi's Avatar TATW & Albion Local Mod
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    10,687

    Default Crusade/Jihad AI target limitation? - SOLVED

    Hi
    Gone through a big bunch of threads by now but found no one about my concern;

    Can the AI be manipulated to 1) prefere a special religion/factions as target or 2) ignore certain religions/factions?
    Example 1) AI crusades are only targeted at muslim nations?
    Example 2) AI jihads wont be declared at orthodox nations?

    AFAIK you can somewhat alter the AI logics, who it start war with and so on, through descr_campaign_ai_db.xml
    The thing is that war in general, between for example muslims and orthodox, should not be limited but the muslims should just be as unlikely as possible to launch a jihad against any orthodox faction - even if orthodox are owning a settlement noted as targets in descr_regions.txt. Either based upon the orthodox religion itself or if I can edit in factions one by one as unlikely targets.
    Or, using the same example, that muslims will only start jihads directed at catholics/catholic factions, thus removing any need to restrain them from using jihad against other factions such as orthodox ones?

    At the moment my unpacker won't launch so I cant compare my mod-version of the descr_campaign_ai_db.xml, lacking any entries about crusades or jihads it seems, to an original one. Thought I could just as well begin to ask weither people tried to edit crusade/jihad-targets in this manner first and weither its considered possible?
    Or if its would to be altered in descr_campaign_db.xml, then perhaps its not possible at all, as here's a section about crusade/jihad but nothing obvious to alter?

    Cheers Ngugi
    Last edited by Ngugi; December 31, 2011 at 08:41 AM.

    Kingdom of Lindon preview video out





    DCI: Last Alliance
    - WIP Second Age mod | DCI: T˘l Acharn - mighty D˙nedain Counter Invasions |
    Additional Mercenary Minimod - more mercs; for TATW and DCI | Family Tree minimods - lore improvements | Remade Event Pictures - enhance cultures trough images |
    Favorite TATW compilation: Withwnars Submod Collection
    Patron of Mank, Kiliš Alý, FireFreak111, MIKEGOLF & Arachir Galudirithon, Earl of Memory

  2. #2
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,277

    Default Re: Crusade/Jihad AI target limitation?

    Bump. I'm working with Ngugi on this and we have hit a snag: the AI is calling Jihads on 'wrong' targets. That is, settlements owned by allies, or at least fellow 'good' factions.

    Is there any way to prevent this?

    Either by some condition that says "cannot call jihad on factions { x, y, z }" or "can only call jihads on catholic religion".

    descr_campaign_db.xml and descr_campaign_ai_db.xml don't look promising. Am I correct in thinking that descr_campaign_ai_db.xml's invasion settings are overridden/ignored by jihads? If not then we might be able to use some new rules in there with link_campaign_ai during jihads, to at least stop factions joining a jihad.

    The player calling a jihad on the 'wrong' target is not a big issue - that is up to them.

    If this is not possible then is there any way to give jihad missions to the AI and make it so that only those the AI may do; it can't call them directly?

    Any help would be great.

  3. #3

    Icon1 Re: Crusade/Jihad AI target limitation?

    Ngugi and Withwnar: There is probably no reliable way to stop the AI calling a Jihad on the wrong target.

    But it may be possible to stop any faction actually joining that Jihad:
    Spoiler Alert, click show to read: 
    Code:
    declare_counter wrong_target_jihad_sicily
    declare_counter wrong_target_jihad_turks
    
    	monitor_event CrusadeCalled IsJihad
    		and not TargetReligion catholic
    		if I_NumberOfSettlements sicily >= 1
    		and I_IsFactionAIControlled sicily
    		set_religion sicily northmen
    		set_counter wrong_target_jihad_sicily 2
    	end_if
    		if I_NumberOfSettlements turks >= 1
    		and I_IsFactionAIControlled turks
    		and I_EventCounter union_accepted = 1
    		set_religion turks northmen
    		set_counter wrong_target_jihad_turks 2
    	end_if
    	end_monitor
    
    	monitor_event FactionTurnStart FactionType sicily
    		and I_CompareCounter wrong_target_jihad_sicily >= 1
    		inc_counter wrong_target_jihad_sicily -1
    
    		if I_CompareCounter wrong_target_jihad_sicily = 0
    		set_religion sicily islam
    	end_if
    	end_monitor
    
    	monitor_event FactionTurnStart FactionType turks
    		and I_CompareCounter wrong_target_jihad_turks >= 1
    		inc_counter wrong_target_jihad_turks -1
    
    		if I_CompareCounter wrong_target_jihad_turks = 0
    		set_religion sicily islam
    	end_if
    	end_monitor
    Last edited by TNZ; December 29, 2011 at 03:31 AM.

  4. #4
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,277

    Default Re: Crusade/Jihad AI target limitation?

    Thanks very much TNZ.

    Change all of the potential jihad joining factions to non-islam religion while the jihad is in progress. Yes, that should do the trick. Nice one.

  5. #5
    Ngugi's Avatar TATW & Albion Local Mod
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    10,687

    Default Re: Crusade/Jihad AI target limitation?

    Thanks TNZ, once more your knowlidge is of great value to our project

    Kingdom of Lindon preview video out





    DCI: Last Alliance
    - WIP Second Age mod | DCI: T˘l Acharn - mighty D˙nedain Counter Invasions |
    Additional Mercenary Minimod - more mercs; for TATW and DCI | Family Tree minimods - lore improvements | Remade Event Pictures - enhance cultures trough images |
    Favorite TATW compilation: Withwnars Submod Collection
    Patron of Mank, Kiliš Alý, FireFreak111, MIKEGOLF & Arachir Galudirithon, Earl of Memory

  6. #6

    Default Re: Crusade/Jihad AI target limitation?

    Does limiting the targets of Crusade and Jihad to for example Rome and Mecca respectively also limit AI calling Crusade/Jihads or will it ignore only 2 defined targets following some hardcoded plan and calling them on anything it wants?

  7. #7

    Default Re: Crusade/Jihad AI target limitation?

    Quote Originally Posted by Ichon View Post
    Does limiting the targets of Crusade and Jihad to for example Rome and Mecca respectively also limit AI calling Crusade/Jihads or will it ignore only 2 defined targets following some hardcoded plan and calling them on anything it wants?
    It will do the highlighted part.

  8. #8
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,277

    Default Re: Crusade/Jihad AI target limitation?

    Solved!

    TNZ's idea did work up to a point. Islam factions were prevented from joining the jihad but it had no effect on any armies that were already joined (I was hoping that it would cancel it for them but no such luck). Worse yet, if the target's owner is allied with all of these jihading army factions then they don't attack the settlement. They all just stand about. After 50 turns I stopped testing; clearly nothing was going to happen. (In one test two of those factions actually went to war with each other, though their homelands were nowhere near each other.)

    Also, TNZ made the excellent point (elsewhere) that even if the target was originally 'valid' (settlement owner wise) if an 'invalid' faction captures it then they are now the target faction. As soon as a jihad army attacks the settlement there will be war between these two factions.

    The solution handles both situations.

    1) During the turn of islam factions, change the religion of 'invalid' factions also to islam. This eliminates all of their settlements as possible jihad targets, because they are now islam-owned. At the end of the turn change them back to whatever they should be. This is only done during AI turns, not the player's, otherwise all of those other factions will appear to the player as being islam. So this only prevents the AI from calling "wrong jihads", not the player (which is fine).

    2) When an 'invalid' faction captures a jihad target, change their religion to islam. This instantly cancels the jihad and their religion can now be switched back.

    3) If the target settlement is gifted to an 'invalid' faction then do the same as 2).

    As an alternative to 1) I tried switching the religion to islam when the jihad was called. This didn't work. The religion did switch but it did not cancel the jihad. Even if it did work it would mean that the jihad call is still wasted; a wait before they can try again... and that might be a wasted one too... and so on...

    On a side note, I found that this...

    Code:
    monitor_event ArmyTakesCrusadeTarget IsJihad
    ...only fires when the army - all units within it - is on jihad. It does not fire if the army is a mixture of jihad and non-jihad. And does not fire if the army is not on jihad at all. And therefore does not fire if the army is of another faction (non-islam).

    This works just fine...
    Code:
    monitor_event GeneralCaptureSettlement IsJihadTarget

  9. #9

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    Can I have a jihad call to another islamic faction? I like mod this to represent "aztec flower wars" https://en.wikipedia.org/wiki/Flower_war

    plz help !
    ...Feel like a true dyslexic codder...

  10. #10
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,277

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    It is hardcoded that islam can't call jihads on islam, like catholic can't call crusades on catholic. I don't think switching religions, as described above, would help: e.g. during an islam faction's turn make all other islam factions a non-islam religion. At some point those factions need switching back to islam (e.g. during their own turn) and if they were a jihad target then at that point the jihad would end.

    One way could be to add a new religion (if there are any religion slots left) and script-set that religion for whichever islam faction you wish to target. The difference being that this time you don't switch them back to islam, at least for a decent duration. They remain a non-islam faction and are therefore fair game. So it becomes a question of who gets to be switched (under what conditions) and how long for. But changing a faction's religion might have implications elsewhere; some files working on the assumption that they are islam, e.g descr_campaign_ai_db.xml (AI logic).

  11. #11
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    3,946

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    Sorry to dig up this corpse.

    I have an issue with a Pope faction calling crusades left, right and center. I'm not sure if it's actually the Pope faction that calls for a crusade or another catholic faction. Anyway, I was wondering if this script would also work with Catholic factions. Could you use this script to temporarily switch the religion of all factions to say orthodox in order to prevent the pope from calling crusades?

    Also, how would this script look like? I'm a noob at scripting, but I try my best to read what does what in a script, with mixed results to say the least. Any help would be appreciated.

  12. #12
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,277

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    Could you use this script to temporarily switch the religion of all factions to say orthodox in order to prevent the pope from calling crusades?
    Does the game not call crusades on Orthodox faction settlements? I don't remember. And do you mean all factions, or all crusade-calling ones, or all potential target ones?

    Something to bear in mind when considering changing religions in-game: descr_campaign_ai_db.xml typically has many rules about how to behave against factions based on their religion. Changing religions therefore changes those behaviours.

    Something else is the religious buildings being auto-destroyed upon capture by a different religion: that would not happen if the capturing faction was religion-switched to be the same as the building they're capturing.

  13. #13
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    3,946

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    Quote Originally Posted by Withwnar View Post
    Does the game not call crusades on Orthodox faction settlements? I don't remember. And do you mean all factions, or all crusade-calling ones, or all potential target ones?

    Something to bear in mind when considering changing religions in-game: descr_campaign_ai_db.xml typically has many rules about how to behave against factions based on their religion. Changing religions therefore changes those behaviours.

    Something else is the religious buildings being auto-destroyed upon capture by a different religion: that would not happen if the capturing faction was religion-switched to be the same as the building they're capturing.
    Nope, you can't call a crusade on orthodox factions. I only want to prevent crusades from happening until a faction has become powerful enough and meets a number of conditions so it can call a crusade and rally all other factions to participate. Perhaps this can also be achieved by lowering the amount of favor points a faction has with the pope, so factions can't call a crusade, but I assume that the pope can still call one, so...
    Also, won't the game crash if the pope gets assigned a different religion? I haven't tried it yet.

    Also, all factions have the same religion (catholic) except for the rebels who are heretic. I believe that buildings that spread religion don't automatically get destroyed? Doesn't that depend on the temple_ suffix in EDB?

  14. #14
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,277

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    but I assume that the pope can still call one
    So do I, though not certain. And my experience in religion switching is only in TATW which doesn't have priests. e.g. If a catholic faction has a cardinal then does he stay a cardinal when switched to say orthodox? Surely not, is my feeling.

    Maybe consider removing the pope until such time that crusades are allowed to be called?

    I believe that buildings that spread religion don't automatically get destroyed? Doesn't that depend on the temple_ suffix in EDB?
    Buildings with a "Religion" attribute and a "city" or "castle" qualifier.

  15. #15
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    3,946

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    Quote Originally Posted by Withwnar View Post
    So do I, though not certain. And my experience in religion switching is only in TATW which doesn't have priests. e.g. If a catholic faction has a cardinal then does he stay a cardinal when switched to say orthodox? Surely not, is my feeling.
    He will still stay a cardinal or priest or whatever, but if you'd switch religion he would then convert the province to the new religion instead. Priests aren't tied to a specific religion, but to factions.


    Quote Originally Posted by Withwnar View Post
    Maybe consider removing the pope until such time that crusades are allowed to be called?
    That would be quite an awkward solution, since that would render the whole College of Cardinals mechanic and favor points with the Pope obsolete.


    Quote Originally Posted by Withwnar View Post
    Buildings with a "Religion" attribute and a "city" or "castle" qualifier.
    Good, I have neither a "city" or "castle" qualifier designated in EDB so everything should be just fine.


    I guess one way is to make sure that every faction temporarily switches to orthodox when it's the AI turn. Another way would be to make sure that the favor point of factions all stay low enough to prevent a crusade from happening and at the same time prevent catholic factions from getting excommunicated.

  16. #16
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,277

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    He will still stay a cardinal or priest or whatever, but if you'd switch religion he would then convert the province to the new religion instead. Priests aren't tied to a specific religion, but to factions.
    But will he remain in the College of Cardinals? That's what I was driving at. It makes no sense that he would, as he's no longer catholic, but I don't know.

    If he doesn't then religion switching and pope removal both stuff up the College, in which case pope removal might be the lesser of two evils.

    Good, I have neither a "city" or "castle" qualifier designated in EDB so everything should be just fine.
    descr_campaign_ai_db.xml might still be a problem though. I'd be searching for "catholic" in there before deciding on a religion switching approach.

  17. #17

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    This thread seems to imply that crusade and jihad targets are 1) the same for human and AI factions, i.e. the AI will only pick a target that shows up on your (human) priest/imam list and 2) that these available targets are only determined by the religion of the target faction, i.e. if the target faction is non-islam, then they can be targeted for jihad whereas all religions can be target for crusade, even excommunicated catholic factions (?). The specific settlements the game picks for these non-islam target factions seem to also be based on additional modifiers like settlement population or income or some such - I've never seen it allow targeting of small, unimportant villages, for example.

    Are my inferences correct? Is there truly no way to limit crusade/jihad targets on a region-by-region basis? Does anyone know what the "additional modifiers" are that limit the possible crusade/jihad targets to only a subset of a target faction's regions? For my purposes, I don't care who the owning faction is for a jihad target (as long as they're non-islam), I only would like to restrict the targets to a fixed set of regions.

    Vanilla and some mods have hidden resources like "crusade", "jihad", and "horde_target" which, as far as I can tell, don't appear to do anything at all. Or at least, there doesn't appear to be anything hard coded about these hidden resources. I've asked about a related issue here as I've never encountered a hidden resource that actually did anything other than serve as an identifier in export_descr_buildings and export_descr_guilds. Am I wrong about this?
    Last edited by Callistonian; September 21, 2020 at 10:18 AM.

  18. #18
    bitterhowl's Avatar Centenarius
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    838

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    Horde_target is fully functional. AFAIK horde should appear not much than at 75 tiles from target for correct work. And in my mod I got one target for each horde in area.

    My sister, do you still recall
    The blue Hasan and Khalkhin-Gol?

    Because AI is dumb and full of errors.

  19. #19

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    You must have parameters in descr_campaign_db or elsewhere set up differently. In my mod, I've tried spawning the horde in regions with the horde_target HR, I've tried spawning them nearby these regions, I've tried having the horde start on the map in descr_strat instead of spawn, I've tried forcing the horde to attack the settlement (they sack and pop out), I've tried gifting the settlement to the horde (using the console command and using a dummy faction with give_everything. Nothing works. The horde invariably picks a random settlement somewhere on the map and marches (very slowly) towards it. I haven't found any way to force a horde to settle let alone to determine where this will happen.

  20. #20
    bitterhowl's Avatar Centenarius
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    838

    Default Re: Crusade/Jihad AI target limitation? - SOLVED

    I did everything as described here https://www.twcenter.net/forums/show...dvanced-users)

    And everything works just fine.

    My sister, do you still recall
    The blue Hasan and Khalkhin-Gol?

    Because AI is dumb and full of errors.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •