Page 1 of 9 123456789 LastLast
Results 1 to 20 of 177

Thread: Lesson 1

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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 Lesson 1

    For information about course materials see this thread. Whatever mod folder you use make sure you start with an empty campaign_script. The requirements for this class are that you be able to set up your own mod folder and be familiar with the structure.

    Some terms you need to be familiar with:

    Monitor
    This simply starts the script by checking (monitoring) whether or not the events and conditions you have listed have happened. The most common use is monitor_event which is what we will mostly be working with, but you can also use monitor_conditions. When a monitor of either type is called, it loops through the conditions to determine a true/false value. If the value returned is true then the commands will run.

    Command
    Something you want the game to do, such as add or remove money or create units. There is a list of valid commands in the Docudemons but you can also use console_command and run the commands that you would normally run through the shell.

    Event
    Something that happens during the course of gameplay. Most of the time this is related to factions, settlements, and characters but can also be used to check things like when a counter changes or a building gets constructed.

    Condition
    Conditions are the core of your script. Improperly listing conditions will cause your script to fail. Consider this like a true/false question. If the result of the listed conditions is True, then the commands in the script fire.

    Counter
    This is the only variable we have to work with, and you can only use numbers. You use counters as extra conditions so that you can expand your options when firing commands. Counters must be declared in the top of your script and can be set to a static number or moved up and down using the inc_counter command, or set to a specific number using the set_counter command.

    EventCounter
    Similar to a Counter, but when used in the EDB or Traits files it only returns a true/false value. Anything other than 0 returns True to the script. This confuses some people but consider it like this: With an event there are only two options; either the event has happened, or it has not happened.

    Local
    This is simply used to determine whether the character, faction, or settlement belongs to the player or to the AI. If something is Local it belongs to the player, if not then it belongs to an AI faction.

    Not
    Usually when you are checking conditions you are looking for something that returns a True value, but occasionally you will want to know when something is False. This is where the Not value comes in.

    Export
    Not all Events can be used with all Conditions. When an Event fires, the game engine puts several things into memory for that particular monitor such as the faction type or the settlement name or details about a character. Those items that are placed into memory are called Exports and are listed in the Docudemons for each Event.

    Trigger Requirement
    Each condition will have a list of Trigger Requirements, these are items that must be available from the event for the condition to be able to check them. If the Event does not Export the Trigger Requirement, then you cannot use the Condition inside the monitor.


    Now its time to write your first script. When I am writing a new script I use the same process every time. What do I want to happen (command), and when exactly do I want it to happen (event + condition). First find the command or the console_command you want to run, and run it inside a generic monitor that you KNOW has valid conditions. The reason I always do this is so that if something doesn't work properly then I know its the command syntax and not the monitor itself. For this I usually use:
    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     commands go here
    end_monitor
    FactionTurnEnd is simply the end of a factions processing turn. We throw the FactionIsLocal condition on the end of it so that the monitor only fires once, for whatever faction the player happens to select. If we did not include a condition the script would fire true and run the command up to 31 times, once for each faction in the game. If we wanted to check a specific faction then we would do it like this:

    Code:
    monitor_event FactionTurnEnd FactionType england
     commands go here
    end_monitor
    Note that we have included the FactionType condition, followed by a valid faction name. If you compare the Export of FactionTurnEnd you will see that it exports faction and that FactionType has a trigger requirement of faction. If we wanted to check every faction except the faction the player is using, then we would use the not command like this:
    Code:
    monitor_event FactionTurnEnd not FactionIsLocal
     commands go here
    end_monitor
    For our first script we are going to write a money script. Kingdoms has a scripting command for adding money to a faction, M2TW does not so we have to do it through a console_command:
    console_command add_money england, 2000
    So our entire monitor will look like this:
    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     console_command add_money england, 2000
    end_monitor
    With this script, every time the player clicks the TurnEnd button England will have 2000 added to its treasury. You can verify this by playing as England and just clicking TurnEnd a few times. But a money script that only adds money to 1 faction every turn isnt really much good. We need to add more conditions to get it tweaked exactly how we want it. For this we will have to build a monitor for each faction.

    This will fire for each faction we build a monitor for, no matter if the faction belongs to the player or the AI.
    Code:
    monitor_event FactionTurnEnd FactionType england
     console_command add_money england, 2000
    end_monitor
    monitor_event FactionTurnEnd FactionType sicily
     console_command add_money sicily, 2000
    end_monitor
    monitor_event FactionTurnEnd FactionType hre
     console_command add_money hre, 2000
    end_monitor
    If we want it to only fire for the AI factions and not for the player, then we add another condition by using AND and NOT.
    Code:
    monitor_event FactionTurnEnd FactionType england
     and not FactionIsLocal
     console_command add_money england, 2000
    end_monitor
    monitor_event FactionTurnEnd FactionType sicily
     and not FactionIsLocal
     console_command add_money sicily, 2000
    end_monitor
    monitor_event FactionTurnEnd FactionType hre
     and not FactionIsLocal
     console_command add_money hre, 2000
    end_monitor
    Now we are getting somewhere. Our money script will add_money 2000 to each faction we build a monitor for, but will not give any help to the player. But there are no real options included, it will just happen every turn. To get some real flexibility we have to add a few more conditions and monitors. If a faction doesnt need help, then there is no point adding money to their treasury. Likewise some factions may need more help than others.

    Your task will be to build at least 4 monitors for a single faction to either add or subtract money based on their current condition. Some of the conditions you can use are:
    Treasury
    LosingMoney

    Feel free to mix and match other conditions if you wish, and please post your scripts in spoilers.
    Last edited by Augustus Lucifer; June 20, 2009 at 04:41 AM.

  2. #2
    aduellist's Avatar Push the button Max!
    Join Date
    Mar 2005
    Location
    Shenandoah Valley
    Posts
    1,822

    Default Re: Lesson 1

    Here goes. Successful implementation verified in log.

    Spoiler Alert, click show to read: 
    Code:
    ;
    ; Campaign script
    ;
    script
    
    monitor_event FactionTurnEnd FactionType england
       and FactionIsLocal
       and Treasury < 1000   
       console_command add_money england, 2000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType england
       and FactionIsLocal
       and Treasury > 10000   
       console_command add_money england, -2000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType england
       and FactionIsLocal
       and FactionIncome <= 1000   
       console_command add_money england, 1000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType england
       and FactionIsLocal
       and FactionIncome >= 5000    
       console_command add_money england, -1000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType england
       and FactionIsLocal
       and LosingMoney   
       console_command add_money england, 2000
    end_monitor
    
    monitor_event BuildingCompleted SettlementName London
       and SettlementBuildingFinished = market
       console_command add_money england, 500
    end_monitor
    
    ; keep script unfinished until last monitor termination
    wait_monitors
    
    end_script


    BTW for anyone else using the Barebones folder, there's an error in Barebones_headercfg.txt that prevents logging.

    Spoiler Alert, click show to read: 
    Code:
    to=mods/barebones/logs/Barebones.system.log.txt
    level=*script* trace
    should be

    Code:
    [log]
    to=mods/barebones/logs/Barebones.system.log.txt
    level=*script* trace
    Last edited by aduellist; June 20, 2009 at 02:06 AM.
    Under the patronage of TheFirstONeill
    Proud team member of
    THERA, A New Beginning


    "The trouble with fighting for human freedom is that one spends most of one's time defending scoundrels. For it is against scoundrels that oppressive laws are first aimed, and oppression must be stopped at the beginning if it is to be stopped at all." H. L. Mencken

    "Liberty is meaningless where the right to utter one’s thoughts and opinions has ceased to exist. That, of all rights, is the dread of tyrants. It is the right which they first of all strike down." Frederick Douglass

  3. #3

    Default Re: Lesson 1

    Finished :

    Spoiler Alert, click show to read: 

    ;
    ; Campaign script
    ;
    script

    monitor_event FactionTurnEnd FactionType england
    and FactionIsLocal
    console_command add_money england , 1500
    end_monitor

    monitor_event FactionTurnEnd FactionType england
    and FactionIsLocal
    and Treasury < 500
    console_command add_money england, 3000
    end_monitor

    monitor_event FactionTurnEnd FactionType england
    and FactionIsLocal
    and Treasury > 8000
    console_command add_money england, -3000
    end_monitor

    monitor_event FactionTurnEnd FactionType spain
    and FactionIsLocal
    console_command add_money spain, 1000
    end_monitor

    monitor_event FactionTurnEnd FactionType spain
    and FactionIsLocal
    and Treasury < 1000
    console_command add_money spain, 2000
    end_monitor

    monitor_event FactionTurnEnd FactionType spain
    and FactionIsLocal
    and Treasury > 10000
    console_command add_money spain, -5000
    end_monitor

    monitor_event FactionTurnEnd FactionType hre
    and FactionIsLocal
    console_command add_money hre, 2000
    end_monitor

    monitor_event FactionTurnEnd FactionType france
    and FactionIsLocal
    console_command add_money france, 2500
    end_monitor


    For HRE and France I have not done the same as for England and Spain, because I think the two nations always need money

    WikkeD

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

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

    Default Re: Lesson 1

    @ All Students:

    I'm not sure if this will be covered in a future lesson or not so I haven't added it to the first post. That is the function of 'commenting'. Commenting lines make the game not parse them, and are used to explain what the script does to others who may read it and your future self.

    The comment character which denotes a comment(everything after it on that line will be commented out) is: ;

    Use comments liberally, because trust me if your script is appropriately complex you will need to remind even yourself what it does exactly if you come back to it months later. Good commenting is done above each monitor that needs explanation or above an 'individual script' that comprises all the monitors used for the same overall purpose to explain what it is intended to do.

    Here's an example of commenting a monitor(you don't have to understand what it does quite yet):
    Spoiler Alert, click show to read: 

    Code:
    ;Decrease the policy timer each turn
    monitor_event FactionTurnEnd FactionIsLocal
    		and I_CompareCounter policy_timer > 0
    	inc_counter policy_timer -1
    end_monitor


    And here's an example of commenting above an 'individual script':
    Spoiler Alert, click show to read: 

    Code:
    ;**********Script 1A-2 - Detect Local Faction**********
    ;|Author| Augustus Lucifer
    ;|Purpose| Detects the local faction and sets a counter accordingly.
    ;|Changelog|
    ; o Script Created 3-17-09
    ; o 3-31-09
    ;		Commented out Ghurid.


    You don't have to be as organized as myself, only comment as much as you(and anyone you're working with) requires for the utmost efficiency. I do however find that indexing your script so you can CTRL+F through it easily is absolutely integral to getting through long scripts.

    @ Any students who read Lesson 1 prior to this post:

    There is no faction named 'italy' in the code. This has been fixed now to be sicily. In order to determine what the viable parameters for faction names you can use are for base M2 or another mod are, go into the data folder and find the file descr_sm_factions.txt . The labels on each 'faction' line are what the faction is referred to in coding and scripting, which is generally different from how it looks in the display, and in some cases like hre is an abbreviation you might not find without looking.

    @ aduellist:

    Looks good. I see no errors in the script and you've used a healthy variety of different conditions to differentiate the monitors. Your name has been added to the list for completing Lesson 1.

    @ WikkeD:

    Have you verified that the script works in-game by playing those factions and observing the effects? One thing I noticed is in the very first monitor you have a space before the comma after england. Depending on how stringent the game reads the syntax of that particular console command it could cause it to not fire or halt the script, or it could consider it the same as no space. If you are experiencing problems that is the first place you should look to remedy.

    @ All students taking Lesson 1:

    For the purpose of money scripts it is important to use large numbers when adding to a faction's money. Why? Because if you use low numbers it is hard to observe if it's working as the faction income may overshadow it. Using numbers upwards of 10000 simply for testing purposes insures you see the effects of the script at work.
    Last edited by Augustus Lucifer; June 20, 2009 at 05:01 AM.

  5. #5

    Default Re: Lesson 1

    Have you verified that the script works in-game by playing those factions and observing the effects? One thing I noticed is in the very first monitor you have a space before the comma after england. Depending on how stringent the game reads the syntax of that particular console command it could cause it to not fire or halt the script, or it could consider it the same as no space. If you are experiencing problems that is the first place you should look to remedy.
    I correct it and post it later again.

    WikkeD

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

    Default Re: Lesson 1

    Ok, here's mine:
    Spoiler Alert, click show to read: 

    Code:
    ;
    ; Campaign script
    ;
    script
    
        monitor_event FactionTurnEnd FactionType hre
            and FactionIsLocal 
            console_command add_money hre, 10000
        end_monitor
    
        monitor_event FactionTurnEnd FactionType hre
            and FactionIsLocal
            and FactionIncome >= 5000    
            console_command add_money hre, -1000
        end_monitor
    
        monitor_event FactionTurnEnd FactionType hre
             and not FactionIsLocal
            and FactionIncome <= 500
             console_command add_money hre, 2000
        end_monitor
    
        monitor_event FactionTurnEnd FactionType hre
             and not FactionIsLocal
            and number_of_provinces <= 2
             console_command add_money hre, 5000
        end_monitor
    
        monitor_event BuildingCompleted SettlementName Vienna FactionType hre
            and SettlementBuildingFinished = market
             console_command add_money hre, 2000
        end_monitor
    
    
            ; keep script unfinised until last monitor termination
        wait_monitors
    
    end_script


    I have added the 1st monitor to check if the whole thing is working and it works.



  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: Lesson 1

    Quote Originally Posted by Augustus Lucifer View Post
    @ Any students who read Lesson 1 prior to this post:

    There is no faction named 'italy' in the code. This has been fixed now to be sicily. In order to determine what the viable parameters for faction names you can use are for base M2 or another mod are, go into the data folder and find the file descr_sm_factions.txt . The labels on each 'faction' line are what the faction is referred to in coding and scripting, which is generally different from how it looks in the display, and in some cases like hre is an abbreviation you might not find without looking.
    AL is right of course, and I should have mentioned this to him earlier. The typo was intentional to prevent a pure copy and paste of my code. Since this basically a text only class I will be dropping a few spoilers like that into my code so people have to actually think to make it work.


    Looks like everyone is doing great so far. I notice a few people forgot to use AND in front of their conditions. This will break your script.

    Code:
    monitor_event some_event some_condition
    AND next_condition
    AND next_condition
    King Theoden - + rep for going the extra mile with difficulty
    Nevada - + rep for adding building conditions

  8. #8

    Default Re: Lesson 1

    I've tried again, but it doesn't work...
    Here the script :

    Spoiler Alert, click show to read: 

    ;
    ; Campaign script
    ;
    script

    monitor_event FactionTurnEnd FactionType england
    and FactionIsLocal
    and Treasury < 500
    console_command add_money england, 3500
    end_monitor

    monitor_event FactionTurnEnd FactionType england
    and FactionIsLocal
    and Treasury > 8000
    console_command add_money england, -3000
    end_monitor

    monitor_event FactionTurnEnd FactionType france
    and FactionIsLocal
    and Treasury < 1000
    console_command add_money england, 2000
    end_monitor

    monitor_event FactionTurnEnd FactionType france
    and FactionIsLocal
    and Treasury > 10000
    console_command add_money england, -3000
    end_monitor

  9. #9
    aduellist's Avatar Push the button Max!
    Join Date
    Mar 2005
    Location
    Shenandoah Valley
    Posts
    1,822

    Default Re: Lesson 1

    Quote Originally Posted by GrnEyedDvl View Post
    Nevada - + rep for adding building conditions
    What, I don't get +rep for using building conditions?

    Just kidding. In my original script there was nothing tying it to a specific faction. So it doesn't really qualify as meeting the requirements of the lesson.

    BTW, has anyone played around with the SupportCostsPercentage condition?
    Last edited by aduellist; June 20, 2009 at 04:39 PM.
    Under the patronage of TheFirstONeill
    Proud team member of
    THERA, A New Beginning


    "The trouble with fighting for human freedom is that one spends most of one's time defending scoundrels. For it is against scoundrels that oppressive laws are first aimed, and oppression must be stopped at the beginning if it is to be stopped at all." H. L. Mencken

    "Liberty is meaningless where the right to utter one’s thoughts and opinions has ceased to exist. That, of all rights, is the dread of tyrants. It is the right which they first of all strike down." Frederick Douglass

  10. #10

    Default Re: Lesson 1

    Ok. I've never scripted before:

    Spoiler Alert, click show to read: 


    ;
    ;campaign script
    ;
    script

    monitor_event FactionTurnEnd FactionType poland
    and not FactionIsLocal
    and Treasury > 1000
    console_command add_money poland, 4000
    end_monitor

    monitor_event FactionTurnEnd FactionType papal_states
    and not FactionIsLocal
    and Treasury < 100000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -15000
    end_monitor

    monitor_event FactionTurnEnd FactionType timurids
    and not FactionIsLocal
    and Treasury < 300000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    console_command add_money timurids, -20000
    end_monitor

    montor_event FactionTurnEnd FactionType russia
    and not FactionIsLocal
    console_command add_money russia, 4000
    end_monitor

    ; keep script unfinished until last monitor termination
    wait_monitors

    end_script
    Last edited by Odoaker; June 20, 2009 at 06:13 AM.
    Developer of Rising Sumer
    Beta-tester for ChC; Mapper of Colonialism-TW;

  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: Lesson 1

    @ Odoaker:

    A good start and thinking outside the box a bit, which is good. You have a few problems in your script which are bound to cause it to not function:

    1) In order for the console command add_money to work as intended, you need to specify the faction name in the command. The condition and the command work separately, just because the faction name is listed in the FactionType condition doesn't mean the console command applies to them. This way you could check what money hre has and add money to poland as a result to help them combat HRE. So you need to specify which faction you want to add the money to:

    Code:
    monitor_event FactionTurnEnd FactionType hre
    and FactionIsLocal
    and Treasury > 1000
    and LosingMoney
    console_command add_money hre, 4000
    end_monitor
    2) The condition LosingMoney does not take 'parameters'(information in addition to the condition it uses to specify). Unlike the Treasury and FactionIncome conditions, it is not looking to see how much money you're losing, just if you're losing money. The exact wording and example of the DocuDemon is as follows:

    Code:
    Identifier:              LosingMoney
    Trigger requirements:    
    Parameters:              None
    Sample use:              LosingMoney
    Description:             Is the faction losing money on the end of year balance sheet?
    Battle or Strat:         Strat
    Class:                   LOSING_MONEY
    Implemented:             Yes
    Author:                  Guy
    So you would just use and LosingMoney or and not LosingMoney without anything after it to determine if the faction has a negative income.

    3) There is no console command called subtract_money. If you want to remove money from a faction then you use the add_money command but use a negative number, like so:

    Code:
    monitor_event FactionTurnEnd FactionType papal_states
    and not FactionIsLocal
    and Treasury < 100000
    console_command add_money papal_states, -10000
    end_monitor
    4) The game only allows you to add(or subtract) at most 20000(in M2) or 40000(in Kingdoms) in one console command. If you want to add more than that, you will need to use separate console commands.
    Code:
    monitor_event FactionTurnEnd FactionType papal_states
    and not FactionIsLocal
    and Treasury < 100000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -20000
    console_command add_money papal_states, -15000
    end_monitor
    That would result in the faction losing 95,000. I wouldn't do that in a lump sum anyways though, there's more effective ways to cripple a faction or boost a faction if that is the intent, and it could prove problematic removing that much money at once.

    5) Novgorod is not a faction in M2. If you are basing it on a mod that adds novgorod and they have that as the specified name in the descr_sm_factions.txt then it's fine. If not it won't work and you should use russia instead.

    6) You should always add wait_monitors right above end_script. Only add these once at the very bottom of the file, it is not necessary to add them after each new individual script and will break the file.

    Code:
    ;script ends here
    wait_monitors
    
    end_script
    Last edited by Augustus Lucifer; June 20, 2009 at 05:27 AM.

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

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

    Default Re: Lesson 1

    @ karlost123456789:

    You will need to use sicily rather than italy unless a mod you are basing it on uses italy as a faction name in the code. Additionally, you will probably want to change the BuildingCompleted monitor to fire for the same faction that owns the settlement so you can observe the results(since papal states owns Rome you'd be better off using spain and Madrid).

  13. #13

    Default

    Alright , made a difficulty script to add even more money to some AI factions on VH difficulty

    Spoiler Alert, click show to read: 
    Code:
    script
    
    ;; Difficulty script
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction england
    
     console_command add_money sicily, 2000
     console_command add_money hre, 2000
     console_command add_money france, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money egypt, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction france
    
     console_command add_money sicily, 2000
     console_command add_money hre, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money egypt, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction sicily
    
     console_command add_money france, 2000
     console_command add_money hre, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money egypt, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction egypt
    
     console_command add_money france, 2000
     console_command add_money hre, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction hre
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction spain
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money hre, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction venice
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money spain, 2000
     console_command add_money russia, 2000
     console_command add_money hre, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction russia
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money spain, 2000
     console_command add_money venice, 2000
     console_command add_money hre, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    ;;; Loop
    wait_monitors
    
    end_script

  14. #14
    Lü Bu's Avatar "Mightyest Man Alive"
    Join Date
    May 2008
    Location
    Split,Croatia
    Posts
    5,332

    Default Re: Lesson 1

    Yay,my first script
    Spoiler Alert, click show to read: 

    ;
    ; Campaign script
    ;
    script

    monitor_event FactionTurnEnd FactionType papal_states
    and FactionIsLocal
    and Treasury < 1500
    console_command add_money papal_states, 4000
    end_monitor

    monitor_event FactionTurnEnd FactionType papal_states
    and FactionIsLocal
    and Treasury > 10000
    console_command add_money papal_states, -500
    end_monitor

    monitor_event FactionTurnEnd FactionType papal_states
    and FactionIsLocal
    and FactionIncome <= 1000
    console_command add_money papal_states, 1500
    end_monitor

    monitor_event FactionTurnEnd FactionType papal_states
    and FactionIsLocal
    and FactionIncome >= 5000
    console_command add_money papal_states, -2000
    end_monitor

    monitor_event FactionTurnEnd FactionType papal_states
    and FactionIsLocal
    and LosingMoney
    console_command add_money papal_states, 3000
    end_monitor

    monitor_event BuildingCompleted SettlementName Rome
    and SettlementBuildingFinished = market
    console_command add_money papal_states, 4000
    end_monitor

    ; keep script unfinished until last monitor termination
    wait_monitors

    end_script
    Last edited by Lü Bu; June 20, 2009 at 05:39 AM.
    Proud patron of Wlesmana
    Assyria Total War
    Check update thread for new HQ models
    My Workshop™


  15. #15
    Lü Bu's Avatar "Mightyest Man Alive"
    Join Date
    May 2008
    Location
    Split,Croatia
    Posts
    5,332

    Default Re: Lesson 1

    AL and grnEyedDvl I try to move some lines from end of page but this changes simply wont apply
    Proud patron of Wlesmana
    Assyria Total War
    Check update thread for new HQ models
    My Workshop™


  16. #16
    Lü Bu's Avatar "Mightyest Man Alive"
    Join Date
    May 2008
    Location
    Split,Croatia
    Posts
    5,332

    Default Re: Lesson 1

    Ok,fixing post my #1-st post
    Ok.Better now?
    Last edited by Lü Bu; June 20, 2009 at 05:39 AM.
    Proud patron of Wlesmana
    Assyria Total War
    Check update thread for new HQ models
    My Workshop™


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

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

    Default Re: Lesson 1

    Quote Originally Posted by karlost123456789 View Post
    Ok,fixing post my #1-st post
    Ok.Better now?
    Yes. You've been added to the list as completing Lesson 1. I'd suggest as an aside that factions like papal_states and slave not be used for the purposes of this class, simply because you can't play as them to observe the effects. They're not intrinsically different otherwise, but elements of the code make it harder to see if you're doing it right.

    Quote Originally Posted by KingTheoden1 View Post
    Alright , made a difficulty script to add even more money to some AI factions on VH difficulty

    Spoiler Alert, click show to read: 
    Code:
    script
    
    ;; Difficulty script
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction england
    
     console_command add_money sicily, 2000
     console_command add_money hre, 2000
     console_command add_money france, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money egypt, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction france
    
     console_command add_money sicily, 2000
     console_command add_money hre, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money egypt, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction sicily
    
     console_command add_money france, 2000
     console_command add_money hre, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money egypt, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction egypt
    
     console_command add_money france, 2000
     console_command add_money hre, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction hre
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money spain, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction spain
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money venice, 2000
     console_command add_money russia, 2000
     console_command add_money hre, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction venice
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money spain, 2000
     console_command add_money russia, 2000
     console_command add_money hre, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and CampaignDifficulty = very_hard
     and I_LocalFaction russia
    
     console_command add_money france, 2000
     console_command add_money egypt, 2000
     console_command add_money england, 2000
     console_command add_money spain, 2000
     console_command add_money venice, 2000
     console_command add_money hre, 2000
     console_command add_money poland, 2000
     console_command add_money sicily, 2000
    
    end_monitor
    
    ;;; Loop
    wait_monitors
    
    end_script
    Good. As an aside and this will probably be covered later when we talk more about 'if statements', but things like difficulty setting are a good thing to set a counter for and use the counter to check, because it enables you to condense the monitors required. But we'll get to that later, will add you to completion of Lesson 1.

  18. #18

    Default Re: Lesson 1

    I assume these 'if statements' and counters are stuff like :

    Code:
    script
    declare_counter faction1
    
    if I_LocalFaction england
    set_counter faction1 1
    end_if
    
    end_script
    ?

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

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

    Default Re: Lesson 1

    Quote Originally Posted by KingTheoden1 View Post
    I assume these 'if statements' and counters are stuff like :

    Code:
    script
    declare_counter faction1
    
    if I_LocalFaction england
    set_counter faction1 1
    end_if
    
    end_script
    ?
    Not quite. Don't worry about it I'm sure it will be covered in a later lesson.

  20. #20

    Default Re: Lesson 1

    Alright , that's great I heard counters were waay better in M2TW than in RTW (because they don't need to be reactivated every time you reload or something like that .)

Page 1 of 9 123456789 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
  •