mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-25 05:41:42 +00:00
Adapt linedef type 414 to UDMF
This commit is contained in:
parent
69e0c636a0
commit
890934264b
4 changed files with 212 additions and 97 deletions
|
@ -3081,6 +3081,45 @@ udmf
|
|||
{
|
||||
title = "Linedef Executor (misc.)";
|
||||
|
||||
414
|
||||
{
|
||||
title = "Play Sound Effect";
|
||||
prefix = "(414)";
|
||||
arg0
|
||||
{
|
||||
title = "Source";
|
||||
type = 11;
|
||||
enum
|
||||
{
|
||||
0 = "Triggering object";
|
||||
1 = "Trigger sector";
|
||||
2 = "Nowhere";
|
||||
3 = "Tagged sectors";
|
||||
}
|
||||
}
|
||||
arg1
|
||||
{
|
||||
title = "Listener";
|
||||
type = 11;
|
||||
enum
|
||||
{
|
||||
0 = "Triggering player";
|
||||
1 = "Everyone";
|
||||
2 = "Everyone touching tagged sectors";
|
||||
}
|
||||
}
|
||||
arg2
|
||||
{
|
||||
title = "Target sector tag";
|
||||
type = 13;
|
||||
}
|
||||
stringarg0
|
||||
{
|
||||
title = "Sound name";
|
||||
type = 2;
|
||||
}
|
||||
}
|
||||
|
||||
415
|
||||
{
|
||||
title = "Run Script";
|
||||
|
|
|
@ -1273,7 +1273,6 @@ static void P_LoadSidedefs(UINT8 *data)
|
|||
}
|
||||
|
||||
case 4: // Speed pad parameters
|
||||
case 414: // Play SFX
|
||||
{
|
||||
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||
if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
|
||||
|
@ -1286,6 +1285,20 @@ static void P_LoadSidedefs(UINT8 *data)
|
|||
break;
|
||||
}
|
||||
|
||||
case 414: // Play SFX
|
||||
{
|
||||
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||
if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
|
||||
{
|
||||
char process[8 + 1];
|
||||
M_Memcpy(process, msd->toptexture, 8);
|
||||
process[8] = '\0';
|
||||
sd->text = Z_Malloc(strlen(process) + 1, PU_LEVEL, NULL);
|
||||
M_Memcpy(sd->text, process, strlen(process) + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 9: // Mace parameters
|
||||
case 14: // Bustable block parameters
|
||||
case 15: // Fan particle spawner parameters
|
||||
|
@ -3696,6 +3709,50 @@ static void P_ConvertBinaryMap(void)
|
|||
case 411: //Stop plane movement
|
||||
lines[i].args[0] = tag;
|
||||
break;
|
||||
case 414: //Play sound effect
|
||||
lines[i].args[2] = tag;
|
||||
if (tag != 0)
|
||||
{
|
||||
if (lines[i].flags & ML_EFFECT5)
|
||||
{
|
||||
lines[i].args[0] = TMSS_TAGGEDSECTOR;
|
||||
lines[i].args[1] = TMSL_EVERYONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines[i].args[0] = TMSS_NOWHERE;
|
||||
lines[i].args[1] = TMSL_TAGGEDSECTOR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lines[i].flags & ML_NOCLIMB)
|
||||
{
|
||||
lines[i].args[0] = TMSS_NOWHERE;
|
||||
lines[i].args[1] = TMSL_TRIGGERER;
|
||||
}
|
||||
else if (lines[i].flags & ML_EFFECT4)
|
||||
{
|
||||
lines[i].args[0] = TMSS_NOWHERE;
|
||||
lines[i].args[1] = TMSL_EVERYONE;
|
||||
}
|
||||
else if (lines[i].flags & ML_BLOCKMONSTERS)
|
||||
{
|
||||
lines[i].args[0] = TMSS_TRIGGERSECTOR;
|
||||
lines[i].args[1] = TMSL_EVERYONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines[i].args[0] = TMSS_TRIGGERMOBJ;
|
||||
lines[i].args[1] = TMSL_EVERYONE;
|
||||
}
|
||||
}
|
||||
if (sides[lines[i].sidenum[0]].text)
|
||||
{
|
||||
lines[i].stringargs[0] = Z_Malloc(strlen(sides[lines[i].sidenum[0]].text) + 1, PU_LEVEL, NULL);
|
||||
M_Memcpy(lines[i].stringargs[0], sides[lines[i].sidenum[0]].text, strlen(sides[lines[i].sidenum[0]].text) + 1);
|
||||
}
|
||||
break;
|
||||
case 415: //Run script
|
||||
{
|
||||
INT32 scrnum;
|
||||
|
|
196
src/p_spec.c
196
src/p_spec.c
|
@ -1906,6 +1906,105 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller)
|
|||
}
|
||||
}
|
||||
|
||||
static void P_PlaySFX(INT32 sfxnum, mobj_t *mo, sector_t *callsec, INT16 tag, textmapsoundsource_t source, textmapsoundlistener_t listener)
|
||||
{
|
||||
if (sfxnum == sfx_None)
|
||||
return; // Do nothing!
|
||||
|
||||
if (sfxnum < sfx_None || sfxnum >= NUMSFX)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "Line type 414 Executor: sfx number %d is invalid!\n", sfxnum);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if you can hear the sound
|
||||
switch (listener)
|
||||
{
|
||||
case TMSL_TRIGGERER: // only play sound if displayplayer
|
||||
if (!mo)
|
||||
return;
|
||||
|
||||
if (!mo->player)
|
||||
return;
|
||||
|
||||
if (mo->player != &players[displayplayer] && mo->player != &players[secondarydisplayplayer])
|
||||
return;
|
||||
|
||||
break;
|
||||
case TMSL_TAGGEDSECTOR: // only play if touching tagged sectors
|
||||
{
|
||||
UINT8 i = 0;
|
||||
mobj_t *camobj = players[displayplayer].mo;
|
||||
ffloor_t *rover;
|
||||
boolean foundit = false;
|
||||
|
||||
for (i = 0; i < 2; camobj = players[secondarydisplayplayer].mo, i++)
|
||||
{
|
||||
if (!camobj)
|
||||
continue;
|
||||
|
||||
if (foundit || Tag_Find(&camobj->subsector->sector->tags, tag))
|
||||
{
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Only trigger if mobj is touching the tag
|
||||
for (rover = camobj->subsector->sector->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (!Tag_Find(&rover->master->frontsector->tags, tag))
|
||||
continue;
|
||||
|
||||
if (camobj->z > P_GetSpecialTopZ(camobj, sectors + rover->secnum, camobj->subsector->sector))
|
||||
continue;
|
||||
|
||||
if (camobj->z + camobj->height < P_GetSpecialBottomZ(camobj, sectors + rover->secnum, camobj->subsector->sector))
|
||||
continue;
|
||||
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundit)
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
case TMSL_EVERYONE: // no additional check
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Play the sound from the specified source
|
||||
switch (source)
|
||||
{
|
||||
case TMSS_TRIGGERMOBJ: // play the sound from mobj that triggered it
|
||||
if (mo)
|
||||
S_StartSound(mo, sfxnum);
|
||||
break;
|
||||
case TMSS_TRIGGERSECTOR: // play the sound from calling sector's soundorg
|
||||
if (callsec)
|
||||
S_StartSound(&callsec->soundorg, sfxnum);
|
||||
else if (mo)
|
||||
S_StartSound(&mo->subsector->sector->soundorg, sfxnum);
|
||||
break;
|
||||
case TMSS_NOWHERE: // play the sound from nowhere
|
||||
S_StartSound(NULL, sfxnum);
|
||||
break;
|
||||
case TMSS_TAGGEDSECTOR: // play the sound from tagged sectors' soundorgs
|
||||
{
|
||||
INT32 secnum;
|
||||
|
||||
TAG_ITER_SECTORS(tag, secnum)
|
||||
S_StartSound(§ors[secnum].soundorg, sfxnum);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean is_rain_type (INT32 weathernum)
|
||||
{
|
||||
switch (weathernum)
|
||||
|
@ -2368,102 +2467,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
break;
|
||||
|
||||
case 414: // Play SFX
|
||||
{
|
||||
INT32 sfxnum;
|
||||
|
||||
sfxnum = sides[line->sidenum[0]].toptexture;
|
||||
|
||||
if (sfxnum == sfx_None)
|
||||
return; // Do nothing!
|
||||
if (sfxnum < sfx_None || sfxnum >= NUMSFX)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "Line type 414 Executor: sfx number %d is invalid!\n", sfxnum);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tag != 0) // Do special stuff only if a non-zero linedef tag is set
|
||||
{
|
||||
// Play sounds from tagged sectors' origins.
|
||||
if (line->flags & ML_EFFECT5) // Repeat Midtexture
|
||||
{
|
||||
// Additionally play the sound from tagged sectors' soundorgs
|
||||
sector_t *sec;
|
||||
|
||||
TAG_ITER_SECTORS(tag, secnum)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
S_StartSound(&sec->soundorg, sfxnum);
|
||||
}
|
||||
}
|
||||
|
||||
// Play the sound without origin for anyone, as long as they're inside tagged areas.
|
||||
else
|
||||
{
|
||||
UINT8 i = 0;
|
||||
mobj_t* camobj = players[displayplayer].mo;
|
||||
ffloor_t *rover;
|
||||
boolean foundit = false;
|
||||
|
||||
for (i = 0; i < 2; camobj = players[secondarydisplayplayer].mo, i++)
|
||||
{
|
||||
if (!camobj)
|
||||
continue;
|
||||
|
||||
if (foundit || Tag_Find(&camobj->subsector->sector->tags, tag))
|
||||
{
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Only trigger if mobj is touching the tag
|
||||
for(rover = camobj->subsector->sector->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (!Tag_Find(&rover->master->frontsector->tags, tag))
|
||||
continue;
|
||||
|
||||
if (camobj->z > P_GetSpecialTopZ(camobj, sectors + rover->secnum, camobj->subsector->sector))
|
||||
continue;
|
||||
|
||||
if (camobj->z + camobj->height < P_GetSpecialBottomZ(camobj, sectors + rover->secnum, camobj->subsector->sector))
|
||||
continue;
|
||||
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundit)
|
||||
S_StartSound(NULL, sfxnum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (line->flags & ML_NOCLIMB)
|
||||
{
|
||||
// play the sound from nowhere, but only if display player triggered it
|
||||
if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer]))
|
||||
S_StartSound(NULL, sfxnum);
|
||||
}
|
||||
else if (line->flags & ML_EFFECT4)
|
||||
{
|
||||
// play the sound from nowhere
|
||||
S_StartSound(NULL, sfxnum);
|
||||
}
|
||||
else if (line->flags & ML_BLOCKMONSTERS)
|
||||
{
|
||||
// play the sound from calling sector's soundorg
|
||||
if (callsec)
|
||||
S_StartSound(&callsec->soundorg, sfxnum);
|
||||
else if (mo)
|
||||
S_StartSound(&mo->subsector->sector->soundorg, sfxnum);
|
||||
}
|
||||
else if (mo)
|
||||
{
|
||||
// play the sound from mobj that triggered it
|
||||
S_StartSound(mo, sfxnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
P_PlaySFX(line->stringargs[0] ? get_number(line->stringargs[0]) : sfx_None, mo, callsec, line->args[2], line->args[0], line->args[1]);
|
||||
break;
|
||||
|
||||
case 415: // Run a script
|
||||
|
|
15
src/p_spec.h
15
src/p_spec.h
|
@ -112,6 +112,21 @@ typedef enum
|
|||
TMP_BOTH = 2,
|
||||
} textmapplanes_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TMSS_TRIGGERMOBJ = 0,
|
||||
TMSS_TRIGGERSECTOR = 1,
|
||||
TMSS_NOWHERE = 2,
|
||||
TMSS_TAGGEDSECTOR = 3,
|
||||
} textmapsoundsource_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TMSL_EVERYONE = 0,
|
||||
TMSL_TRIGGERER = 1,
|
||||
TMSL_TAGGEDSECTOR = 2,
|
||||
} textmapsoundlistener_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TML_SECTOR = 0,
|
||||
|
|
Loading…
Reference in a new issue