X, Y, Z Coords Comparison

TFlan

I could change this in my User CP.
Reaction score
64
Its been awhile since I've even touched the world editor...

Is there a way to check the X, Y, and Z coordinates of an object and compare it to another? And have this run constantly, checking for this condition?
 

cleeezzz

The Undead Ranger.
Reaction score
268
GetUnitX(Unit)
GetUnitY(Unit)
GetFlyingHeight(Unit) (there is a little thing to this, it gets the set height, not the current height.)

your going to have to use some jass or custom scipting
 

TFlan

I could change this in my User CP.
Reaction score
64
Ah...

And on non-flat terrain that would be a problem.

Is there a way to get around this issue?
 

cleeezzz

The Undead Ranger.
Reaction score
268
it should be fine on non-flat terrain, what i meant was that when you use SetUnitFlyingHeight and change the height from 600 to 0 at a slow rate, in-game, you will see the unit slowly fall to the ground, however, if you use GetUnitFlyingHeight while its descending, it will still say 0, because it retrieves the height it was set at, not its current descending height.

in order to avoid this, you need a period trigger to set the flying height a small interval higher or lower at an instant rate, so it looks smooth + will give an accurate Z value
 

Azlier

Old World Ghost
Reaction score
461
You can indeed get the Z (not flying height) of a unit.
JASS:

That's assuming that Height is a global real variable made in the variable editor. It will get the Z of the triggering unit. Caution: Do not use with things like 3rd person cameras! GetLocationZ has a habit of overshooting hills by as much as 2x the actual height! Oh, and this leaks a point.
 

cleeezzz

The Undead Ranger.
Reaction score
268
isnt that terrain height though? i dont think it finds the units flying height.

btw, you can use Terrain height + Flying height of the unit to figure out a constant height from a 0 point.
 

Azlier

Old World Ghost
Reaction score
461
No, it will not find flying height. If you want that, do exactly as you have stated: GetLocationZ + flying height.
 

TFlan

I could change this in my User CP.
Reaction score
64
Correct me if I'm wrong.

JASS:
function compareCoords takes unit unitOne, unit unitTwo returns boolean
local unitOnex = GetLocationX(unitOne)
local unitOney = GetLocationY(unitOne)
local unitOnez = GetLocationZ(GetUnitLoc(GetTriggerUnit(unitOne)))
local unitTwox = GetLocationX(unitTwo)
local unitTwoy = GetLocationY(unitTwo)
local unitTwoz = GetLocationZ(GetUnitLoc(GetTriggerUnit(unitTwo)))
if unitOnex==unitTwox && unitOney==unitTwoy && unitOnez==unitTwoz then
return true
else
return false
endif
endfunction


I butchered that.
 

Azlier

Old World Ghost
Reaction score
461
JASS:
function compareCoords takes unit unitOne, unit unitTwo returns boolean
  local location unitOneLoc = GetUnitLoc(UnitOne)
  local location unitTwoLoc = GetUnitLoc(UnitTwo)
  local unitOnex = GetLocationX(unitOneLoc)
  local unitOney = GetLocationY(unitOneLoc)
  local unitOnez = GetLocationZ(unitOneLoc)
  local unitTwox = GetLocationX(unitTwoLoc)
  local unitTwoy = GetLocationY(unitTwoLoc)
  local unitTwoz = GetLocationZ(unitTwoLoc)
  call RemoveLocation(unitOneLoc)
  call RemoveLocation(unitOneLoc)
  set unitOneLoc = null
  set unitTwoLoc = null
if unitOnex==unitTwox and unitOney==unitTwoy and unitOnez==unitTwoz then
    set unitOnex = null
    set unitOney = null
    set unitOnez = null
    set unitTwox = null
    set unitTwoy = null
    set unitTwoz = null
    return true
else
    set unitOnex = null
    set unitOney = null
    set unitOnez = null
    set unitTwox = null
    set unitTwoy = null
    set unitTwoz = null
    return false
endif
endfunction
 

TFlan

I could change this in my User CP.
Reaction score
64
Well that's retarded syntax structure. Haha.

Thanks though.

About the flat terrain situation; will I have to use this?:

JASS:
local z = GetFlyingHeight(Unit) +  GetLocationZ(GetUnitLoc(Unit))
 

Azlier

Old World Ghost
Reaction score
461
If you really need to calculate flying and unit height, yes. You must. But how in the world are you going to get two units with the same exact X, Y, Z, and flying height in order to make that trigger work?

By the way, I deleaked the code back in my last post (I hope, I really am a complete noob when it comes to JASS. Do reals even need to be nulled?).
 

TFlan

I could change this in my User CP.
Reaction score
64
A unit does not consume a single point on any plane, whether it be x, y, or z.

Each unit has a collision area, that gives you a rough idea of how much space you should allocate for a collision of two units.

So in reality it would not be 1x==2x and 1y==2y and 1z==2z, but rather 2x+30 > 1x > 2x-30 format.

Not an exact condition, but the idea gets across. I'm surprised this hasn't been discussed about in these forums before, a search only showed x, y comparisons.
 

Azlier

Old World Ghost
Reaction score
461
So, in reality, you are attempting to create collision for warcraft? Being able to detect running into a building on all three planes? It very much sounds like a three dimensional A unit is in range of (unit) condition.
Apprentice said:
What you propose is possible. I shall get back to you on this matter, fellow magister.
 

TFlan

I could change this in my User CP.
Reaction score
64
That it is.

Now is there a way to cause this to constantly check for this condition without horrifically lagging anyone and everyone playing?
 

Azlier

Old World Ghost
Reaction score
461
There is. I was thinking of this matter at the same time as you. Use the normal A unit is in range of event, but check the Z before performing actions! That way you get what you want without getting every unit's x, y, and z every 0.02 seconds or whatever and causing the major lag.

However, I don't know if it would lag at all with just the checking. Warcraft is incredibly efficient! I worked with Game Maker. Very, very low efficiency. It can't handle a 2-d Mario without lagging!

And, I think we may be clogging up the world editor help. Let's move this over to private messages.
 

TFlan

I could change this in my User CP.
Reaction score
64
Private Messages defeat the purpose of a forum.

Is there an event that triggers when a unit collides on the x, y? If so then a simple Z check will be enough, and there will be no loop consuming resources.

If not, then...

What is less likely to occur?
2 Units being around the same point on the x, y axis or 2 Units being around the same point on the z axis

That will decide the first condition to either break the loop or continue.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Is there an event that triggers when a unit collides on the x, y?

There's "unit comes in range", but it isn't generic.

The alternative is a periodic check... that tests everything of interest.

SquareRoot(dx * dx + dy * dy + dz * dz), with dx the differences between two units' Xs, dy the difference... gets you the distance between two 3D points.



As a random guess, having nearly the same height is more likely than having nearly the same position "on the ground".


> GetLocationZ has a habit of overshooting hills by as much as 2x the actual height!

It gets the height of the terrain at some point. No mystery there.
It might desync though if your map uses any terrain deformations (triggered or from spells).
 

TFlan

I could change this in my User CP.
Reaction score
64
Would this work?

JASS:
function compareCoords takes unit uA, unit uB, integer cArea returns boolean
	local uA<u> = uA
	local uB<u> = uB
	local location uA[l] = GetUnitLoc(uA<u>)
	local location uB[l] = GetUnitLoc(uB<u>)
	local uA[x] = GetLocationX(uA[l])
	local uB[x] = GetLocationX(uB[l])
	local uA[y] = GetLocationY(uA[l])
	local uB[y] = GetLocationY(uB[l])
	local uA[z] = GetLocationZ(uA[l]) + GetFlyingHeight(uA<u>)
	local uB[z] = GetLocationZ(uB[l]) + GetFlyingHeight(uB<u>)
	call RemoveLocation(uA[l])
	call RemoveLocation(uB[l])
	if uA[x] &gt;= uB[x] - cArea and uA[x] &lt;= uB[x] + cArea then
		if uA[y] &gt;= uB[y] - cArea and uA[y] &lt;= uB[y] + cArea then
			if uA[z] &gt;= uB[z] - cArea and uA[z] &lt;= uB[z] + cArea then
				set uA = null
				set uB = null
				return true
			else
				set uA = null
				set uB = null
				return false
			endif
		else
			set uA = null
			set uB = null
			return false
		endif
	else
		set uA = null
		set uB = null
		return false
	endif
endfunction</u></u></u></u></u></u>


Edit::
Sorry didn't see you posted AceHart. Reading yours now.

Edit::
Thanks for the clarification on the Z coordinate, Ace.
 

TFlan

I could change this in my User CP.
Reaction score
64
Using notepad on a laptop without any WC3 related programs on it.

'x' is the index of array uA. In this case it has the value of the X coordinate of unit uA (unit A)

Made it into an array so I don't have 24 lines of setting 6 different variables equal to null. If this array structure is not allowed in JASS then I'll just have it create the variables after passing the previous condition.

I've taken all of 10 minutes to look into JASS syntax structure and rules. If something is wrong, just correct it in a post if you wouldn't mind. Forget a quotation or whatever.

I'm assuming setting a variable to null completely deletes it? Again, haven't touched WC3 editor in a very long time, not sure if that does fix a memory leak? A previous poster wrote that in his/her code block, so I followed, assuming it was right.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top