wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 08-31-2009, 01:13 PM   #16
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Anachron
You should add an option what player to play the sound to
Uh, well, I am pretty sure that the following won't desync:
Collapse JASS:
if GetLocalPlayer() == MyPlayer then
    call RunSound(MySound)
endif

Furthermore, though, when does it ever make sense for only one player viewing an action to hear the sound? If I shoot a missile at a point, all players should hear the explosion, stuff like that.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf

Last edited by Rising_Dusk : 08-31-2009 at 01:14 PM.
Rising_Dusk is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 08-31-2009, 01:19 PM   #17
Fledermaus
default string
 
Fledermaus's Avatar
 
Join Date: May 2006
Posts: 616

Submissions (1)

Fledermaus has a spectacular aura about (144)

Send a message via MSN to Fledermaus
Default

When a player was hit by an explosive and they've got that weird screeching noise you hear in movies? :p
Fledermaus is offline   Reply With Quote
Old 08-31-2009, 01:30 PM   #18
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Wouldn't that apply to anyone in range, though, in which case a 3-D sound would work great? (With different range cutoff settings than default, of course)
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 01:53 PM   #19
Fledermaus
default string
 
Fledermaus's Avatar
 
Join Date: May 2006
Posts: 616

Submissions (1)

Fledermaus has a spectacular aura about (144)

Send a message via MSN to Fledermaus
Default

Not if you've got Divine Shield, or it's team V team and your explosives don't TK.

But yeah, enough silly buggers. The local block should be fine for people who ever want to locally play a sound, don't really think the system needs to support that but it couldn't hurt to.

Last edited by Fledermaus : 08-31-2009 at 01:53 PM.
Fledermaus is offline   Reply With Quote
Old 08-31-2009, 01:56 PM   #20
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

I guess I can see the applications of that in that scenario. I think the local block should be OK. If Ani wants me to, I can add RunSoundForPlayer, though.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 02:06 PM   #21
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,368

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

Useful library (god I hate WC3 sounds' implementation sometimes, it's so annoying). Anyway, correct me if I'm wrong, but won't the H2I - min handle implementation bug out if the handles on the map (rather than just the sounds on the map) exceeds 8191?

As to for local blocks, putting it in local blocks would be fine for running, but in combination with releasing when done, you'll run into issues, won't you? Since you may later on get new sound being created on some systems but not others, due to different numbers of sounds release / in the stack.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 08-31-2009, 02:18 PM   #22
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Captain Griffen
Anyway, correct me if I'm wrong, but won't the H2I - min handle implementation bug out if the handles on the map (rather than just the sounds on the map) exceeds 8191?
Yes, I suppose I should apply that MAX_SIZE array size to all arrays using that storage method. You can always increase the MAX_SIZE variable to something like 500000 if you can't keep handle count down, it just slows down because of big arrays. It should still run perfectly fine, though.
Quote:
Originally Posted by Captain Griffen
As to for local blocks, putting it in local blocks would be fine for running, but in combination with releasing when done, you'll run into issues, won't you? Since you may later on get new sound being created on some systems but not others, due to different numbers of sounds release / in the stack.
You'd use NewSound and ReleaseSound outside of the local block, all that'd be used inside it would be RunSound, which should be fine.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf

Last edited by Rising_Dusk : 08-31-2009 at 02:19 PM.
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 07:30 PM   #23
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,368

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

Quote:
Originally Posted by Rising_Dusk
Yes, I suppose I should apply that MAX_SIZE array size to all arrays using that storage method. You can always increase the MAX_SIZE variable to something like 500000 if you can't keep handle count down, it just slows down because of big arrays. It should still run perfectly fine, though.

I'd say that's excessive when you could, for a far smaller performance hit, make it use a hash to between 1 and 8191.

Quote:
You'd use NewSound and ReleaseSound outside of the local block, all that'd be used inside it would be RunSound, which should be fine.

Yea, but you might want to make a RecycleSoundWhenDoneForPlayer.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 08-31-2009, 08:46 PM   #24
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Captain Griffen
I'd say that's excessive when you could, for a far smaller performance hit, make it use a hash to between 1 and 8191.
Hrm, that's probably true. What hash would you recommend?
Quote:
Originally Posted by Captain Griffen
Yea, but you might want to make a RecycleSoundWhenDoneForPlayer.
Huh, why? You can just RecycleSoundWhenDone() a sound that is only played locally and it will recycle it happily properly whenever.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 08:49 PM   #25
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,514

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

Anyone else find it ironic that the guy who develops a Sound library is the one who is constantly reminding everyone that his computer doesn't have sound enabled?

:P


Noice library.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 08-31-2009, 08:56 PM   #26
Mr.Malte
User
 
Mr.Malte's Avatar
 
Join Date: Apr 2008
Posts: 286

Submissions (2)

Mr.Malte is on a distinguished road (11)

Default

Quote:
Originally Posted by Captain Griffen
I'd say that's excessive when you could, for a far smaller performance hit, make it use a hash to between 1 and 8191.
Hrm, that's probably true. What hash would you recommend?
Quote:


Thats a nice idea, since the hash is just used internally, you'd not even have index conflicts.
Mr.Malte is offline   Reply With Quote
Old 08-31-2009, 09:08 PM   #27
ToukoAozaki
extends net.wc3c.Jasser
 
Join Date: Jun 2008
Posts: 336

Submissions (5)

ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)

Send a message via MSN to ToukoAozaki
Default

Actually I had plans to make exactly the same thing. (even interfaces are 98% similar, but whatever.) I threw it away due to hassles making the library neat. One of such hassle is locally played sounds when it comes to recycling.

The most correct way of recycling should be making sure whether the sound is still in use. The problem here is that you are not going to know whether a sound is idle if it is played in local fashion, unless you apply some dirty synchronization tricks. Once the stack becomes to have different number of sounds, trying to get the sound will desync when the stack is empty for some players but not to the others. This is because creating sounds desync whatsoever.

In your code, I see you utilizing timers to circumvent this fuss. It might be an alternative, but it has weaknesses. First, timers don't work quite well with sounds. For instance, the sound will continue playing when the game is paused, while the timer won't. Also, the sound durations are real-time, while timer depends on the game speed. This means the sound will cut off prematurely.

To fix the problem, you should try getting the approximate factor that each game speed poses to the game time. OTOH, game being paused can be a non-issue, since it would only make the sound unusuable for some extra time.
ToukoAozaki is offline   Reply With Quote
Old 08-31-2009, 09:52 PM   #28
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,368

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

Quote:
Originally Posted by Rising_Dusk
Hrm, that's probably true. What hash would you recommend?

H2I - H2I / 8191 * 8191 (+1 to avoid 0 and maybe 8190?), then loop to see if it's already being used.

Quote:
Huh, why? You can just RecycleSoundWhenDone() a sound that is only played locally and it will recycle it happily properly whenever.

So when does it recycle? If it's dependant upon when the sound finishes, and it's only played in local block, then you'll have a problem.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 08-31-2009, 10:08 PM   #29
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Captain Griffen
H2I - H2I / 8191 * 8191 (+1 to avoid 0 and maybe 8190?), then loop to see if it's already being used.
And make it O(n) with that loop? I guess speed doesn't matter, but Vex has got me not liking that in principle. I dunno, if TimerUtils red can get away with an H2I-MIN_HANDLE_ID approach, I don't think it's a problem. I do see your point here, though, but I'm just not sure..
Quote:
Originally Posted by Captain Griffen
So when does it recycle?
It runs a timer to circumvent the problem with recycling local sounds, since the stack needs to be synchronized for all players. Basically, it always recycles after the sound's defined duration regardless if the sound is played for a certain player or not. This keeps it consistent and keeps the stack happy. (Which I deemed a priority)
Quote:
Originally Posted by ToukoAozaki
In your code, I see you utilizing timers to circumvent this fuss. It might be an alternative, but it has weaknesses. First, timers don't work quite well with sounds. For instance, the sound will continue playing when the game is paused, while the timer won't. Also, the sound durations are real-time, while timer depends on the game speed. This means the sound will cut off prematurely.

To fix the problem, you should try getting the approximate factor that each game speed poses to the game time. OTOH, game being paused can be a non-issue, since it would only make the sound unusuable for some extra time.
Yes, I noticed that too. The most frustrating part is the difference when the game lags, because that causes some strange discontinuities as well. I found that the difference between game time and real time is only noticeable for sounds over 2 minutes long (this may be system-dependent, as my computer is relatively slow). In testing I didn't think it was that big of an issue, but if it's system-dependent then it's basically impossible to reliably fix.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 10:30 PM   #30
ToukoAozaki
extends net.wc3c.Jasser
 
Join Date: Jun 2008
Posts: 336

Submissions (5)

ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)

Send a message via MSN to ToukoAozaki
Default

Quote:
Originally Posted by Rising_Dusk
And make it O(n) with that loop? I guess speed doesn't matter, but Vex has got me not liking that in principle. I dunno, if TimerUtils red can get away with an H2I-MIN_HANDLE_ID approach, I don't think it's a problem. I do see your point here, though, but I'm just not sure..

That is O(n) only if hashing function returns a constant value, making hash collisions 100% of the time. The technique Griffen suggested is one of the hashtable techniques to deal with hash collisions. Basically you save a copy of the key object reference itself, and compare it with the stored value after lookup with the hash of the key. If the key doesn't match, then try checking the next object pointed by the entry. This is generally done with linked lists, but arrays will do fine if every object has assigned unique indices. This technique generally works like supposed O(1) on average. Having poor hash will make the performance closer to theoretical O(n) worse case though.

Quote:
Originally Posted by Rising_Dusk
Yes, I noticed that too. The most frustrating part is the difference when the game lags, because that causes some strange discontinuities as well. I found that the difference between game time and real time is only noticeable for sounds over 2 minutes long (this may be system-dependent, as my computer is relatively slow). In testing I didn't think it was that big of an issue, but if it's system-dependent then it's basically impossible to reliably fix.

Just get an approximate factor and add the extra gap (like 15 percentage point). While added gap would make recycling a bit inefficient, but at least it would be bulletproof from unwanted bugs.

Last edited by ToukoAozaki : 08-31-2009 at 10:35 PM.
ToukoAozaki is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 04:14 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services