Beispiel #1
0
void SN_StopSequence(mobj_t *mobj)
{
	seqnode_t *node;

	for(node = SequenceListHead; node; node = node->next)
	{
		if(node->mobj == mobj)
		{
			S_StopSound(mobj);
			if(node->stopSound)
			{
				S_StartSoundAtVolume(mobj, node->stopSound, node->volume);
			}
			if(SequenceListHead == node)
			{
				SequenceListHead = node->next;
			}
			if(node->prev)
			{
				node->prev->next = node->next;
			}
			if(node->next)
			{
				node->next->prev = node->prev;
			}
			Z_Free(node);
			ActiveSequences--;
		}
	}
}
Beispiel #2
0
static int CmdAmbientSound(void)
{
    int volume;

    volume = Pop();
    S_StartSoundAtVolume(NULL, S_GetSoundID(ACStrings[Pop()]), volume);
    return SCRIPT_CONTINUE;
}
Beispiel #3
0
static int CmdSectorSound(void)
{
    int volume;
    mobj_t *mobj;

    mobj = NULL;
    if (ACScript->line)
    {
        mobj = (mobj_t *) & ACScript->line->frontsector->soundorg;
    }
    volume = Pop();
    S_StartSoundAtVolume(mobj, S_GetSoundID(ACStrings[Pop()]), volume);
    return SCRIPT_CONTINUE;
}
Beispiel #4
0
static int CmdThingSound(void)
{
    int tid;
    int sound;
    int volume;
    mobj_t *mobj;
    int searcher;

    volume = Pop();
    sound = S_GetSoundID(ACStrings[Pop()]);
    tid = Pop();
    searcher = -1;
    while ((mobj = P_FindMobjFromTID(tid, &searcher)) != NULL)
    {
        S_StartSoundAtVolume(mobj, sound, volume);
    }
    return SCRIPT_CONTINUE;
}
Beispiel #5
0
static void P_LightningFlash(void)
{
    int i;
    sector_t *tempSec;
    bool foundSec;
    int flashLight;
    static PointThinker thunderSndOrigin;

    if(LightningFlash)
    {
        LightningFlash--;

        if(LightningFlash)
        {
            for(i = 0; i < numsectors; i++)
            {
                tempSec = &sectors[i];

                if(tempSec->intflags & SIF_SKY &&
                        tempSec->oldlightlevel < tempSec->lightlevel - 4)
                {
                    tempSec->lightlevel -= 4;
                }
            }
        }
        else
        {
            for(i = 0; i < numsectors; i++)
            {
                tempSec = &sectors[i];

                if(tempSec->intflags & SIF_SKY)
                    tempSec->lightlevel = tempSec->oldlightlevel;
            }

            if(LevelSky != -1 && LevelTempSky != -1)
                skytexture = LevelSky;
        }
    }
    else
    {
        LightningFlash = (P_Random(pr_lightning) & 7) + 8;
        flashLight     = 200 + (P_Random(pr_lightning) & 31);

        foundSec = false;

        for(i = 0; i < numsectors; i++)
        {
            tempSec = &sectors[i];

            if(tempSec->intflags & SIF_SKY)
            {
                tempSec->oldlightlevel = tempSec->lightlevel;
                tempSec->lightlevel    = flashLight;

                if(tempSec->lightlevel < tempSec->oldlightlevel)
                    tempSec->lightlevel = tempSec->oldlightlevel;

                foundSec = true;
            }
        }

        if(foundSec)
        {
            if(LevelSky != -1 && LevelTempSky != -1)
                skytexture = LevelTempSky;

            S_StartSoundAtVolume(&thunderSndOrigin, sfx_thundr,
                                 127, ATTN_NONE, CHAN_AUTO);
        }

        if(!NextLightningFlash)
        {
            if(M_Random() < 50)
                NextLightningFlash = (M_Random() & 15) + 16;
            else
            {
                if(M_Random() < 128 && !(leveltime & 32))
                    NextLightningFlash = ((M_Random() & 7) + 2) * 35;
                else
                    NextLightningFlash = ((M_Random() & 15) + 5) * 35;
            }
        }
    }
}
Beispiel #6
0
void P_AmbientSound(void)
{
	afxcmd_t cmd;
	int sound;
	boolean done;

	if(!AmbSfxCount)
	{ // No ambient sound sequences on current level
		return;
	}
	if(--AmbSfxTics)
	{
		return;
	}
	done = false;
	do
	{
		cmd = *AmbSfxPtr++;
		switch(cmd)
		{
			case afxcmd_play:
				AmbSfxVolume = P_Random()>>2;
				S_StartSoundAtVolume(NULL, *AmbSfxPtr++, AmbSfxVolume);
				break;
			case afxcmd_playabsvol:
				sound = *AmbSfxPtr++;
				AmbSfxVolume = *AmbSfxPtr++;
				S_StartSoundAtVolume(NULL, sound, AmbSfxVolume);
				break;
			case afxcmd_playrelvol:
				sound = *AmbSfxPtr++;
				AmbSfxVolume += *AmbSfxPtr++;
				if(AmbSfxVolume < 0)
				{
					AmbSfxVolume = 0;
				}
				else if(AmbSfxVolume > 127)
				{
					AmbSfxVolume = 127;
				}			
				S_StartSoundAtVolume(NULL, sound, AmbSfxVolume);
				break;
			case afxcmd_delay:
				AmbSfxTics = *AmbSfxPtr++;
				done = true;
				break;
			case afxcmd_delayrand:
				AmbSfxTics = P_Random()&(*AmbSfxPtr++);
				done = true;
				break;
			case afxcmd_end:
				AmbSfxTics = 6*TICSPERSEC+P_Random();
				AmbSfxPtr = LevelAmbientSfx[P_Random()%AmbSfxCount];
				done = true;
				break;
			default:
				I_Error("P_AmbientSound: Unknown afxcmd %d", cmd);
				break;
		}
	} while(done == false);
}
Beispiel #7
0
void SN_UpdateActiveSequences(void)
{
	seqnode_t *node;
	boolean sndPlaying;

	if(!ActiveSequences || paused)
	{ // No sequences currently playing/game is paused
		return;
	}
	for(node = SequenceListHead; node; node = node->next)
	{
		if(node->delayTics)
		{
			node->delayTics--;
			continue;
		}
		sndPlaying = S_GetSoundPlayingInfo(node->mobj, node->currentSoundID);
		switch(*node->sequencePtr)
		{
			case SS_CMD_PLAY:
				if(!sndPlaying)
				{
					node->currentSoundID = *(node->sequencePtr+1);
					S_StartSoundAtVolume(node->mobj, node->currentSoundID,
						node->volume);
				}
				node->sequencePtr += 2;
				break;
			case SS_CMD_WAITUNTILDONE:
				if(!sndPlaying)
				{
					node->sequencePtr++;
					node->currentSoundID = 0;
				}
				break;
			case SS_CMD_PLAYREPEAT:
				if(!sndPlaying)
				{
					node->currentSoundID = *(node->sequencePtr+1);
					S_StartSoundAtVolume(node->mobj, node->currentSoundID,
						node->volume);
				}
				break;
			case SS_CMD_DELAY:
				node->delayTics = *(node->sequencePtr+1);
				node->sequencePtr += 2;
				node->currentSoundID = 0;
				break;
			case SS_CMD_DELAYRAND:
				node->delayTics = *(node->sequencePtr+1)+
					M_Random()%(*(node->sequencePtr+2)-*(node->sequencePtr+1));
				node->sequencePtr += 2;
				node->currentSoundID = 0;
				break;
			case SS_CMD_VOLUME:
				node->volume = (127*(*(node->sequencePtr+1)))/100;
				node->sequencePtr += 2;
				break;
			case SS_CMD_STOPSOUND:
				// Wait until something else stops the sequence
				break;
			case SS_CMD_END:
				SN_StopSequence(node->mobj);
				break;
			default:	
				break;
		}
	}
}