Results 1 to 30 of 116

Thread: An Intermediate Guide to Scripting

Hybrid View

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

    Default Re: An Intermediate Guide to Scripting

    If I use spawn and move command to not local faction with monitor_event, hothing happaned:

    script
    monitor_event FactionTurnStart FactionType romans_julii
    and not FactionIsLocal
    spawn_army
    faction romans_julii
    character Flavius Julius, general, command 0, influence 0, management 0, subterfuge 0, age 20, x 180, y 5
    unit roman generals guard cavalry, soldiers 20 exp 9 armour 1 weapon_lvl 0
    unit roman legionary first cohort ii, soldiers 40 exp 0 armour 0 weapon_lvl 0
    unit roman legionary cohort ii, soldiers 60 exp 0 armour 0 weapon_lvl 0
    unit roman praetorian cohort i, soldiers 60 exp 0 armour 0 weapon_lvl 0
    end
    console_command move_character Flavius Julius 170, 5
    campaign_wait 1
    console_command move_character Flavius Julius 160, 15
    end_monitor
    end_script


    If I use it to not local faction without monitor_event spawn work, but no moves

    If I use it to local faction spawn works, move works too.

  2. #2
    Simulation Monkey Member The_Mark's Avatar
    Join Date
    Dec 2004
    Location
    Helsinki, Finland
    Posts
    2,613

    Default Re: An Intermediate Guide to Scripting

    Weird. Beats me why it doesn't work.

    The only thing I can think of is that you were playing with the Julii when testing with not FactionIsLocal, but that wouldn't still explain why the moves didn't work..

  3. #3

    Default Re: An Intermediate Guide to Scripting

    Is there easiest way to check - me and my ally's- diplomatic stance for all other fractions? I am chartage, my ally is spain.

    script
    declare_counter war0
    set_counter war0 0
    declare_counter war1
    set_counter war1 0
    declare_counter war2
    set_counter war2 0
    declare_counter war3
    set_counter war3 0
    declare_counter war4
    set_counter war4 0
    declare_counter war5
    set_counter war5 0
    declare_counter loop
    set_counter loop 0

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction romans_brutii = AtWar
    set_counter war0 1
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction romans_brutii <= Neutral
    set_counter war0 0
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction romans_julii = AtWar
    set_counter war1 1
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction romans_julii <= Neutral
    set_counter war1 0
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction romans_scipii = AtWar
    set_counter war2 1
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction romans_scipii <= Neutral
    set_counter war2 0
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction gauls = AtWar
    set_counter war3 1
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction gauls <= Neutral
    set_counter war3 0
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction numidia = AtWar
    set_counter war4 1
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction numidia <= Neutral
    set_counter war4 0
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction greek_cities = AtWar
    set_counter war5 1
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and FactionIsLocal
    and DiplomaticStanceFromFaction greek_cities <= Neutral
    set_counter war5 0
    end_monitor

    monitor_event FactionTurnStart FactionType spain
    and not FactionIsLocal
    and DiplomaticStanceFromFaction romans_brutii < AtWar
    and DiplomaticStanceFromFaction carthage = Allied
    and I_CompareCounter war0 = 1
    console_command diplomatic_stance spain romans_brutii war
    end_monitor

    monitor_event FactionTurnStart FactionType spain
    and not FactionIsLocal
    and DiplomaticStanceFromFaction romans_julii < AtWar
    and DiplomaticStanceFromFaction carthage = Allied
    and I_CompareCounter war1 = 1
    console_command diplomatic_stance spain romans_julii war
    end_monitor

    monitor_event FactionTurnStart FactionType spain
    and not FactionIsLocal
    and DiplomaticStanceFromFaction romans_scipii < AtWar
    and DiplomaticStanceFromFaction carthage = Allied
    and I_CompareCounter war2 = 1
    console_command diplomatic_stance spain romans_scipii war
    end_monitor

    monitor_event FactionTurnStart FactionType spain
    and not FactionIsLocal
    and DiplomaticStanceFromFaction gauls < AtWar
    and DiplomaticStanceFromFaction carthage = Allied
    and I_CompareCounter war3 = 1
    console_command diplomatic_stance spain gauls war
    end_monitor

    monitor_event FactionTurnStart FactionType spain
    and not FactionIsLocal
    and DiplomaticStanceFromFaction numidia < AtWar
    and DiplomaticStanceFromFaction carthage = Allied
    and I_CompareCounter war4 = 1
    console_command diplomatic_stance spain numidia war
    end_monitor

    monitor_event FactionTurnStart FactionType spain
    and not FactionIsLocal
    and DiplomaticStanceFromFaction greek_cities < AtWar
    and DiplomaticStanceFromFaction carthage = Allied
    and I_CompareCounter war5 = 1
    console_command diplomatic_stance spain greek_cities war
    end_monitor

    while I_CompareCounter loop = 0
    end_while

    end_script

  4. #4
    Simulation Monkey Member The_Mark's Avatar
    Join Date
    Dec 2004
    Location
    Helsinki, Finland
    Posts
    2,613

    Default Re: An Intermediate Guide to Scripting

    You probably have the easiest way right there in your hands. If you don't need to check for specific factions there are a couple of conditions (OnWarFooting or similar), but for specific factions there's really no way around it. If you start doing these kind of repetitive scripts you should learn how to do script generators, with php, C++, excel or similar.

  5. #5

    Default Re: An Intermediate Guide to Scripting

    Great thread ER :)

  6. #6
    Arbeit macht fleisch Member ScionTheWorm's Avatar
    Join Date
    May 2005
    Location
    Norwegen
    Posts
    778

    Default Re: An Intermediate Guide to Scripting

    is it possible to have nested loops, if-statements and so on? could be a time saver in-game

    pseudo-code:
    Code:
    if 1
    if 2
    [do something]
    end if ; 2
    if 3
    [do something]
    end if ; 3
    while [something]
    [do something]
    end while
    end if ; 1
    edit: I just realized it is

    another thing, for it to be a background script you have to add
    Code:
    while I_CompareCounter loop = 0
    end_while
    won't it go faster if you have
    Code:
    while I_CompareCounter loop = 0
    campaign_wait 1
    end_while
    ?
    Last edited by ScionTheWorm; 12-31-2005 at 03:23.

  7. #7
    Shaidar Haran Senior Member SAM Site Champion Myrddraal's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    5,752

    Default Re: An Intermediate Guide to Scripting

    won't it go faster if you have
    while I_CompareCounter loop = 0
    campaign_wait 1
    end_while?
    Well I don't think it would be noticable to be honest, but in theory yes

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