Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: Creating a World - Faction Limits for Agents

  1. #1
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Creating a World - Faction Limits for Agents

    One day I got tired of the endless spy and priest spams of the AI. Turns out using the faction_capabilities didn't work as it simply decreased the agent_limit of the individual buildings until at a certain number of buildings in the faction no recruitment at all was possible.
    Which meant it had to be via the script. After some testing and some help here now the finished result for spies and assassins:

    Code:
    ;=== Faction Limits for agents ===
    
    declare_counter spy_counter
    declare_counter assassin_counter
    
    monitor_event PreFactionTurnStart TrueCondition   ; resetting counters for the coming faction
            set_event_counter spy_limit 0
            set_counter spy_counter 0
            set_event_counter assassin_limit 0
            set_counter assassin_counter 0
    end_monitor
    
    monitor_event CharacterTurnStart TrueCondition
        and AgentType = spy
        inc_counter spy_counter 1
            if I_CompareCounter spy_counter = 2   ; corresponding to desired max number
                set_event_counter spy_limit 1
            end_if
    end_monitor
    monitor_event CharacterTurnStart TrueCondition
        and AgentType = assassin
        inc_counter assassin_counter 1
            if I_CompareCounter assassin_counter = 2   ; corresponding to desired max number
                set_event_counter assassin_limit 1
            end_if
    end_monitor
    EDB entry for each agent's entry

    Code:
                capability
                {
                    agent spy  0  requires factions { all, } and not event_counter spy_limit 1
                    agent_limit spy 1    ; limit per building - still needs to be set to restrict at lower levels of building count
                    agent assassin  0  requires factions { all, } and not event_counter assassin_limit 1
                    agent_limit assassin 1    ; limit per building - still needs to be set to restrict at lower levels of building count
                }
    Recruiting will be disabled\enabled in the round after the number of agents has reached or fallen below the desired maximum number respectively.
    Last edited by Gigantus; April 29, 2017 at 06:13 AM.










  2. #2
    Polycarpe's Avatar Back into action!
    Join Date
    Feb 2010
    Location
    Quebec, Canada
    Posts
    3,338

    Default Re: Creating a World - Faction Limits for Agents

    Interesting, that means an AI faction can't spawn across the map and during the game the limited number of agents scripted?

    if the spy_counter = 2 means that faction can't recruit more than 2 spies in total?

    Regards.

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    Correct: "counter = 2 ; corresponding to desired max number" is the maximum number of the agent type permitted per faction.










  4. #4
    Polycarpe's Avatar Back into action!
    Join Date
    Feb 2010
    Location
    Quebec, Canada
    Posts
    3,338

    Default Re: Creating a World - Faction Limits for Agents

    Thank you dear Gigantus, you are helping me to remove the rust from my skills. +rep

  5. #5
    Vipman's Avatar Protector Domesticus
    Join Date
    Jul 2010
    Location
    Romania
    Posts
    4,405

    Default Re: Creating a World - Faction Limits for Agents

    But unfortunately it's still possible for player to have 5 cities with inn and recruit 5 spies in one turn, right?

  6. #6
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    I haven't tested for that, if it is indeed possible, then only in the first round - I doubt it though.










  7. #7
    Vipman's Avatar Protector Domesticus
    Join Date
    Jul 2010
    Location
    Romania
    Posts
    4,405

    Default Re: Creating a World - Faction Limits for Agents

    Well if I have just 1 spy, spy_limit is 0 and it's possible to recruit 1 spy in any city with inn. I'm able to put spies on recruiting queue in as many cities I have and they will be all trained, as I see that the monitor checks the number of spies at start of the turn, so not during the turn, script doesn't check how many spies I put on queue to change counter depending on that, and agents are trained after clicking end turn.

    To avoid this it would be necessary for monitor to run between every spy/assassin recruited (which would be at SettlementTurnEnd or something I guess?) and once a limit is reached it has to cancel rest of spies/assassins on recruiting queue. Would be good if such a thing is possible and works.

  8. #8
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    Are you sure they will all get trained? I would have thought they will get stuck in the recruitment queue.

    Certainly will have to try myself.

    Edit: yes, you are right, that exploit will work. I doubt the AI will recruit that many agents in one round, so it's still a partial success I would think.
    The AddedToTrainingQueue event might just do the trick. I'll come back on that one.

    Edit2: that appears only to work for units from the EDU, not characters.
    The AgentCreated event might get the the surplus agents stuck in the training queue when it fires, but then it's only the player that will be effected by it I would say. More testing...

    Edit3: Nope, no luck.
    Last edited by Gigantus; March 14, 2014 at 05:02 AM. Reason: mo' testing










  9. #9
    Vipman's Avatar Protector Domesticus
    Join Date
    Jul 2010
    Location
    Romania
    Posts
    4,405

    Default Re: Creating a World - Faction Limits for Agents

    Well with the script here they got trained, faction had limit of 1 assassin, I trained 2 assassins in the same turn
    http://www.twcenter.net/forums/showt...1#post12929010

    Only way I can see it, your script might work if order would be like this: I click end turn, SettlementTurnEnd comes (if this is when buildings/units are recruited), 1 spy is recruited, CharacterTurnStart for this spy comes, your script kicks in and increases counter and if limit is reached it disables recruiting more spies, then SettlementTurnEnd continues with units/buildings and other spies are cancelled from the queue.

    But I have no idea if it works like this. Don't know exactly the order of all these either. If it's not like I said above, then another way I guess would be if in your script you'd use CharacterTurnEnd or most probably SettlementTurnEnd instead of CharacterTurnStart to check the number of spies/assassins, it might be possible that monitor might run while each spy is recruited and once limit is reached other spies are cancelled since spies aren't trainable anymore. But this is just a guess.

    Edit: Would also be good if you can make to be able to recruit just 1 type of such agent per turn per whole faction
    Last edited by Vipman; March 14, 2014 at 05:02 AM.

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

    Default Re: Creating a World - Faction Limits for Agents

    CharacterTurnEnd or most probably SettlementTurnEnd instead
    For the player* recruitment happens after clicking the turn end button and before any of the xxxTurnEnd events. It is too late by then even for those events.

    * AI I don't know.

    AddedToTrainingQueue - I don't think could have worked anyway: the script attached to it would be setting the event counter to 0 which in turn would remove that agent from the queue (I think) because they are no longer recruitable according to the "agent" line conditions.

    AgentCreated - I think is (was) the only hope. But would setting the event counter to 0 at that time remove any other agents of that type from the queues? I don't know: maybe at that point the game has already decided who will be recruited this turn and cares not about "agent" conditions (event counters), so it is too late by the time AgentCreated fires.

  11. #11
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    Quote Originally Posted by Withwnar View Post
    AddedToTrainingQueue - I don't think could have worked anyway: the script attached to it would be setting the event counter to 0 which in turn would remove that agent from the queue (I think) because they are no longer recruitable according to the "agent" line conditions.
    This does work for units listed in the EDU. It would have been perfect as each addition to the queue would increase the counter, stopping the agent from appearing in the recruitment rooster once the counter is 'full'.
    Code:
    monitor_event AddedToTrainingQueue FactionIsLocal
        and AgentType = spy ; invalid as only the type entry from EDU is accepted
        inc_counter spy_counter 1
    end_monitor
    Quote Originally Posted by Withwnar View Post
    AgentCreated - I think is (was) the only hope. But would setting the event counter to 0 at that time remove any other agents of that type from the queues? I don't know: maybe at that point the game has already decided who will be recruited this turn and cares not about "agent" conditions (event counters), so it is too late by the time AgentCreated fires.
    This event is basically 'after the effect' and does not prevent recruiting. Re removal - see the above argument.










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

    Default Re: Creating a World - Faction Limits for Agents

    AddedToTrainingQueue: a shame about AgentType not working. But for completeness it would also have needed a RemovedFromTrainingQueue event, which doesn't exist.

    AgentCreated: in your test were you setting the event counter as well as the counter? e.g....

    Code:
    monitor_event AgentCreated FactionIsLocal
        and AgentType = spy
        
        inc_counter spy_counter 1
        
        if I_CompareCounter spy_counter = 2   ; corresponding to desired max number
            set_event_counter spy_limit 1
        end_if
    
    end_monitor

  13. #13
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    I used counter and event_counter because the counter will increase until the limit (2) set earlier. The event_counter will only be either zero or one and will be used in the EDB. You could of course rewrite the script and EDB entry to only use event_counters, but that may end up being a bit convoluted as the EDB entry can only test for event_counter xyz 1










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

    Default Re: Creating a World - Faction Limits for Agents

    I meant that in your script example in post 11 you are only setting the counter and not the thing that affects EDB: the event counter. So I was wondering if your test of AgentCreated (which you said didn't work) was the same: was not setting the event counter.

  15. #15
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    Post #11's monitor is using the script of post #1, consider it a replacement of this monitor:
    Code:
    monitor_event CharacterTurnStart TrueCondition
         and AgentType = spy
    It didn't work in the sense of 'it didn't prevent the multiple recruiting exploit' - otherwise it did just as well as the CharacterTurnStart monitor










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

    Default Re: Creating a World - Faction Limits for Agents

    Okay, thanks. Then, yes, it looks like that by the time AgentCreated fires the horse has already bolted; it is too late to try adjusting event counters to affect recruitment via EDB conditions.

  17. #17
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    I think putting a reasonably high recruiting price versus low wages should deter the AI to do multiple recruiting of a single agent type per round. As such the script will do it's work, as to the player - well, I am of the opinion that I should be able to defeat the AI within it's rules, if I really need to make use of exploits then it's probably time to rethink my strategy. (It's one of my 'house rules' --> no exploits)










  18. #18
    Valiant Champion's Avatar Praepositus
    Join Date
    Jun 2008
    Location
    Central Kentucky
    Posts
    5,443

    Default Re: Creating a World - Faction Limits for Agents

    how do I disable assassins and inquisators?

    BETTER PIKES
    https://www.twcenter.net/forums/show...2#post16143112

    THE PIKE WARS HAVE BEGUN!

  19. #19
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Faction Limits for Agents

    assassins - remove their recruitment entries from the EDB
    inquisitors - via descr_campaign_db, this entry in the <religion> section: <max_inquisitors uint="0"/>










  20. #20
    Valiant Champion's Avatar Praepositus
    Join Date
    Jun 2008
    Location
    Central Kentucky
    Posts
    5,443

    Default Re: Creating a World - Faction Limits for Agents

    thanks. but what about the assassins guild buildings and assassination missions?

    BETTER PIKES
    https://www.twcenter.net/forums/show...2#post16143112

    THE PIKE WARS HAVE BEGUN!

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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