What phantombeta and I posted are two slightly different ways to do the same thing. e.g. if you load up my example in a zscript file and summon the actor, you will see a half-size zombie going through the animation and you will hear the boss/spit sound looping continuously (like an ambient sound).
phantombeta's code does basically the same thing. Our animation timings will be different though, because I set the first frame to be 35 tics long, because I thought that was what was wanted.
I notice that your code requires the 0 argument on the thing to be set to 1 before sound can be heard (fair enough) but just a quick check - you have actually set the argument in the map right? If you haven't, it won't make a sound.
It's also worth pointing out that you are using A_PlaySound. This has been deprecated. It is better to use A_StartSound (as per mine and phantombeta's examples).
I'm also still not sure why the first spawn frame has such a long duration. It will be sitting there not animating for about 18 seconds before the animation starts. Is that what you want?
[edit]Having now seen the image, you just want a torch that sits there making a torch crackling sound? If so, then, phantombeta's code will do it just fine. If you want to incorporate the option of having the torch be silent, that's a reasonably easy addition - along the lines of what you have already done.
Something like this would probably do it:
Code: Select all
class TOCT : Actor
{
Default
{
Height 70;
Radius 40;
Scale .5;
}
States
{
Spawn:
TOCT A 0 nodelay A_JumpIf(args[0] == 1, "Animation");
TOCT A 0 A_StartSound("FIRET/Loop", CHAN_BODY, CHANF_LOOPING, 1.0, ATTN_NORM, 0, 0);
Animation:
TOCT ABCDEFG 4;
Loop;
}
}
(Variations of the above are possible)
I haven't tested it, but I think that should check arg0 and if it is 1, it will jump to the animation without playing the sound. If arg0 is anything else, it should also start the sound and then progress on to the animation. The sound should keep playing while the animation just loops over and over.