• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] 0,0 coordinates bug..

Status
Not open for further replies.
Level 1
Joined
Oct 15, 2019
Messages
2
Hey i make a function to create a grid.. it works but at x0 or y0 it bugs out and looks like this.

FIRSTT.png


Sec.png



and Here is my code

function CreateArena takes real StartX,real StartY, integer Wight,integer Hight returns nothing

local real x = StartX
local real y = StartY
local integer Enum = 0
local integer AnzahlAnKreisen = Wight*Hight
local integer WieOftX =0

local integer intex = 0
local integer Wightlocal = Wight
local boolean Varien =false
set Wightlocal = Wightlocal

loop
exitwhen Enum >= AnzahlAnKreisen
set Enum = Enum+1
if WieOftX >= Wightlocal then
if Varien == false then
set x = StartX -64
set y = y -128
set WieOftX = 0
set Varien = true

elseif Varien == true then
set x = StartX
set y = y -128
set WieOftX = 0
set Varien = false
endif
endif

if WieOftX < Wightlocal then
set x = x-128
set WieOftX = WieOftX+1
endif
set RectGebieteins[intex].Reci =Rect(-64,-64,64,64)
call MoveRectTo(RectGebieteins[intex].Reci,x,y)
call CreateNUnitsAtLoc( 1, 'ncop', Player(0), GetRectCenter(RectGebieteins[intex].Reci), bj_UNIT_FACING )
set intex = intex +1

endloop
endfunction


So my qustions is simpel? WHY?
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
I think wc3neverdies is onto the right problem here. Best guess is that using call CreateNUnitsAtLoc( 1, 'ncop', Player(0), GetRectCenter(RectGebieteins[intex].Reci), bj_UNIT_FACING ) takes into account unit pathing when placing the unit (usually location-based unit functions do). Instead I would use native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit or possibly use SetUnitX() and SetUnitY() after creating the unit to ensure it's in the right location (those functions definitively do ignore pathing).

Also you're leaking a location in that CreateNUnitsAtLoc call, and there's no real reason to move a rect to a location to get its center... just use those center coordinates directly. And [code=jass][/code] tags exist for code to be readable.
 
Level 1
Joined
Oct 15, 2019
Messages
2
Yes you're right. It was just a test function for the grid and I was wondering about why this bug only happened at 0,0 it was rly strange. I will use the nativ function with x, y


Thx for the help guys.
 
Status
Not open for further replies.
Top