• 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.

Basics - HandleId

Status
Not open for further replies.
Level 2
Joined
Jul 12, 2018
Messages
17

Tasks

Code



Create 5 footmen units and print their handleid to screen.


Declare 2 local variables and let them point to the same unit, then print both of their handleids.



JASS:
scope Part1n2 initializer main
    private function main takes nothing returns nothing
        local integer i = 0
        local real x
        local real y
        local unit man1
        local unit man2
       
        loop
            exitwhen i == 5
           
            set x  = GetRectCenterX(bj_mapInitialPlayableArea) + 300*Cos(((I2R(i) + 1)*(360/5))*bj_DEGTORAD)
            set y  = GetRectCenterY(bj_mapInitialPlayableArea) + 300*Sin(((I2R(i) + 1)*(360/5))*bj_DEGTORAD)
            set man1 = CreateUnit(Player(0), 'hfoo', x, y, GetRandomReal(0, 359))
            set man2 = man1
            set i = i + 1
        endloop
       
        call BJDebugMsg("1st handle is " + I2S(GetHandleId(man1)))
        call BJDebugMsg("2nd handle is " + I2S(GetHandleId(man2)))
    endfunction
endscope

 

Attachments

  • [Crash Course] Basics - HandleId.w3m
    23.7 KB · Views: 73
It was marely a tiny personal tip.
What comes for me understandable is something like:
JASS:
local real angle = 0
local real angle_change = (bj_PI*2)/FOOTMAN_AMOUNT

loop
    exitwhen angle >= (bj_PI*2)
    ... create( )
    set angle = angle + angle_change
endloop
Using integer count as condition / doing calculs inside loop works just the same. It's what you prefer. ; )
 
Status
Not open for further replies.
Top