Dont understand this.

BRUTAL

I'm working
Reaction score
118
for the example slide trigger in TT theres this part
JASS:
static method create takes unit whichUnit, real tx, real ty returns Data
        local Data data = Data.allocate()
        local real Dx
        local real Dy
        local real distance
        local real angle
        
        set data.whichUnit = whichUnit
        set data.x = GetUnitX(whichUnit)
        set data.y = GetUnitY(whichUnit)
        
        set Dx = tx - data.x
        set Dy = ty - data.y
        
        set distance = RMinBJ(SLIDE_MAX_DISTANCE, SquareRoot(Dx * Dx + Dy * Dy))
        set data.ticks = R2I(distance / (SLIDE_SPEED*TT_PERIOD))  // <-------<< remember this formula
        
        set angle = Atan2(Dy, Dx)
        set data.dx = (SLIDE_SPEED*TT_PERIOD) * Cos(angle)
        set data.dy = (SLIDE_SPEED*TT_PERIOD) * Sin(angle)
        
        call SetUnitPathing( data.whichUnit, false )
        return data
    endmethod


what are tx, and ty? i dont see them anywhere except in the function agruments same with whichUnit
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
tx and ty are the coordinates of the target point of the slide. They are where the slide should end. They are used here
JASS:
        set Dx = tx - data.x
        set Dy = ty - data.y

to determine the total distance that the unit needs to be moved.
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
Look closer?
set data.whichUnit = whichUnit
set data.x = GetUnitX(whichUnit)
set data.y = GetUnitY(whichUnit)

set Dx = tx - data.x
set Dy = ty - data.y
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
Well, it's the only function you provided, we don't even see the function in which this one is called :\
 

Nexor

...
Reaction score
74
if a function takes something, it means that you call it with arguments after the functionname and that function can manipulate/change the value of those arguments.
JASS:
function Something takes unit whichUnit returns boolean
    if GetWidgetLife(whichUnit) > .405 then
        return true
    else
        return false
    endif
endfunction

this function will decide whether a unit is alive.
you can call it like this: call Something(whichUnit)
and it'll return a boolean value
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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