HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Gravity Slide System Trigger

05-14-2008, 04:08 PM#1
rulerofiron99
Made a quick system that makes all units slide down hills and stuff.

The trigger:
Trigger:
SlideSystem
Collapse Events
Time - Every 0.05 seconds of game time
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in slideg and do (Actions)
Collapse Loop - Actions
Set u = (Picked unit)
Custom script: set udg_sliderx = GetUnitX(udg_u)
Custom script: set udg_slidery = GetUnitY(udg_u)
Set slidep[0] = (Position of u)
Custom script: set udg_sliderz[0] = GetLocationZ(udg_slidep[0])
-------- --- --------
Set slidep[1] = (slidep[0] offset by (32.00, 0.00))
Custom script: set udg_sliderz[1] = GetLocationZ(udg_slidep[1])
Set sliderx = (sliderx - (sliderz[1] x 0.10))
Custom script: call RemoveLocation(udg_slidep[1])
-------- --- --------
Set slidep[1] = (slidep[0] offset by (-32.00, 0.00))
Custom script: set udg_sliderz[1] = GetLocationZ(udg_slidep[1])
Set sliderx = (sliderx + (sliderz[1] x 0.10))
Custom script: call RemoveLocation(udg_slidep[1])
-------- --- --------
Set slidep[1] = (slidep[0] offset by (0.00, 32.00))
Custom script: set udg_sliderz[1] = GetLocationZ(udg_slidep[1])
Set slidery = (slidery - (sliderz[1] x 0.10))
Custom script: call RemoveLocation(udg_slidep[1])
-------- --- --------
Set slidep[1] = (slidep[0] offset by (0.00, -32.00))
Custom script: set udg_sliderz[1] = GetLocationZ(udg_slidep[1])
Set slidery = (slidery + (sliderz[1] x 0.10))
Custom script: call RemoveLocation(udg_slidep[1])
Custom script: call SetUnitX(udg_u, udg_sliderx)
Custom script: call SetUnitY(udg_u, udg_slidery)
Custom script: call RemoveLocation(udg_slidep[0])
This is the main trigger, does all the sliding.

Trigger:
RemoveSlider
Collapse Events
Unit - A unit Dies
Collapse Conditions
((Triggering unit) is in slideg) Equal to True
Collapse Actions
Unit Group - Remove (Triggering unit) from slideg
And of course to remove the units from the group.

The problem is the lag this generates - tested 400 units running to a point using this system and no system, with an FPS difference of about 5 (this is quite something for slower, older pcs).

Is there any way that I can optimize this code? I looked through jass craft for a GetUnitZ function, but couldn't find.
05-14-2008, 04:31 PM#2
moyack
Quote:
Is there any way that I can optimize this code?
Yes!! doing it in JASS :P

Quote:
I looked through jass craft for a GetUnitZ function, but couldn't find.
GetUnitZ doesn't exists, you have to use GetLocationZ()
05-14-2008, 04:59 PM#3
grim001
The most important thing for you to change if you want to drastically improve performance is to stop creating and destroying locations. Use one global location, and recycle it for every time you need to use GetLocationZ.
05-14-2008, 06:39 PM#4
rulerofiron99
Thanks grim001, I'll give that a try.

moyack, the idea behind this system being in GUI is that it'll be easier to use for more people - generally when I make a map and forget about it, others pick it up on Battle.net or epicwar.com and continue it, so I like to make my triggers easy to use.

Another thing, I think there are a few JASS systems that include gravity sliding... I'm too GUI to use them.