HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Region array with custom text

08-05-2002, 02:10 PM#1
Mandork
I'm currently working on a "Sneaker-map" where two players are assassins and are going to kill the emperor. However, to make sure the game doesn't get too easy, I am trying to make so that the emperor moves to a randomly selected region. To do this I would need a array with all the possible Regions, but I was thinking that this would be a good time to start learning how to edit with custom text (JASS, is it?). Anyway, this is how I've written it:
Code:
function Trig_Text_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 9
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_MoveTo[GetForLoopIndexA()] = gg_rct_Waypoint_0 + GetForLoopIndexA()
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Text takes nothing returns nothing
    set gg_trg_Text = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Text, function Trig_Text_Actions )
endfunction

The problem is that I can't enable it. If I try I get a error message saying "Line 64: Expected a name.". Could anyone help me with this?
08-05-2002, 03:15 PM#2
weaaddar
Expected a name ussually implies to variables in Custom Text your variables are case sensitvie. So make sure you have spelt it EXACTLY as it apears in your var window.
08-05-2002, 04:46 PM#3
Mandork
What I've changed is this:
Code:
set udg_MoveTo[GetForLoopIndexA()] = gg_rct_Waypoint_0 + GetForLoopIndexA()
Before I changed it the value was gg_rct_Waypoint_01, so it must be something with the way I use GetForLoopIndexA(), right?
08-05-2002, 06:56 PM#4
dataangel
Quote:
set udg_MoveTo[GetForLoopIndexA()] = gg_rct_Waypoint_0 + GetForLoopIndexA()


The problem with this code is that gg_rct_Waypoint_0 is a region, and GetForLoopIndexA() is an integer. You can't add the two together ;)

WE isn't smart enough to realize that you mean gg_rct_Waypoint_0 + 1 = gg_rct_Waypoint_1, and seeing as there's no operator overloading ala C++ in JASS, you just plain can't do this :P

You're going to have to set the regions by hand.

A possibly easier alternative is to set peasants around the map where you want waypoint, and at map init, unit group all the peasants and set each part of the array to be the position of the peasant + a radius (the function is something like Region Centered at X with height x and width x).
08-05-2002, 07:19 PM#5
Mandork
Hmm, I thought JASS (once again, JASS is it?) was a bit smarter than Java, C and those "normal" programming languages.. Oh, well, I'd better get started setting the array manually, since I didn't really understand the peasant thingy. Care to tell?
08-05-2002, 07:47 PM#6
weaaddar
Oh yeah jass sucks Learn to live with it ( I want Structs damn :). I think you could probably trick the 01 part some how. But adding an integer to it isn't the way. I'll give it a whirl but manual defination is probably the way your gonna go.
08-05-2002, 07:54 PM#7
Mandork
Well, I've loades the 22 possible Move-To-Regions into the Array, but now (of course) I have a new problem. Some of the regions are placed on the way to an other, so I have to check if it is really the randomly chosen region that the unit has stepped on. I've made a variable containing the region in question, but i realized that I don't know how to check if the regions match. Any idea?
08-06-2002, 01:28 AM#8
dataangel
To check if two regions are the same, you're going to have to do a real condition like so:

real comparison and real comparison and real comparison and realcomparison

:P

Each comparison checks the minY of both regions to be the same, then the minX, then the MaxY, then the MaxX. However, if none of the regions overlap each other, go ahead and just check the minx/miny or maxx/maxy
08-06-2002, 01:33 AM#9
dataangel
BTW, JASS is actually much stupider than C or Java. Or rather, it's not stupider, but it's more specialized. It's also a higher level language than C or Java, which means it does more of the low level memory work, etc. for you. The consequence of this is that its less powerful.
08-06-2002, 05:28 AM#10
Karma Patrol
Although it's not in JASS, snoop aroun this map a bit.