Skip to content

Commit

Permalink
mod: add suicide dead anim and explosion pain anim
Browse files Browse the repository at this point in the history
  • Loading branch information
Aranud committed Aug 13, 2019
1 parent 881d001 commit 9ef41c2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
4 changes: 2 additions & 2 deletions etmain/animations/human/base/body.aninc
Expand Up @@ -6,9 +6,9 @@
death_rifle_head_2 33 52 0 20 0 0 0
dead_rifle_head_2 84 1 1 20 0 0 0
death_machinegun_2 85 38 0 20 0 0 0
dead_machinegun_2 122 1 1 20 0 0 0
dead_machinegun_2 122 1 1 20 0 0 0 // same as dead_machinegun_1
death_gut 130 41 0 20 0 0 0
dead_gut 170 1 1 20 0 0 0
dead_gut 170 1 1 20 0 0 0 // same as dead_machinegun_1

wounded_idle_1 173 144 144 20 0 0 0

Expand Down
10 changes: 10 additions & 0 deletions etmain/animations/scripts/human_base.script
Expand Up @@ -94,6 +94,11 @@ STATE COMBAT
{
dead
{
suicide
{
both dead_rifle_head_2
}

default
{
both dead_machinegun_1
Expand Down Expand Up @@ -3041,6 +3046,11 @@ climbdismount

DEATH
{
suicide
{
both death_rifle_head_2
}

enemy_weapon knives, enemy_position behind
{
both death_machinegun_1
Expand Down
2 changes: 2 additions & 0 deletions src/cgame/cg_players.c
Expand Up @@ -2472,6 +2472,8 @@ void CG_AnimPlayerConditions(bg_character_t *character, centity_t *cent)
}

BG_UpdateConditionValue(es->clientNum, ANIM_COND_IMPACT_POINT, IMPACTPOINT_UNUSED, qtrue);
BG_UpdateConditionValue(es->clientNum, ANIM_COND_STUNNED, 0, qtrue);
BG_UpdateConditionValue(es->clientNum, ANIM_COND_SUICIDE, 0, qtrue);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/game/bg_animation.c
Expand Up @@ -256,7 +256,7 @@ typedef struct
animStringItem_t *values;
} animConditionTable_t;

static animStringItem_t animConditionsStr[] =
static animStringItem_t animConditionsStr[NUM_ANIM_CONDITIONS + 1] =
{
{ "WEAPONS", -1 },
{ "ENEMY_POSITION", -1 },
Expand All @@ -279,6 +279,7 @@ static animStringItem_t animConditionsStr[] =
{ "FLAILING_TYPE", -1 },
{ "GEN_BITFLAG", -1 },
{ "AISTATE", -1 },
{ "SUICIDE", -1 },

{ NULL, -1 },
};
Expand Down Expand Up @@ -306,6 +307,7 @@ static animConditionTable_t animConditionsTable[NUM_ANIM_CONDITIONS] =
{ ANIM_CONDTYPE_VALUE, animFlailTypeStr },
{ ANIM_CONDTYPE_BITFLAGS, animGenBitFlagStr },
{ ANIM_CONDTYPE_VALUE, animAIStateStr },
{ ANIM_CONDTYPE_VALUE, NULL },
};

//------------------------------------------------------------
Expand Down Expand Up @@ -1997,4 +1999,6 @@ void BG_AnimUpdatePlayerStateConditions(pmove_t *pmove)
}

BG_UpdateConditionValue(ps->clientNum, ANIM_COND_IMPACT_POINT, IMPACTPOINT_UNUSED, qtrue);
BG_UpdateConditionValue(ps->clientNum, ANIM_COND_STUNNED, 0, qtrue);
BG_UpdateConditionValue(ps->clientNum, ANIM_COND_SUICIDE, 0, qtrue);
}
9 changes: 5 additions & 4 deletions src/game/bg_public.h
Expand Up @@ -619,7 +619,7 @@ typedef struct

// callbacks to test the world
// these will be different functions during game and cgame
void (*trace)(trace_t * results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask);
void (*trace)(trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask);
int (*pointcontents)(const vec3_t point, int passEntityNum);

/// used to determine if the player move is for prediction if it is, the movement should trigger no events
Expand All @@ -628,7 +628,7 @@ typedef struct
} pmove_t;

// if a full pmove isn't done on the client, you can just update the angles
void PM_UpdateViewAngles(playerState_t *ps, pmoveExt_t *pmext, usercmd_t *cmd, void (trace) (trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int tracemask);
void PM_UpdateViewAngles(playerState_t *ps, pmoveExt_t *pmext, usercmd_t *cmd, void(trace) (trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int tracemask);
int Pmove(pmove_t *pmove);
void PmovePredict(pmove_t *pmove, float frametime);

Expand Down Expand Up @@ -2186,6 +2186,7 @@ typedef enum
ANIM_COND_FLAILING_TYPE,
ANIM_COND_GEN_BITFLAG, ///< general bit flags (to save some space)
ANIM_COND_AISTATE, ///< our current ai state (sometimes more convenient than creating a separate section)
ANIM_COND_SUICIDE,

NUM_ANIM_CONDITIONS
} scriptAnimConditions_t;
Expand Down Expand Up @@ -2903,8 +2904,8 @@ typedef enum popupMessageBigType_e
#define HITBOXBIT_LEGS 2048
#define HITBOXBIT_CLIENT 4096

void PM_TraceLegs(trace_t *trace, float *legsOffset, vec3_t start, vec3_t end, trace_t *bodytrace, vec3_t viewangles, void (tracefunc)(trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int ignoreent, int tracemask);
void PM_TraceHead(trace_t *trace, vec3_t start, vec3_t end, trace_t *bodytrace, vec3_t viewangles, void (tracefunc)(trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int ignoreent, int tracemask);
void PM_TraceLegs(trace_t *trace, float *legsOffset, vec3_t start, vec3_t end, trace_t *bodytrace, vec3_t viewangles, void(tracefunc)(trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int ignoreent, int tracemask);
void PM_TraceHead(trace_t *trace, vec3_t start, vec3_t end, trace_t *bodytrace, vec3_t viewangles, void(tracefunc)(trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int ignoreent, int tracemask);
void PM_TraceAllParts(trace_t *trace, float *legsOffset, vec3_t start, vec3_t end);
void PM_TraceAll(trace_t *trace, vec3_t start, vec3_t end);

Expand Down
20 changes: 15 additions & 5 deletions src/game/g_combat.c
Expand Up @@ -636,6 +636,9 @@ void player_die(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
// set enemy location
BG_UpdateConditionValue(self->s.number, ANIM_COND_ENEMY_POSITION, 0, qfalse);

// play specific anim on suicide
BG_UpdateConditionValue(self->s.number, ANIM_COND_SUICIDE, meansOfDeath == MOD_SUICIDE, qtrue);

// FIXME: add POSITION_RIGHT, POSITION_LEFT
if (infront(self, inflictor))
{
Expand Down Expand Up @@ -1537,13 +1540,20 @@ void G_Damage(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t
BG_UpdateConditionValue(targ->client->ps.clientNum, ANIM_COND_IMPACT_POINT, (rand() + 1) ? IMPACTPOINT_SHOULDER_RIGHT : IMPACTPOINT_SHOULDER_LEFT, qtrue);
BG_AnimScriptEvent(&targ->client->ps, targ->client->pers.character->animModelInfo, ANIM_ET_PAIN, qfalse, qtrue);
}
else if (targ->client && targ->health > 0 && GetMODTableData(mod)->isHeadshot)
else if (targ->client && targ->health > 0)
{
G_LogRegionHit(attacker, HR_BODY);
hr = HR_BODY;
if (g_debugBullets.integer)
if (GetMODTableData(mod)->isHeadshot)
{
G_LogRegionHit(attacker, HR_BODY);
hr = HR_BODY;
if (g_debugBullets.integer)
{
trap_SendServerCommand(attacker - g_entities, "print \"Body Shot\n\"");
}
}
else if (GetMODTableData(mod)->isExplosive)
{
trap_SendServerCommand(attacker - g_entities, "print \"Body Shot\n\"");
BG_UpdateConditionValue(targ->client->ps.clientNum, ANIM_COND_STUNNED, 1, qtrue);
}

BG_AnimScriptEvent(&targ->client->ps, targ->client->pers.character->animModelInfo, ANIM_ET_PAIN, qfalse, qtrue);
Expand Down

0 comments on commit 9ef41c2

Please sign in to comment.