• 🏆 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!

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: 68
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