Page 2 of 4 FirstFirst 1234 LastLast
Results 31 to 60 of 116

Thread: An Intermediate Guide to Scripting

  1. #31
    EB Traiter Member Malrubius's Avatar
    Join Date
    Jan 2005
    Location
    On a tree-covered mountain in Anniston, Alabama, USA
    Posts
    2,633

    Default Re: An Intermediate Guide to Scripting

    I'm going to need some, to keep up with you, LorDBulA, and The_Mark!

    Ah! the Generals! they are numerous, but not good for much (especially if they're Languorous)!
    -- Aristophanes, if he played EB

  2. #32

    Default Re: An Intermediate Guide to Scripting

    Question guys, which I feel is a little silly but here it is nonetheless: how do you test if a character has a certain trait, and what level of the trait? I tried the following and it doesn't work:

    Code:
    monitor_event CharacterTurnStart TrueCondition
       if FactionType empire_west
          if Trait AgeTraitLevel1 = 1
             ; do some stuff
          end_if
       end_if
    end_monitor
    Last edited by SigniferOne; 02-05-2006 at 05:52.

  3. #33
    EB Traiter Member Malrubius's Avatar
    Join Date
    Jan 2005
    Location
    On a tree-covered mountain in Anniston, Alabama, USA
    Posts
    2,633

    Default Re: An Intermediate Guide to Scripting

    Code:
    monitor_event CharacterTurnStart FactionType empire_west
          and Trait AgeTraitLevel1 = 1
             ; do some stuff
         
    end_monitor

    Ah! the Generals! they are numerous, but not good for much (especially if they're Languorous)!
    -- Aristophanes, if he played EB

  4. #34

    Default Re: An Intermediate Guide to Scripting

    Hmm, that's weird, I thought both "FactionType" and "Trait" were conditions, and thus not usable in monitor_event, but only in monitor_conditions, or "if" clauses?

  5. #35
    EB Traiter Member Malrubius's Avatar
    Join Date
    Jan 2005
    Location
    On a tree-covered mountain in Anniston, Alabama, USA
    Posts
    2,633

    Default Re: An Intermediate Guide to Scripting

    Hmm, we have syntax like that in our EBBS background script, and it seems to work.

    Ah! the Generals! they are numerous, but not good for much (especially if they're Languorous)!
    -- Aristophanes, if he played EB

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

    Default Re: An Intermediate Guide to Scripting

    That is because monitor_event in fact requires an event AND a condition.
    If you don't want one, you have to use monitor_event EVENT TrueCondition or else the game will crash.

  7. #37

    Default Re: An Intermediate Guide to Scripting

    Right, but then what could be the reason why isolating the conditions into their own "if" statements, e.g in my code above, doesn't work?

  8. #38

    Default Re: An Intermediate Guide to Scripting

    Because most conditionals require exports from an event (eg, settlement, character) - and therefore need to be included in a monitor_event. It's only conditionals that start with I_ that do not require an event which can be used in if and monitor_conditions.
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  9. #39
    Senior Member Senior Member Duke John's Avatar
    Join Date
    May 2003
    Location
    Netherlands
    Posts
    2,917

    Default Re: An Intermediate Guide to Scripting

    While experimenting with scripts I noticed that some AdviceThreads in export_descr_advice.txt have a parameter. I found SettlementName and CharacterName. Not useful for me, but I guess some can use it to make their Advisor texts a little bit more detailed, showing the settlement's or character's name.

  10. #40
    Member Member paullus's Avatar
    Join Date
    Aug 2005
    Location
    always in places where its HOT
    Posts
    11,904

    Default Re: An Intermediate Guide to Scripting

    Is there a way to make the background script detect whether an AI faction has done something, and then have that trigger an event script at the start of the player's turn?
    "The mere statement of fact, though it may excite our interest, is of no benefit to us, but when the knowledge of the cause is added, then the study of history becomes fruitful." -Polybios


  11. #41

    Default Re: An Intermediate Guide to Scripting

    Depends on what the AI faction has done. What AI event do you want to trigger it?
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  12. #42

    Default Re: An Intermediate Guide to Scripting

    Which of the following events would be detectable for an AI nation?
    Takes a (particular) city.
    Declares war/peace with another nation.
    Accumulates X amount of money.
    Family member (specifically faction leader) dies.
    Family member accumulates X command stars.
    Conquer a whole new world.

    Development - Discussion

  13. #43

    Default Re: An Intermediate Guide to Scripting

    These should be possible.
    Just open beginer screepting guide and dive in into RTW script documentation.

  14. #44
    Member Member paullus's Avatar
    Join Date
    Aug 2005
    Location
    always in places where its HOT
    Posts
    11,904

    Default Re: An Intermediate Guide to Scripting

    Quote Originally Posted by Epistolary Richard
    Depends on what the AI faction has done. What AI event do you want to trigger it?
    Beseiging a city would probably be best.
    "The mere statement of fact, though it may excite our interest, is of no benefit to us, but when the knowledge of the cause is added, then the study of history becomes fruitful." -Polybios


  15. #45

    Default Re: An Intermediate Guide to Scripting

    Besieging a city's tricky, you can put a conditional in for a monitor to fire if an enemy family member is within one tile of a certain location and if the two factions are at war.

    Gets a bit cumbersome with large numbers of factions and cities, but it's possible.

    LorDBulA does something similar with his Roma siege script, have a look at his code:
    http://www.twcenter.net/forums/showthread.php?t=24968

    You can use something like that to increment a counter and then have a separate monitor_event FactionTurnStart FactionIsLocal with an I_CompareCounter condition. Be sure to set the counter back to 0 though, otherwise it will keep triggering.
    Last edited by Epistolary Richard; 03-05-2006 at 10:34.
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  16. #46

    Default Re: An Intermediate Guide to Scripting

    This is a quite similar question, but I hope it can be done:

    Is it possible to make an army (or naval army) besiege a city/port at game start through a script? I'm not very familiar with scrpits, so I hope someone could help me with this one.

    - Tittils -


    The Fourth Age: Total War - Map Manager, Editor and Coder

  17. #47
    Member Member paullus's Avatar
    Join Date
    Aug 2005
    Location
    always in places where its HOT
    Posts
    11,904

    Default Re: An Intermediate Guide to Scripting

    ER,

    Sorry I was unclear. I meant to say "besieging a neutral city." Unless I'm missing something (certainly a possibility), I don't think those conditions would work with a city you do not own. Is there anything else I could try?

    Thanks much.
    "The mere statement of fact, though it may excite our interest, is of no benefit to us, but when the knowledge of the cause is added, then the study of history becomes fruitful." -Polybios


  18. #48

    Default Re: An Intermediate Guide to Scripting

    As it was said there is no easy way to check for siege.
    The only way is to detect enemy army near a settlement.
    You can do this for any faction holding city and any faction standing next to the city.
    Proximity alert should be set to 2 titles. If you set it to 1 it wont be triggered if enemy attacks from any of city corners.

  19. #49
    Member Member paullus's Avatar
    Join Date
    Aug 2005
    Location
    always in places where its HOT
    Posts
    11,904

    Default Re: An Intermediate Guide to Scripting

    Oh ok, I guess I misunderstood. Thanks.
    "The mere statement of fact, though it may excite our interest, is of no benefit to us, but when the knowledge of the cause is added, then the study of history becomes fruitful." -Polybios


  20. #50

    Default Re: An Intermediate Guide to Scripting

    I don't understand, I'm using Malrubius' code:

    Code:
    monitor_event CharacterTurnStart FactionType empire_west
          and Trait AgeTraitLevel1 = 1
             ; do some stuff
         
    end_monitor
    To do something to the character when a turn starts, but nothing happens. Here's the full code:

    Code:
    	console_command give_trait "Gaius Fabricius" GoodCommander 2
    	campaign_wait 2
    	console_command add_money 1000
    	campaign_wait 2
    
    	monitor_event CharacterTurnStart FactionType empire_west
    		and Trait GoodCommander = 2
    
    		; do stuff
    
    	end_monitor
    I start the campaign, press F1 and run the script, the Trait is added, I press Next Turn expecting some stuff to happen to the char based on that trait, but nothing happens... Help?

    PS: ER, would you like me to use the other thread referencing this one from now on?
    Last edited by SigniferOne; 03-10-2006 at 05:00.

  21. #51

    Default Re: An Intermediate Guide to Scripting

    Is that the full script? Do you have 'script' at the beginning? end_script at the end? Do you have a loop so that the script is still running the next turn?

    If you have all that try getting rid of the campaign_wait commands.
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  22. #52

    Default Re: An Intermediate Guide to Scripting

    Do you have a loop so that the script is still running the next turn?
    Maybe that's my problem. I was under the assumption that if a script was launched, that it will persist throughout the entire game session, including all the monitors. Is that right, or do I have to have some sort of loop to keep the script persisting through the turns?

    All of the action that I want to happen above is inside the monitor, which I thought will persist though turn 2, even though loaded at turn 1 (assuming the game wasn't reloaded).
    Last edited by SigniferOne; 03-11-2006 at 02:56.

  23. #53

    Default Re: An Intermediate Guide to Scripting

    Have a look at the first script in the first post, there's your basic background script with a while loop. You need a while loop at the bottom otherwise the script will terminate immediately.
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  24. #54

    Default Re: An Intermediate Guide to Scripting

    When script execution reaches end_script command you can guess what happens next :)

  25. #55

    Default Re: An Intermediate Guide to Scripting

    I think I figured out what was going wrong:

    inside that event monitor I have two commands:

    Code:
    console_command add_money 10000
    campaign_wait 2
    console_command kill_character "Gaius Fabricius"
    campaign_wait 2
    (the campaign waits are apparently necessary for all console_commands).

    Ok so here's what happens: apparently, under some conditions, the kill_character command does-not-work, and the script processing engine seems to stop processing. What's been happening in my script, and why I was prompted to post in this thread, was that I've been developing a background script for the Paeninsula Italica mod; I tried inserting just one command that had to be in my script -- kill_character -- and it would not work (hence my posts). I started this script every time I started a new campaign in our beta campaign map, so obviously we have a lot of things unbalanced yet, and a lot of provinces (over 50) rebel on the next turn. Also, the Adoption thing springs into action, since there are like 3 generals for the entire faction.

    SO -- to make a long story short -- when I start the campaign and run my script, after pressing next turn, all this massive avalanche of events starts to happen on the next turn, and the kill_character event does not work. It is in the monitor correctly, and the monitor is triggered correctly, but the command simply doesn't work! How do I know the monitor is triggered correctly? Because I placed the give money command before it, which never fails to work. And what's even more, I placed a second give money command after it, e.g.

    Code:
    console_command add_money 10000
    campaign_wait 2
    console_command kill_character "Gaius Fabricius"
    campaign_wait 2
    console_command add_money 10000
    campaign_wait 2
    And the execution never reaches the second money command, and no money is added after the first. This is a very weird problem. Here's what's even weirder: sometimes, if I keep pressing Next Turn, the event_monitor is still apparently running in the background, sometimes will make the kill_character command work. So sometimes, a few turns in, the character does get killed (although the money command works always, at least the first one).

    It seems that the script engine somehow gets "stuck" on the kill_character command, and simply does not proceed executing any further. I thought that maybe it's from all the events happening so fast, and tried to somehow pause the game, or at least pause all the events and UI things happening, until my script monitor runs and finishes its stuff. Thus, I tried everything imaginable, e.g.:

    Code:
    	monitor_event FactionTurnStart FactionIsLocal
    		declare_show_me
    		hide_ui
    		suspend_unscripted_advice true
    		disable_entire_ui
    
    		console_command add_money 10000
    		campaign_wait 5
    		console_command kill_character "Gaius Fabricius"
    		campaign_wait 5
    		console_command add_money 10000
    		campaign_wait 5
    
    		enable_entire_ui
    		suspend_unscripted_advice false
    		show_ui
    	end_monitor
    all the things that I guessed could suspend the proper flow of the game until my poor script has finished. None of these things work. One of the funny things is, I just added the "hide_ui" thing, to try and hide the events until my script finishes, and -- the UI gets hidden, the "adoption" event pops up anyway (due to the conditions in my campaign), and when I dismiss it, the UI continues to remain hidden. The script simply does not proceed further, beyond the kill_character command, the UI remains hidden even though the script says to unhide it. It just gets stuck. And I know that the kill_character command works always when in direct script mode (i.e. without the monitors), and it sometimes works even in the monitors, seemingly when there aren't that many events popping up. So that's what's been going on with my script :-) Anyone else have something similar?
    Last edited by SigniferOne; 03-12-2006 at 07:04.

  26. #56

    Default Re: An Intermediate Guide to Scripting

    Okay guys, in order to narrow down the source of the problem, I have considerably cleaned up the campaign situation, gave the faction enough generals so that adoptions would not pop up, removed almost all the provinces owned so that there are would be no rebellions, etc. Now, practically no events happen on each turn, and yet the problem with kill_character still persists!

    I don't want to clutter up ER's thread with this one problem, so I've started a new thread, where I explain the situation in less clumsy terms, the above complications have been removed as I just said, and I also posted screenshots of what goes on.

    The thread is here: https://forums.totalwar.org/vb/showthread.php?t=62364
    Last edited by SigniferOne; 03-12-2006 at 08:41.

  27. #57

    Default Re: An Intermediate Guide to Scripting

    A few more questions: the only way to browse if a character has one of a list of traits is by having a monitor event for each trait, right? i.e. there's no way to do something like right:

    if Trait X = 1
    do A
    if Trait Y = 1
    do B

    Also, is there a limit for how many "and" conditions can exist for event_monitors? This sort of information seems not to be included in the Hardcoded Limits thread.
    Last edited by SigniferOne; 03-12-2006 at 21:44.

  28. #58

    Default Re: An Intermediate Guide to Scripting

    I think that's because no one has ever hit it. From my understanding of CA it seems unlikely that they would have imposed a limit because they never expected people to be using big scripts. But equally there may be an extent by which a big monitor may not work right.

    There's no easy way to do the trait thing - however if you want to use that in many different monitors then you may want to have a separate monitor to use the existence to set a counter. You can then use an if I_CompareCounter line within your monitors.
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  29. #59
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: An Intermediate Guide to Scripting

    I've found problems in making the command test_message working:
    https://forums.totalwar.org/vb/showp...65&postcount=8

    Any of the experts in scripting could give me the tip?

  30. #60
    Member Member Piko's Avatar
    Join Date
    Dec 2004
    Location
    Belgium,Bredene
    Posts
    59

    Default Re: An Intermediate Guide to Scripting

    Can someone supply me with a code for changing diplomacy between factions? Thanks.

Page 2 of 4 FirstFirst 1234 LastLast

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