Results 1 to 30 of 41

Thread: CA's Modding FAQ

Threaded View

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

    Default Re: CA's Modding FAQ

    Question1:

    Is it now possible to use descr_skeleton.txt, and does the game parse it?


    --------


    Question 2:

    Can any scripting functions take counters as parameters, instead of requiring explicitly defined numbers? For example, is it possible to do a script where you do a for() loop, replicated by the game's while command, which browses through each tile on the campaign map, and if it finds a general of one's faction there, to place another general in that spot? Speaking in pseudo-code, this would work like:

    Code:
    define counter x
    define counter y
    
    for (x from 0 to map's known width) {
       for (y from 0 to map's known height) {
          if (character X is at tile x,y) // possible to do using CharacterNearTile
             spawn_army at x, y
             ...
             end
       }
    }
    There the x and y are not specifically defined, but are whatever the counter values may be at that time.

    Right now it might seem that all commands require explicit specification of the location, so that if we wanted to replicate the code above using RTW's scripting code, we'd have to explicitly unravel those two for() loops (i.e. the two "while" loops) and explicitly say,

    if (General X is present at 1,1)
    spawn_army at 1,1

    if (General X is present at 1,2)
    spawn_army at 1,2

    which, considering the size of maps in the game (with both dimensions spanning hundreds of pixels), means that there theoretically will be 10,000 such if loops in order for the script to be able to find General X and place a new army wherever General X might be on the map. And if you have more than one general...

    Now granted, optimization is possible and we can use a binary search instead of a linear search (using hidden virtues to divide the map into quadrants, and then search only in that quadrant:

    Code:
    if General X has trait xLocationUnder 50 
       and General X has trait yLocationOver50 
       and has trait yLocationUnder100)
    
       search x from 0 to 50
         search y from 50 to 100

    Still, however, this optimization improves only the actual performance of the script, and still requires a whole lot of coding from the scripter, compared to how easy it could be if counters can be variables.

    I have tried this use of counters as variables for two commands: "reposition_character", and "console_command move" command, and for both of them, if I use an expression such as "x, 120" to specify a location, the engine will place the character at 0, 120, regardless of the value x currently holds.
    Last edited by SigniferOne; 10-24-2005 at 19:25.

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