Anchor Ideya logic

# Conflicts:
#	src/p_enemy.c
#	src/p_inter.c
This commit is contained in:
mazmazz 2018-08-13 02:17:07 -04:00
parent 6b8c8d5a3e
commit 54cb7ddf32
2 changed files with 68 additions and 10 deletions

View file

@ -8543,21 +8543,42 @@ void A_ToggleFlameJet(mobj_t* actor)
//
// var1 = Angle adjustment (aka orbit speed)
// var2:
// Lower 16 bits: height offset
// Bits 1-10: height offset, max 1023
// Bits 11-16: X radius factor (max 63, default 20)
// Bit 17: set if object is Nightopian Helper
// Bit 18: Unused
// Bit 19: set to not sync scale to player
// Bit 18: set to define X/Y/Z rotation factor
// Bits 19-20: Unused
// Bits 21-26: Y radius factor (max 63, default 32)
// Bits 27-32: Z radius factor (max 63, default 32)
//
// If MF_GRENADEBOUNCE is flagged on mobj, use actor->threshold to define X/Y/Z radius factor, max 1023 each:
// Bits 1-10: X factor
// Bits 11-20: Y factor
// Bits 21-30: Z factor
void A_OrbitNights(mobj_t* actor)
{
INT32 ofs = (var2 & 0xFFFF);
INT32 ofs = (var2 & 0x3FF);
boolean ishelper = (var2 & 0x10000);
boolean donotrescale = (var2 & 0x40000);
INT32 xfactor = 32, yfactor = 32, zfactor = 20;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_OrbitNights", actor))
return;
#endif
if (actor->flags & MF_GRENADEBOUNCE)
{
xfactor = (actor->threshold & 0x3FF);
yfactor = (actor->threshold & 0xFFC00) >> 10;
zfactor = (actor->threshold & 0x3FF00000) >> 20;
}
else if (var2 & 0x20000)
{
xfactor = (var2 & 0xFC00) >> 10;
yfactor = (var2 & 0x3F00000) >> 20;
zfactor = (var2 & 0xFC000000) >> 26;
}
if (!actor->target
|| (actor->target->player &&
// if NiGHTS special stage and not NiGHTSmode.
@ -8576,9 +8597,9 @@ void A_OrbitNights(mobj_t* actor)
const angle_t fa = (angle_t)actor->extravalue1 >> ANGLETOFINESHIFT;
const angle_t ofa = ((angle_t)actor->extravalue1 + (ofs*ANG1)) >> ANGLETOFINESHIFT;
const fixed_t fc = FixedMul(FINECOSINE(fa),FixedMul(32*FRACUNIT, actor->scale));
const fixed_t fh = FixedMul(FINECOSINE(ofa),FixedMul(20*FRACUNIT, actor->scale));
const fixed_t fs = FixedMul(FINESINE(fa),FixedMul(32*FRACUNIT, actor->scale));
const fixed_t fc = FixedMul(FINECOSINE(fa),FixedMul(xfactor*FRACUNIT, actor->scale));
const fixed_t fh = FixedMul(FINECOSINE(ofa),FixedMul(zfactor*FRACUNIT, actor->scale));
const fixed_t fs = FixedMul(FINESINE(fa),FixedMul(yfactor*FRACUNIT, actor->scale));
actor->x = actor->target->x + fc;
actor->y = actor->target->y + fs;

View file

@ -797,14 +797,47 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
P_NightserizePlayer(player, special->health); // Transform!
if (!spec)
{
if (toucher->tracer) // Move the ideya over to the drone!
if (toucher->tracer) // Move the ideya!
{
mobj_t *orbittarget = special->target ? special->target : special;
mobj_t *hnext = orbittarget->hnext;
mobj_t *hnext = orbittarget->hnext, *anchorpoint = NULL;
if (toucher->tracer->type == MT_GOTEMERALD
&& toucher->tracer->state-states >= S_ORBIDYA1
&& toucher->tracer->state-states <= S_ORBIDYA5)
{
mobj_t *mo2;
thinker_t *th;
UINT16 ideyanum = (toucher->tracer->state-states) - mobjinfo[MT_GOTEMERALD].missilestate;
// scan the thinkers to find the corresponding anchorpoint
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
continue;
mo2 = (mobj_t *)th;
if (mo2->type == MT_IDEYAANCHOR)
{
if(mo2->health == ideyanum)
{
anchorpoint = mo2;
break;
}
}
}
if (anchorpoint)
{
toucher->tracer->flags |= MF_GRENADEBOUNCE; // custom radius factors
toucher->tracer->threshold = 8 << 20; // X factor 0, Y factor 0, Z factor 8
}
}
P_SetTarget(&orbittarget->hnext, toucher->tracer);
P_SetTarget(&orbittarget->hnext->hnext, hnext); // Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.
P_SetTarget(&orbittarget->hnext->target, orbittarget); // goalpost
P_SetTarget(&orbittarget->hnext->target, anchorpoint ? anchorpoint : orbittarget); // goalpost
P_SetTarget(&toucher->tracer, NULL);
if (hnext)
@ -818,7 +851,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{
mobj_t *hnext = special->target ? special->target : special; // goalpost
while ((hnext = hnext->hnext))
{
hnext->flags &= ~MF_GRENADEBOUNCE;
hnext->threshold = 0;
P_SetTarget(&hnext->target, toucher);
}
}
return;
}