Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/20/24 06:09
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, Edgar_Herrera), 695 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Music ends #458546
03/19/16 07:45
03/19/16 07:45
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline 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:

Code:
...

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 Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I notice that when I put this code:

Code:
...

snd_stop ( songHandle);

songHandle = snd_loop(sndWizMusic, 100, 0);

...



before this code:

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 Offline
User
EpsiloN  Offline
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 laugh

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.

Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Music ends [Re: EpsiloN] #458691
03/25/16 10:56
03/25/16 10:56
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
What I find confusing about your code is that it happens all in a while loop; I would move some of it to a new function and call that instead (with an if() before it ofcourse) to make the code cleaner and to see the bugs faster.

Also this action is named wizardEnemy_action yet you describe it is about the player, is wizardEnemy_action a spelling/c&p mistake or does the player get moved by the enemy? (if so, than that sounds confusing too)

Re: Music ends [Re: EpsiloN] #458729
03/27/16 07:48
03/27/16 07:48
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: EpsiloN
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 laugh

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.
Re: Music ends [Re: Ruben] #458734
03/28/16 11:57
03/28/16 11:57
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
To eliminate the possibility that the song is trying to start over and over again, set the new handle to the song and play it only if the new handle is NULL. Otherwise, don't play anything.
After it stops, I cant remember if the handle becomes NULL by itself, or you have to set it somehow to NULL by hand.

This will play the full song over and over if its that sort of bug, not just the beginning...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1