Item touch sound

Viper Snake

Member
What is a good way to have an item play a sound when it is picked up by having a player touch it? I thought diesound might work for this but it does not.
 
its automated right now

data/sounds/get.wav

    ~Played when a player picks up an item.


data/sounds/money.wav

    ~Played when a player grabs a score item.
 
Thanks, but I really need it to be item specific. I'm making a castlevania style game and can't have small hearts, big hearts, wall meat, money bags, etc using the same pickup sound.
 
O Ilusionista said:
have you tried to override the get.wav with a blank sound and call a custom .wav on the death anim?

Yeah, but it doesn't play the death anim when touched, it just disappears instantly.

Code:
name	Heart
mp	2
type	item
subtype	touch
shadow	0
candamage player
cantgrab
falldie 1
palette	data/chars/items/heart.png


anim	death
	loop	0
	delay	1
	sound	data/sounds/heart.wav
	frame	data/chars/marianne/blank.png
		
anim	idle
	loop	1
	delay	5
	offset	8 14
	bbox	0 0 16 14
	frame	data/chars/items/heart.png
 
items dont use death anims when you grab them, i wanted to use that when collecting stuff in my mod so i could have smooth animations of disappearing items, i used attack in item idle animation and follow animation, i dont remember exactly, it worked but i couldnt collect many items close to each other, there had to be some amount of time between each collecting of single item, you took them too fast and second one was still there etc.
 
I use didhitscript to play sounds on pickup, 

Code:
void main()
{
  int iSnd = loadsample("data/sounds/itemup.wav");
  
  playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 120, 0); //itemup sfx
}

For the item entity,

Remove subtype touch from entity header, now replace BBOX for ITEMBOX, add didhitscript to char header.

didhitscript data/scripts/dhit/nameofscript.c
 
I agree with Beastie about using didhitscript + using silent SFX for get.wav to disable default SFX.

For efficiency, you could check item's name in didhitscript and change played SFX based on that name.
 
Good idea BB, this is just part of my didhit script for weapon and ammo pickups, the script also sets player weapon, ammo etc. so they are all individual scripts at the moment.

If using this trick remember if the item adds score it will also play money.wav along with the scripted sfx.
 
Hey guys, I am trying to make this but without success.
I already set a didhit and removed the subtype and changed the bbox to itembox, but the engine plays both 1up.wav and my sound.

name      avid
type      item
nolife      1
facing 1
gfxshadow 1
didhitscript    data/scripts/didhit/summon.c

anim idle
loop 1
delay 6
itembox 0 0 36 36
offset 20 46
frame data/chars/misc/logoavrn1b.png
offset 20 48
frame data/chars/misc/logoavrn1.png
offset 20 50
frame data/chars/misc/logoavrn1.png
offset 20 52
frame data/chars/misc/logoavrn1.png
offset 20 50
frame data/chars/misc/logoavrn1.png
offset 20 48
frame data/chars/misc/logoavrn1.png
offset 20 46
frame data/chars/misc/logoavrn1.png
offset 20 44
frame data/chars/misc/logoavrn1.png
offset 20 46
frame data/chars/misc/logoavrn1.png
offset 20 48
frame data/chars/misc/logoavrn1.png
offset 20 50
frame data/chars/misc/logoavrn1.png
offset 20 52
frame data/chars/misc/logoavrn1.png
offset 20 50
frame data/chars/misc/logoavrn1.png
offset 20 48
frame data/chars/misc/logoavrn1.png
offset 20 46
frame data/chars/misc/logoavrn1.png
offset 20 44
frame data/chars/misc/logoavrn1.png

My didhitscript:
Code:
void main()
{
   setglobalvar("HelperControl", 1);
   int SFX1 = loadsample("data/sounds/announcer/avengers-assemble.wav");
   playsample(SFX1, 0, 120, 120, 100, 0);
}

What I am doing wrong?
 
Back
Top Bottom