Results 1 to 8 of 8

Thread: Spawning a stack in a region that just saw a battle?

Hybrid View

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

    Default Spawning a stack in a region that just saw a battle?

    Is it possible to spawn a stack in a region 1 or 2 turns after a battle occurred there?

    Cheers
    "I don't want to sit around Windsor because ermm .. I just generally don't like England that much" - Prince Harry, 3rd in Line for the British Thrown



    For King or Country - The English civil wars.

  2. #2

    Default Re: Spawning a stack in a region that just saw a battle?

    Code:
    declare_counter battle_in_region_x
    declare_counter turns_to_region_x_spawn
     
    set_counter battle_in_region_x 0
    set_counter turns_to_region_x_spawn -1
     
    monitor_event FactionTurnStart FactionType slave
      set_counter battle_in_region_x 0
    end_monitor
     
    monitor_event PreBattle IsRegionOneOf x
      set_counter turns_to_region_x_spawn 3
    end_monitor
     
    monitor_event FactionTurnStart FactionType slave
    and I_CompareCounter turns_to_region_x_spawn == 0
      spawn_army
        ;spawn army here
      end
      set_counter turns_to_region_x_spawn -1
    end_monitor
     
    monitor_event FactionTurnStart FactionType slave
    and I_CompareCounter turns_to_region_x_spawn > 0
      inc_counter turns_to_region_x_spawn -1
    end_monitor
    Repeat for each region.
    Last edited by Azim; September 05, 2008 at 03:59 PM.

    Dominion of the Sword, a Medieval II: Total War Supermod
    Under the patronage of Archaon. Proud member of the House of Siblesz
    My friend died from chain letters. If you don't post this again 100 times, he will come and kill you in your sleep!

  3. #3

    Default Re: Spawning a stack in a region that just saw a battle?

    AFAIK, PreBattle doesn't work.

  4. #4

    Default Re: Spawning a stack in a region that just saw a battle?

    I think PreBattle fires while you are in the battle map, so you can't use strat map commands in a PreBattle monitor, but all we are doing here is setting counters, so it should be fine. (Please correct me if I am wrong)

    Dominion of the Sword, a Medieval II: Total War Supermod
    Under the patronage of Archaon. Proud member of the House of Siblesz
    My friend died from chain letters. If you don't post this again 100 times, he will come and kill you in your sleep!

  5. #5

    Default Re: Spawning a stack in a region that just saw a battle?

    Azim, first, thank you for your help. Second, is there no way to functionise this? Do I really need to repeat this block of code for each region? If so, all I have to say is, Wow! Two years ago I wrote a terrain engine in C in less lines of code than it will take to add this script to my mod.

    Cheers
    Last edited by AlphaDelta; September 06, 2008 at 11:59 PM.
    "I don't want to sit around Windsor because ermm .. I just generally don't like England that much" - Prince Harry, 3rd in Line for the British Thrown



    For King or Country - The English civil wars.

  6. #6
    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: Spawning a stack in a region that just saw a battle?

    Quote Originally Posted by AlphaDelta View Post
    Azim, first, thank you for your help. Second, is there no way to functionise this? Do I really need to repeat this block of code for each region? If so, all I have to say is, Wow! Two years ago I wrote a terrain engine in C in less lines of code than it will take to add this script to my mod.

    Cheers
    The scripting engine is limited, there is no way to pull a region name other than by scripting a possibility for each region. Sad but true.


    Quote Originally Posted by Azim View Post
    I think PreBattle fires while you are in the battle map, so you can't use strat map commands in a PreBattle monitor, but all we are doing here is setting counters, so it should be fine. (Please correct me if I am wrong)
    I believe Prebattle fires on the battle map, but will export region. PostBattle is the same way.
    Last edited by GrnEyedDvl; September 07, 2008 at 12:14 AM.

  7. #7

    Default Re: Spawning a stack in a region that just saw a battle?

    @Alpha
    Check out the length of the 2 scripts in my sig, garrison script and recruitment limitations, both combined are about 100,000 lines of code. which is pretty resourceful of me considering the limits we have with this scripting engine and what each script manages to do! and both run without turn lag... but they give an idea of how much code you need to write to perform specific things, you can't use any kind of 'method' and have to script every individual event or condition you want monitored... there are no real short cuts like in a regular programming language such as Java...

    Which is going to be your biggest issue if you are scripting this for the AI, every settlement or region you script will be completly dependant on whether it is the AI or players turn, which may end up meaning you will need to script each region\settlement twice (one for player turn one for AI turn)...

    Depending on the aim of the mod you plan to write the script for, i would suggest targeting specific regions first. Until you know what kind of cost it will take on turn lag...

    Good luck with it tho, sounds like an interesting idea for a script
    ...longbows, in skilled hands, could reach further than trebuchets...

  8. #8

    Default Re: Spawning a stack in a region that just saw a battle?

    100,000 lines of code to do something that should take little more than a hundred. CA....

    I'll add Azim's code for a few regions and see how it goes.

    Cheers
    "I don't want to sit around Windsor because ermm .. I just generally don't like England that much" - Prince Harry, 3rd in Line for the British Thrown



    For King or Country - The English civil wars.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •