Jump to content

Photo

Scripting help


  • Please log in to reply
5 replies to this topic

#1 Rocksfan13

Rocksfan13

    Looks best in Blue

  • Members
  • Real Name:Doug
  • Location:Earth

Posted 17 September 2018 - 02:41 PM

Hey all. I recently came across a script that assigns a sound affect to any combo I give it to.

However, I am really looking to give it to my pots and skulls. I currently have those set as a flower combo so it shows the pieces "breaking".

 

The problem I have is with the extra sounds rule turned on, all bushes, grass, and flowers get the default Tall Grass SFX.

And with the FFC assigned to them it also plays what I tell the FFC to play.

 

So it plays both.

 

My question is, is there anyway to tweak this script to cancel out the Default sound effect?

I do not want the rule off as it works fine for all of the bushes and grass combos.

 

Here's what I got:

// Script that will check the combo under it
// When the combo changes (be it script, slash->next, etc.)
// It will play the given sfx
// d1 = Sound effect

import "std.zh"

ffc script PotRandomItem
{
    void run(int itm, int sfx)
    {
        // Grab the combo under the FFC initially
        int combo = Screen->ComboD[ComboAt(this->X+4, this->Y+4)];

        // While that combo is the same, wait
        while(Screen->ComboD[ComboAt(this->X+4, this->Y+4)] == combo)
            Waitframe();

        // Play the given sound effect
        Game->PlaySound(sfx);
    }
}


#2 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 17 September 2018 - 02:46 PM

In current released versions, you would need to turn off the rule I believe. I can't think of a way to stop that from playing.

#3 Architect Abdiel

Architect Abdiel

    Kingdom Builder

  • Members
  • Real Name:Michael
  • Location:Florida

Posted 17 September 2018 - 03:10 PM

I haven't really worked with sound effects, but maybe you could get a blank sfx to load into the tall grass chipped sfx.

#4 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 17 September 2018 - 03:22 PM

Another option would be to change the combo type to Slash (Item) and make the breaking animation part of the script. I've done that myself; I could add it into that script pretty easily.

In fact, I've already done it. Here:
// Script that will check the combo under it
// When the combo changes (be it script, slash->next, etc.)
// It will play the given sfx
// d1 = Sound effect
// d2 = Smash animation sprite

import "std.zh"

ffc script PotRandomItem
{
    void run(int itm, int sfx, int sprite)
    {
        // Grab the combo under the FFC initially
        int combo = Screen->ComboD[ComboAt(this->X+4, this->Y+4)];

        // While that combo is the same, wait
        while(Screen->ComboD[ComboAt(this->X+4, this->Y+4)] == combo)
            Waitframe();

        // Play the given sound effect
        Game->PlaySound(sfx);
        
        if(sprite>0)
        {
            lweapon graphic=Screen->CreateLWeapon(LW_SCRIPT10);
            graphic->CollDetection=false;
            graphic->UseSprite(sprite);
            graphic->X=this->X-8;
            graphic->Y=this->Y-8;
            graphic->Extend=3;
            graphic->TileWidth=2;
            graphic->TileHeight=2;
            graphic->DeadState=graphic->NumFrames*Max(graphic->ASpeed, 1);
        }
    }
}
These are the tiles I'm using:
BrokenPot.png

That's 8 frames. A speed of 4 matches LttP.

#5 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 17 September 2018 - 06:47 PM

If you want to use a lot of custom slashables on one screen, you might want to use this script I made:

https://www.purezc.n...=scripts&id=287

 

Instead of having one FFC per slashable object on the screen, it uses one FFC per unique slashable combo ID on the screen.

s287s1.png

So a screen like this would use four FFCs instead of...36? (impossible)


Edited by Moosh, 17 September 2018 - 06:47 PM.


#6 Rocksfan13

Rocksfan13

    Looks best in Blue

  • Members
  • Real Name:Doug
  • Location:Earth

Posted 18 September 2018 - 07:52 AM

Thank you guys.

 

I find Saffith's script to fit my needs better here moosh, but yours is excellent as well.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users