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.
FaMoUs
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Speed diffrence on this functions?

Unread post by FaMoUs »

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

User avatar
3ICE
Admin
Posts: 2629
Joined: Sat Mar 01, 2008 11:34 pm
Realm: Europe
Account: 3ICE
Clan: 3ICE
Location: Hungary
Contact:

Re: Speed diffrence on this functions?

Unread post by 3ICE »

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

FaMoUs
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

Unread post by FaMoUs »

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.

User avatar
3ICE
Admin
Posts: 2629
Joined: Sat Mar 01, 2008 11:34 pm
Realm: Europe
Account: 3ICE
Clan: 3ICE
Location: Hungary
Contact:

Re: Speed diffrence on this functions?

Unread post by 3ICE »

The topic I linked is closed so I can't easily let them know about your find...
ImageImageImageImageImage
Image
ImageImage

FaMoUs
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

Unread post by FaMoUs »

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.

User avatar
3ICE
Admin
Posts: 2629
Joined: Sat Mar 01, 2008 11:34 pm
Realm: Europe
Account: 3ICE
Clan: 3ICE
Location: Hungary
Contact:

Re: Speed diffrence on this functions?

Unread post by 3ICE »

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

FaMoUs
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

Unread post by FaMoUs »

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 563 times

User avatar
3ICE
Admin
Posts: 2629
Joined: Sat Mar 01, 2008 11:34 pm
Realm: Europe
Account: 3ICE
Clan: 3ICE
Location: Hungary
Contact:

Re: Speed diffrence on this functions?

Unread post by 3ICE »

The result is not conclusive. Need two maps.
ImageImageImageImageImage
Image
ImageImage

FaMoUs
Posts: 44
Joined: Thu Jan 26, 2012 3:03 pm
Realm: US East
Account: FaMoUs
Clan: AKR

Re: Speed diffrence on this functions?

Unread post by FaMoUs »

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

User avatar
3ICE
Admin
Posts: 2629
Joined: Sat Mar 01, 2008 11:34 pm
Realm: Europe
Account: 3ICE
Clan: 3ICE
Location: Hungary
Contact:

Re: Speed diffrence on this functions?

Unread post by 3ICE »

And touch the vanilla world editor? Well, okay.
ImageImageImageImageImage
Image
ImageImage

Post Reply

Who is online

Users browsing this forum: No registered users and 66 guests