Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Key Animation Cog Problems
Key Animation Cog Problems
2003-01-12, 7:19 PM #1
Ok.. I have this cog that animates a key, and plays a sound while it does it. when the level first loads, it looks and sounds great. But if the player dies and starts over, the key still works, but the sound doesn't play. I tried changing the "startup" to "newplayer", but then neither the sound or the key works.

# ANIMAET TEH THINGS WITH KEYS
# MAED BY G00Nb0Y
# SI NOT MAED BY LUCASARTS SO DIE
symbols

int sndchannel=-1 local
thing animthing
keyframe key
flex vol
sound sound
message startup
end

code
startup:
if (sndchannel!=-1) sndchannel=-1;
sndchannel=PlaySoundThing(sound, animthing, vol, -1, -1, 0x80);
PlayKey(animthing, key, 1, 0x14);
end



[This message has been edited by Spiral (edited January 12, 2003).]
||||||||||||||||||||
2003-01-12, 8:06 PM #2
Code:
# ANIMAET TEH THINGS WITH KEYS
# MAED BY G00Nb0Y
# SI NOT MAED BY LUCASARTS SO DIE
symbols

int          sndchannel = -1   local 
thing        animthing         local
keyframe     key               local 
flex         vol               local
sound        animsound         local
message      startup
message      newplayer
end 

code

startup:
newplayer:

if (sndchannel != -1) sndchannel = -1;
sndchannel = PlaySoundThing(animsound, animthing, vol, -1, -1, 0x80);
PlayKey(animthing, key, 1, 0x14);

end


[This message has been edited by Dormouse (edited January 12, 2003).]
Also, I can kill you with my brain.
2003-01-12, 8:13 PM #3
there is no change

[This message has been edited by Spiral (edited January 12, 2003).]
||||||||||||||||||||
2003-01-12, 11:47 PM #4
1) Newplayer only works in MP levels.
2) That sound isnt set to loop. Add 0x1 to the flags to make it loop.
And when the moment is right, I'm gonna fly a kite.
2003-01-13, 3:46 AM #5
Lack of return(); might cause a problem.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-01-13, 4:51 AM #6
It also helps if you only make 'sndchannel=-1' local.

Use Code Tags At least Dormouse did. Thanks. [http://forums.massassi.net/html/wink.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-01-13, 6:23 AM #7
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Emon:
Lack of return(); might cause a problem.</font>


It would, but not in this case. The cog will compile, and run. Because he is only using the one message, the return isnt mandatory, but its always good practice to put one in there anyway.
And when the moment is right, I'm gonna fly a kite.
2003-01-13, 8:44 AM #8
GBK, where should I put the "0x1" at?
||||||||||||||||||||
2003-01-13, 10:36 AM #9
the sound is not supposed to loop. It is supposed to play once, and it does, but it doesnt play at all when the level is restarted.
I'm just an old man with a skooma problem.
2003-01-13, 10:52 AM #10
Since when are COGs compiled?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-01-13, 11:03 AM #11
I think I found the problem. Notice the whitespace in the If statement. I also added a Return(); since I figured it might cause a problem, and it certantly won't break it.

Code:
# ANIMAET TEH THINGS WITH KEYS
# MAED BY G00Nb0Y
# SI NOT MAED BY LUCASARTS SO DIE
symbols

int			sndchannel = -1			local
thing			animthing
keyframe		key
flex			vol
sound			sound
message		startup

end


code

startup:

	If(sndchannel != -1) sndchannel = -1;
	sndchannel = PlaySoundThing(sound, animthing, vol, -1, -1, 0x80);
	PlayKey(animthing, key, 1, 0x14);
	Return();

end


You could also remove the If and just use:

Code:
	sndchannel = -1;


[Edit]Fear the enhanced TABs![/Edit]
[Edit]AIEEE!! THEY BACK FIRED!![/Edit]

[This message has been edited by Emon (edited January 13, 2003).]

[This message has been edited by Emon (edited January 13, 2003).]
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-01-13, 12:26 PM #12
return; even. [http://forums.massassi.net/html/tongue.gif]
-Hell Raiser
2003-01-13, 1:03 PM #13
Nice comments, Spiral. ;]

[This message has been edited by Grismath (edited January 13, 2003).]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2003-01-13, 3:51 PM #14
I thought it had () [http://forums.massassi.net/html/confused.gif]

Why is it called return if no value is being returned?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-01-13, 4:21 PM #15
I thout it was just return;
Ive moved over to JK2
2003-01-13, 6:10 PM #16
what comments were nice??
||||||||||||||||||||
2003-01-13, 6:14 PM #17
He means the comments in your code, which I think are actually Gunny's.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-01-13, 9:20 PM #18
Emon, i tried your cog, and nothing worked.. the 3do key didn't work, and the sound didn't even play the first time
||||||||||||||||||||
2003-01-13, 10:57 PM #19
*sigh*

Code:
# ANIMAET TEH THINGS WITH KEYS
# MAED BY G00Nb0Y
# SI NOT MAED BY LUCASARTS SO DIE
symbols

thing animthing
keyframe key
flex vol=1
sound sound
message startup

end


code

startup:
Sleep(0.5);
PlaySoundThing(sound, animthing, vol, 0, 20, 0x80);
PlayKey(animthing, key, 3, 0x14);
Return;
end


You are doing nothing with the sound, there is NO REASON WHATSOEVER to save the channel. Return; does NOT have (). And playing a sound at -1 for bolth min and max raidus is never a good idea.
And when the moment is right, I'm gonna fly a kite.
2003-01-14, 5:55 AM #20
By the way, what's the difference between flex and float? Is flex like COG's double?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-01-14, 7:09 AM #21
Flex and float are pretty much the same thing. The JKSpecs points out that it seems float was abandoned for the most part in favor of flex.
2003-01-14, 7:27 AM #22
Flex - float, Stop - Return, JKgetlocalplayer(), Getlocalplayerthing(). Multiple ways of expressing the same thing.
And when the moment is right, I'm gonna fly a kite.
2003-01-14, 10:17 AM #23
Thanks, that last one works awesomely
||||||||||||||||||||

↑ Up to the top!