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

Thread: Tribute and Catastrophe scripts? -Help needed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Tribute and Catastrophe scripts? -Help needed

    Hi there,

    I'm currently creating a mod on my own with a new map and some scripting things in it, bt I'm a scripting noob so I'll need some help.

    1st issue.

    Tribute.
    I know this might be somewhat easy for you, but not for me:

    It's an event on that you can decide:

    Some factions are at the beginning of a game "owned" by another one, so they need to pay tribute.

    There comes the event:
    It should appear every turn during the first 30 turns and it must be done for any of the factions that are "owned", but it shall only be activated when they're the local faction.
    The possibilities for the player are:
    Pay 2000 Florins (Yes) or Rebel (No) (Rebel shall lead to the thing that armies of the nation you just got independent from shall spawn and attack you)

    After 30 turns, there shall automatically the armies, as then all of the factions get independent. (This happens not when you got independent before)

    So (just a scheme, not what I tried to type in):

    monitor_event Tribute
    and FactionIs xy
    and FactionIsLocal

    Decide
    Yes
    No

    Yes
    kings_purse -2000 florins

    No
    spawn army faction z
    unit
    .
    .
    .

    after 30 turns
    span army faction z
    unit


    2nd issue:

    Monsters

    An event for the player only
    Since people in the Medieval ages were always aware of monsters and other things, I thought it would be fun to make them "appear"

    An event pops up at random times and says "monster in your province"

    You can decide:
    Pay 1000 florins for someone to kill the monster(yes)
    Let the monster be, during it destroys your holdings (Substract 50-400 Florins from kings purse for the next 5 turns, the money you substract should be set randomly amongst 50 and 400 Florins) (No)

    So, again a small scheme:

    monitor_event
    monster
    FactionIsLocal
    RandomChanceToShowUp= 25 out of 100

    Yes
    kings_purse -1000

    No
    kings_purse -50 =< x =< -400

    So, is this doable, if yes, how?

    Thanks and Greetings,
    Nevada



  2. #2

    Default Re: Tribute and Catastrophe scripts? -Help needed

    The issue with spawn_army: you have to give the exact x and y coordinates, there is no way arround that.
    I suggest to construct the script for one faction at first, the faction you intend to play. Otherwise you will face a script which requieres hunderds of thousend lines of code (no, I'm not exaggerating).
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  3. #3
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    you misunderstood.
    The above thing is just an idea of what I (as scripting-noob) think it should look like, a short lookup over the things that arte required.

    The script with the army should work easily, as the army that has to be spawned comes always from one faction, which is the same in all cases (at least in my mod)



  4. #4

    Default Re: Tribute and Catastrophe scripts? -Help needed

    That script will require thousands and thousands of lines of code...

    For example... this part...
    You can decide:
    Pay 1000 florins for someone to kill the monster(yes)
    Let the monster be, during it destroys your holdings (Substract 50-400 Florins from kings purse for the next 5 turns, the money you substract should be set randomly amongst 50 and 400 Florins) (No)

    So, again a small scheme:
    if you want 50-400 florins subtracted, and it be randomly generated, you will need over 1000 lines of code just to do that... seriously...

    generate_random_number RandNum 50 400
    if RandNum = 50
    do this code
    end if
    if RandNum = 51
    do thos code
    end if

    etc etrc etc

    But dont be discouraged, take a look at my recruitment limitations scipt, it is about 60,000 lines of code... it was over 600,000 when i first wrote it because i was new to scripting and didnt know any short cuts... but yeah seriously, your looking at somwhere in the vaccinity of 100,000 plus lines of code for each segment of your idea depending on the number of factions and regions in the mod......
    ...longbows, in skilled hands, could reach further than trebuchets...

  5. #5
    alhoon's Avatar Comes Rei Militaris
    Join Date
    Apr 2008
    Location
    Chania, Greece
    Posts
    24,233

    Default Re: Tribute and Catastrophe scripts? -Help needed

    Quote Originally Posted by Tsarsies View Post
    That script will require thousands and thousands of lines of code...

    For example... this part...


    if you want 50-400 florins subtracted, and it be randomly generated, you will need over 1000 lines of code just to do that... seriously...

    generate_random_number RandNum 50 400
    if RandNum = 50
    do this code
    end if
    if RandNum = 51
    do thos code
    end if

    etc etrc etc
    Ehhh... You know it could be done like 50, 100, 200 and 400 instead of 50,51, 52, etc.

    Still, since it should check many factions it would be a large script.
    alhoon is not a member of the infamous Hoons: a (fictional) nazi-sympathizer KKK clan. Of course, no Hoon would openly admit affiliation to the uninitiated.
    "Angry Uncle Gordon" describes me well.
    _______________________________________________________
    Beta-tester for Darthmod Empire, the default modification for Empire Total War that does not ask for your money behind patreon.
    Developer of Causa Belli submod for Darthmod, headed by Hammeredalways and a ton of other people.
    Developer of LtC: Random maps submod for Lands to Conquer (that brings a multitude of random maps and other features).

  6. #6
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    damn, when it's this way I'll make the ransom number smaller...



  7. #7
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Tribute and Catastrophe scripts? -Help needed

    Ok lets take this one problem at a time. For the random monster. I think we can do this with far fewer lines of code than hundreds of thousands, though it will still be large. Probably around 2500 lines depending on options and how many settlements there are.

    How often do you want one to appear? And how many different monsters will there be? For Kingdoms or M2? I will write for Kingdoms.

    This has 121 lines of code, and is hardly finished, but you should be able to easily expand it from here. You can also look at my other scripting stuff for ideas, this is basically a combination of my Hire Ancillaries and my Roving Buildings scripts.

    Code:
    monitor_event FactionTurnEnd FactionIsLocal
        and I_EventCounter monster_appears == 0
        if RandomPercent > 90 ; 10% chance
            set_event_counter monster_appears 1
            generate_random_counter monster_type 1 5
            if I_EventCounter monster_type == 1
                set_event_counter monster_name 1 ; dragon
            end_if
            if I_EventCounter monster_type == 2
                set_event_counter monster_name 2 ; medusa
            end_if
            if I_EventCounter monster_type == 3
                set_event_counter monster_name 3 ; troll
            end_if
            if I_EventCounter monster_type == 4
                set_event_counter monster_name 4 ; frankenstein
            end_if
            if I_EventCounter monster_type == 5
                set_event_counter monster_name 5 ; dracula
            end_if        
    end_monitor
    
    
    monitor_event FactionTurnStart FactionIsLocal
        and I_EventCounter monster_appears == 1
        
        generate_random_counter pick_region 1 50 ; however many settlements there are
        if I_EventCounter pick_region == 1 ; london
            and I_EventCounter monster_type == 1
                set_event_counter london_monster 1
        end_if
        if I_EventCounter pick_region == 1 ; london
            and I_EventCounter monster_type == 2
                set_event_counter london_monster 2
        end_if
        if I_EventCounter pick_region == 1 ; london
            and I_EventCounter monster_type == 3
                set_event_counter london_monster 3
        end_if
        if I_EventCounter pick_region == 1 ; london
            and I_EventCounter monster_type == 4
                set_event_counter london_monster 4
        end_if
        if I_EventCounter pick_region == 1 ; london
            and I_EventCounter monster_type == 5
                set_event_counter london_monster 5
        end_if
            
        if I_EventCounter pick_region == 2 ; paris
            and I_EventCounter monster_type == 1
                set_event_counter paris_monster 1
        end_if
        if I_EventCounter pick_region == 2 ; paris
            and I_EventCounter monster_type == 2
                set_event_counter paris_monster 2
        end_if
        if I_EventCounter pick_region == 2 ; paris
            and I_EventCounter monster_type == 3
                set_event_counter paris_monster 3
        end_if
        if I_EventCounter pick_region == 2 ; paris
            and I_EventCounter monster_type == 4
                set_event_counter paris_monster 4
        end_if
        if I_EventCounter pick_region == 2 ; paris
            and I_EventCounter monster_type == 5
                set_event_counter paris_monster 5
        end_if
        
        ;5 options for each region you want to get the monster
    end_monitor
            
            
    monitor_event SettlementTurnEnd SettlementName London ;need one for each settlement
        and SettlementIsLocal
        and I_EventCounter pick_region == 1
        
        add_events 
        event counter kill_london_monster_accepted
        event counter kill_london_monster_declined
        date 0
        end_add_events
        
        if I_EventCounter london_monster == 1
            historic_event london_monster_1 true
        end_if 
        if I_EventCounter london_monster == 2
            historic_event london_monster_2 true
        end_if 
        if I_EventCounter london_monster == 3
            historic_event london_monster_3 true
        end_if 
        if I_EventCounter london_monster == 4
            historic_event london_monster_4 true
        end_if 
        if I_EventCounter london_monster == 5
            historic_event london_monster_5 true
        end_if 
    end_monitor
            
    monitor_event EventCounter EventCounterType kill_london_monster_accepted
        if I_EventCounter kill_london_monster_accepted == 1
            if I_LocalFaction england
                add_money england -2000
            end_if
            if I_LocalFaction france
                add_money france -2000
            end_if
        end_if
    end_monitor
            
    monitor_event EventCounter EventCounterType kill_london_monster_declined
        if I_EventCounter kill_london_monster_declined == 1
            if I_LocalFaction england
                increment_kings_purse england -100
            end_if
            if I_LocalFaction france
                increment_kings_purse france -100
            end_if
        end_if
    end_monitor

  8. #8
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    thank you very much, GrnEyedDvl.

    It's really a great help, since I only know the very basics of scripting.

    Give me a few days and I think I'll get the tribute done on my own, since I finished a part of the map that is huge enough for testing.

    pick_region == 2 ; paris
    How do I know the region number?
    I think i understood the rest halfway through...

    (well, somehow it' funny, I based it on YOUR barebonesmod and on YOUR mapclass files. And thanks again for the script^^
    I hope I cn give out a small preview (of the mod this is for) in November)

    And since you say I can look at your other stuff:
    -Nice AI project
    -how far did you get the bankingscript?
    -I'm interested in the Hiring-Ancillaries-Script, with the aditional thing I once suggested (random event to kick off the bard, if you remember)(and which i'd try to do on my own...)
    Last edited by Nevada; October 08, 2008 at 01:24 PM.



  9. #9
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Tribute and Catastrophe scripts? -Help needed

    I havent worked on banking or anything else lately, been tied up with other stuff.

  10. #10
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    ah, ok.

    pick_region == 2 ; paris
    But how do I get the region number?



  11. #11
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Tribute and Catastrophe scripts? -Help needed

    Thats not the region ID of Paris, I just used that number for Paris. You can assign anything you wish.

  12. #12
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    how do I assign this number?



  13. #13
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Tribute and Catastrophe scripts? -Help needed

    Just pick one, I just used the number 1 for London and the number 2 for Paris.

  14. #14
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    Ok, i think i got it now, you define the number below wheere it says SettlementName London ......

    Edit: i wanted to +rep you, but I need to spread...



  15. #15
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Tribute and Catastrophe scripts? -Help needed

    Quote Originally Posted by Nevada View Post
    Ok, i think i got it now, you define the number below wheere it says SettlementName London ......
    Exactly


    Edit: i wanted to +rep you, but I need to spread...
    No worries about the rep, that's not why I do stuff like this. The thought was enough.

  16. #16
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    No worries about the rep, that's not why I do stuff like this. The thought was enough.
    Yes, but I wanted to give you this in return.

    You know it could be done like 50, 100, 200 and 400
    At firt i wanted to do it like that, but I think doing it with those 5 monsters and all the cities, since there will be approximately the full limit of regions.

    I'll see what I will do.



  17. #17
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    Code:
    ;
    ; Campaign script
    ;
    script
    
      ;;start
      
                    restrict_strat_radar false
                    
            ; ---------------------
            ; counters
            
            declare_counter tribute_pay
            
            
      ;;Tribute to pay for Northern Kingdoms
      
      monitor_event FactionTurnEnd FactionIsLocal
        and counter tribute_pay == 0
        
        add_events 
        event counter tribute_pay_accepted
        event counter tribute_pay_declined
        date 0
        end_add_events
        
            set_event_counter tribute_pay_accepted 0
            set_event_counter tribute_pay_declined 0
       
    end_monitor
            
    monitor_event EventCounter EventCounterType tribute_pay_accepted
        if I_EventCounter tribute_pay_accepted == 1
            if I_LocalFaction venice
                add_money venice -1500
            end_if
            if I_LocalFaction venice
                add_money england -1500
            end_if
            if I_LocalFaction venice
                add_money milan -1500
            end_if
      end_if
    end_monitor
            
    monitor_event EventCounter EventCounterType tribute_pay_declined
        if I_EventCounter tribute_pay_declined == 1
            if I_LocalFaction venice
            set_counter tribute_pay ==1
              
            end_if
            if I_LocalFaction england
            set_counter tribute_pay ==1
              
            end_if
            if I_LocalFaction milan
            set_counter tribute_pay ==1
              
            end_if
        end_if
    end_monitor
    
        wait_monitors
    
    end_script
    Ok, that's my campaignscript so far and i tried to set up the tribute script on my own, but the event doesn't appear ingame.

    How can i make it appear every turn until turn 30 or until the counter tribute_pay is set to 1 (whatever happens first, aftrer turn 30, i want the counter to be set automatically to 1)



  18. #18
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Tribute and Catastrophe scripts? -Help needed

    In the set_counter line you shouldnt have the == signs.

  19. #19
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Tribute and Catastrophe scripts? -Help needed

    I removed them.

    I was also looking through the script of the Teutonic Campaign, especially the part of the Calmar union and this grew out of it:

    Code:
    ;
    ; Campaign script
    ;
    script
    
      ;;start
      
                    restrict_strat_radar false
                    
            ; ---------------------
            ; counters
            
            declare_counter tribute_pay
            
            
      ;;Tribute to pay for Northern Kingdoms
      
      monitor_event FactionTurnStart FactionIsLocal
        and counter tribute_pay = 0
        
        add_events 
        event counter tribute_pay_accepted
        event counter tribute_pay_declined
        date 0
        end_add_events
        
            set_event_counter tribute_pay_accepted 0
            set_event_counter tribute_pay_declined 0
       
    end_monitor
    
        monitor_event FactionTurnStart FactionIsLocal
        and counter tribute_pay =0
            
          add_event
        
                historic_event pay_tribute true factions { england, venice, milan, }
           end_add_event 
        
            
        end_monitor
            
    monitor_event EventCounter EventCounterType tribute_pay_accepted
        if I_EventCounter tribute_pay_accepted == 1
            if I_LocalFaction venice
                add_money venice -1500
            end_if
            if I_LocalFaction venice
                add_money england -1500
            end_if
            if I_LocalFaction venice
                add_money milan -1500
            end_if
      end_if
    end_monitor
            
    monitor_event EventCounter EventCounterType tribute_pay_declined
        if I_EventCounter tribute_pay_declined == 1
            if I_LocalFaction venice
            set_counter tribute_pay =1
              
            end_if
            if I_LocalFaction england
            set_counter tribute_pay =1
              
            end_if
            if I_LocalFaction milan
            set_counter tribute_pay =1
              
            end_if
        end_if
    end_monitor
    
        wait_monitors
    
    end_script



  20. #20
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Tribute and Catastrophe scripts? -Help needed

    I think you misunderstood me, there shouldnt be any = sign when assigning the value, that is only used for checking the value.

    set_counter counter_name 1
    if I_CompareCounter counter_name = 1

Page 1 of 2 12 LastLast

Posting Permissions

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