Results 1 to 30 of 82

Thread: alpaca's Script-O-Rama

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: alpaca's Script-O-Rama

    Hmm ok well I'll test it out soon enough, this is puzzling for me. Meanwhile, I dug up Epistolary Richard's two scripting threads, which are frankly worth gold. I really think you should make a prominent link to them, or else incorporate them somehow: Beginner's and Intermediate Guide to scripting.

    There are some fascinating tidbits from the Intermediate Guide. For instance, say you want your script to automatically automerge all units for you, but there's only one problem -- there is no scripting command to automerge. No worries, because TW scripting allows you to call shortcuts! Thus, you can create a script to automerge, or to automatically call Ctrl+S to periodically save your campaign, or any other shortcut like that. Here's the code, from the Intermediate Guide:

    Quote Originally Posted by Stuie
    Code:
    monitor_event CharacterSelected FactionType romans_brutii
         and FactionIsLocal          
         call_object_shortcut campaign_hud automerge_units
    end_monitor
    
    monitor_event SettlementSelected FactionType romans_brutii          
         and FactionIsLocal          
         call_object_shortcut campaign_hud automerge_units
    end_monitor
    
    monitor_event CharacterSelected FactionType gauls          
         and FactionIsLocal          
         call_object_shortcut campaign_hud automerge_units
    end_monitor
    or if you want your script to speed things up,

    Quote Originally Posted by Myrddraal
    Code:
    here is a neat scripting command which I found whilst working on the MP campaign:
    
    call_object_shortcut
    
    Here is an example of the syntax:
    
    call_object_shortcut strat_ui speedup_ai
    
    the strat_ui bit is the category of the shortcut. If you open data\text\descr_shortcuts.txt and scroll to the bottom end, you'll find a list of the shortcuts with their categories to the right.
    Here's a list of all ui_elements that can be called: https://forums.totalwar.org/vb/showp...25&postcount=5

    One interesting thing from there is that you can have your script order a "order_halt" shortcut (Backspace), and trigger it whenever an enemy character becomes visible. Without this feature, normally your issued movement orders will be continued to full, even if enemies become visible in the meanwhile; else, you need to carefully watch all your characters' movements and quickly press backspace, not a pleasant alternative. Of course this script would need to be balanced, because you don't want it preventing your characters from movement altogether, when within sight of enemies. So you'd have the script disable itself after it first triggers.
    Last edited by SigniferOne; 04-11-2007 at 21:15.

  2. #2
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: alpaca's Script-O-Rama

    Yep I was planning to go through these again to see what I can incorporate here.
    Would be cool if you could explain a bit about the scripts you mentioned so I can copy&paste them into one of my above posts as examples, or about the call_shortcut as a concept (that was actually one I had planned but I am not at all averse to somebody else doing the work )

  3. #3

    Default Re: alpaca's Script-O-Rama

    I think it's the create_unit command that doesn't work if you leave out the comma after the unit name.
    It's not a map.

  4. #4
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: alpaca's Script-O-Rama

    Quote Originally Posted by nikolai1962
    I think it's the create_unit command that doesn't work if you leave out the comma after the unit name.
    As I said earlier, it's a freaking working example

    @lordyu:
    Code:
            monitor_event EventCounter EventCounterType mongols_invasion_warn 1
    
            and EventCounter > 0 
    
    Should be
    
    monitor_event EventCounter EventCounterType mongols_invasion_warn 
            and EventCounter > 0

  5. #5

    Default Re: alpaca's Script-O-Rama

    As I said earlier, it's a freaking working example
    yes but there's two ways to spawn units, spawn_army and create_unit. create_unit needs the comma.
    It's not a map.

  6. #6
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: alpaca's Script-O-Rama

    Quote Originally Posted by nikolai1962
    yes but there's two ways to spawn units, spawn_army and create_unit. create_unit needs the comma.
    Ah my apologies, I didn't read your post correctly

  7. #7

    Default Re: alpaca's Script-O-Rama

    lordyu, the actual problem in your code (aside from the "1" typo in the event handler) is that you use == in your if statements. You need to use =. The error log was helpful in tracing down that one.

  8. #8

    Default Re: alpaca's Script-O-Rama

    Quote Originally Posted by alpaca
    Yep I was planning to go through these again to see what I can incorporate here.
    Would be cool if you could explain a bit about the scripts you mentioned so I can copy&paste them into one of my above posts as examples, or about the call_shortcut as a concept (that was actually one I had planned but I am not at all averse to somebody else doing the work )
    Sure, no problem. I'll do it in a little bit, when I get everything straightened out over here.

  9. #9

    Default Re: alpaca's Script-O-Rama

    PHP Code:
    Campaign script
    ;
    script
            
    ; ---------------------
            ; 
    counters
            
            declare_counter Opened_Faction_Overview_Scroll
            declare_counter Opened_Settlement_Scroll
            declare_counter mongols_Volograd
            declare_counter mongols_Ani
            declare_counter mongols_Baghdad
            declare_counter timurids_Volograd
            declare_counter timurids_Ani
            declare_counter timurids_Baghdad
            
            
            
    ; ---------------------
            ; 
    start up

            freeze_faction_ai aztecs

            restrict_strat_radar false

            
    ;----------------------
            ; 
    monitors

            
    ;-- Mongols invasions --
        
    monitor_event EventCounter EventCounterType mongols_invasion_warn 1

            
    and EventCounter 0
            
    ADD SCOUTING INVASION
            add_events
                event    counter    mongols_invasion
                date    4 8
           end_add_events
            
    if I_EventCounter mongols_invasion_warn == 2
                terminate_monitor
            end_if
        end_monitor

        monitor_event EventCounter EventCounterType mongols_invasion
            
    and EventCounter 0
            
    if I_EventCounter mongols_invasion == 1
                add_events
            
    ;;; SCOUTING INVASION
                    events    emergent_faction    mongols
                    date    0
    ;                 region     Ani_Province
                    region    Volograd_Province
                    region     Baghdad_Province
                    movie    event
    /mongols_invade.bik
                    
    ;ADD MONGOL INVASION 1
                    events    counter    mongols_invasion
                    date    2
                end_add_events 
    is there anything wrong with this script. The mongols will not appear and i keep getting CTD.
    i traced the problem to this
    00:50:00.781 [game.script.exec] [trace] exec <if> at line 42 in Europa/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    00:50:00.781 [game.script.exec] [trace] exec <add_events> at line 44 in Europa/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    00:50:01.546 [system.rpt] [error] Medieval 2: Total War encountered an unspecified error and will now exit.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO