Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 64

Thread: Concepts and Theories

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

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

    Default Re: Concepts and Theories

    Quote Originally Posted by Stephan View Post
    does that mean i have to write a new script for every enemy faction?
    That is where the Script Replicator comes into play.

    As well in the above example you would need to include other conditions to check if you are at war with the faction most notably, and anything else to further specify it. You would need to also find a way to check which cities you own and by transition which ports, and write one for every port.

  2. #22

    Default Re: Concepts and Theories

    Yep , i think so

    And to make it complete : you also need to 'define' wich faction owns the port , so they get the penalty for the port blockade

    I'd define the factions like this :

    Code:
    script
    
    declare_counter port1
    declare_counter port2
    ; ... so on for all factions
    
    if I_SettlementOwner 'Settlement' = hre
    
    set_counter port1 1
    
    end_if
    
    if I_SettlementOwner 'Settlement' = france
    
    set_counter port2 1
    
    end_if
    
    if I_CompareCounter port1 = 1
      and I_CharacterTypeNearTile 'faction' admiral 1 , x, z
    
    console_command add_money hre -1000
    
    end_if
    
    wait_monitors
    end_script
    Or :


    Code:
    script
    
    declare_counter port1
    ; ... so on for all factions
    
    ;; Setup for each faction
    if I_SettlementOwner 'Settlement' = hre
    
    set_counter port1 1
    
    end_if
    
    if I_SettlementOwner 'Settlement' = france
     
     set_counter port1 2
     
     end_if
    
    ;; Comparing wich faction has the port
    if I_CompareCounter port1 = 1
      and I_CharacterTypeNearTile 'faction' admiral 1 , x, z
    
    console_command add_money hre -1000
    
    end_if
    
    ;; Comparing wich faction has the port
    if I_CompareCounter port1 = 2
      and I_CharacterTypeNearTile 'faction' admiral 1 , x, z
    
    console_command add_money france -1000
    
    wait_monitors
    end_script
    This would be one very long script

    Ah , damn , AL was ahead of me

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

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

    Default Re: Concepts and Theories

    I would encourage using event monitors for everything where possible. In place of if statements the command monitor_conditions should be used, which does the same thing but functions outside of a monitor. if statements should be thus reserved mainly to functioning within a monitor_conditions or monitor_event.

    You don't want to check something like that all the time or it will start to cause lag. Monitoring an event works best because it only happens when the event happens, not every time the conditions are met which is at countless intervals. So something to the effect of:

    Code:
    monitor_event FactionTurnEnd FactionType slave
            and I_CompareCounter ports_penalty_active == 1
    
    [[Settlement owner counter checks go here in if statements]]
    end_monitor
    ;Use PreFactionTurnStart in Kingdoms
    monitor_event FactionTurnStart FactionIsLocal
            and I_CompareCounter ports_penalty_active == 1
    
    [[Admiral near port goes here in if statements. Use nested if statements]]
    end_monitor
    The ports_penalty_active counter is something I advise for all big game-changing scripts that aren't integral to the game. This only works for Kingdoms though but in essence you'd fire an accept/decline to determine if they want to activate the script system at game start, so those not interested in getting port penalties don't have to. We'll get into that later. For M2 you might be able to do it in a Showme but I can only recommend that any new modification be built on Kingdoms.
    Last edited by Augustus Lucifer; June 22, 2009 at 09:13 AM.

  4. #24

    Default Re: Concepts and Theories

    Ah , kk , didn't know bout if statements

    And yea , don't know bout M2TW scripting , so thx for bringing that up

  5. #25
    Stephan's Avatar Campidoctor
    Join Date
    Jun 2008
    Location
    Wien
    Posts
    1,575

    Default Re: Concepts and Theories

    wow thats complex but i dont think thats what i want to do
    maybe i should explain what i want to do:
    for the phoenician cities sea trade was very important. The player(and also the ai) should try to stop the 3 main ports tyre, sidon and byblos from being blockaded, if not you should loose money.

    this is what i have at the moment

    monitor_event I_CharacterTypeNearTile faction(i guess i have to do that for every faction) admiral 1, x, y(koordinates of the port)
    (dont know where to set the ",")
    and I_SettlementOwner Tyr_Province = milan (phoenician cities)
    console_command add_money milan, -2000
    end_monitor

    Yes, I know that Ishtar is spelled wrong

  6. #26

    Default Re: Concepts and Theories

    Some notes :

    I don't think you can use "I_" inside a monitor .. I always use :

    if I_CharacterTypeNearTile ...

    But im's sure GED or AL will give more feedback

    i think 'settlementowner' requires a settlement to follow , not a region ..

    Apart from that , looks good

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

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

    Default Re: Concepts and Theories

    You can use I_ commands in a monitor without an if statement, the problem with the above is that a condition is being used without an event in a monitor_event. And yes you are correct that I_SettlementOwner wants the name of the city rather than the region/province.

    I would discourage extending something like that to the AI, because the AI doesn't know what effects scripts have on it. The AI Phoenicians won't decide to stop ports from being blockaded because there's a script in place to hurt them if they are, they'll only know that they are having money taken away, not why or how to prevent it.

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

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

    Default Re: Concepts and Theories

    Quote Originally Posted by Augustus Lucifer View Post
    I would discourage extending something like that to the AI, because the AI doesn't know what effects scripts have on it. The AI Phoenicians won't decide to stop ports from being blockaded because there's a script in place to hurt them if they are, they'll only know that they are having money taken away, not why or how to prevent it.
    Exactly right. Remember when you are scripting for the AI you have to make their choices for them. The AI doesnt "know" anything, all of the AI decisions are based upon a point system that is far beyond the scope of this class. If you want to know more about how that works then look up some stuff by Lusted and Xeryx on the campaign AI.

  9. #29

    Default Re: Concepts and Theories

    How do you script something in based on SettlementTaxLevel?
    Son of PW

  10. #30

    Default Re: Concepts and Theories

    I guess my questions got lost in the long blockaded port discussion I'll post it again :

    Quote Originally Posted by KingTheoden1 View Post
    I have some questions : Is it possible in M2TW to script movies ? I know a way-around in RTW , but i don't know 1 for M2TW ..
    Also : I have installed Barebones folder , as i had some probs creating my own modfolder . it has a campaign_script though .. Should i delete all that is inside it ?

  11. #31

    Default Re: Concepts and Theories

    Hey guys can you with me your opinion on this script, its base on class 1 but what i wanna know is if it makes sense for a general case, i mean to take money from the player and letting the player get too rich too soon, and if the game is turning difficult and the debt is too high it will try to help you a bit.
    Spoiler Alert, click show to read: 
    Code:
    script
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 20000
    console_command add_money east_anglia, -20000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury < -5000
    console_command add_money east_anglia, 5000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and loosing_money
    console_command add_money east_anglia, 1000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 30000
    console_command add_money east_anglia, -15000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and SettlementTaxLevel > tax_high
    console_command add_money east_anglia, -5000
    end_monitor
    wait_monitors
    
    end_script
    i am going to use it for all FactionIsLocal but what i can´t figure is when to stop it, i need it to stop by half way of the campaign been the campaign start 620ad and end in 1050ad. perhaps by creating a mission at 820ad or turn 200, once completed that mission this script becomes useless.
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  12. #32

    Default Re: Concepts and Theories

    Hmm .. A mission you say ? Here you go , in this script , the "mission" is to capture Rome with Venice (just an example)

    Code:
    script
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 20000
    and not I_SettlementOwner Rome = Venice ; Say that the mission is to capture Venice
    and not I_TurnNumber >= 200 ; So that it won't activate the script after turn number 200
    console_command add_money east_anglia, -20000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury < -5000
    and not I_SettlementOwner Rome = Venice 
    and not I_TurnNumber >= 200 
    
    console_command add_money east_anglia, 5000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    ;and loosing_money Are you sure it shouldnt' be : LosingMoney
    and not I_SettlementOwner Rome = Venice 
    and not I_TurnNumber >= 200 
    
    console_command add_money east_anglia, 1000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 30000
    and not I_SettlementOwner Rome = Venice 
    and not I_TurnNumber >= 200 
    
    console_command add_money east_anglia, -15000
    end_monitor
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and SettlementTaxLevel > tax_high
    and not I_SettlementOwner Rome = Venice 
    and not I_TurnNumber >= 200 
    
    console_command add_money east_anglia, -5000
    end_monitor
    
    wait_monitors
    
    end_script
    Ordened your script a little and added what you asked for Might wanna test it out though

    I'd also wait for feedback from GED or AL , as they are the pro's

    (The bolded parts are the stuff i added)
    Last edited by Killerbee; June 23, 2009 at 03:07 PM.

  13. #33

    Default Re: Concepts and Theories

    Thanks buddy, it is very clear but you got me in the opposite direction mate, i want the script to stop working at 200 turns not to start, i appreciate the feedback though, + rep however i will definitely test it and see what happen.

    Edited:

    and not I_TurnNumber >= 200
    You were totally right i was wrong my bad! i haven´t tested it yet though, but shouldn´t be with out the not
    and I_TurnNumber >= 200
    ?
    ReEdited:

    It clearly did trigger it but nothing happen actually!!
    Spoiler Alert, click show to read: 
    Code:
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 11 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 18 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 25 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 32 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 39 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <wait_monitors> at line 43 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt


    This is what the code look like:
    Spoiler Alert, click show to read: 
    Code:
    script
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 20000
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, -20000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury < -5000
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, 5000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and LosingMoney
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, 1000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 30000
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2 
    console_command add_money east_anglia, -15000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and SettlementTaxLevel > tax_high
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, -5000
    end_monitor
    wait_monitors
    
    end_script
    or was it suppose to happen something? or it was just deactivate the script after turn 2?
    Last edited by Icedie El Guaraní; June 23, 2009 at 06:40 PM.
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  14. #34

    Default Re: Concepts and Theories

    Quote Originally Posted by Icedie of South View Post
    You were totally right i was wrong my bad! i haven´t tested it yet though, but shouldn´t be with out the not
    and I_TurnNumber >= 200
    ?
    Nope , in words , this means :

    And i am not at a turn number larger than 200 ..

    So , if you are at a turn number smaller than 200 , the script will activate and decrease your money ,y ou see ?

    Quote Originally Posted by Icedie of South View Post
    ReEdited:

    It clearly did trigger it but nothing happen actually!!
    Spoiler Alert, click show to read: 
    Code:
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 11 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 18 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 25 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 32 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <monitor_event> at line 39 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    23:28:15.218 [game.script.exec] [trace] exec <wait_monitors> at line 43 in mods/VacuusLuxLucis/data/world/maps/campaign/imperial_campaign/campaign_script.txt


    This is what the code look like:
    Spoiler Alert, click show to read: 
    Code:
    script
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 20000
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, -20000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury < -5000
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, 5000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and LosingMoney
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, 1000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and Treasury > 30000
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2 
    console_command add_money east_anglia, -15000
    end_monitor
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and SettlementTaxLevel > tax_high
    and not I_SettlementOwner Lundewic = gwynedd
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, -5000
    end_monitor
    wait_monitors
    
    end_script
    or was it suppose to happen something? or it was just deactivate the script after turn 2?
    I think it's supossed to stop (the script for decreasing money should stop) after turn 2 , and after "gwynedd' is the owner of 'Lundewic' ..

    Check if all faction names you listed are correct in descr_sm_factions(for RTW , dunno if this file exists for MTW2) , and if all conditions/commands are correct , like in the docudemons .. Btw , you have something weird :

    Code:
    ; ...
    
    monitor_event FactionTurnEnd FactionType east_anglia
    and FactionIsLocal
    and SettlementTaxLevel > tax_high
    and not I_SettlementOwner Lundewic = gwynedd
    
    and not I_TurnNumber >= 2
    console_command add_money east_anglia, -5000
    end_monitor
    
    wait_monitors
    ; ...
    This means that east anglia will keep getting money penalty until gwynedd captures Lundewic .. Quite weird no ? Shouldn' that be ;

    Code:
    ; ...
    
    monitor_event FactionTurnEnd FactionType east_anglia
     and FactionIsLocal
     and SettlementTaxLevel > tax_high
     and not I_SettlementOwner Lundewic = east_anglia ; instead of gwynned ?
    
     and not I_TurnNumber >= 2
     console_command add_money east_anglia, -5000
     end_monitor
    
     wait_monitors
    ; ...

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

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

    Default Re: Concepts and Theories

    One thing is that you're using a negative where it isn't needed. You don't need to use not for the I_TurnNumber command because you can just use the opposite operator, a number greater than or equal to a number will always be the opposite of a number less than or equal to a number, except when they are equal to the number. And when they're equal to a number and you don't want that number to count, you simply remove the equal.

    >= = Greater Than or Equal
    <= = Less Than or Equal
    < = Less Than
    > = Greater Than
    == = Equal

    So when I say:

    and I_TurnNumber >= 5

    That means the script will fire when the Turn Number is 5 or higher. If I were to say:

    and not I_TurnNumber >=5

    That means the script will fire when the Turn Number is 4 or lower. That is the same as saying:

    and I_TurnNumber < 5

    A negative as applied to a greater/less than or equal to, is the same as the opposite sign minus the =.

  16. #36

    Default Re: Concepts and Theories

    That would idd be more usefull

    So instead of :

    and not I_TurnNumber >= 200

    you better say :

    and I_TurnNumber <= 200

    Sorry Icedie

    Btw , is the "=" really needed after a "<" or a ">" ? I think it's not in RTW , but that might be different here ..

  17. #37

    Default Re: Concepts and Theories

    Quote Originally Posted by KingTheoden1 View Post
    ?
    This means that east anglia will keep getting money penalty until gwynedd captures Lundewic .. Quite weird no ? Shouldn' that be ;

    Code:
    ; ...
    
    monitor_event FactionTurnEnd FactionType east_anglia
     and FactionIsLocal
     and SettlementTaxLevel > tax_high
     and not I_SettlementOwner Lundewic = east_anglia ; instead of gwynned ?
    
     and not I_TurnNumber >= 2
     console_command add_money east_anglia, -5000
     end_monitor
    
     wait_monitors
    ; ...
    Yes you are correct, it suppose to be east_anglia but i thought it was a mission, if i capture it from them the script will be disabled.
    Any ways it was just an example.
    I will try it later tonight thanks, i wanna to set up this script for all anglo-saxon´s faction (Mercia, northumbria, Wessex, Essex, Cantware , East_Anglia) so that the britons(Gwynedd, Gwent, Powys, Dyfet, Alt_Clut, Dyfneint) aren´t over powered to soon, opposite to the AS´s script i wanna them to be kept alive for as long as possible , because i am planning to add a script that unite the britons under the Dehebaurth banner. and keep the overall factions at a average level of wealth so that when the Vikings arrive in 793ad they find the British and Irish factions at their mercy.
    I will be asking more questions though.

    @AL


    >= = Greater Than or Equal
    <= = Less Than or Equal
    < = Less Than
    > = Greater Than
    == = Equal
    I don´t understand what the = means in MTW2 terms, in the docudemon appear as a logic token?
    <= = (what does the double = means?)
    < = Less than and < less than ( what is the difference?)
    == = ( i hav enever seen this, i am missunderstanding your xplanation, sorry Its my poor English´s fault)
    Contribuitor IBIICB-WOTN-Modeler-Scripter


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

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

    Default Re: Concepts and Theories

    I will try to clear up the < > confusion. Yes these are all logic tokens.

    1 = 1

    2 > 1

    1 < 2

    2 >= 1

    1 <= 2

    Obviously 1 = 1 is not a problem. But lets say we are comparing TurnNumber, and we are currently at turn 20.

    TurnNumber = 20

    if I_TurnNumber = 20 returns a True value, commands will run

    if I_TurnNumber = 10 returns a False value, commands will not run

    if I_TurnNumber >= 10 returns a True value, commands will run

    if I_TurnNumber <= 10 returns a False value, commands will not run


    What you are doing when you put conditions in a script, is looking for a True value. If all conditions are met, then a True value is returned and the commands inside the script will run. Maybe a good way to write it is like this. I will leave out the monitor_event for now...


    FactionTurnEnd FactionIsLocal - if this is True, process next line
    and FactionType england - Player is England = true then process next line
    and TurnNumber >= 20 - if it is turn 20 or higher, and all of the above is true, then process next line


    Everything you do is geared towards determining whether the conditions are True or False, and then running commands when they are True. Even if you use the Not command you are looking for True.


    FactionTurnEnd not FactionIsLocal

    You would assume that because of the not that you are looking for False. This will screw you up. What you are looking for is a True value when the faction is NOT controlled by the player.

    Players faction is England, when player clicks TurnEnd and FactionTurnEnd processes. What we are looking for is a faction NOT controlled by the player. So ask this question:

    Is this faction NOT controlled by the player? The answer is false because England IS controlled by the player.

    Does that help any??

  19. #39
    Romanos IV's Avatar The 120th Article, § 4
    Join Date
    Jun 2008
    Location
    the hell outta here (Athens, European Client State of Greece)
    Posts
    3,882

    Default Re: Concepts and Theories

    and TurnNumber >= 20 - if it is turn 20 or higher, and all of the above is true, then process next line
    Just a question: if this the only condition in a script, will it fire in turn 20 or randomly after turn 19?
    Under the noble patronage of Jimkatalanos

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

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

    Default Re: Concepts and Theories

    Quote Originally Posted by Romanos IV View Post
    Just a question: if this the only condition in a script, will it fire in turn 20 or randomly after turn 19?
    It will fire on Turn 20 and every following turn, unless you either terminate_monitor so it only runs once, or do something like set a counter in the monitor and require the counter so it only fires again when you flip it back. If you want it to fire randomly after Turn 20 you can use RandomPercent or the command generate_random_counter.

Page 2 of 4 FirstFirst 1234 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
  •