Random Mission Area Position Generator

Just a neat function I made that I feel can be pretty useful.

[code]
//Mission Area == MissionArea.getArea() = (X, Y, W, H) Origin Corner->|\ | EXAMPLE DIAGRAM
//X -> coordinate for origin corner | \ |
//Y -> coordinate for origin corner | \ |
//W -> width or X axis expansion from origin corner | \ |
//H -> height or Y axis expansion from origin corner | \|

Comments

  • edited August 2009
    I was actually about to write something like this for my NotRabbit gametype. I'd use this but I was going to write something more in shorthand.

    Couple questions...
    • Why is %H subtracted from %Y? Is the game north/south confused or something?
    • Why do you concatenate blank text on the beginning and end?
  • You're first point:
    • Why is %H subtracted from %Y? Is the game north/south confused or something?

    Yes, actually, when you look in mission editor/mission area editor the game actually flips the north south directions on the pop-up hud (or whatever you want to call that). So, instead of the normal grid pattern
    ( - + ) ( + + )
    ( - - ) ( + - )
    it's
    ( - - ) ( + - )
    ( - + ) ( + + )
    ###########
    Therefore the need for the H to be subtracted from Y.

    The second question: Why do I link the blank text at the ends? Habit, I guess. I've gotten used to doing "Some text that incorporates "@%SomeKindOfVariable@" here."
    So yeah, you can get rid of those ""@ / @"" from the code.
  • Revision To Previous Comments:
    • While it is true that the Mission Area Editor shows the missions area upside down, it does not actually contribute to the North and South positions being screwed up in a way to need H subtracted from Y. My previous results from testing were, so to say, false positives. My test mission area (0, 0, 1000, -1000) seemed to show that the numbers would never reach outside the mission area.
    • What I should have done is to test all the different types of mission areas (-,-,-,-; +,+,+,+; etc...) to be sure. I've since done this (16 total types) and have found no problems with the RMPG function.
    Thanks to Red Shifter for making me re-check my function.
    function RMPG(%Z)
    {
             %X = getWord(MissionArea.getArea(), 0);
             %Y = getWord(MissionArea.getArea(), 1);
             %W = getWord(MissionArea.getArea(), 2);
             %H = getWord(MissionArea.getArea(), 3);
             if (!%Z)
                %Z = 0;
             else
                %Z = getRandom(MissionArea.flightCeiling, 0);
    
             %OppX = ((%X) + (%W));
             %OppY = ((%Y) + (%H));
             %Position = getRandom(%X, %OppX) SPC getRandom(%Y, %OppY) SPC %Z;
    
             return %Position;
    }
    

    Here's The Way I Tested It, Just Skip This If You Don't Care :P
    (>) = Outcome; Either (ThisNum, orThisNum) for X coord : (ThisNum, orThisNum) Y coord
    
    1, 1, 1, 1      > (1, 2):(1, 2)
    1, 1, 1, -1     > (1, 2):(1, 0)
    1, 1, -1, 1     > (1, 0):(1, 2)
    1, -1, 1, 1     > (1, 2):(-1, 0)
    -1, 1, 1, 1     > (-1, 0):(1, 2)
    -1, -1, 1, 1    > (-1, 0):(-1, 0)
    -1, -1, -1, 1   > (-1, -2):(-1, 0)
    -1, -1, -1, -1  > (-1, -2):(-1, -2)
    -1, 1, 1, -1    > (-1, 0):(1, 0)
    1, -1, -1, 1    > (1, 0):(-1, 0)
    1, 1, -1, -1    > (1, 0):(1, 0)
    -1, 1, -1, 1    > (-1, -2):(1, 2)
    1, -1, 1, -1    > (1, 2):(-1, -2)
    -1, 1, -1, -1   > (-1, -2):(1, 0)
    -1, -1, 1, -1   > (-1, 0):(-1, -2)
    1, -1, 1, -1    > (1, 0):(-1, -2)
    
    All Outcomes(16) Met The Requirement (Multiple Times).
    
Sign In or Register to comment.