HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Of Mice, Men, Arrays, Regions and Positional Data

09-29-2002, 05:47 AM#1
Guest
Hello to all World Editor Experts out there!

After about 7 straight hours of work tonight, here are 3 Points of Stuckdom I'm unable to extricate myself from:

1. Are two-dimensional arrays possible?

2. Is it possible to create a region around an item during gameplay using a trigger?

I've managed to Move a pre-existing region to be centered on a Hero's position, but as for creating a new region, I'm at a loss after hours of 'editorial' guessing games.

And now for something... completely different.

3. How can I track the changing distance between a unit and an item?

OK, spent almost 3 hrs on this one. Here's what I can do...

Set realvariablename = (Distance between (Position of (Triggering Unit)) and (Position of (Target Item of issued order)))

This worked great!! It set my distance variable to a real number, 622.448. However, I fired this trigger at one-tenth second intervals as my Hero ran towards the item, but the game display text still referred to the original distance between the unit and item. In other words, it repeatedly reported 622.448. So, what I really need to know is how to capture a unit's current position at any moment, then I could simply compare that to the item's position since it doesn't move.

Sorry for the 'size' of that last question, but it's been harder than a rock golem to figure out. Thanks in advance for any and all help, suggestions, etc...
09-29-2002, 07:18 AM#2
Guest
1) No

2) What exactly are you trying to do? You can use coordinates to create a "temporary" region for your conditions or whatnot. IE:

If ((Region centered at (position of (traget item of issued order)) with size (20, 20)) contains (triggerin unit) then do....

You can also do it with 4 coordinates, or 2 points.

If you wanted an event for when they entered this region, you could use GoldenUrg's patch (http://goldenurg.tripod.com) to create an event at runtime with the coordinates you want to use.

3) I would set the Triggering unit to a variable, and then use that to track it (making sure that the trigger doesn't fire multiple times and change the variable to another unit).
09-29-2002, 11:40 AM#3
SuperIKI
To create a new region this could prove useful:
From common.j:
Code:
native CreateRegion             takes nothing returns region
native RemoveRegion             takes region whichRegion returns nothing

native RegionAddRect            takes region whichRegion, rect r returns nothing
native RegionClearRect          takes region whichRegion, rect r returns nothing

native RegionAddCell           takes region whichRegion, real x, real y returns nothing
native RegionAddCellAtLoc      takes region whichRegion, location whichLocation returns nothing
native RegionClearCell         takes region whichRegion, real x, real y returns nothing
native RegionClearCellAtLoc    takes region whichRegion, location whichLocation returns nothing

Two dimensional arrays can only be faked by a one dimensional array with a function like
function getIndex takes integer x, integer y returns integer
Like you must do in the very old programming languages.
09-29-2002, 02:38 PM#4
Guest
Remember that you can use the 'unit in range' condition/event instead of the unit in region thing, I can't think of any situation in which you'd need a region over a unit/item.
09-29-2002, 05:08 PM#5
Mr.Safety
Quote:
Originally posted by Teup
I can't think of any situation in which you'd need a region over a unit/item.

Actually, I needed one for my map. I needed a rectangular (not square of circle) region for a cinematic. Don't ask why, it would take too long to explain. But I did need one.

But Teup is right, very very rarely do you need them.
09-29-2002, 08:28 PM#6
dataangel
Two dimensional arrays are possible with an index function, if yer real nice to weaaddar he should show you the code for it in his bag demo (it's relatively simple).

Also, your trigger would work, but I'm willing to bet you're doing this

Event - Map Init
Action - Set real variable =blahdistanceblah

Event - Every .1 seconds
Action - Game text: real variable

You need the real variable to be constantly updated, it won't adjust for you.
09-29-2002, 09:20 PM#7
weaaddar
A) THe bag demos code is released.
But I'll explain it anyway.
Basically you choose how long the Y axis of your array is this is the only disicision you have to make. I used total player number which should remain static through out the game.
Now you set up an indexer function
Code:
Function Indexer takes integer X integer Y returns integer
return(X*4+y)
endfunction
Then to use it you would go Array[Indexer(X,y)] and walah you just set up your 2d array enjoy.

Well thats really it..
09-29-2002, 09:26 PM#8
Guest
Thanks weaaddar.

So far I haven't ventured into the Custom Text forest. I'm waiting for my sword (mind) to sharpen up a bit. But I'll try your code out as it looks like a good solution.

By the way, an tutorials out there re: Custom Text coding?

Thanks!
09-29-2002, 10:33 PM#9
weaaddar
Unfortuantly most people are expecting me to do it as I'm quite knowledgeable in the subject but I'm quite lazy and instead review really bad video games like this one...
http://war3pub.net/upload/index.php?...0date%20ex.zip
09-30-2002, 04:27 PM#10
Guest
Quote:
Originally posted by Mithrandir
Actually, I needed one for my map. I needed a rectangular (not square of circle) region for a cinematic. Don't ask why, it would take too long to explain. But I did need one.

But Teup is right, very very rarely do you need them.


LOL that situation also passed my mind when I said that, but I though: no thats insane, no-one needs that :D
10-01-2002, 06:26 PM#11
Aiursrage2k
Okay i was thinking of your idea, could you replace the items with units, then when the player comes in the region of the unit, change it to an item, when he leaves change it back to a unit or whatever you want.