Jump to content

Photo

Music.zh

header music enhanced boss enemy

  • Please log in to reply
17 replies to this topic

#1 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 July 2017 - 06:32 AM

Foreward
Music.zh is a header for ZScript that contains functiosn for the handling of audio, and music files. In particular, it has ffcs and functions for the use of boss music, special enemy music, and similar, using MIDI files, enhanced music files, or both.
 
Here is an updated version of Music.zh, v1.3.1 (mirror on Pastebin), that fixes a minor bug, and a demo quest that demonstrates how to use the enhanced music ffc for bosses, with included NSFs as a ZIP file.

This version also adds some additional, (unproven) ffc scripts, and cleans up some functions. If you were using an older version, the return type on the function PlayEnhMusicFile(int filename_message, int trk) has changed from float, to bool, but I added a legacy conversion function for such cases. The function itself works slightly differently, though, so you may need to check that scripts using it still work as you intend them to work.

 

As of v1.3.1, Music.zh includes a global function ( WandSound(int sfx) ) and a demo global active script that allows you to assign a sound to the wand, for slashing, or stabbing, that will play even if the magic projectile does not fire; and this sound is separate from the firing sound.
 

The demo quest features most components of this header, including the following:

 

 

  • ffc script playMIDI : Plays an arbitrary MIDI on a given screen.
  • ffc script NPC_MIDI : Plays a MIDI while an enemy with a specific ID is on-screen
  • ffc script NPC_Music: Plays an enhanced music file, while an enemy with a specific ID is on-screen.
  • ffc script BossMusic : Set up MIDIS for a boss theme, victory jingle, and post-boss-death music.
  • ffc script BossMusicEnhanced_InternalStrings : Use Message Strings to supply the filenames, for boss music with many configuration options.
  • ffc script music_zh_spawnnpc : Spawns an arbirary NPC on collision with the ffc, at the screen coordinates of flag 37 (NPC ID 0).
  • global script Music_ZH_Global_Active : A demonstration of the WandSound(int sound) function.

 

I will continue working on it as time permits, and possibly create a demo for the rest of its features. For the moment, most of the requests that I have had have related to the enhanced boss music functions, so that is what you will find in the demo.
 
Feel free to submit functions for inclusion if you wish, or to make suggestions, if you feel that it is lacking.

 

One aspect of NPC_MIDI and NPC_Music is unproven: They are designed to restore enhanced music on a DMap that has it, when they npc dies; and this is untested. The behaviour is as follows:

                int enh_music[256] = {0}; 
		Game->GetDMapMusicFilename(Game->GetCurDMap(), enh_music);
		
		int enh_trk = Game->GetDMapMusicTrack(Game->GetCurDMap());
		for ( q[0] = 0; q[0] < 256; q[0]++ ) { if ( enh_music[q] == ' ' ) enh_music[q] = 0; } //kill the space. 
		bool enhanced =  ( enh_music[0] != 0 ); //is the dmap music enhanced?

 
I will need to validate what happens here, but it should be correct.
 
This header requires string.zh for ZC v2.50.3RC1 and lower.


Edited by ZoriaRPG, 03 July 2017 - 11:38 AM.

  • Jenny likes this

#2 Alucard648

Alucard648

    Wizard

  • Members
  • Location:castle Dracula

Posted 03 July 2017 - 07:48 AM

404 Not found.



#3 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 03 July 2017 - 09:11 AM

Same trouble here
Also, can this affect the volume of the music? Be neat for a Ganon's Tower like thing

#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 July 2017 - 09:40 AM

404 Not found.

 

 

Same trouble here
Also, can this affect the volume of the music? Be neat for a Ganon's Tower like thing

 

Fixed above.

 

ZScript has no control over the volume in 2.50.x. I have considered adding controls for volume and other effects to Audio-> in 2.55/2.60, but I am leery about doing that, because I don;t want to empower certain people to make pranks that blast a user wearing headphones.

 

Edit, 3rd July, 2017 at 17:36GMT: I uploaded a ZIP package, and an updated header. The links in the top post are current with these files.


Edited by ZoriaRPG, 03 July 2017 - 11:39 AM.


#5 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 03 July 2017 - 10:09 AM

I have considered adding controls for volume and other effects to Audio-> in 2.55/2.60, but I am leery about doing that, because I don;t want to empower certain people to make pranks that blast a user wearing headphones.


Didn't think of that. Yeah, that would be a pretty bad idea - although if the volume doesn't affect sound effects, that could be solved.
Another thing I should ask (since I'm unable to check right now) is if more than one track (MIDI or enhanced) could be placed at once.

 

Edit: Just looking through the code now, for the ffc BossMusicEnhanced_InternalStrings (the one which plays enhanced music for bosses): what is the STRING number For the D3 and D4 arguments? Is that a string which is displayed when the code runs?


Edited by klop422, 03 July 2017 - 12:11 PM.


#6 Lüt

Lüt

    Germanize

  • Members
  • Real Name:Steve
  • Location:Chicago

Posted 03 July 2017 - 12:00 PM

ZScript has no control over the volume in 2.50.x. I have considered adding controls for volume and other effects to Audio-> in 2.55/2.60, but I am leery about doing that, because I don;t want to empower certain people to make pranks that blast a user wearing headphones.

Well, that's up to the individual, and a thing like that would be quickly marked as a troll quest.

And even now, it's possible to load a totally clipped-out .wav sound effect into the game, and further reduce the volumes of the other sound effects to ensure the user sets the volume high to compensate. And the same goes with music - anybody with the most basic MIDI editor can turn down the volumes of all the MIDI files except for one extremely loud one. The fact that nobody has done this yet (as far as I'm aware) is a good indicator that abuse of a feature like that would be very low, probably non-existent.

 

What's far more important (and what I was actually going to ask about eventually) is the ability to slightly lower the music volumes in overworld caves like LttP does. My method would have been a separate DMap with the same MIDI as the overworld to ensure the music doesn't restart upon entering/exiting the cave, then have an FFC volume adjustment to lower the music by about 25%. But perhaps music volume percentage could even be an entire DMap setting. It would certainly suit multi-room caves the best.


  • Avaro likes this

#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 July 2017 - 12:15 PM

Well, that's up to the individual, and a thing like that would be quickly marked as a troll quest.

And even now, it's possible to load a totally clipped-out .wav sound effect into the game, and further reduce the volumes of the other sound effects to ensure the user sets the volume high to compensate. And the same goes with music - anybody with the most basic MIDI editor can turn down the volumes of all the MIDI files except for one extremely loud one. The fact that nobody has done this yet (as far as I'm aware) is a good indicator that abuse of a feature like that would be very low, probably non-existent.

 

What's far more important (and what I was actually going to ask about eventually) is the ability to slightly lower the music volumes in overworld caves like LttP does. My method would have been a separate DMap with the same MIDI as the overworld to ensure the music doesn't restart upon entering/exiting the cave, then have an FFC volume adjustment to lower the music by about 25%. But perhaps music volume percentage could even be an entire DMap setting. It would certainly suit multi-room caves the best.

 

I will look into adding something to the Audio-> functions to do this, but it may be rejected by the senior developers.

 

If you want this feature, then I advise making a case for it over on AGN. Adding it is technically trivial, but there is a general disdain for adding any scripting feature that can affect UI settings in play here, that I do not want to argue over.

 

Doing this in a way other than globally affecting the volume, would be much harder, but also technically possible. I do resist mucking with anything related to 'enhanced music' until we shift out the old libs for newer libs, as I do not want to do it twice, or thrice.


Edited by ZoriaRPG, 03 July 2017 - 12:18 PM.


#8 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 03 July 2017 - 04:48 PM

Getting an error message - might be caused by something I did.

Just for reference, I've imported std.zh, string.zh, ffcscript.zh, and of course music.zh

Anyway, the error is as such:

 

PASS 4: TYPE-CHECKING/COMPLETING FUNCTION SYMBOL TABLES/CONSTANT FOLDING MUSIC.ZH, LINE 850: ERROR T21: COULD NOT MATCH TYPE SIGNATURE COLLISION(FFC)



#9 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 July 2017 - 06:36 PM

Getting an error message - might be caused by something I did.

Just for reference, I've imported std.zh, string.zh, ffcscript.zh, and of course music.zh

Anyway, the error is as such:

 

PASS 4: TYPE-CHECKING/COMPLETING FUNCTION SYMBOL TABLES/CONSTANT FOLDING MUSIC.ZH, LINE 850: ERROR T21: COULD NOT MATCH TYPE SIGNATURE COLLISION(FFC)

 

Ah, right. Change that to LinkCollision(this) . You can in fact, rip out that entire ffc script (npc spawn trigger) if you have no need for it.



#10 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 03 July 2017 - 06:40 PM

I see that this is more a compilation of usable scripts rather than a script library.



#11 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 July 2017 - 07:09 PM

I see that this is more a compilation of usable scripts rather than a script library.

 

Actually, that is functionally no different than ghost.zh, or other 'libraries'. I find it interesting that the use of 'library' in the ZScript world seems to denote that it is a header (with scripts); while in the programming world, the term is restricted to binary files.

 

It is, whatever it is. The intended application of Music.zh is to make it easier to implement musical cues.



#12 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 11 July 2017 - 11:14 AM

Is it possible to play music from a different .nsf file than what is currently being played? Would have asked earlier, but haven't been able to play around with ZQuest for about a week.



#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 11 July 2017 - 11:42 AM

Is it possible to play music from a different .nsf file than what is currently being played? Would have asked earlier, but haven't been able to play around with ZQuest for about a week.

 

Howzat?

 

I do not understand the context of your question. Do you mean: 'Is it able to change from an NSF set on a DMap, to another NSF?' ?

 

If so, then aye, that is intended to be a feature in the present header.


Edited by ZoriaRPG, 11 July 2017 - 11:43 AM.


#14 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 11 July 2017 - 12:05 PM

Is it possible to play music from a different .nsf file than what is currently being played? Would have asked earlier, but haven't been able to play around with ZQuest for about a week.

 

It's possible without this header even, it's a normal ZScript function.



#15 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 11 July 2017 - 12:39 PM

It's possible without this header even, it's a normal ZScript function.


Quite. One of the goals that I had in mind with functions in the header, is to revert to a DMap enhanced music file when an effect that plays an enhanced music file, ends. Thus, you can revert to the base DMap music when a boss dies. It ensures that entering an empty boss room does not play pointless, dramatic fight music.

That is why I say, it is an intended feature.

Edited by ZoriaRPG, 11 July 2017 - 12:41 PM.




Also tagged with one or more of these keywords: header, music, enhanced, boss, enemy

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users