Add the remaining code from the Lua script to get wall spikes actually working so far

This commit is contained in:
Monster Iestyn 2017-07-13 23:00:45 +01:00
parent aa947ea022
commit eacf753f2c
3 changed files with 89 additions and 1 deletions

View file

@ -6045,7 +6045,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
4, // mass
0, // damage
sfx_None, // activesound
MF_SOLID|MF_NOGRAVITY|MF_PAPERCOLLISION, //MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SCENERY|MF_NOCLIPHEIGHT, // flags
MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SCENERY|MF_NOCLIPHEIGHT|MF_PAPERCOLLISION, // flags
S_NULL // raisestate
},

View file

@ -959,6 +959,45 @@ static boolean PIT_CheckThing(mobj_t *thing)
P_DamageMobj(tmthing, thing, thing, 1, 0);
}
if (tmthing->type == MT_WALLSPIKE && tmthing->flags & MF_SOLID && thing->player) // wall spike impales player
{
fixed_t bottomz, topz;
bottomz = tmthing->z;
topz = tmthing->z + tmthing->height;
if (tmthing->eflags & MFE_VERTICALFLIP)
bottomz -= FixedMul(FRACUNIT, tmthing->scale);
else
topz += FixedMul(FRACUNIT, tmthing->scale);
if (thing->z + thing->height >= bottomz // above bottom
&& thing->z < topz) // below top
{ // don't check angle, the player was clearly in the way in this case
P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE);
}
}
else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && tmthing->player)
{
fixed_t bottomz, topz;
bottomz = thing->z;
topz = thing->z + thing->height;
if (thing->eflags & MFE_VERTICALFLIP)
bottomz -= FixedMul(FRACUNIT, thing->scale);
else
topz += FixedMul(FRACUNIT, thing->scale);
if (tmthing->z + tmthing->height >= bottomz // above bottom
&& tmthing->z < topz // below top
&& !P_MobjWasRemoved(thing->tracer)) // this probably wouldn't work if we didn't have a tracer
{ // use base as a reference point to determine what angle you touched the spike at
angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tmthing->x, tmthing->y);
angle_t diffangle = thing->angle - touchangle;
if (diffangle > ANGLE_180)
diffangle = InvAngle(diffangle);
if (diffangle <= ANGLE_22h) // if you touched it at this close an angle, you get poked!
P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE);
}
}
if (thing->flags & MF_PUSHABLE)
{
if (tmthing->type == MT_FAN || tmthing->type == MT_STEAM)

View file

@ -7373,6 +7373,22 @@ void P_MobjThinker(mobj_t *mobj)
}
else switch (mobj->type)
{
case MT_WALLSPIKEBASE:
if (!mobj->target) {
P_RemoveMobj(mobj);
return;
}
mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|(mobj->target->frame & FF_FRAMEMASK);
if (mobj->angle != mobj->target->angle + ANGLE_90) // reposition if not the correct angle
{
mobj_t *target = mobj->target;
P_UnsetThingPosition(mobj);
mobj->x = target->x - P_ReturnThrustX(target, target->angle, target->radius/2 - FixedMul(FRACUNIT, target->scale));
mobj->y = target->y - P_ReturnThrustY(target, target->angle, target->radius/2 - FixedMul(FRACUNIT, target->scale));
P_SetThingPosition(mobj);
mobj->angle = target->angle + ANGLE_90;
}
break;
case MT_FALLINGROCK:
// Despawn rocks here in case zmovement code can't do so (blame slopes)
if (!mobj->momx && !mobj->momy && !mobj->momz
@ -8066,6 +8082,10 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
if (mobj->spawnpoint)
mobj->fuse += mobj->spawnpoint->angle;
break;
case MT_WALLSPIKE:
P_SetMobjState(mobj, mobj->state->nextstate);
mobj->fuse = mobj->info->speed;
break;
case MT_NIGHTSCORE:
P_RemoveMobj(mobj);
return;
@ -8457,6 +8477,18 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
// Collision helper can be stood on but not pushed
mobj->flags2 |= MF2_STANDONME;
break;
case MT_WALLSPIKE:
{
mobj_t *base = P_SpawnMobj(
mobj->x - P_ReturnThrustX(mobj, mobj->angle, mobj->radius/2 - FixedMul(FRACUNIT, mobj->scale)),
mobj->y - P_ReturnThrustY(mobj, mobj->angle, mobj->radius/2 - FixedMul(FRACUNIT, mobj->scale)),
mobj->z, MT_WALLSPIKEBASE);
base->angle = mobj->angle + ANGLE_90;
P_SetScale(base, mobj->scale);
P_SetTarget(&base->target, mobj);
P_SetTarget(&mobj->tracer, base);
}
// fall through to give standonme flag
case MT_SPIKE:
mobj->flags2 |= MF2_STANDONME;
break;
@ -10122,6 +10154,23 @@ ML_NOCLIMB : Direction not controllable
P_SetThingPosition(mobj);
}
}
else if (i == MT_WALLSPIKE)
{
// Pop up spikes!
if (mthing->options & MTF_OBJECTSPECIAL)
{
mobj->flags &= ~MF_SCENERY;
mobj->fuse = mobj->info->speed;
}
// Use per-thing collision for spikes if the deaf flag is checked.
if (mthing->options & MTF_AMBUSH && !metalrecording)
{
P_UnsetThingPosition(mobj);
mobj->flags &= ~(MF_NOBLOCKMAP|MF_NOCLIPHEIGHT);
mobj->flags |= MF_SOLID;
P_SetThingPosition(mobj);
}
}
//count 10 ring boxes into the number of rings equation too.
if (i == MT_RING_BOX)