Speed diffrence on this functions?

The perfect one step solution for creating Ice/Sliding Mazes in both Reign of Chaos and The Frozen Throne. It is the only decent system around and it even works in RoC, is lagfree, perfectly optimized, fast and reliable. The included TerrainKill feature frees you from the tedious task of creating a thousand kill-regions.

Speed diffrence on this functions?

New postby FaMoUs on Sat Apr 07, 2012 1:00 am

Wouldn't this be faster
Code: Select all
call SetUnitPosition(u,x+Speed[i]*Cos(Deg2Rad(GetUnitFacing(u))), y+Speed[i]*Sin(Deg2Rad(GetUnitFacing(u))))

than calling this 3?
Code: Select all
call SetUnitX(u,x+Speed[i]*Cos(Deg2Rad(GetUnitFacing(u))))
call SetUnitY(u,y+Speed[i]*Sin(Deg2Rad(GetUnitFacing(u))))
call IssueImmediateOrder(u,"stop")

I know it looks a lot more messy but would it be faster since its only calling one function?
Last edited by 3ICE on Sat Apr 07, 2012 2:39 pm, edited 2 times in total.
Reason: Adding "stop" to first code, fixing then→than, removing "stop" from first code
FaMoUs
 
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

New postby 3ICE on Sat Apr 07, 2012 8:07 am

Would have to test it with a thousand units sliding.

Edit: Moved to sliding system.

Edit2: By the way 1.24d stopped SetUnitPosition from cancelling orders, so to make it fair you need call IssueImmediateOrder(u,"stop") in the first code as well.

Edit3: Also, SetUnitPosition() is worse because of its pathability checking being slow. But stopping the unit also checks pathability, so a conclusive result can only be achieved through testing.

I prefer SetUnitX and Y because they are direct control over the unit with nothing getting in the way. We can slide over cliffs, and through buildings, etc.

Edit 4: Optimized code looks messy by default :) It doesn't bother me. But again, only optimize code that is executed frequently, like over 33 times per second.
ImageImageImageImageImage
Image
ImageImage
User avatar
3ICE
Admin
 
Posts: 2126
Joined: Sat Mar 01, 2008 11:34 pm
Location: Hungary
Realm: US East
Account: 3ICE
Clan: 3ICE

Re: Speed diffrence on this functions?

New postby FaMoUs on Sat Apr 07, 2012 2:27 pm

Don't actually need IssueImmediateOrder. Already test it. We on 1.26 right now so I'm guessing they re-added it.
Last edited by FaMoUs on Sat Apr 07, 2012 2:31 pm, edited 1 time in total.
FaMoUs
 
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

New postby 3ICE on Sat Apr 07, 2012 2:29 pm

The topic I linked is closed so I can't easily let them know about your find...
ImageImageImageImageImage
Image
ImageImage
User avatar
3ICE
Admin
 
Posts: 2126
Joined: Sat Mar 01, 2008 11:34 pm
Location: Hungary
Realm: US East
Account: 3ICE
Clan: 3ICE

Re: Speed diffrence on this functions?

New postby FaMoUs on Sat Apr 07, 2012 2:34 pm

Yea I saw. With SetUnitPosition it feels like the steering has improve. Might be my mind tricking me but yes hardly noticeable but i think it did.

-Edit
You Should remove call IssueImmediateOrder(u,"stop") from the first code on my first post since editing is locked in post 1.
FaMoUs
 
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

New postby 3ICE on Sat Apr 07, 2012 2:39 pm

Yeah I made it do that whenever I edit someone else's post. Fix'd.

Edit: So how about that test map? I'd be interested in the result. (But not interested enough to spend a couple hours getting my mapping tools together on this laptop again. Sigh.)
ImageImageImageImageImage
Image
ImageImage
User avatar
3ICE
Admin
 
Posts: 2126
Joined: Sat Mar 01, 2008 11:34 pm
Location: Hungary
Realm: US East
Account: 3ICE
Clan: 3ICE

Re: Speed diffrence on this functions?

New postby FaMoUs on Sat Apr 07, 2012 3:34 pm

Here I edit your slide system and added the 100 demon hunters. Test it. My computer can't handle 100 demon hunters sliding with out my fps dropping since I got a Pentium 4 CPU 2.93GHz with 2.50 GB of RAM.
Attachments
Test.w3m
(19.97 KiB) Downloaded 235 times
FaMoUs
 
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

New postby 3ICE on Sat Apr 07, 2012 3:36 pm

The result is not conclusive. Need two maps.
ImageImageImageImageImage
Image
ImageImage
User avatar
3ICE
Admin
 
Posts: 2126
Joined: Sat Mar 01, 2008 11:34 pm
Location: Hungary
Realm: US East
Account: 3ICE
Clan: 3ICE

Re: Speed diffrence on this functions?

New postby FaMoUs on Sat Apr 07, 2012 3:40 pm

Two maps? Why? To compare to the SetUnitX with SetPosition? Well Just remove the // from the code, didn't actually remove it. Just made them into comments so you can test and resave every time you want to compare
FaMoUs
 
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

New postby 3ICE on Sat Apr 07, 2012 3:47 pm

And touch the vanilla world editor? Well, okay.
ImageImageImageImageImage
Image
ImageImage
User avatar
3ICE
Admin
 
Posts: 2126
Joined: Sat Mar 01, 2008 11:34 pm
Location: Hungary
Realm: US East
Account: 3ICE
Clan: 3ICE

Next

Return to 3ICE's Sliding System for RoC



Who is online

Users browsing this forum: No registered users and 2 guests

cron