Jump to content

Photo

SFX triggering when each combo activates

SFX combo

  • Please log in to reply
7 replies to this topic

#1 Taco Chopper

Taco Chopper

    protector of the darn forum

  • Administrators
  • Pronouns:He / Him
  • Location:South Australia

Posted 05 May 2022 - 10:28 PM

Trying to set up a screen where each flame combo in the below screen makes a noise after the player triggers the whistle flag. I currently have each flame staggering behind the previous one, starting with the bottom left torch and ending with the centre one.

 

Currently I have it set up to use a bunch of secret flags; I assume this would be much easier with FFCs. Here's what I've got at the moment:

 

I did try implementing a combo script to play it upon being triggered but I have a feeling I've not done this right either:

int firesfx = 40;

combodata script torchlight{
	void run() {
		Game->PlaySound(firesfx);
		}
}

also if anyone has suggestions for a good whistle animation script please let me know, I tried using one Joe123 made in 2008 but I was getting function errors when compiling lol


Edited by Taco Chopper, 05 May 2022 - 10:30 PM.


#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 05 May 2022 - 11:07 PM

That script looks right, though there's one change I'd recommend.

int firesfx = 40;

This is a global variable, but since it doesn't ever need to change it should probably be a constant (const int) instead. Typically those are written in all caps, so something like SFX_FIRE. Oh hey, just so happens that one's already declared in std.zh as the default fire sound. If you're using a different one, you could call it SFX_TORCHFIRE or something similar.

 

As for whistle animations, try this:

const int TIL_WHISTLEANIM = 0; //First tile of the whistle animation
const int FRAMES_WHISTLEANIM = 4; //Number of animation frames in the animation
const int ASPEED_WHISTLEANIM = 8; //Speed of the animation

const int WHISTLEANIM_DURATION = 128; //If >0, the above animation will loop for this many frames

//D0: The SFX to play for the whistle. (Set the item's actual SFX to 0 to prevent screen freezing)
itemdata script WhistleAnimation{
	void run(int sfx){
		Game->PlaySound(sfx);
		if(WHISTLEANIM_DURATION){
			int t;
			int frame;
			for(int i=0; i<WHISTLEANIM_DURATION; ++i){
				Link->ScriptTile = TIL_WHISTLEANIM+frame;
				++t;
				if(t>=ASPEED_WHISTLEANIM){
					t = 0;
					frame = (frame+1)%FRAMES_WHISTLEANIM;
				}
				Link->Action = LA_NONE;
				Link->Action = LA_ATTACKING;
				Waitframe();
			}
		}
		else{
			for(int i=0; i<FRAMES_WHISTLEANIM; ++i){
				Link->ScriptTile = TIL_WHISTLEANIM+i;
				for(int j=0; j<ASPEED_WHISTLEANIM; ++j){
					Link->Action = LA_NONE;
					Link->Action = LA_ATTACKING;
					Waitframe();
				}
			}
		}
		Link->Action = LA_NONE;
		Link->ScriptTile = -1;
	}
}

This script is a bit of a hack. You'll want to set your whistle's SFX to 0 and D0 on its item script tab to the whistle sound. This is because scripts can't actually run while the whistle sound is playing normally. It's just too powerful and had to be nerfed. You'll also need to have Item Scripts Continue To Run checked under ZScript->Quest Script Settings. This lets item scripts run for multiple frames.



#3 Taco Chopper

Taco Chopper

    protector of the darn forum

  • Administrators
  • Pronouns:He / Him
  • Location:South Australia

Posted 05 May 2022 - 11:28 PM

Not having much luck with the fire sfx script I'm afraid - even after updating the script like you pointed out. This isn't the first time I've had issues with combo scripts either though - was trying to implement a pot smash script the other day and it wasn't activating either. Is there anything I need to do aside from assigning the script to the combo?

 

I see what you mean with the whistle script, it's jank city and I love it. Is there a way to extend the time in the main script body? I thought setting FRAMES_WHISTLEANIM to 30 (all duplicated tiles) would do the trick, but it looks like it just cuts out after the first seven or eight frames:

 

zqmBAeu.gif

 

My other thought for the secret to be triggered by having FFC combos drawn in using scripting; mostly just using ->Data to change the combo data from a blank 1x2 to the flames. This room's also meant to be an elevator of sorts too. The flames would just be part of it; I'd have the bridge sprites close up, the bottom layer close up and then a screen quake effect for each change. Stuff I know I can script in, I just need to figure out how to get the first part working properly.


Edited by Taco Chopper, 05 May 2022 - 11:33 PM.


#4 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 06 May 2022 - 12:18 AM

Whistle animation thing is probably tied to WHISTLEANIM_DURATION. If it's 0, the animation length will be one full loop of the animation but otherwise the animation will loop for the duration of that time.

 

No idea what's going on with combo scripts. It seems exceptionally simple. You're placing the script on the lit torch combo so when it switches to that the sound plays I imagine? Are there any other combo scripts involved? There used to be issues with a combo switching to another combo ID that also has a script, but I thought those were all fixed...



#5 Taco Chopper

Taco Chopper

    protector of the darn forum

  • Administrators
  • Pronouns:He / Him
  • Location:South Australia

Posted 06 May 2022 - 12:25 AM

... hm. WHISTLEANIM_DURATION is set to 128. Set that to 0 and it's all good now. Thanks!

 

As for the combo scripts, I'm unsure. Depends on when those issues were fixed - I'm using the April 25th nightly. This is what I have set in the combo, I doubt I'd need to set anything for D0 or D1 because it's not requiring anything else, right?


edit: so i'm stupid and didn't have "combos run scripts on layer" in quest script settings turned on. for any of them. turns out turning it on does the job!
 


Edited by Taco Chopper, 06 May 2022 - 03:02 AM.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 15 May 2022 - 12:48 AM

I sincerely wish that I never added combo scripts: DarkDragon said to add them and I followed his direction. C'est la vie.



#7 Taco Chopper

Taco Chopper

    protector of the darn forum

  • Administrators
  • Pronouns:He / Him
  • Location:South Australia

Posted 23 August 2022 - 11:54 AM

bumping this to ask if there's any way that the new "whistle" animation script can be modified to pause gameplay while the animations and music are playing?

 

i love the fluidity of the animation, but there's a few drawbacks that come with it. secret combos trigger straight away, and there has to be zero enemy placement on the screen or else the player's a sitting duck.



#8 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 27 September 2022 - 09:50 AM

You could change an FFC to the "Freeze all Action" combotype (or whatever it's called) for the duration of the whistle animation.  If you're using any Tango stuff from CC/PoRC (not sure if you are) then I think FFC's 31/32 are already reserved for doing that so you could take a look at that to see how it works.
 
 
Link->Action = LA_NONE;
Link->Action = LA_ATTACKING;
 
Moosh, is this to disable the shield as long as you keep running these lines?



Also tagged with one or more of these keywords: SFX, combo

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users