Freeze sound

mersox

Active member
Hi guys! Is there a default way to add a sound effect when a characer is frozen? The freeze effect and its color map work fine, I just want to add a sound effect. I have tried with some didhitscripts but they don't work (the program exits abruptly once it loads the stage where the character with said didhitcript is)

This is the first didhitscript I tried:

void main()
{
    void self = getlocalvar("self"); //Get calling entity.
  //void opponent = getentityproperty(self, "opponent");
  void opponent = getlocalvar("damagetaker");
int iSnd = loadsample("data/sounds/(tmnt2/break01.wav");

int anim = getentityproperty(self, "animationid");

    if((anim == openborconstant("ANI_ATTACK3")) && (frame < 15)){

playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 120, 0);

    }

else {

playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 0, 0);

    }

  }

And my second attempt:

void main(){
    void self = getlocalvar("self");
    void anim = getentityproperty(self,"animationID");
   
    int iSnd = loadsample("data/sounds/(tmnt2/break01.wav");

    if(anim == openborconstant("ANI_ATTACK3")){
     

      if(frame <= 15){
        playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 120, 0);
      }
    }
}

Any ideas?
 
mersox said:
Hi guys! Is there a default way to add a sound effect when a characer is frozen? The freeze effect and its color map work fine, I just want to add a sound effect. I have tried with some didhitscripts but they don't work (the program exits abruptly once it loads the stage where the character with said didhitcript is)

This is the first didhitscript I tried:

void main()
{
    void self = getlocalvar("self"); //Get calling entity.
  //void opponent = getentityproperty(self, "opponent");
  void opponent = getlocalvar("damagetaker");
int iSnd = loadsample("data/sounds/(tmnt2/break01.wav");

int anim = getentityproperty(self, "animationid");

    if((anim == openborconstant("ANI_ATTACK3")) && (frame < 15)){

playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 120, 0);

    }

else {

playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 0, 0);

    }

  }

And my second attempt:

void main(){
    void self = getlocalvar("self");
    void anim = getentityproperty(self,"animationID");
   
    int iSnd = loadsample("data/sounds/(tmnt2/break01.wav");

    if(anim == openborconstant("ANI_ATTACK3")){
     

      if(frame <= 15){
        playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 120, 0);
      }
    }
}

Any ideas?

Hi mersox!!
Where you declare frame? Do you use animpos maybe?
 
Thank you, White Dragon. I'm not sure I understand the question. I didn't use animpos.

I linked the didhitscript to the following character (red parts are the ones relevant to this case):

name tokka_boss
health 80
speed 7
aggression -100

type enemy
shadow 1
aironly 1
cantgrab 1
remove 0
noquake 1
falldie 0
subject_to_screen 1
nolife 1
bounce 0
jumpheight 3
nodrop 2
escapehits 1


nopain 1

lifebarstatus 68 3 1 1 0 0 0 0 -500
nameposition 80 64
iconposition 132 64
lifeposition 133 65

icon data/chars/tokka/icon_boss.png

score 1 -1

didhitscript data/scripts/didhitscript_freeze.c

takedamagescript data/scripts/takedamage_blink_no_voice.c

animationscript data/scripts/script.c

remap data/chars/tokka/idle.png data/chars/tokka/idlered.png



anim spawn
loop 0
offset 35 72


delay 2
move 2
frame data/chars/tokka/idle.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/idle.png


frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk01.png


frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk02.png



anim idle


loop 0
offset 35 72
bbox 25 18 28 56
delay 1
frame data/chars/tokka/idle.png




anim walk
loop 1
offset 35 72
bbox 25 18 28 56
delay 15
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/idle.png




anim pain
loop 0
offset 35 72
delay 4
sound    data/sounds/(tmnt2/hit02.wav

data/chars/tokka/pain.png
frame data/chars/tokka/painred.png
frame data/chars/tokka/pain.png
frame data/chars/tokka/painred.png
frame data/chars/tokka/pain.png
frame data/chars/tokka/painred.png


anim death
loop 0
offset 35 72
delay 1
frame data/chars/tokka/dead.png

anim fall
@script
void self = getlocalvar("self");
int Enemy = openborvariant("count_enemies");

if(frame == 0 && Enemy == 1) {
playmusic("data/music/silence.bor", 1);

    }
@end_script

sound    data/sounds/(tmnt2/death.wav
loop 0
offset 35 72
delay 20
frame data/chars/tokka/dead.png


anim attack1 **jumpattack


range 50 300
loop 0
offset 35 72
jumpframe 6 3 3
landframe 7
bbox 25 18 28 56
delay 14

frame data/chars/tokka/crouch.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/crouch.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/crouch.png
frame data/chars/tokka/idle.png

delay 300
attack 42 27 24 33 5 1 0 1
frame data/chars/tokka/jumpattack.png
delay 1
frame data/chars/tokka/crouch.png



anim attack2 **punch combo


range 0 40
fastattack 1
loop 0
offset 35 72
bbox 25 18 28 56

delay 7

frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/idle.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/walk02.png
frame data/chars/tokka/walk01.png
frame data/chars/tokka/idle.png

delay 8

frame data/chars/tokka/punch01.png
attack 35 29 38 14 1 0 0 1
sound    data/sounds/(tmnt2/fwoosh01.wav
frame data/chars/tokka/punch02.png
attack 0 0 0 0 0
frame data/chars/tokka/punch01.png
attack 35 29 38 14 1 0 0 1
sound    data/sounds/(tmnt2/fwoosh01.wav
frame data/chars/tokka/punch02.png
attack 0 0 0 0 0
frame data/chars/tokka/punch01.png
attack 35 29 38 14 1 0 0 1
sound    data/sounds/(tmnt2/fwoosh01.wav
frame data/chars/tokka/punch02.png
attack 0 0 0 0 0
frame data/chars/tokka/punch01.png
attack 38 12 28 38 2 1 0 1
sound    data/sounds/(tmnt2/fwoosh01.wav
delay 20
frame data/chars/tokka/uppercut.png


anim attack3 **shield


range 0 80
rangea 10 100
loop 0
offset 35 72
bbox 35 72 1 1
fastattack 1
delay 5
freeze 44 15 18 14 0 2 0 1 0 2

frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png
frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png
frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png
frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png
frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png
frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png
frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png
frame data/chars/tokka/shield.png
frame data/chars/tokka/shieldblue.png

delay 8
bbox 25 18 28 56
freeze 0 0 0 0 0
frame data/chars/tokka/punch01.png
attack 38 5 38 48 5 1 0 1
sound    data/sounds/(tmnt2/fwoosh01.wav
delay 30
frame data/chars/tokka/uppercut.png
 
animpos is for calling frame.

Code:
    void vAniPos = getentityproperty(vSelf, "animpos"); //Get current animation frame

Here's an example with using animpos. Yes, I copied Goliath's duck script and modified for mine. Right now, I'm not using this kind anymore but to show you how animpos is used similar to frame but you need to call out that animpos function if you wanna do for frame (so it's kinda different):

Code:
if(vAniID == openborconstant("ANI_FOLLOW7"))
	{ // Duck2 anim?
		if(iDownR)
		{ // Down key relesed?
			//changeentityproperty(vSelf, "animation", openborconstant("ANI_IDLE"));
			changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW6"));
			// Change to IDLE anim
			//changeentityproperty(vSelf, "velocity", 0, 0, 0);
			// Set velocity
			//changeentityproperty(vSelf, "aiflag", "idling", 1);
			changeentityproperty(vSelf, "aiflag", "idling", 0);
			// Change to idle status
		}
		else if (vAniPos == 2 || vAniPos == 3 || vAniPos == 4 || vAniPos == 5)
		{ // Select frames
			if(iAttack)
			{ // Attack key press
				changeentityproperty(vSelf, "animation", openborconstant("ANI_DUCKATTACK"));
				// Change to Duckattack anim
			}
			else if(iAttack)
			{ // Attack key press
				changeentityproperty(vSelf, "animation", openborconstant("ANI_DUCKATTACK"));
				// Change to Duckattack anim
			}
		}
	}
 
I noticed that you want to play a sound just if ( frame <= 15 )
but you can get a frame into 2 ways:
1) getlocalvar("frame") *only* if your are in an animationscript event
2) getentityproperty(self,"animpos") in any avent

in your script I see  the selection:
if ( frame <= 15 )

but I dont see a declaration of frame variable.
So first you need to declare it:
int frame = getentityproperty(self,"animpos");
 
White Dragon said:
I noticed that you want to play a sound just if ( frame <= 15 )
but you can get a frame into 2 ways:
1) getlocalvar("frame") *only* if your are in an animationscript event
2) getentityproperty(self,"animpos") in any avent

in your script I see  the selection:
if ( frame <= 15 )

but I dont see a declaration of frame variable.
So first you need to declare it:
int frame = getentityproperty(self,"animpos");

Thank you, White Dragon! It worked!

Also thanks maxman for explaining what is animpos.
 
Back
Top Bottom