• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Alternative to this?

Status
Not open for further replies.
Level 3
Joined
Feb 20, 2007
Messages
32
Well, I'm trying to get a block of terrain to create a diamond shape. It works... But only if the x/y coordinants are multiples of 128, or near that. Otherwise, it comes out a jumbled mess. Probably because I add in factors of 128. Here's the code I'm using, it's pritty simple.

JASS:
 local gamecache g = LocalVars()
 local group ga = CreateGroup()
 local unit u
 local real x = GetHandleReal(g, "SSSX") //Theyse are all passed from an ExecuteFunc call.
 local real y = GetHandleReal(g, "SSSY")
 local real x2
 local real y2
 local integer i = 0
 local integer ot = GetHandleInt(g, "SSSO")
 local real rt = 0.0
 local real dist = GetHandleReal(g, "SSSD")

 call BJDebugMsg(R2S(x))
 call BJDebugMsg(R2S(y))

 loop
 set rt = rt + 45.00
 loop
  set x2 = PolarX(x, i * 128, rt)
  set y2 = PolarY(y, i * 128, rt)
  call SetTerrainType(x2, y2, 'Cpos', 1, 1, 1)
  exitwhen(i*128 >= R2I(dist)) 
  set i = i + 1
 endloop
 set i = 0
 exitwhen(rt >= 360)
 endloop
<If there are unused variables, they're used for other purposes>

My PolarX and PolarY are derivitives of PolarProjectionBJ I'm just using them so I dont leak a location.
(
JASS:
function PolarX takes real x, real dist, real angle returns real
 return x + dist * Cos(angle * bj_DEGTORAD)
endfunction

function PolarY takes real y, real dist, real angle returns real
 return y + dist * Sin(angle * bj_DEGTORAD)
endfunction

Is there any alternative to this method? I'd really like to be able to use this code in my map, but it's to screwey if placement is not exact.

Thank you.
 
Status
Not open for further replies.
Top