HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Jass - Ice Slide Trigger

09-21-2006, 07:21 AM#1
Fr0zenLord
I copied this from GUI, (then convert to jass), then I made a jass trigger from scratch, trying to copy the trigger that I converted to jass...

Where did I go wrong

Todays Problems: unexpected return in "Returns nothing function"
expected a name (the exitwhen bj_forloop > bj_forloopend)
Invalid type for specified Operator ( call RemoveLocation(udg_Point[1])
Expected "Endif"
Expected "Endif"
Expected a function name (call TriggerAddAction, bllah blah, ice slide)
Expeced endif again!


Collapse JASS:
function Trig_Ice_Slide_Jass_Func001Func002C takes nothing returns nothing
    if ( not ( GetTerrainTypeBJ(udg_Point[1]) == 'Iice' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Ice_Slide_Jass_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_ForLoopAIndexEnd
        set udg_Point[1] = GetUnitLoc(udg_Raq[GetForLoopIndexA()])
        if ( Trig_Ice_Slide_Jass_Func001Func002C() ) then
            set udg_Point[2] = PolarProjectionBJ(udg_Point[1], 30.00, GetUnitFacing(udg_Raq[GetForLoopIndexA()]))
            call SetUnitPositionLoc( udg_Raq[GetForLoopIndexA()], udg_Point[2] )
            call RemoveLocation(udg_Point[2])
        else
        endif
        call RemoveLocation(udg_Point[1])
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
   endloop
endfunction

//===========================================================================
function InitTrig_Ice_Slide_Jass takes nothing returns nothing
    set gg_trg_Ice_Slide_Jass = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Ice_Slide_Jass, 0.03 )
    call TriggerAddAction( gg_trg_Ice_Slide_Jass, function Trig_Ice_Slide_Jass_Actions )
endfunction

Edit: Use the [jass] tag next time.
09-21-2006, 07:47 AM#2
Fireeye
Didn't look exactly, but found 1 error till now.
Collapse JASS:
function Trig_Ice_Slide_Jass_Func001Func002C takes nothing returns nothing 
is wrong change it to
Collapse JASS:
function Trig_Ice_Slide_Jass_Func001Func002C takes nothing returns boolean
09-21-2006, 08:11 AM#3
aquilla
Are you sure GetTerrainType returns an integer like that? I thought it returned a number between 0 and numberoftilesinmap-1. Anyways, why would you convert to jass and not use any of it's benefits? o.o
Collapse JASS:
function IceSlide takes nothing returns nothing
    local integer i = 0 // if there's something you don't understand - ask
    local real x
    local real y
    local real a
    loop
        exitwhen i > 11
        set x = GetUnitX(udg_Raq[i])
        set x = GetUnitY(udg_Raq[i])
        if GetTerrainType(x, y) == 'Iice' then
            set a = GetUnitFacing(udg_Raq[i])*bj_RADTODEG
            call SetUnitPosition(udg_Raq[i], x + 40*Cos(a), y + 40*Sin(a))
        endif
        set i = i+1
   endloop
endfunction

//===========================================================================
function InitTrig_Ice_Slide_Jass takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.04, true, function IceSlide)
endfunction
You won't be able to turn off this trigger, if you want to be able to use your InitTrig function. Also download JassCraft from the resources if you haven't already :) it helps A LOT!
09-21-2006, 09:16 AM#4
Fr0zenLord
Holy moly your smart! lol, thanks so much +Rep XD

Could you explain, what the local real "a" is for? and what Cos, and Sin mean? lol\

Collapse JASS:
function Ice_Slide takes nothing returns nothing
    local integer i = 0
    local real x
    local real y
    local real a
    loop
        exitwhen i > 11
        set x = GetUnitX(udg_Raq[i])
        set x = GetUnitY(udg_Raq[i])
        if GetTerrainType(x, y) == 'Iice' then
        call SetUnitPosition(udg_Raq[i], x + 40*Cos(a), y + 40*Sin(a))
    endif
    set i = i + 1
   endloop
endfunction

//===========================================================================
function InitTrig_Ice_Slide takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.03, true, function Ice_Slide)
endfunction

Timer said Expected a function name, why not use call TriggerRegisterTimerEventPeriodic? not as good?
Fixed, Had the name wrong (trig_ice_slide_actions) not ice_slide XD, Sorry to keep bothering you -.- how would I make a "Turn trigger" for the sliding lol... :/

Would also appreciate it to know how to pick every player at map initilization, and make visibility for them
09-21-2006, 11:50 AM#5
blu_da_noob
Quote:
Originally Posted by aquilla
Are you sure GetTerrainType returns an integer like that? I thought it returned a number between 0 and numberoftilesinmap-1.

No, it returns a 'tile id', much like standard unit and ability ids (same base etc).


Cos and Sin are standard trig things, the ratios between sides of a right-angled triangle, you learn about them at school (I don't feel like giving any kind of real explanation right now). You should find information quite easily by googling or in, say, wikipedia.


For pick every player: Are you wanting to use GUI or JASS? If JASS, you need to be looking at forces (not playergroups).
09-21-2006, 01:01 PM#6
Rising_Dusk
Collapse JASS:
call SetUnitPosition(udg_Raq[i], x + 40*Cos(a), y + 40*Sin(a))
I recommend doing the Cos(a) and Sin(a) calculations once and storing them to some variable.
That way you're not calculating the same thing a dozen times.

Also, just a note, all of these SetUnitPosition()s will be executed at the same time.
So in game, if you want every single unit in unit-array Raq to slide 40 distance in some unknown direction a...
Well.. I'm not sure if that was what you were looking for, but it might be, so who knows.

And to make a unit turn in the slide, just increment the units' facing angles over a period of time. Using a timer helps here.
09-21-2006, 07:30 PM#7
aquilla


Using a trigger like you did would work too but this should decrease loadtime by a few milli-moments :D
Quote:
Originally Posted by Fr0zenLord
Could you explain, what the local real "a" is for? and what Cos, and Sin mean? lol
seems i missed to set the angle xD added comments, hope they make sense
Collapse JASS:
function IceSlide takes nothing returns nothing
    local integer i = 0 // initiate locals
    local real x
    local real y
    local real a
    loop
        exitwhen i > 11 // loop through all players (change if incorrect number), if you generally use GUI
                        // change 11 to 12 and the first row to local integer i = 1
        set x = GetUnitX(udg_Raq[i])    // gets the units current position - x and y
        set y = GetUnitY(udg_Raq[i])
        if GetTerrainType(x, y) == 'Iice' then
            set a = GetUnitFacing(udg_Raq[i])*bj_RADTODEG   // set the angle in which we will move the units to the unit's
                                                            // facing angle and convert the value from degrees to radians
            call SetUnitPosition(udg_Raq[i], x + 30*Cos(a), y + 30*Sin(a))  // sets a unit's x and y values. Cosinus and sinus
                                                                            // (familiar from math) help you get the correct distance
                                                                            // to move the unit for the x and y axis
        endif
        set i = i+1 // loop
    endloop
endfunction

//===========================================================================
function InitTrig_Ice_Slide takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.03, true, function IceSlide) // starts a new timer at an interval, repeating and each time calling the function
endfunction

Quote:
Originally Posted by Fr0zenLord
how would I make a "Turn trigger" for the sliding lol... :/
hmmm?
Quote:
Originally Posted by Fr0zenLord
Would also appreciate it to know how to pick every player at map initilization, and make visibility for them

dunno if this would desync the map (as it uses local player), so test it;
Collapse JASS:
call FogModifierStart(CreateFogModifierRect(GetLocalPlayer(), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea, true, false))

if it does desync, do it in GUI. Or, loop through all players and add the "fog modifier" to each of them;
Collapse JASS:
    local integer i = 0
    loop
        exitwhen i > 11
        call FogModifierStart(CreateFogModifierRect(Player(i), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea, true, false))
        set i = i+1
    endloop
this taken from JassCraft (which I hope you use :D);
Collapse JASS:
native FogModifierStart             takes fogmodifier whichFogModifier returns nothing    
native CreateFogModifierRect        takes player forWhichPlayer, fogstate whichState, rect where, boolean useSharedVision, boolean afterUnits returns fogmodifier
I just checked what the GUI-function did and used the natives directly;
Collapse JASS:
function CreateFogModifierRectBJ takes boolean enabled, player whichPlayer, fogstate whichFogState, rect r returns fogmodifier
    set bj_lastCreatedFogModifier = CreateFogModifierRect(whichPlayer, whichFogState, r, true, false)
    if enabled then
        call FogModifierStart(bj_lastCreatedFogModifier)
    endif
    return bj_lastCreatedFogModifier
endfunction
jasscraft ftw! :)

edit: yes it is, fixed it and found the reason it didn't work ._.
09-21-2006, 08:05 PM#8
Fireeye
Is this an error?
Collapse JASS:
            set x = GetUnitY(udg_Raq[i])
Shouldn't it be
Collapse JASS:
 
           set y = GetUnitY(udg_Raq[i])

For me it looks like one, cause you stored the X-Value already in it.
Nobody is perfect
09-21-2006, 09:21 PM#9
Fr0zenLord
Omg Stil doesnt work, dunno why, it looks right to me...
I also tried "changing" the second x to y, did nothing

Collapse JASS:
function Ice_Slide takes nothing returns nothing
    local integer i = 1
    local real x
    local real y
    local real a
    loop
        exitwhen i > 12
        set x = GetUnitX(udg_Raq[i])
        set x = GetUnitY(udg_Raq[i])
        set a = GetUnitFacing(udg_Raq[i])*bj_RADTODEG
        if GetTerrainType(x, y) == 'Iice' then
        call SetUnitPosition(udg_Raq[i], x + 40*Cos(a), y + 40*Sin(a))
    endif
    set i = i + 1
   endloop
endfunction

//===========================================================================
function InitTrig_Ice_Slide takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.03, true, function Ice_Slide)
endfunction
09-21-2006, 09:28 PM#10
aquilla
uhm, crap. I edited to fix it (I hope)