Jump to content

Photo

[Request] Change Enhanced Music Track Script and Play SFX when Walking


  • Please log in to reply
23 replies to this topic

#1 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Pronouns:He / Him

Posted 20 January 2012 - 05:05 PM

I was wondering if it is possible to change the track from enhanced music in zelda classic with scripting. What I need is for it to change the track when enemies are on the screen and change it back when they are all defeated. In the gbs files, I have about 40-50 tracks, and I have to make a new dmap each time I want the music to change.

Also, I need a script that plays the walking in water sfx when link walks in shallow water.

Thanks!,
~Sepulcher

EDIT: I realized that the title was a bit too long and it cut off the "in Shallow Water" part.

Edited by Sepulcher, 20 January 2012 - 05:08 PM.


#2 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 20 January 2012 - 06:42 PM

For request #2 (untested):
See below for fixed script

If you don't know how to combine global scripts, put the const int line near the top, and the parts from int splashTimer from splashTimer++ inside your while(true) loop.

Edited by MoscowModder, 25 January 2012 - 05:24 PM.


#3 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Pronouns:He / Him

Posted 20 January 2012 - 07:08 PM

Shouldn't this have something to check if link is on CT_SHALLOWWATER and if he's walking? It doesn't look like it checks for those two. I'll test it though.

#4 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 20 January 2012 - 07:36 PM

OMG MEGA FAIL. I meant to include that. I forgot. Sorry. Fixing Fixed.
Try that ^^

Edited by MoscowModder, 20 January 2012 - 07:39 PM.


#5 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Pronouns:He / Him

Posted 25 January 2012 - 05:14 PM

It compiles, but doesn't work. Also, make sure that it only plays the sfx when you are walking. If you already have that part added in there, sorry. I'm just used to seeing Link->Action=LA_WALKING and Link->Action!=LA_WALKING.

#6 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 25 January 2012 - 05:23 PM

Man, I've seriously been embarrassing myself in my latest scripting attempts.

Okay. This one is tested and worked in my test quest.
As soon as Link gets into the water, the splash sound plays, and then repeats every 10 (configurable) frames. When Link stops walking or leaves the water, the timer resets so it plays again when he next moves.

After I wrack my brain for possible improvements I might even submit this to the DB.

CODE
import "std.zh"

const int splashFreq = 10; //Number of frames between splash SFX

global script waterSplash{
    void run(){
        int splashTimer = splashFreq;
        while(true){
            if( Screen->ComboT[ComboAt(Link->X+7,Link->Y+15)] == CT_SHALLOWWATER
            && Link->Action==LA_WALKING
            ){
                if( splashTimer >= splashFreq ){
                    Game->PlaySound(SFX_SPLASH);
                    splashTimer = 0;
                }
                splashTimer++;
            }
            else splashTimer = splashFreq;
            Waitframe();
        }
    }
}


By the way, the last version checked if Link's position changed to run the sound effect, as I wasn't thinking of Link->Action at the time.

Edited by MoscowModder, 25 January 2012 - 06:23 PM.


#7 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 25 January 2012 - 05:28 PM

icon_smile.gif

Hi icon_smile.gif

Do you Sepulcher or MoscowModder mind if i also use this script?

Edited by judasrising, 25 January 2012 - 05:28 PM.


#8 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 25 January 2012 - 05:31 PM

I don't mind at all.

#9 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 25 January 2012 - 05:32 PM

QUOTE(MoscowModder @ Jan 26 2012, 01:31 AM) View Post

I don't mind at all.


Thank you.

And Sepulcher what do you say?


#10 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Pronouns:He / Him

Posted 25 January 2012 - 05:41 PM

Fine with me! icon_smile.gif I mean, it is MoscowModder's code icon_wink.gif

#11 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 25 January 2012 - 05:42 PM

QUOTE(Sepulcher @ Jan 26 2012, 01:41 AM) View Post

Fine with me! icon_smile.gif I mean, it is MoscowModder's code icon_wink.gif


Thank you

It was your idea icon_thumbsup.gif


#12 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Pronouns:He / Him

Posted 25 January 2012 - 05:52 PM

ugh, it's still not working. it's not playing the sfx. >__<

Edit: Can I send you the qst file?

Edited by Sepulcher, 25 January 2012 - 05:53 PM.


#13 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 25 January 2012 - 06:24 PM

Minor update: now checks for water in the middle of Link's feet instead of the middle of his left side. Also, I submitted it to the Script Database.

Concerning your first request - given ZC's very rudimentary support for Enhanced Music, I'm going to guess that it's not possible. It would be possible with MIDIs, though.

Edited by MoscowModder, 25 January 2012 - 06:24 PM.


#14 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 28 January 2012 - 01:15 AM

Could that be modified to work with Tall Grass (Continuous) as well as shallow water?

#15 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 28 January 2012 - 01:42 AM

Yup, and only one line need to be changed.

CODE
import "std.zh"

const int splashFreq = 10; //Number of frames between splash SFX

global script waterSplash{
    void run(){
        int splashTimer = splashFreq;
        while(true){
            if( Screen->ComboT[ComboAt(Link->X+7,Link->Y+15)] == CT_TALLGRASS
            && Link->Action==LA_WALKING
            ){
                if( splashTimer >= splashFreq ){
                    Game->PlaySound(SFX_SPLASH);
                    splashTimer = 0;
                }
                splashTimer++;
            }
            else splashTimer = splashFreq;
            Waitframe();
        }
    }
}


There ya go, basically the same script, only it'll play an sfx for tall grass instead of shallow water now.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users