Adapt linedef type 422 to UDMF

This commit is contained in:
MascaraSnake 2021-09-21 14:59:58 +02:00
parent be480eead0
commit d8b5cb6c90
3 changed files with 65 additions and 27 deletions

View file

@ -3202,6 +3202,21 @@ udmf
}
}
422
{
title = "Switch to Cut-Away View";
prefix = "(422)";
arg0
{
title = "Viewpoint tag";
type = 14;
}
arg1
{
title = "Time";
}
}
423
{
title = "Change Sky";

View file

@ -3870,6 +3870,11 @@ static void P_ConvertBinaryMap(void)
case 421: //Stop lighting effect
lines[i].args[0] = tag;
break;
case 422: //Switch to cut-away view
lines[i].args[0] = tag;
lines[i].args[1] = P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS;
lines[i].args[2] = (lines[i].flags & ML_NOCLIMB) ? sides[lines[i].sidenum[0]].textureoffset >> FRACBITS : 0;
break;
case 423: //Change sky
case 424: //Change weather
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;

View file

@ -2187,6 +2187,39 @@ static mobj_t *P_GetObjectTypeInSectorNum(mobjtype_t type, size_t s)
return NULL;
}
static mobj_t* P_FindObjectTypeFromTag(mobjtype_t type, mtag_t tag)
{
if (udmf)
{
INT32 mtnum;
mobj_t *mo;
TAG_ITER_THINGS(tag, mtnum)
{
mo = mapthings[mtnum].mobj;
if (!mo)
continue;
if (mo->type != type)
continue;
return mo;
}
return NULL;
}
else
{
INT32 secnum;
if ((secnum = Tag_Iterate_Sectors(tag, 0)) < 0)
return NULL;
return P_GetObjectTypeInSectorNum(type, secnum);
}
}
/** Processes the line special triggered by an object.
*
* \param line Line with the special command on it.
@ -2550,15 +2583,13 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 422: // Cut away to another view
{
mobj_t *altview;
INT32 aim;
if ((!mo || !mo->player) && !titlemapinaction) // only players have views, and title screens
return;
if ((secnum = Tag_Iterate_Sectors(tag, 0)) < 0)
return;
altview = P_GetObjectTypeInSectorNum(MT_ALTVIEWMAN, secnum);
if (!altview)
altview = P_FindObjectTypeFromTag(MT_ALTVIEWMAN, line->args[0]);
if (!altview || !altview->spawnpoint)
return;
// If titlemap, set the camera ref for title's thinker
@ -2568,31 +2599,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
else
{
P_SetTarget(&mo->player->awayviewmobj, altview);
mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS;
mo->player->awayviewtics = line->args[1];
}
if (line->flags & ML_NOCLIMB) // lets you specify a vertical angle
{
INT32 aim;
aim = sides[line->sidenum[0]].textureoffset>>FRACBITS;
aim = (aim + 360) % 360;
aim *= (ANGLE_90>>8);
aim /= 90;
aim <<= 8;
if (titlemapinaction)
titlemapcameraref->cusval = (angle_t)aim;
else
mo->player->awayviewaiming = (angle_t)aim;
}
aim = udmf ? altview->spawnpoint->pitch : line->args[2];
aim = (aim + 360) % 360;
aim *= (ANGLE_90>>8);
aim /= 90;
aim <<= 8;
if (titlemapinaction)
titlemapcameraref->cusval = (angle_t)aim;
else
{
// straight ahead
if (!titlemapinaction)
mo->player->awayviewaiming = 0;
// don't do cusval cause that's annoying
}
mo->player->awayviewaiming = (angle_t)aim;
}
break;