mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-22 09:11:21 +00:00
Adapt rock spawner to UDMF
This commit is contained in:
parent
2c0fb5e80f
commit
1b023732d0
3 changed files with 41 additions and 32 deletions
|
@ -12,6 +12,7 @@
|
|||
/// \brief Enemy thinking, AI
|
||||
/// Action Pointer Functions that are associated with states/frames
|
||||
|
||||
#include "dehacked.h"
|
||||
#include "doomdef.h"
|
||||
#include "g_game.h"
|
||||
#include "p_local.h"
|
||||
|
@ -6182,48 +6183,34 @@ void A_RockSpawn(mobj_t *actor)
|
|||
{
|
||||
mobj_t *mo;
|
||||
mobjtype_t type;
|
||||
INT32 i = Tag_FindLineSpecial(12, (INT16)actor->threshold);
|
||||
line_t *line;
|
||||
fixed_t dist;
|
||||
fixed_t randomoomph;
|
||||
|
||||
if (LUA_CallAction(A_ROCKSPAWN, actor))
|
||||
return;
|
||||
|
||||
if (i == -1)
|
||||
if (!actor->spawnpoint)
|
||||
return;
|
||||
|
||||
type = actor->spawnpoint->stringargs[0] ? get_number(actor->spawnpoint->stringargs[0]) : MT_ROCKCRUMBLE1;
|
||||
|
||||
if (type < MT_NULL || type >= NUMMOBJTYPES)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "A_RockSpawn: Unable to find parameter line 12 (tag %d)!\n", actor->threshold);
|
||||
CONS_Debug(DBG_GAMELOGIC, "A_RockSpawn: Invalid mobj type %s!\n", actor->spawnpoint->stringargs[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
line = &lines[i];
|
||||
|
||||
if (!(sides[line->sidenum[0]].textureoffset >> FRACBITS))
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "A_RockSpawn: No X-offset detected! (tag %d)!\n", actor->threshold);
|
||||
return;
|
||||
}
|
||||
|
||||
dist = P_AproxDistance(line->dx, line->dy)/16;
|
||||
|
||||
if (dist < 1)
|
||||
dist = 1;
|
||||
|
||||
type = MT_ROCKCRUMBLE1 + (sides[line->sidenum[0]].rowoffset >> FRACBITS);
|
||||
|
||||
if (line->flags & ML_NOCLIMB)
|
||||
randomoomph = P_RandomByte() * (FRACUNIT/32);
|
||||
else
|
||||
randomoomph = 0;
|
||||
dist = max(actor->spawnpoint->args[0] << (FRACBITS - 4), 1);
|
||||
if (actor->spawnpoint->args[2])
|
||||
dist += actor->spawnpoint->args[2] ? P_RandomByte() * (FRACUNIT/32) : 0; // random oomph
|
||||
|
||||
mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_FALLINGROCK);
|
||||
P_SetMobjState(mo, mobjinfo[type].spawnstate);
|
||||
mo->angle = R_PointToAngle2(line->v2->x, line->v2->y, line->v1->x, line->v1->y);
|
||||
mo->angle = FixedAngle(actor->spawnpoint->angle << FRACBITS);
|
||||
|
||||
P_InstaThrust(mo, mo->angle, dist + randomoomph);
|
||||
mo->momz = dist + randomoomph;
|
||||
P_InstaThrust(mo, mo->angle, dist);
|
||||
mo->momz = dist;
|
||||
|
||||
var1 = sides[line->sidenum[0]].textureoffset >> FRACBITS;
|
||||
var1 = actor->spawnpoint->args[1];
|
||||
A_SetTics(actor);
|
||||
}
|
||||
|
||||
|
|
|
@ -12722,10 +12722,6 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
|
|||
if (!P_SetupParticleGen(mthing, mobj))
|
||||
return false;
|
||||
break;
|
||||
case MT_ROCKSPAWNER:
|
||||
mobj->threshold = mthing->angle;
|
||||
mobj->movecount = mthing->extrainfo;
|
||||
break;
|
||||
case MT_POPUPTURRET:
|
||||
if (mthing->angle)
|
||||
mobj->threshold = mthing->angle;
|
||||
|
|
|
@ -4877,6 +4877,32 @@ static void P_ConvertBinaryMap(void)
|
|||
mapthings[i].type = 761;
|
||||
break;
|
||||
}
|
||||
case 1202: //Rock spawner
|
||||
{
|
||||
mtag_t tag = (mtag_t)mapthings[i].angle;
|
||||
INT32 j = Tag_FindLineSpecial(12, tag);
|
||||
INT32 typeoffset;
|
||||
|
||||
if (j == -1)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "Rock spawner: Unable to find parameter line 12 (tag %d)!\n", tag);
|
||||
break;
|
||||
}
|
||||
mapthings[i].angle = AngleFixed(R_PointToAngle2(lines[j].v2->x, lines[j].v2->y, lines[j].v1->x, lines[j].v1->y)) >> FRACBITS;
|
||||
mapthings[i].args[0] = P_AproxDistance(lines[j].dx, lines[j].dy) >> FRACBITS;
|
||||
mapthings[i].args[1] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS;
|
||||
mapthings[i].args[2] = !!(lines[j].flags & ML_NOCLIMB);
|
||||
typeoffset = sides[lines[j].sidenum[0]].rowoffset >> FRACBITS;
|
||||
if (typeoffset < 0 || typeoffset > 15)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "Rock spawner: Invalid Y offset %d (tag %d)!\n", typeoffset, tag);
|
||||
break;
|
||||
}
|
||||
|
||||
mapthings[i].stringargs[0] = Z_Malloc(17, PU_LEVEL, NULL);
|
||||
sprintf(mapthings[i].stringargs[0], "MT_ROCKCRUMBLE%d", typeoffset + 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue