Results 1 to 16 of 16

Thread: Religion Switching

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    JorisofHolland's Avatar Primicerius
    Join Date
    Jan 2009
    Location
    In a house
    Posts
    3,779

    Default Religion Switching

    I'm working on a script that will enable all factions (in the Americas Capmaign) to switch religion, if they ally a nation that has a different religion, they will have to choose between their ways and the way of the other.
    Now, the script isn't causing much trouble but one thing is: the "offer", that will enable the choise. I tried to change one of the events and replace it with the one from the Teutonic Campaign, but it did not work. Does anyone know waht I am doing wrong/missing/whatever?
    The Enemy of Human Souls
    Sat grieving at the cost of coals;
    For Hell had been annexed of late,
    And was a sovereign Southern State.

  2. #2
    konny's Avatar Artifex
    Join Date
    Jul 2007
    Location
    Germania Inferior
    Posts
    3,631

    Default Re: Religion Switching

    Absolutly impossible to say without knowing the code you are trying to implement.

    Team member of: Das Heilige Römische Reich, Europa Barbarorum, Europa Barbarorum II, East of Rome
    Modding help by Konny: Excel Traitgenerator, Setting Heirs to your preference
    dHRR 0.8 beta released! get it here
    New: Native America! A mini-mod for Kingdoms America

  3. #3
    JorisofHolland's Avatar Primicerius
    Join Date
    Jan 2009
    Location
    In a house
    Posts
    3,779

    Default Re: Religion Switching

    This is the script I use (just a test round):
    Spoiler Alert, click show to read: 

    monitor_event FactionTurnStart FactionType mayans

    if I_TurnNumber = 2

    ;offer conversion to christianity
    historic_event america_discovered true factions { mayans, }

    terminate_monitor

    end_if


    And I used a strings.bin editor to copy the "Lithuania Conversion" (in historic_events.txt) text from teutonic campaign to my modfolder, and pasted it in the "america discovered" event.
    Last edited by JorisofHolland; August 29, 2009 at 10:04 AM.
    The Enemy of Human Souls
    Sat grieving at the cost of coals;
    For Hell had been annexed of late,
    And was a sovereign Southern State.

  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Religion Switching

    Don't I wish it was that easy!

    If at all you need the whole stuff from the campaign_script file of the teutonic campaign.










  5. #5
    JorisofHolland's Avatar Primicerius
    Join Date
    Jan 2009
    Location
    In a house
    Posts
    3,779

    Default Re: Religion Switching

    So I have to copy and change everything related to the conversion?
    The Enemy of Human Souls
    Sat grieving at the cost of coals;
    For Hell had been annexed of late,
    And was a sovereign Southern State.

  6. #6
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Religion Switching

    I am no script guru, but I would think so. A simple 'cloning' should do the trick. And the obvious historic_events file.
    Get the converter to work with it in TXT format.










  7. #7
    JorisofHolland's Avatar Primicerius
    Join Date
    Jan 2009
    Location
    In a house
    Posts
    3,779

    Default Re: Religion Switching

    The converter works easier than the editor I used, thanks for that and the advice, of course
    BTW: Does the converter automatically reconvert the files?
    The Enemy of Human Souls
    Sat grieving at the cost of coals;
    For Hell had been annexed of late,
    And was a sovereign Southern State.

  8. #8
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Religion Switching

    The 'reconversion' happens automatically: at the start of the game new string.bin files will be generated if the corresponding TXT file is 'younger'.










  9. #9
    JorisofHolland's Avatar Primicerius
    Join Date
    Jan 2009
    Location
    In a house
    Posts
    3,779

    Default Re: Religion Switching

    Thanks again
    The Enemy of Human Souls
    Sat grieving at the cost of coals;
    For Hell had been annexed of late,
    And was a sovereign Southern State.

  10. #10
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Religion Switching

    One is glad to be of service










  11. #11
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Religion Switching

    The religious conversion used in the teutonic campaign is a bit more complex then that. What you have there in the above is just an event, all it will do is pop an accept/decline scroll, the resulting click on Accept or Decline hasn't been programmed to actually do anything.

    This part of the script is the meat of it in terms of the actual conversion, a lot of the rest just handles timers and things which add complexity. I've color coded some of the relevant lines and left a comment line in red below it to explain what the lines are doing.
    Code:
    	monitor_conditions I_EventCounter lithuania_conversion_accepted = 1 
    ;;This counter is set when you click Accept, so the monitor looks for clicking accept and then everything within this monitor fires
    		
    		;Three easy steps for conversion
    		
    		;1 - Convert the people
    		set_religion lithuania catholic 
                    ;;Blue = command to change religion, Green = Faction to change it for, Orange = Religion to change it to; this command is the basic religion change, nothing else is technically needed for the religion itself to change.
    		change_population_religion lithuania catholic 75 pagan
                    ;;Blue = Command to convert a % of the population to the new religion, Green = Faction to affect the change on, Indigo = Religion to convert them into, Cyan = Total % out of 100 to convert, Orange = Religion to take the converted % from
                    ;;So if religious distribution before was Pagan 95%, Orthodox 5%, Catholic 0%, after the above command runs it would be Pagan 20%, Orthodox 5%, Catholic 75%
    		
    		;2 - Destroy the pagan buildings
    		destroy_buildings lithuania temple_dievas true
    		;;Blue = Command to destroy all buildings across faction of specified type, Green = Faction to affect it on, Indigo = The internal name of the building level to be destroyed, Orange = Whether or not to refund the cost of the building to the faction; Same is true for all below
    		destroy_buildings lithuania temple_dievas_castle true
    		destroy_buildings lithuania temple_perkunas true
    		destroy_buildings lithuania temple_perkunas_castle true
    		destroy_buildings lithuania temple_giltine true
    		destroy_buildings lithuania temple_giltine_castle true
    		
    		;3 - Disband the pagan units
    		retire_characters Lithuania priest
    		;;Blue = Command to remove all agents of the specified type, Green = Faction to affect it on, Indigo = Agent to affect it on
    
    end_monitor
    So you would need to modify all of the above to work for your event name, factions, religions, buildings, agent types, etc. If you're using the americas event a very simple example would be this:
    Code:
    monitor_event EventCounter EventCounterType america_discovered_accepted
        and I_EventCounter america_discovered_accepted == 1
    ;;Checks the accepted event counter being set to 1 by the player clicking Accept
    
    ;set religion conversion counter to be picked up next turn
    set_event_counter religious_conversion 1
    ;reset the event counter so it doesn't keep firing
    set_event_counter america_discovered_accepted 0
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
        and FactionType mayans
        and FactionReligion pagan
        and I_EventCounter religious_conversion == 1
    ;;Checks that the faction is mayans, the religious conversion has been accepted, and the current religion is Pagan
    
    ;Change religion for mayans  
      set_religion mayans catholic
    ;Convert 75% of the populace to new religion
      change_population_religion mayans catholic 75 pagan
    end_monitor
    That's just an example. The above script doesn't destroy religious buildings or retire characters, you'll have to look up which ones you want to destroy. It also only works for the mayans and only if they're currently pagan and converting to catholic. Furthermore, it doesn't define the reasons why they're getting the conversion or the conversion event, so it doesn't factor in an allied religion.

    All of these things you need to define for your script, as well as other specific caveats. For instance it currently converts 75% of the population to the new religion, but if it were my script I'd make that much lower since to me the mere fact that the leader says the state religion has changed isn't going to make that high of a percentage forsake the old religion immediately.

  12. #12
    JorisofHolland's Avatar Primicerius
    Join Date
    Jan 2009
    Location
    In a house
    Posts
    3,779

    Default Re: Religion Switching

    Quote Originally Posted by Augustus Lucifer View Post
    The religious conversion used in the teutonic campaign is a bit more complex then that. What you have there in the above is just an event, all it will do is pop an accept/decline scroll, the resulting click on Accept or Decline hasn't been programmed to actually do anything.

    This part of the script is the meat of it in terms of the actual conversion, a lot of the rest just handles timers and things which add complexity. I've color coded some of the relevant lines and left a comment line in red below it to explain what the lines are doing.
    Code:
        monitor_conditions I_EventCounter lithuania_conversion_accepted = 1 
    ;;This counter is set when you click Accept, so the monitor looks for clicking accept and then everything within this monitor fires
     
            ;Three easy steps for conversion
     
            ;1 - Convert the people
            set_religion lithuania catholic 
                    ;;Blue = command to change religion, Green = Faction to change it for, Orange = Religion to change it to; this command is the basic religion change, nothing else is technically needed for the religion itself to change.
            change_population_religion lithuania catholic 75 pagan
                    ;;Blue = Command to convert a % of the population to the new religion, Green = Faction to affect the change on, Indigo = Religion to convert them into, Cyan = Total % out of 100 to convert, Orange = Religion to take the converted % from
                    ;;So if religious distribution before was Pagan 95%, Orthodox 5%, Catholic 0%, after the above command runs it would be Pagan 20%, Orthodox 5%, Catholic 75%
     
            ;2 - Destroy the pagan buildings
            destroy_buildings lithuania temple_dievas true
            ;;Blue = Command to destroy all buildings across faction of specified type, Green = Faction to affect it on, Indigo = The internal name of the building level to be destroyed, Orange = Whether or not to refund the cost of the building to the faction; Same is true for all below
            destroy_buildings lithuania temple_dievas_castle true
            destroy_buildings lithuania temple_perkunas true
            destroy_buildings lithuania temple_perkunas_castle true
            destroy_buildings lithuania temple_giltine true
            destroy_buildings lithuania temple_giltine_castle true
     
            ;3 - Disband the pagan units
            retire_characters Lithuania priest
            ;;Blue = Command to remove all agents of the specified type, Green = Faction to affect it on, Indigo = Agent to affect it on
     
    end_monitor
    So you would need to modify all of the above to work for your event name, factions, religions, buildings, agent types, etc. If you're using the americas event a very simple example would be this:
    Code:
    monitor_event EventCounter EventCounterType america_discovered_accepted
        and I_EventCounter america_discovered_accepted == 1
    ;;Checks the accepted event counter being set to 1 by the player clicking Accept
     
    ;set religion conversion counter to be picked up next turn
    set_event_counter religious_conversion 1
    ;reset the event counter so it doesn't keep firing
    set_event_counter america_discovered_accepted 0
     
    end_monitor
     
    monitor_event FactionTurnStart FactionIsLocal
        and FactionType mayans
        and FactionReligion pagan
        and I_EventCounter religious_conversion == 1
    ;;Checks that the faction is mayans, the religious conversion has been accepted, and the current religion is Pagan
     
    ;Change religion for mayans  
      set_religion mayans catholic
    ;Convert 75% of the populace to new religion
      change_population_religion mayans catholic 75 pagan
    end_monitor
    That's just an example. The above script doesn't destroy religious buildings or retire characters, you'll have to look up which ones you want to destroy. It also only works for the mayans and only if they're currently pagan and converting to catholic. Furthermore, it doesn't define the reasons why they're getting the conversion or the conversion event, so it doesn't factor in an allied religion.

    All of these things you need to define for your script, as well as other specific caveats. For instance it currently converts 75% of the population to the new religion, but if it were my script I'd make that much lower since to me the mere fact that the leader says the state religion has changed isn't going to make that high of a percentage forsake the old religion immediately.
    Most of what you say I already knew, but there are some things I didn't. However, the biggest problem is (for now) the event isn't offered as it should.
    The Enemy of Human Souls
    Sat grieving at the cost of coals;
    For Hell had been annexed of late,
    And was a sovereign Southern State.

  13. #13
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Religion Switching

    Quote Originally Posted by JorisofHolland View Post
    Most of what you say I already knew, but there are some things I didn't. However, the biggest problem is (for now) the event isn't offered as it should.
    If you're using the code you posted a few posts up, terminating a monitor within an if statement will break it.

  14. #14
    JorisofHolland's Avatar Primicerius
    Join Date
    Jan 2009
    Location
    In a house
    Posts
    3,779

    Default Re: Religion Switching

    I have this code, but still one or two problems (maybe even more)
    Code:
     
     
     declare_counter americas_discovered
     declare_coutner religious_conversion
     
     monitor_event FactionTurnStart FactionType mayans
     
      if I_TurnNumber = 2
       and I_EventCounter americas_discovered = 0
     
       ;offer conversion to christianity
       historic_event americas_discovered true factions { mayans, }
     
       ;if AI random chance to accept
       if I_IsFactionAIControlled mayans
     
        generate_random_counter random_accept 0 2
        if I_EventCounter random_accept < 2
         set_event_counter americas_discovered_accepted 1
        end_if
     
       end_if 
     
       terminate_monitor
    ;
    ;   Counter for converting
    ;
    monitor_event EventCounter EventCounterType america_discovered_accepted
        and I_EventCounter america_discovered_accepted == 1
    ;;Checks the accepted event counter being set to 1 by the player clicking Accept
    ;set religion conversion counter to be picked up next turn
    set_event_counter religious_conversion 1
    ;reset the event counter so it doesn't keep firing
    set_event_counter america_discovered_accepted 0
    end_monitor
    monitor_event FactionTurnStart FactionIsLocal
        and FactionType mayans
        and FactionReligion pagan
        and I_EventCounter religious_conversion == 1
    ;;Checks that the faction is mayans, the religious conversion has been accepted, and the current religion is Pagan
    ;Change religion for mayans  
      set_religion mayans catholic
    ;Convert 75% of the populace to new religion
      change_population_religion mayans catholic 75 pagan
    end_monitor
    There is no "offer" in the 2d turn, in the third it just continious playing normal, as in the 4th turn.
    Last edited by JorisofHolland; September 04, 2009 at 08:24 AM.
    The Enemy of Human Souls
    Sat grieving at the cost of coals;
    For Hell had been annexed of late,
    And was a sovereign Southern State.

  15. #15
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Religion Switching

    One problem is shown in red:
    Code:
     monitor_event FactionTurnStart FactionType mayans
     
      if I_TurnNumber = 2
       and I_EventCounter americas_discovered = 0
    You declared a counter but are checking for an event counter. Try using I_CompareCounter instead. You're also missing an end_monitor on the first monitor, which is likely the real issue. The other one would probably function but if you tried to manipulate it and make it 1 or something then it would be off-base.

  16. #16

    Icon1 Re: Religion Switching

    Just an idea:

    Spoiler Alert, click show to read: 
    Code:
    	monitor_event FactionTurnStart FactionType mayans
    		and FactionReligion pagan
    		and I_TurnNumber = 2
    		if I_LocalFaction mayans
    		add_events
    		event	counter	americas_discovered_accepted
    		event	counter	americas_discovered_declined
    	 	date	0
    	 	end_add_events
    		historic_event americas_discovered true
    	end_if
    
    		if I_IsFactionAIControlled mayans
    		and RandomPercent >= 50
    		set_event_counter americas_discovered_accepted 1
    	end_if
    	end_monitor
    
    	monitor_conditions I_EventCounter americas_discovered_accepted = 1
      		set_religion mayans catholic
      		change_population_religion mayans catholic 75 pagan
    		set_event_counter americas_discovered_accepted 0
    	end_monitor
    
    	monitor_conditions I_EventCounter americas_discovered_declined = 1
    		set_event_counter americas_discovered_declined 0
    	end_monitor

Posting Permissions

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