* New Egg Guard behaviour!

* Fix the thing I mistakenly messed up with all of the things I moved out of P_SpawnMapThing without good reason to.
This commit is contained in:
toasterbabe 2018-05-22 23:02:54 +01:00
parent 847f8b4ef0
commit dbcd259bd6
3 changed files with 108 additions and 83 deletions

View File

@ -6862,47 +6862,77 @@ void A_GuardChase(mobj_t *actor)
if (actor->reactiontime)
actor->reactiontime--;
if ((!actor->tracer || !actor->tracer->health) && actor->threshold != 42)
if (actor->threshold != 42) // In formation...
{
P_SetTarget(&actor->tracer, NULL);
actor->threshold = 42;
P_SetMobjState(actor, actor->info->painstate);
actor->flags |= MF_SPECIAL|MF_SHOOTABLE;
return;
fixed_t speed;
if (!actor->tracer || !actor->tracer->health)
{
P_SetTarget(&actor->tracer, NULL);
actor->threshold = 42;
P_SetMobjState(actor, actor->info->painstate);
actor->flags |= MF_SPECIAL|MF_SHOOTABLE;
return;
}
speed = actor->extravalue1*actor->scale;
if (actor->flags2 & MF2_AMBUSH)
speed <<= 1;
if (speed
&& !P_TryMove(actor,
actor->x + P_ReturnThrustX(actor, actor->angle, speed),
actor->y + P_ReturnThrustY(actor, actor->angle, speed),
false)
&& speed > 0) // can't be the same check as previous so that P_TryMove gets to happen.
{
if (actor->spawnpoint && ((actor->spawnpoint->options & (MTF_EXTRA|MTF_OBJECTSPECIAL)) == MTF_OBJECTSPECIAL))
actor->angle += ANGLE_90;
else if (actor->spawnpoint && ((actor->spawnpoint->options & (MTF_EXTRA|MTF_OBJECTSPECIAL)) == MTF_EXTRA))
actor->angle -= ANGLE_90;
else
actor->angle += ANGLE_180;
}
if (actor->extravalue1 < actor->info->speed)
actor->extravalue1++;
}
// turn towards movement direction if not there yet
if (actor->movedir < NUMDIRS)
else // Break ranks!
{
actor->angle &= (7<<29);
delta = actor->angle - (actor->movedir << 29);
// turn towards movement direction if not there yet
if (actor->movedir < NUMDIRS)
{
actor->angle &= (7<<29);
delta = actor->angle - (actor->movedir << 29);
if (delta > 0)
actor->angle -= ANGLE_45;
else if (delta < 0)
actor->angle += ANGLE_45;
}
if (delta > 0)
actor->angle -= ANGLE_45;
else if (delta < 0)
actor->angle += ANGLE_45;
}
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE))
{
// look for a new target
if (P_LookForPlayers(actor, true, false, 0))
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE))
{
// look for a new target
if (P_LookForPlayers(actor, true, false, 0))
return; // got a new target
P_SetMobjStateNF(actor, actor->info->spawnstate);
return;
}
// possibly choose another target
if (multiplayer && (actor->target->health <= 0 || !P_CheckSight(actor, actor->target))
&& P_LookForPlayers(actor, true, false, 0))
return; // got a new target
P_SetMobjStateNF(actor, actor->info->spawnstate);
return;
}
// possibly choose another target
if (multiplayer && (actor->target->health <= 0 || !P_CheckSight(actor, actor->target))
&& P_LookForPlayers(actor, true, false, 0))
return; // got a new target
// chase towards player
if (--actor->movecount < 0 || !P_Move(actor, (actor->flags2 & MF2_AMBUSH) ? actor->info->speed * 2 : actor->info->speed))
{
P_NewChaseDir(actor);
actor->movecount += 5; // Increase tics before change in direction allowed.
// chase towards player
if (--actor->movecount < 0 || !P_Move(actor, (actor->flags2 & MF2_AMBUSH) ? actor->info->speed * 2 : actor->info->speed))
{
P_NewChaseDir(actor);
actor->movecount += 5; // Increase tics before change in direction allowed.
}
}
// Now that we've moved, its time for our shield to move!

View File

@ -1406,23 +1406,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return;
case MT_EGGSHIELD:
{
fixed_t touchx, touchy, touchspeed;
angle_t angle;
if (P_AproxDistance(toucher->x-special->x, toucher->y-special->y) >
P_AproxDistance((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y))
{
touchx = toucher->x + toucher->momx;
touchy = toucher->y + toucher->momy;
}
else
{
touchx = toucher->x;
touchy = toucher->y;
}
angle = R_PointToAngle2(special->x, special->y, touchx, touchy) - special->angle;
touchspeed = P_AproxDistance(toucher->momx, toucher->momy);
angle_t angle = R_PointToAngle2(special->x, special->y, toucher->x, toucher->y) - special->angle;
fixed_t touchspeed = P_AproxDistance(toucher->momx, toucher->momy);
if (touchspeed < special->scale)
touchspeed = special->scale;
// Blocked by the shield?
if (!(angle > ANGLE_90 && angle < ANGLE_270))
@ -1439,6 +1426,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
// Play a bounce sound?
S_StartSound(toucher, special->info->painsound);
// experimental bounce
if (special->target)
special->target->extravalue1 = -special->target->info->speed;
return;
}
else if (((player->powers[pw_carry] == CR_NIGHTSMODE) && (player->pflags & PF_DRILLING))

View File

@ -8594,22 +8594,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->reactiontime >>= 1;
}
break;
case MT_THZTREE:
// Spawn the branches
P_SpawnMobjFromMobj(mobj, 1*FRACUNIT, 0, 0, MT_THZTREEBRANCH)->angle = mobj->angle + ANGLE_22h;
P_SpawnMobjFromMobj(mobj, 0, 1*FRACUNIT, 0, MT_THZTREEBRANCH)->angle = mobj->angle + ANGLE_157h;
P_SpawnMobjFromMobj(mobj, -1*FRACUNIT, 0, 0, MT_THZTREEBRANCH)->angle = mobj->angle + ANGLE_270;
break;
case MT_BIGMINE:
mobj->extravalue1 = FixedHypot(mobj->x, mobj->y)>>FRACBITS;
break;
case MT_CEZPOLE:
// Spawn the banner
P_SpawnMobjFromMobj(mobj,
P_ReturnThrustX(mobj, mobj->angle, 4<<FRACBITS),
P_ReturnThrustY(mobj, mobj->angle, 4<<FRACBITS),
0, MT_CEZBANNER)->angle = mobj->angle + ANGLE_90;
break;
case MT_WAVINGFLAG:
{
mobj_t *prev = mobj, *cur;
@ -8625,22 +8612,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
}
}
break;
case MT_HHZTREE_TOP:
{ // Spawn the branches
angle_t mobjangle = mobj->angle & (ANGLE_90-1);
mobj_t *leaf;
#define doleaf(x, y) \
leaf = P_SpawnMobjFromMobj(mobj, x, y, 0, MT_HHZTREE_PART);\
leaf->angle = mobjangle;\
P_SetMobjState(leaf, leaf->info->seestate);\
mobjangle += ANGLE_90
doleaf(1*FRACUNIT, 0);
doleaf(0, 1*FRACUNIT);
doleaf(-1*FRACUNIT, 0);
doleaf(0, -1*FRACUNIT);
#undef doleaf
}
break;
case MT_JACKO1:
case MT_JACKO2:
case MT_JACKO3:
@ -10410,6 +10381,39 @@ ML_EFFECT4 : Don't clip inside the ground
mobj->destscale = mobj->scale;
}
break;
case MT_THZTREE:
{ // Spawn the branches
angle_t mobjangle = FixedAngle((mthing->angle % 113)<<FRACBITS);
P_SpawnMobjFromMobj(mobj, 1*FRACUNIT, 0, 0, MT_THZTREEBRANCH)->angle = mobjangle + ANGLE_22h;
P_SpawnMobjFromMobj(mobj, 0, 1*FRACUNIT, 0, MT_THZTREEBRANCH)->angle = mobjangle + ANGLE_157h;
P_SpawnMobjFromMobj(mobj, -1*FRACUNIT, 0, 0, MT_THZTREEBRANCH)->angle = mobjangle + ANGLE_270;
}
break;
case MT_CEZPOLE:
{ // Spawn the banner
angle_t mobjangle = FixedAngle(mthing->angle<<FRACBITS);
P_SpawnMobjFromMobj(mobj,
P_ReturnThrustX(mobj, mobjangle, 4<<FRACBITS),
P_ReturnThrustY(mobj, mobjangle, 4<<FRACBITS),
0, MT_CEZBANNER)->angle = mobjangle + ANGLE_90;
}
break;
case MT_HHZTREE_TOP:
{ // Spawn the branches
angle_t mobjangle = FixedAngle(mthing->angle<<FRACBITS) & (ANGLE_90-1);
mobj_t *leaf;
#define doleaf(x, y) \
leaf = P_SpawnMobjFromMobj(mobj, x, y, 0, MT_HHZTREE_PART);\
leaf->angle = mobjangle;\
P_SetMobjState(leaf, leaf->info->seestate);\
mobjangle += ANGLE_90
doleaf(1*FRACUNIT, 0);
doleaf(0, 1*FRACUNIT);
doleaf(-1*FRACUNIT, 0);
doleaf(0, -1*FRACUNIT);
#undef doleaf
}
break;
case MT_FLAMEHOLDER:
if (!(mthing->options & MTF_OBJECTSPECIAL)) // Spawn the fire
P_SpawnMobjFromMobj(mobj, 0, 0, mobj->height, MT_FLAME);
@ -10459,7 +10463,7 @@ ML_EFFECT4 : Don't clip inside the ground
mobj_t *elecmobj;
elecmobj = P_SpawnMobj(x, y, z, MT_CYBRAKDEMON_ELECTRIC_BARRIER);
P_SetTarget(&elecmobj->target, mobj);
elecmobj->angle = FixedAngle(mthing->angle*FRACUNIT);;
elecmobj->angle = FixedAngle(mthing->angle<<FRACBITS);;
elecmobj->destscale = mobj->scale*2;
P_SetScale(elecmobj, elecmobj->destscale);
}
@ -10531,7 +10535,7 @@ ML_EFFECT4 : Don't clip inside the ground
// spawn base
{
const angle_t mobjangle = FixedAngle(mthing->angle*FRACUNIT); // the mobj's own angle hasn't been set quite yet so...
const angle_t mobjangle = FixedAngle(mthing->angle<<FRACBITS); // the mobj's own angle hasn't been set quite yet so...
const fixed_t baseradius = mobj->radius - mobj->scale;
mobj_t *base = P_SpawnMobj(
mobj->x - P_ReturnThrustX(mobj, mobjangle, baseradius),
@ -10599,7 +10603,7 @@ ML_EFFECT4 : Don't clip inside the ground
}
if (doangle)
mobj->angle = FixedAngle(mthing->angle*FRACUNIT);
mobj->angle = FixedAngle(mthing->angle<<FRACBITS);
// ignore MTF_ flags and return early
if (i == MT_NIGHTSBUMPER)