Spark radius now follows players

This commit is contained in:
Latapostrophe 2018-09-20 18:31:38 +02:00
parent 09287df890
commit 73c66e3bc4
3 changed files with 26 additions and 14 deletions

View file

@ -3019,19 +3019,19 @@ state_t states[NUMSTATES] =
// Oh no it's annoying lightning states.......
// Lightning Sparks (it's the ones we'll use for the radius)
{SPR_KSPK, FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_KSPARK2}, // S_KSPARK1
{SPR_NULL, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_KSPARK3}, // S_KSPARK2
{SPR_KSPK, FF_FULLBRIGHT|1, 2, {NULL}, 0, 0, S_KSPARK4}, // S_KSPARK3
{SPR_NULL, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_KSPARK5}, // S_KSPARK4
{SPR_KSPK, FF_FULLBRIGHT|2, 2, {NULL}, 0, 0, S_KSPARK6}, // S_KSPARK5
{SPR_NULL, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_KSPARK7}, // S_KSPARK6
{SPR_KSPK, FF_FULLBRIGHT|3, 2, {NULL}, 0, 0, S_KSPARK8}, // S_KSPARK7
{SPR_NULL, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_KSPARK9}, // S_KSPARK8
{SPR_KSPK, FF_TRANS40|FF_FULLBRIGHT|4, 2, {NULL}, 0, 0, S_KSPARK10}, // S_KSPARK9
{SPR_NULL, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_KSPARK11}, // S_KSPARK10
{SPR_KSPK, FF_TRANS50|FF_FULLBRIGHT|5, 2, {NULL}, 0, 0, S_KSPARK12}, // S_KSPARK11
{SPR_NULL, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_KSPARK13}, // S_KSPARK12
{SPR_KSPK, FF_TRANS60|FF_FULLBRIGHT|6, 2, {NULL}, 0, 0, S_NULL}, // S_KSPARK13
{SPR_KSPK, FF_FULLBRIGHT, 2, {A_LightningFollowPlayer}, 0, 0, S_KSPARK2}, // S_KSPARK1
{SPR_NULL, FF_FULLBRIGHT, 1, {A_LightningFollowPlayer}, 0, 0, S_KSPARK3}, // S_KSPARK2
{SPR_KSPK, FF_FULLBRIGHT|1, 2, {A_LightningFollowPlayer}, 0, 0, S_KSPARK4}, // S_KSPARK3
{SPR_NULL, FF_FULLBRIGHT, 1, {A_LightningFollowPlayer}, 0, 0, S_KSPARK5}, // S_KSPARK4
{SPR_KSPK, FF_FULLBRIGHT|2, 2, {A_LightningFollowPlayer}, 0, 0, S_KSPARK6}, // S_KSPARK5
{SPR_NULL, FF_FULLBRIGHT, 1, {A_LightningFollowPlayer}, 0, 0, S_KSPARK7}, // S_KSPARK6
{SPR_KSPK, FF_FULLBRIGHT|3, 2, {A_LightningFollowPlayer}, 0, 0, S_KSPARK8}, // S_KSPARK7
{SPR_NULL, FF_FULLBRIGHT, 1, {A_LightningFollowPlayer}, 0, 0, S_KSPARK9}, // S_KSPARK8
{SPR_KSPK, FF_TRANS40|FF_FULLBRIGHT|4, 2, {A_LightningFollowPlayer}, 0, 0, S_KSPARK10}, // S_KSPARK9
{SPR_NULL, FF_FULLBRIGHT, 1, {A_LightningFollowPlayer}, 0, 0, S_KSPARK11}, // S_KSPARK10
{SPR_KSPK, FF_TRANS50|FF_FULLBRIGHT|5, 2, {A_LightningFollowPlayer}, 0, 0, S_KSPARK12}, // S_KSPARK11
{SPR_NULL, FF_FULLBRIGHT, 1, {A_LightningFollowPlayer}, 0, 0, S_KSPARK13}, // S_KSPARK12
{SPR_KSPK, FF_TRANS60|FF_FULLBRIGHT|6, 2, {A_LightningFollowPlayer}, 0, 0, S_NULL}, // S_KSPARK13
// The straight bolt...
{SPR_LZI1, FF_FULLBRIGHT, 2, {A_LightningFollowPlayer}, 0, 0, S_LZIO12}, // S_LZIO11

View file

@ -2749,7 +2749,10 @@ static void K_DoThunderShield(player_t *player)
sx = player->mo->x + FixedMul((player->mo->scale*THUNDERRADIUS), FINECOSINE((an*i)>>ANGLETOFINESHIFT));
sy = player->mo->y + FixedMul((player->mo->scale*THUNDERRADIUS), FINESINE((an*i)>>ANGLETOFINESHIFT));
mo = P_SpawnMobj(sx, sy, player->mo->z, MT_THOK);
mo-> angle = an*i;
mo->extravalue1 = THUNDERRADIUS; // Used to know whether we should teleport by radius or something.
mo->scale = player->mo->scale*3;
P_SetTarget(&mo->target, player->mo);
P_SetMobjState(mo, S_KSPARK1);
}
}

View file

@ -8323,9 +8323,18 @@ void A_LightningFollowPlayer(mobj_t *actor)
if (LUA_CallAction("A_LightningFollowPlayer", actor))
return;
#endif
fixed_t sx, sy;
if (actor->target)
{
P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z);
if (actor->extravalue1) // Make the radius also follow the player somewhat accuratly
{
sx = actor->target->x + FixedMul((actor->target->scale*actor->extravalue1), FINECOSINE((actor->angle)>>ANGLETOFINESHIFT));
sy = actor->target->y + FixedMul((actor->target->scale*actor->extravalue1), FINESINE((actor->angle)>>ANGLETOFINESHIFT));
P_TeleportMove(actor, sx, sy, actor->target->z);
}
else // else just teleport to player directly
P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z);
actor->momx = actor->target->momx;
actor->momy = actor->target->momy;
actor->momz = actor->target->momz; // Give momentum since we don't teleport to our player literally every frame.