mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Merge branch 'damage-polish' into 'master'
Damage Polish See merge request KartKrew/Kart!1524
This commit is contained in:
commit
9aa99db2e6
9 changed files with 84 additions and 31 deletions
|
|
@ -668,6 +668,7 @@ struct player_t
|
||||||
UINT16 superring; // You were awarded rings, and have this many of them left to spawn on yourself.
|
UINT16 superring; // You were awarded rings, and have this many of them left to spawn on yourself.
|
||||||
UINT8 nextringaward; // When should we spawn our next superring ring?
|
UINT8 nextringaward; // When should we spawn our next superring ring?
|
||||||
UINT16 ringvolume; // When consuming lots of rings, lower the sound a little.
|
UINT16 ringvolume; // When consuming lots of rings, lower the sound a little.
|
||||||
|
UINT16 ringburst; // Queued number of rings to lose after hitlag ends
|
||||||
|
|
||||||
UINT8 curshield; // see kartshields_t
|
UINT8 curshield; // see kartshields_t
|
||||||
UINT8 bubblecool; // Bubble Shield use cooldown
|
UINT8 bubblecool; // Bubble Shield use cooldown
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "m_random.h"
|
#include "m_random.h"
|
||||||
#include "p_local.h"
|
#include "p_local.h"
|
||||||
#include "r_main.h"
|
#include "r_main.h"
|
||||||
|
#include "s_sound.h"
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
void K_AddHitLag(mobj_t *mo, INT32 tics, boolean fromDamage)
|
void K_AddHitLag(mobj_t *mo, INT32 tics, boolean fromDamage)
|
||||||
|
|
@ -129,13 +130,38 @@ static void K_SpawnSingleHitLagSpark(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
static void K_PlayHitLagSFX(mobj_t *victim, UINT8 tics)
|
||||||
|
|
||||||
|
Plays a damage sound for a player.
|
||||||
|
|
||||||
|
Input Arguments:-
|
||||||
|
victim - Object getting damaged.
|
||||||
|
tics - How long the hitlag was.
|
||||||
|
|
||||||
|
Return:-
|
||||||
|
N/A
|
||||||
|
--------------------------------------------------*/
|
||||||
|
static void K_PlayHitLagSFX(mobj_t *victim, UINT8 tics)
|
||||||
|
{
|
||||||
|
sfxenum_t soundID = sfx_dmga1;
|
||||||
|
|
||||||
|
if (P_Random(PR_DECORATION) & 1) // might want to use this set for some other scenario, instead of randomized?
|
||||||
|
{
|
||||||
|
soundID = sfx_dmgb1;
|
||||||
|
}
|
||||||
|
|
||||||
|
soundID += ((tics * (NUM_HITLAG_SOUNDS - 1)) + (MAXHITLAGTICS >> 1)) / MAXHITLAGTICS;
|
||||||
|
S_StartSound(victim, soundID);
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
static void K_SpawnHitLagEFX(mobj_t *victim, mobj_t *inflictor, mobj_t *source, UINT8 tics)
|
static void K_SpawnHitLagEFX(mobj_t *victim, mobj_t *inflictor, mobj_t *source, UINT8 tics)
|
||||||
|
|
||||||
Spawns several hitlag sparks for damage.
|
Spawns several hitlag sparks for damage.
|
||||||
|
|
||||||
Input Arguments:-
|
Input Arguments:-
|
||||||
victim - Object getting touched.
|
victim - Object getting damaged.
|
||||||
inflictor - Object touching the victim. May be NULL.
|
inflictor - Object touching the victim. May be NULL.
|
||||||
source - Object that inflictor came from. May be NULL or same as inflictor.
|
source - Object that inflictor came from. May be NULL or same as inflictor.
|
||||||
tics - How long the hitlag was.
|
tics - How long the hitlag was.
|
||||||
|
|
@ -152,6 +178,7 @@ static void K_SpawnHitLagEFX(mobj_t *victim, mobj_t *inflictor, mobj_t *source,
|
||||||
|
|
||||||
I_Assert(P_MobjWasRemoved(victim) == false);
|
I_Assert(P_MobjWasRemoved(victim) == false);
|
||||||
|
|
||||||
|
K_PlayHitLagSFX(victim, tics);
|
||||||
P_StartQuakeFromMobj(tics, tics * 2 * mapobjectscale, 512 * mapobjectscale, victim);
|
P_StartQuakeFromMobj(tics, tics * 2 * mapobjectscale, 512 * mapobjectscale, victim);
|
||||||
|
|
||||||
if (P_MobjWasRemoved(inflictor) == false)
|
if (P_MobjWasRemoved(inflictor) == false)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ extern "C" {
|
||||||
#define MAXHITLAGTICS (30)
|
#define MAXHITLAGTICS (30)
|
||||||
#define HITLAGJITTERS (FRACUNIT / 20)
|
#define HITLAGJITTERS (FRACUNIT / 20)
|
||||||
#define NUM_HITLAG_STATES (9)
|
#define NUM_HITLAG_STATES (9)
|
||||||
|
#define NUM_HITLAG_SOUNDS (4)
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
void K_AddHitLag(mobj_t *mo, INT32 tics, boolean fromDamage);
|
void K_AddHitLag(mobj_t *mo, INT32 tics, boolean fromDamage);
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,8 @@ static int player_get(lua_State *L)
|
||||||
lua_pushinteger(L, plr->nextringaward);
|
lua_pushinteger(L, plr->nextringaward);
|
||||||
else if (fastcmp(field,"ringvolume"))
|
else if (fastcmp(field,"ringvolume"))
|
||||||
lua_pushinteger(L, plr->ringvolume);
|
lua_pushinteger(L, plr->ringvolume);
|
||||||
|
else if (fastcmp(field,"ringburst"))
|
||||||
|
lua_pushinteger(L, plr->ringburst);
|
||||||
else if (fastcmp(field,"curshield"))
|
else if (fastcmp(field,"curshield"))
|
||||||
lua_pushinteger(L, plr->curshield);
|
lua_pushinteger(L, plr->curshield);
|
||||||
else if (fastcmp(field,"bubblecool"))
|
else if (fastcmp(field,"bubblecool"))
|
||||||
|
|
@ -775,6 +777,8 @@ static int player_set(lua_State *L)
|
||||||
plr->nextringaward = luaL_checkinteger(L, 3);
|
plr->nextringaward = luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp(field,"ringvolume"))
|
else if (fastcmp(field,"ringvolume"))
|
||||||
plr->ringvolume = luaL_checkinteger(L, 3);
|
plr->ringvolume = luaL_checkinteger(L, 3);
|
||||||
|
else if (fastcmp(field,"ringburst"))
|
||||||
|
plr->ringburst = luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp(field,"curshield"))
|
else if (fastcmp(field,"curshield"))
|
||||||
plr->curshield = luaL_checkinteger(L, 3);
|
plr->curshield = luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp(field,"bubblecool"))
|
else if (fastcmp(field,"bubblecool"))
|
||||||
|
|
|
||||||
|
|
@ -2752,8 +2752,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||||
if (type != DMG_STING)
|
if (type != DMG_STING)
|
||||||
player->flashing = K_GetKartFlashing(player);
|
player->flashing = K_GetKartFlashing(player);
|
||||||
|
|
||||||
P_PlayRinglossSound(target);
|
player->ringburst += ringburst;
|
||||||
P_PlayerRingBurst(player, ringburst);
|
|
||||||
|
|
||||||
K_PopPlayerShield(player);
|
K_PopPlayerShield(player);
|
||||||
player->instashield = 15;
|
player->instashield = 15;
|
||||||
|
|
@ -2829,6 +2828,9 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define RING_LAYER_SIDE_SIZE (3)
|
||||||
|
#define RING_LAYER_SIZE (RING_LAYER_SIDE_SIZE * 2)
|
||||||
|
|
||||||
static void P_FlingBurst
|
static void P_FlingBurst
|
||||||
( player_t *player,
|
( player_t *player,
|
||||||
angle_t fa,
|
angle_t fa,
|
||||||
|
|
@ -2837,16 +2839,11 @@ static void P_FlingBurst
|
||||||
fixed_t objScale,
|
fixed_t objScale,
|
||||||
INT32 i)
|
INT32 i)
|
||||||
{
|
{
|
||||||
mobj_t *mo;
|
mobj_t *mo = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, objType);
|
||||||
fixed_t ns;
|
P_SetTarget(&mo->target, player->mo);
|
||||||
fixed_t momxy = 5<<FRACBITS, momz = 12<<FRACBITS; // base horizonal/vertical thrusts
|
|
||||||
INT32 mx = (i + 1) >> 1;
|
|
||||||
|
|
||||||
mo = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, objType);
|
|
||||||
|
|
||||||
mo->threshold = 10; // not useful for spikes
|
mo->threshold = 10; // not useful for spikes
|
||||||
mo->fuse = objFuse;
|
mo->fuse = objFuse;
|
||||||
P_SetTarget(&mo->target, player->mo);
|
|
||||||
|
|
||||||
// We want everything from P_SpawnMobjFromMobj except scale.
|
// We want everything from P_SpawnMobjFromMobj except scale.
|
||||||
objScale = FixedMul(objScale, FixedDiv(mapobjectscale, player->mo->scale));
|
objScale = FixedMul(objScale, FixedDiv(mapobjectscale, player->mo->scale));
|
||||||
|
|
@ -2857,27 +2854,20 @@ static void P_FlingBurst
|
||||||
mo->destscale = mo->scale;
|
mo->destscale = mo->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
0: 0
|
|
||||||
1: 1 = (1+1)/2 = 1
|
|
||||||
2: 1 = (2+1)/2 = 1
|
|
||||||
3: 2 = (3+1)/2 = 2
|
|
||||||
4: 2 = (4+1)/2 = 2
|
|
||||||
5: 3 = (4+1)/2 = 2
|
|
||||||
*/
|
|
||||||
// Angle / height offset changes every other ring
|
|
||||||
momxy -= mx * FRACUNIT;
|
|
||||||
momz += mx * (2<<FRACBITS);
|
|
||||||
|
|
||||||
if (i & 1)
|
if (i & 1)
|
||||||
|
{
|
||||||
fa += ANGLE_180;
|
fa += ANGLE_180;
|
||||||
|
}
|
||||||
|
|
||||||
ns = FixedMul(momxy, player->mo->scale);
|
// Pitch offset changes every other ring
|
||||||
mo->momx = (mo->target->momx/2) + FixedMul(FINECOSINE(fa>>ANGLETOFINESHIFT), ns);
|
angle_t offset = ANGLE_90 / (RING_LAYER_SIDE_SIZE + 2);
|
||||||
mo->momy = (mo->target->momy/2) + FixedMul(FINESINE(fa>>ANGLETOFINESHIFT), ns);
|
angle_t fp = offset + (((i / 2) % RING_LAYER_SIDE_SIZE) * (offset * 3 >> 1));
|
||||||
|
|
||||||
ns = FixedMul(momz, player->mo->scale);
|
const UINT8 layer = i / RING_LAYER_SIZE;
|
||||||
mo->momz = (mo->target->momz/2) + ((ns) * P_MobjFlip(mo));
|
const fixed_t thrust = (13 * mo->scale) + (7 * mo->scale * layer);
|
||||||
|
mo->momx = (player->mo->momx / 2) + FixedMul(FixedMul(thrust, FINECOSINE(fp >> ANGLETOFINESHIFT)), FINECOSINE(fa >> ANGLETOFINESHIFT));
|
||||||
|
mo->momy = (player->mo->momy / 2) + FixedMul(FixedMul(thrust, FINECOSINE(fp >> ANGLETOFINESHIFT)), FINESINE(fa >> ANGLETOFINESHIFT));
|
||||||
|
mo->momz = (player->mo->momz / 2) + (FixedMul(thrust, FINESINE(fp >> ANGLETOFINESHIFT)) * P_MobjFlip(mo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Spills an injured player's rings.
|
/** Spills an injured player's rings.
|
||||||
|
|
@ -2889,7 +2879,7 @@ static void P_FlingBurst
|
||||||
*/
|
*/
|
||||||
void P_PlayerRingBurst(player_t *player, INT32 num_rings)
|
void P_PlayerRingBurst(player_t *player, INT32 num_rings)
|
||||||
{
|
{
|
||||||
INT32 num_fling_rings;
|
INT32 spill_total, num_fling_rings;
|
||||||
INT32 i;
|
INT32 i;
|
||||||
angle_t fa;
|
angle_t fa;
|
||||||
|
|
||||||
|
|
@ -2911,8 +2901,8 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings)
|
||||||
else if (num_rings <= 0)
|
else if (num_rings <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
num_rings = -P_GivePlayerRings(player, -num_rings);
|
spill_total = -P_GivePlayerRings(player, -num_rings);
|
||||||
num_fling_rings = num_rings+min(0, player->rings);
|
num_fling_rings = spill_total + min(0, player->rings);
|
||||||
|
|
||||||
// determine first angle
|
// determine first angle
|
||||||
fa = player->mo->angle + ((P_RandomByte(PR_ITEM_RINGS) & 1) ? -ANGLE_90 : ANGLE_90);
|
fa = player->mo->angle + ((P_RandomByte(PR_ITEM_RINGS) & 1) ? -ANGLE_90 : ANGLE_90);
|
||||||
|
|
@ -2922,7 +2912,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings)
|
||||||
P_FlingBurst(player, fa, MT_FLINGRING, 60*TICRATE, FRACUNIT, i);
|
P_FlingBurst(player, fa, MT_FLINGRING, 60*TICRATE, FRACUNIT, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < num_rings)
|
while (i < spill_total)
|
||||||
{
|
{
|
||||||
P_FlingBurst(player, fa, MT_DEBTSPIKE, 0, 3 * FRACUNIT / 2, i++);
|
P_FlingBurst(player, fa, MT_DEBTSPIKE, 0, 3 * FRACUNIT / 2, i++);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10031,6 +10031,14 @@ void P_MobjThinker(mobj_t *mobj)
|
||||||
|
|
||||||
if (mobj->player != NULL && mobj->hitlag == 0 && (mobj->eflags & MFE_DAMAGEHITLAG))
|
if (mobj->player != NULL && mobj->hitlag == 0 && (mobj->eflags & MFE_DAMAGEHITLAG))
|
||||||
{
|
{
|
||||||
|
if (mobj->player->ringburst > 0)
|
||||||
|
{
|
||||||
|
// Delayed ring loss
|
||||||
|
P_PlayRinglossSound(mobj);
|
||||||
|
P_PlayerRingBurst(mobj->player, mobj->player->ringburst);
|
||||||
|
mobj->player->ringburst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
K_HandleDirectionalInfluence(mobj->player);
|
K_HandleDirectionalInfluence(mobj->player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -468,6 +468,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
|
||||||
WRITEUINT16(save->p, players[i].superring);
|
WRITEUINT16(save->p, players[i].superring);
|
||||||
WRITEUINT8(save->p, players[i].nextringaward);
|
WRITEUINT8(save->p, players[i].nextringaward);
|
||||||
WRITEUINT8(save->p, players[i].ringvolume);
|
WRITEUINT8(save->p, players[i].ringvolume);
|
||||||
|
WRITEUINT16(save->p, players[i].ringburst);
|
||||||
|
|
||||||
WRITEUINT8(save->p, players[i].curshield);
|
WRITEUINT8(save->p, players[i].curshield);
|
||||||
WRITEUINT8(save->p, players[i].bubblecool);
|
WRITEUINT8(save->p, players[i].bubblecool);
|
||||||
|
|
@ -946,6 +947,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
|
||||||
players[i].superring = READUINT16(save->p);
|
players[i].superring = READUINT16(save->p);
|
||||||
players[i].nextringaward = READUINT8(save->p);
|
players[i].nextringaward = READUINT8(save->p);
|
||||||
players[i].ringvolume = READUINT8(save->p);
|
players[i].ringvolume = READUINT8(save->p);
|
||||||
|
players[i].ringburst = READUINT16(save->p);
|
||||||
|
|
||||||
players[i].curshield = READUINT8(save->p);
|
players[i].curshield = READUINT8(save->p);
|
||||||
players[i].bubblecool = READUINT8(save->p);
|
players[i].bubblecool = READUINT8(save->p);
|
||||||
|
|
|
||||||
10
src/sounds.c
10
src/sounds.c
|
|
@ -1210,6 +1210,16 @@ sfxinfo_t S_sfx[NUMSFX] =
|
||||||
|
|
||||||
{"rank", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Rank slam
|
{"rank", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Rank slam
|
||||||
|
|
||||||
|
// Damage sounds
|
||||||
|
{"dmga1", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
{"dmga2", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
{"dmga3", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
{"dmga4", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
{"dmgb1", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
{"dmgb2", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
{"dmgb3", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
{"dmgb4", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"},
|
||||||
|
|
||||||
// SRB2Kart - Engine sounds
|
// SRB2Kart - Engine sounds
|
||||||
// Engine class A
|
// Engine class A
|
||||||
{"krta00", false, 48, 65, -1, NULL, 0, -1, -1, LUMPERROR, ""},
|
{"krta00", false, 48, 65, -1, NULL, 0, -1, -1, LUMPERROR, ""},
|
||||||
|
|
|
||||||
10
src/sounds.h
10
src/sounds.h
|
|
@ -1279,6 +1279,16 @@ typedef enum
|
||||||
|
|
||||||
sfx_rank,
|
sfx_rank,
|
||||||
|
|
||||||
|
// Damage sounds
|
||||||
|
sfx_dmga1,
|
||||||
|
sfx_dmga2,
|
||||||
|
sfx_dmga3,
|
||||||
|
sfx_dmga4,
|
||||||
|
sfx_dmgb1,
|
||||||
|
sfx_dmgb2,
|
||||||
|
sfx_dmgb3,
|
||||||
|
sfx_dmgb4,
|
||||||
|
|
||||||
// Next up: UNIQUE ENGINE SOUNDS! Hoooooo boy...
|
// Next up: UNIQUE ENGINE SOUNDS! Hoooooo boy...
|
||||||
// Engine class A - Low Speed, Low Weight
|
// Engine class A - Low Speed, Low Weight
|
||||||
sfx_krta00,
|
sfx_krta00,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue