 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
chronoboy Into the past with a splash

Joined: 04 Jun 2010 Posts: 162 Location: Canada
|
Posted: Mon Nov 22, 2010 7:56 pm Post subject: Is there a way to prevent music from looping? |
|
|
I do not see an option in plotscript to prevent music from looping.
Can I import MIDI music as a sound effect and use the options from that to prevent it from looping?
I ask this, as for textboxes and special events, I'd like to use a MIDI file sometimes. I would also like at time, during specific events in the map to have a song play once then revert back to the ambient music.
eg: On the map, your character walks near a traveling bard, while in the area, the music will change to bard music. Once it finishes, it will revert back to the ambient music. _________________ Current project: Chronoboy Adventures
Website: http://www.chronoboy.com/ |
|
Back to top |
|
 |
Pepsi Ranger Reality TV Host

Joined: 05 Feb 2003 Posts: 493 Location: South Florida
|
Posted: Mon Nov 22, 2010 9:00 pm Post subject: |
|
|
You'll probably want to use a timer for this, but be aware that it'll only be mildly accurate, and quite inaccurate during battles and menus.
In The Adventures of Powerstick Man: Extended Edition (which I'm highly considering releasing a second limited-time preview copy of to kick off HotOHR if I can clean it up enough by the weekend), I use four songs in the opening map that trail into each other. The songs play during battles, menus, and victory music, but the timers that switch them pause during menus and do not trigger the expiration scripts until after battles are finished. So, what you have is four songs that almost always "stream" correctly if you don't activate battles and menus, but sometimes restart for a few seconds before playing the next one if you do.
EDIT: For your reference, 18 ticks generally equal one second, so if you choose this method, you'll want to see how long your song is, and then set your timer for (timer,song length in seconds,18 ticks,script trigger).
Short answer: Until TMC implements script multitasking and James implements battlescripting (or maybe just until TMC implements script multitasking), you're probably not going to achieve the effect you're looking for. And even when these things are implemented, true music synchronization won't be. Fortunately, TMC gave me a precision timing script that I posted somewhere either on this board, the Slime Salad board, or Hamsterspeak that achieves these "truer" type timers that make scripts like the one you're attempting (or want to attempt) a little closer to your vision. But they can never be perfect. The only thing you can do to make them perfect is to splice your songs into one mega file, and select that as your "play song."
Note: I believe there's a bitset that allows you to run timers during menus, so you're biggest obstacle may apply only to battles.
Also, in reference to your bard issue, TMC's new Zones feature is very helpful for proximity scripts. I'll be writing a feature for Hamsterspeak about this as soon as he implements a few more functions to it. But the short version is that you can lay out your zones in the editor, and then use "read zone (zone,x,y)" in plotscript to determine whether your hero or npc is within the "trigger" area. I recently used this on my bridges to make footfall sound effects, and it works great. If you haven't used zones yet, you'll want to. These are way better than my old hackneyed method of grid-scripting, which essentially inspired TMC to make zones, as grid-scripting is quite limited and kinda sucks. _________________ Progress Report:
The Adventures of Powerstick Man: Extended Edition
Currently Updating: General sweep of the game world and dialogue boxes. Adding extended maps.
Tightfloss Maiden
Currently Updating: Chapter 2 |
|
Back to top |
|
 |
JSH357

Joined: 02 Feb 2003 Posts: 1705
|
Posted: Mon Nov 22, 2010 9:08 pm Post subject: |
|
|
Yeah, calclulating ticks is seriously annoying work, but it's somewhat fool proofs.
Here's another idea: Upload the song as a sound effect and use
Code: | sound is playing (num)
Checks to see whether a sound effect is playing or not. Useful for synchronization, etc.
|
This is actually the ideal method, but if the song is very large you might be concerned about filesize. |
|
Back to top |
|
 |
chronoboy Into the past with a splash

Joined: 04 Jun 2010 Posts: 162 Location: Canada
|
Posted: Mon Nov 22, 2010 9:10 pm Post subject: |
|
|
I've been hearing about zone from TMC as well, it definitely sounds like a major game changer. I can already see many uses to this.
Can you attach a Zone to a walking NPC perhaps? The NPC can be pinned to a X,Y cord on the zone, and the zones follows the NPC around. Having the zone also take note of the NPCs direction would also be a great feature. Not sure if there are plans for this yet, but it will make creating sneak scenes much much easier, considering you can actually have the guards mobile.
I just wish you could attach scripts to NPCs in a way they run each time the NPC takes a step(similar to how the map steps works, but for NPCs), now that would be a feature to die for(well not die for...) _________________ Current project: Chronoboy Adventures
Website: http://www.chronoboy.com/ |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue Nov 23, 2010 8:11 am Post subject: |
|
|
Yes, using sound effects if possible is the best solution.
Don't use ticks to accurately time things. Use 'milliseconds' instead. Using this, it should be possible to accurately synchronise things to music, unless your system is under very high load.
I would love to add a loop count feature to music, but sdl_mixer, the eternal thorn in my side, doesn't support it. Also, it decompresses sound effects completely before playing them, which is why we have a size limit on sound effects (or you'd easily have hundreds of MB of memory usage, and long pauses when playing).
The "zone pinned to NPC" idea is far too specific to be a builtin feature. That should be done using a timer/loop. You can subtract the hero and npc positions and query the difference in a zone if you really want to.
Quote: | Bob the Hamster: Regarding the idea of an NPC each-step script, the only reason I did not implement that at the same time as the hero each-step script was back then performance was *much* worse, and i didn't think it could happen at a sane speed. There has been a lot of interpreter cleanup since then, so I think it is sensible now.
Although rather than an each-step script it might make more sense to have a new sort of trigger, and "NPC AI script" which is run once for each NPC on every cycle in which it isn't already running (which means that each NPC instance needs to keep track of whether or not its own script has terminated). |
('Talk:Plan for script multitasking')
I think I agree that we should add AI scripts and not on-step scripts. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
chronoboy Into the past with a splash

Joined: 04 Jun 2010 Posts: 162 Location: Canada
|
Posted: Tue Nov 23, 2010 11:31 am Post subject: |
|
|
The Mad Cacti wrote: |
I think I agree that we should add AI scripts and not on-step scripts. |
I agree as well, I have been waiting for some sort of Move Type customizer. In my current game, I am using all sorts of workarounds to achieve NPC schedules in the game. It works, but it would have been much easier(and quicker) to have built AI scripts for them.
plotscript, blacksmith, begin
...
end
As an example, would would make the NPC move from each object related to his/her job, in this case a simple blacksmith. I could even add a nice ting sound effect. _________________ Current project: Chronoboy Adventures
Website: http://www.chronoboy.com/ |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|