From 9d8cb5247a9dcaef214686b0333b01b954f621a0 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 23 Sep 2019 03:15:08 -0400 Subject: [PATCH] Special effects! Tire grease waves, colored stars --- src/d_player.h | 2 ++ src/dehacked.c | 7 ++++++- src/info.c | 55 ++++++++++++++++++++++++++++++++++++++------------ src/info.h | 4 ++++ src/k_kart.c | 23 +++++++++++++++++++++ src/p_map.c | 19 +++++++++++++++++ src/p_mobj.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 149 insertions(+), 14 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index aced985c8..de6cbc46c 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -328,6 +328,8 @@ typedef enum k_spectatewait, // How long have you been waiting as a spectator k_growcancel, // Hold the item button down to cancel Grow k_tiregrease, // Reduced friction timer after hitting a horizontal spring + k_springstars, // Spawn stars around a player when they hit a spring + k_springcolor, // Color of spring stars NUMKARTSTUFF } kartstufftype_t; diff --git a/src/dehacked.c b/src/dehacked.c index 616a81ee9..0e7ddb7e5 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7212,6 +7212,8 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_DRAFTDUST4", "S_DRAFTDUST5", + "S_TIREGREASE", + #ifdef SEENAMES "S_NAMECHECK", #endif @@ -8004,6 +8006,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_KARMAFIREWORK", "MT_RINGSPARKS", "MT_DRAFTDUST", + "MT_TIREGREASE", #ifdef SEENAMES "MT_NAMECHECK", @@ -8491,7 +8494,9 @@ static const char *const KARTSTUFF_LIST[] = { "JAWZTARGETDELAY", "SPECTATEWAIT", "GROWCANCEL", - "TIREGREASE" + "TIREGREASE", + "SPRINGSTARS", + "SPRINGCOLOR" }; #endif diff --git a/src/info.c b/src/info.c index 274cee440..be32f3ebd 100644 --- a/src/info.c +++ b/src/info.c @@ -70,7 +70,7 @@ char sprnames[NUMSPRITES + 1][5] = "DUCK","GTRE","CHES","CHIM","DRGN","LZMN","PGSS","ZTCH","MKMA","MKMP", "RTCH","BOWL","BOWH","BRRL","BRRR","HRSE","TOAH","BFRT","OFRT","RFRT", "PFRT","ASPK","HBST","HBSO","HBSF","WBLZ","WBLN","FWRK","MXCL","RGSP", - "DRAF","XMS4","XMS5","VIEW" + "DRAF","GRES","XMS4","XMS5","VIEW" }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) @@ -3452,6 +3452,8 @@ state_t states[NUMSTATES] = {SPR_DRAF, 3, 1, {NULL}, 0, 0, S_DRAFTDUST5}, // S_DRAFTDUST4 {SPR_DRAF, 4, 1, {NULL}, 0, 0, S_NULL}, // S_DRAFTDUST5 + {SPR_GRES, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 2, 4, S_NULL}, // S_TIREGREASE + #ifdef SEENAMES {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL}, // S_NAMECHECK #endif @@ -6082,7 +6084,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_YELLOW, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6109,7 +6111,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_SALMON, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6136,7 +6138,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_PASTEL, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6163,7 +6165,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_POPCORN, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6190,7 +6192,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_YELLOW, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6217,7 +6219,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_SALMON, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6244,7 +6246,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_PASTEL, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6271,7 +6273,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_POPCORN, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6298,7 +6300,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_YELLOW, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6325,7 +6327,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_SALMON, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6352,7 +6354,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_PASTEL, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -6379,7 +6381,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8, // reactiontime sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + SKINCOLOR_POPCORN, // painchance sfx_s3kb1, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -20271,6 +20273,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_TIREGREASE + -1, // doomednum + S_TIREGREASE, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 8<flags2 |= MF2_DONTDRAW; } + + if (player->kartstuff[k_springstars] && (leveltime & 1)) + { + fixed_t randx = P_RandomRange(-40, 40) * player->mo->scale; + fixed_t randy = P_RandomRange(-40, 40) * player->mo->scale; + fixed_t randz = P_RandomRange(0, player->mo->height >> FRACBITS) << FRACBITS; + mobj_t *star = P_SpawnMobj( + player->mo->x + randx, + player->mo->y + randy, + player->mo->z + randz, + MT_KARMAFIREWORK); + + star->color = player->kartstuff[k_springcolor]; + star->flags |= MF_NOGRAVITY; + star->momx = player->mo->momx / 2; + star->momy = player->mo->momy / 2; + star->momz = player->mo->momz / 2; + star->fuse = 12; + star->scale = player->mo->scale; + star->destscale = star->scale / 2; + + player->kartstuff[k_springstars]--; + } } if (player->playerstate == PST_DEAD || player->kartstuff[k_respawn] > 1) // Ensure these are set correctly here diff --git a/src/p_map.c b/src/p_map.c index 22c6755e7..fbf5b4b06 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -122,6 +122,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) const fixed_t vscale = mapobjectscale + (object->scale - mapobjectscale); fixed_t vertispeed = spring->info->mass; fixed_t horizspeed = spring->info->damage; + UINT8 starcolor = spring->info->painchance; fixed_t savemomx = 0; fixed_t savemomy = 0; @@ -251,7 +252,22 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) { // Less friction when hitting horizontal springs if (!vertispeed) + { + if (!object->player->kartstuff[k_tiregrease]) + { + UINT8 i; + for (i = 0; i < 2; i++) + { + mobj_t *grease; + grease = P_SpawnMobj(object->x, object->y, object->z, MT_TIREGREASE); + P_SetTarget(&grease->target, object); + grease->angle = R_PointToAngle2(0, 0, object->momx, object->momy); + grease->extravalue1 = i; + } + } + object->player->kartstuff[k_tiregrease] = greasetics; //FixedMul(greasetics << FRACBITS, finalSpeed/72) >> FRACBITS + } } // Horizontal speed is used as a minimum thrust, not a direct replacement @@ -271,6 +287,9 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) P_SetTarget(&spring->target, object); P_ResetPlayer(object->player); + + object->player->kartstuff[k_springstars] = max(vertispeed, horizspeed) / FRACUNIT / 2; + object->player->kartstuff[k_springcolor] = starcolor; } return true; diff --git a/src/p_mobj.c b/src/p_mobj.c index e8880f07b..2dda7cb4f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8368,6 +8368,56 @@ void P_MobjThinker(mobj_t *mobj) z); } break; + case MT_TIREGREASE: + if (!mobj->target || P_MobjWasRemoved(mobj->target) || !mobj->target->player + || !mobj->target->player->kartstuff[k_tiregrease]) + { + P_RemoveMobj(mobj); + return; + } + + K_MatchGenericExtraFlags(mobj, mobj->target); + + { + const angle_t off = FixedAngle(40*FRACUNIT); + angle_t ang = mobj->target->angle; + fixed_t z; + UINT8 trans = (mobj->target->player->kartstuff[k_tiregrease] * (NUMTRANSMAPS+1)) / greasetics; + + if (trans > NUMTRANSMAPS) + trans = NUMTRANSMAPS; + + trans = NUMTRANSMAPS - trans; + + z = mobj->target->z; + if (mobj->eflags & MFE_VERTICALFLIP) + z += mobj->target->height; + + if (mobj->target->momx || mobj->target->momy) + ang = R_PointToAngle2(0, 0, mobj->target->momx, mobj->target->momy); + + if (mobj->extravalue1) + ang = (signed)(ang - off); + else + ang = (signed)(ang + off); + + P_TeleportMove(mobj, + mobj->target->x - FixedMul(mobj->target->radius, FINECOSINE(ang >> ANGLETOFINESHIFT)), + mobj->target->y - FixedMul(mobj->target->radius, FINESINE(ang >> ANGLETOFINESHIFT)), + z); + mobj->angle = ang; + + if (leveltime & 1) + mobj->flags2 |= MF2_DONTDRAW; + + if (trans >= NUMTRANSMAPS) + mobj->flags2 |= MF2_DONTDRAW; + else if (trans == 0) + mobj->frame = (mobj->frame & ~FF_TRANSMASK); + else + mobj->frame = (mobj->frame & ~FF_TRANSMASK)|(trans << FF_TRANSSHIFT); + } + break; case MT_THUNDERSHIELD: { fixed_t destx, desty; @@ -9070,6 +9120,9 @@ void P_MobjThinker(mobj_t *mobj) } break; case MT_KARMAFIREWORK: + if (mobj->flags & MF_NOGRAVITY) + break; + if (mobj->momz == 0) { P_RemoveMobj(mobj);