HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Ice Sliding Trigger.

08-29-2006, 02:50 AM#1
weedcraft
Ok now im pretty good with the WE but I've never really been interested in the ice sliding trigger I've been seeing alot of. But then all of the sudden i got really curious about it and im wondering how does it work???? ive got a couple of ideas but i need a lil help
08-29-2006, 03:16 AM#2
Rising_Dusk
"Ice Sliding" in and of itself is done by use of knockback functions on units over some form of ice.
An example would be a JESP spell I submitted awhile back located here.

If you mean knockback in general, you need to move a unit a constantly decreasing amount in some timer until it is being moved by 0, in which case you exit.

These are the functions used by my map --
Collapse JASS:
//***************************************************************************************************************
//*This is the timer that updates a unit sliding and being 'knocked back' across the ground.
//*
function Knockback_Update takes nothing returns nothing
    local integer i = H2I(GetExpiredTimer())
    local unit u = GetUnit(I2Timer(i), "u")
    local real speed = GetReal(I2Timer(i), "speed")
    local real angle = GetReal(I2Timer(i), "angle")
    local real dec = GetReal(I2Timer(i), "dec")
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    set x = ProjectX(x, speed, angle)
    set y = ProjectY(y, speed, angle)
    call SetUnitPosition(u, x, y)
    call SetReal(I2Timer(i), "speed", speed - dec)
    if speed <= 0 then
        call FlushLocals(I2Timer(i))
        call PauseTimer(I2Timer(i))
        call DestroyTimer(I2Timer(i))
    endif
    set u = null
endfunction
Collapse JASS:
//***************************************************************************************************************
//*This starts the knockback function to slide a unit across the ground.
//*
function Knockback takes unit u, real angle, real speed, real decrement returns nothing
    local integer i = H2I(CreateTimer())
    call SetReal(I2Timer(i), "angle", angle)
    call SetReal(I2Timer(i), "speed", speed)
    call SetReal(I2Timer(i), "dec", decrement)
    call SetHandle(I2Timer(i), "u", u)
    call TimerStart(I2Timer(i), .033, true, function Knockback_Update)
endfunction

They use handles and timers to cause a unit to move in some set direction by a constantly decreasing amount until they no longer are moving, in which case it cleans up and stops moving them.

There are other variations of the triggers, but that's basically how they work.
Negative acceleration. :D
08-29-2006, 08:48 AM#3
aquilla
Don't forget to check if terraintype is of type ice or whatever you may use. What Rising_Dusk gave you can be done in GUI too, but taking care of group and location leaks would be a biatch :D
08-29-2006, 09:02 AM#4
The)TideHunter(
Quote:
Originally Posted by Rising_Dusk
Negative acceleration. :D

lol, i need to try that.
Btw, i noticed you used I2Timer(i) quite often, which is kinda slow, did you do that to aviod timer set to null conspiracy?, so you dont have a timer in local?
08-29-2006, 12:48 PM#5
Rising_Dusk
Local timers are fine, it's only a problem when you attach handles to them.
And you can tell me it's as slow as you want, but if I run it 5000 times at once it doesn't move any slower than using local timers. (In game at least)
So blah to you. :P

And yeah, it avoids the timer to null bug entirely.
08-29-2006, 12:52 PM#6
blu_da_noob
Eww. Those functions have the same 'convert integer to handle which is then converted back to integer' thing as your Hurricane spell. The faster you start using the natives the better >.<.
08-29-2006, 08:50 PM#7
weedcraft
Ok now to tell ya the truth i really don't know nothing about at there Jass. But thanks any way Dusk_rising and da blue noob and the ohter people but could you show me a GUI version? If you could or kinna like I don't know teach me how to do the trigger in Jass. If any of this is possible it would be greatly appreachiated.
08-29-2006, 09:06 PM#8
Fireeye
Ok, here's a GUI Slide Trigger, you just have to modify it.

Trigger:
Slide
Collapse Events
Time - Every 0.02 seconds of game time
Conditions
Collapse Actions
Set Temp_Group1 = (Units of type Escaper)
Collapse Unit Group - Pick every unit in Temp_Group1 and do (Actions)
Collapse Loop - Actions
Set Temp_Point1 = (Position of (Picked unit))
Collapse If - Conditions
(Terrain type at Temp_Point1) Equal to Icecrown Glacier - Ice
Collapse Then - Actions
Unit - Move (Picked unit) instantly to (Temp_Point1 offset by 10.00 towards (Facing of (Picked unit)) degrees)
Collapse Else - Actions
Do nothing
Custom script: call RemoveLocation (udg_Temp_Point1)
Custom script: call DestroyGroup (udg_Temp_Group1)
08-29-2006, 09:52 PM#9
Jacek
Check this thread also, although my ways suck:

If you are JASS freak don't look -> leaks inside



edit: good you aren't using 1000s of regions :)
08-29-2006, 11:26 PM#10
Fr0zenLord
Dont know whether your problems been solved or not, but this is the GUI ice slide I use
Trigger:
Ice Slide works
Collapse Events
Time - Every 0.03 seconds of game time
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Set L = (Position of AAUnit[(Integer A)])
Set AAAAPOINT_Copy_4 = (Position of AAUnit[(Integer A)])
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Terrain type at L) Equal to Icecrown Glacier - Ice
(AAUnit[(Integer A)] is alive) Equal to True
((AAUnit[(Integer A)] is Mechanical) Equal to True) or ((AAUnit[(Integer A)] is An Ancient) Equal to True)
Collapse Then - Actions
Set L_Copy = (AAAAPOINT_Copy_4 offset by 13.00 towards (Facing of AAUnit[(Integer A)]) degrees)
Unit - Move AAUnit[(Integer A)] instantly to L_Copy
Collapse Else - Actions
Custom script: call RemoveLocation(udg_AAAAPOINT_Copy_4)
Custom script: call RemoveLocation(udg_L)
Custom script: call RemoveLocation(udg_L_Copy)
Do nothing

AAUNIT is a unit variable with array of 12, that I set players units on map inzitilization, its better then unit groups, as I had them before, and they create massive lag if they run alot and you have alot of em
(Note you need your units placed on map already to set them into AAUNIT)
08-30-2006, 08:41 AM#11
blu_da_noob
(Just a note: Fireeye's trigger leaks one location per unit per expiration of the timer event)
08-30-2006, 09:58 AM#12
The)TideHunter(
Yea Blu's right, you need to set the polar offset to a location then remove it later.
08-30-2006, 12:45 PM#13
Fireeye
Yeah, but for the beginning it's a nice trigger, i'll extend it.
BTW. Frozen i don't understand why you use 3 points, you need max 2.

Trigger:
Slide
Collapse Events
Time - Every 0.02 seconds of game time
Conditions
Collapse Actions
Set Temp_Group1 = (Units of type Escaper)
Collapse Unit Group - Pick every unit in Temp_Group1 and do (Actions)
Collapse Loop - Actions
Set Temp_Point1 = (Position of (Picked unit))
Collapse If - Conditions
(Terrain type at Temp_Point1) Equal to Icecrown Glacier - Ice
Collapse Then - Actions
Set Temp_Point2 = (Position of (Picked unit) offset by 10.00 towards (Facing of (Picked Unit)) degrees)
Unit - Move (Picked unit) instantly to (Temp_Point2)
Custom script: call RemoveLocation (udg_Temp_Point2)
Collapse Else - Actions
Do nothing
Custom script: call RemoveLocation (udg_Temp_Point1)
Custom script: call DestroyGroup (udg_Temp_Group1)
08-30-2006, 01:30 PM#14
Rising_Dusk
I dont like that sort of knockback.
As you have it, the unit gets knocked back by 10 every iteration no matter what.
Also, it only knocks back at all if they're on ice -- So if they slide off of ice all of a sudden the knockback stops.

That isn't realistic at all in terms of how it should happen.
It should detect the ice at the start of the knockback, then cause them to slide along while accelerating in the opposing direction (Slowing the slide) until they reach a halt.
08-30-2006, 04:13 PM#15
blu_da_noob
But only very slight negative acceleration while on ice (low friction) and it should continue to slide when it gets off ice but with much higher negative acceleration. Although that probably wouldn't work for a maze map :P