4 registered members (ozgur, Ayumi, VHX, monarch),
1,161
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Music ends
#458546
03/19/16 07:45
03/19/16 07:45
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
I have a medieval soldier that is climbing spiral stairs in a tower. If the player gets up to a certain height (z level), the game takes control of the player, and moves it along a certain path up the stairs, and then rotates the player to view something that the game wants the player to view. When this happens, I am trying to make a different song play, so that the player knows something different is going on, and that it is not a bug. I have it so that the new song plays, however, after the player automatically moves to the new position, and finishes rotating to view whatever the game wanted it to view, the music abruptly stops after the rotation. This is the code I have for this so far:
...
wizardEnemy_action()
{
...
while(1)
{
...
c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS |
SCAN_FLAG2 | IGNORE_ME);
if (you) // player detected?
{
if((you.z >= 2397) && (you.z < 2500))
{
snd_stop ( songHandle);
songHandle = snd_loop(sndWizMusic, 100, 0);
// sndWizMusic loop starts playing.
ent_moveto(hero, vector(-179, 581, 2458), 5);
wait_for_my(ent_moveto);
ent_turnto(hero,vector(-59,0,0),5);
wait_for_my(ent_turnto);
// sndWizMusic loop stops here for some reason,
// after player's rotation is complete.
...
}
...
}
wait(1);
}
}
Does the ent_turnto function somehow make the sound stop playing? If so, is there a way around it?
Last edited by Ruben; 03/19/16 07:48.
|
|
|
Re: Music ends
[Re: Ruben]
#458547
03/19/16 10:09
03/19/16 10:09
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
I notice that when I put this code:
...
snd_stop ( songHandle);
songHandle = snd_loop(sndWizMusic, 100, 0);
...
before this code:
c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
The music starts before the player reaches z = 2397 , but the music lasts even after the player is automatically moved and rotated.
|
|
|
Re: Music ends
[Re: Ruben]
#458681
03/24/16 22:34
03/24/16 22:34
|
Joined: Jan 2006
Posts: 968
EpsiloN
User
|
User
Joined: Jan 2006
Posts: 968
|
Its hard to say what is causing this, because you're showing only a part of the action. The if conditions might become false after you move the player to his new position, and the whole function stops until you move and turn the player and then continues, possibly hitting some other snd stop instruction... This conclusion comes from the fact that moving snd_stop out of the if conditions plays the music before he reaches the desired height and after the turning took place... I hope this helps EDIT*: You could try renaming your snd handle to something else, for example eventMusicHandle, this way it wont be stopped, until it finishes, because no other snd_stop instruction with that handle exists...
Last edited by EpsiloN; 03/24/16 22:36.
|
|
|
Re: Music ends
[Re: EpsiloN]
#458729
03/27/16 07:48
03/27/16 07:48
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
Its hard to say what is causing this, because you're showing only a part of the action. The if conditions might become false after you move the player to his new position, and the whole function stops until you move and turn the player and then continues, possibly hitting some other snd stop instruction... This conclusion comes from the fact that moving snd_stop out of the if conditions plays the music before he reaches the desired height and after the turning took place... I hope this helps EDIT*: You could try renaming your snd handle to something else, for example eventMusicHandle, this way it wont be stopped, until it finishes, because no other snd_stop instruction with that handle exists... I tried your advice, and used a totally different song handle. Now, the song is lasting a little longer after the rotation is complete, but then it fizzles out, and I hear this little sound that seems to repeat really quickly, like maybe the beginning of the song trying to start once every quarter of a second.
Last edited by Ruben; 03/27/16 07:48.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|