Skip to content

Commit

Permalink
game: Implement breakable map entities
Browse files Browse the repository at this point in the history
  • Loading branch information
LegendaryGuard committed Jul 4, 2024
1 parent c6f1ad6 commit 714c117
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ A legendary 90s era Quake 3 Arena mod.
- [x] ~~Bind key to toggle speed (ki boost). HINT: HASTE POWERUP~~
- [x] ~~Replace ammo to ki energy stamina~~
- [x] ~~Third person traceable crosshair~~
- [x] ~~Breakable map entities ("func_breakable")~~
- [ ] Make ki energy regeneration, ki use, attacks, charging balance indicated on old docs
- [ ] Powerlevel and Power Tiers indicated on old docs
- [x] ~~Hit Stun (makes player can't use ki, melee, block and charge)~~
Expand Down
8 changes: 8 additions & 0 deletions source/game/g_combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,14 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
if ( targ->use && targ->moverState == MOVER_POS1 ) {
targ->use( targ, inflictor, attacker );
}
// BFP - For breakable map entities
if ( targ->takedamage && targ->health > 0 ) {
if ( damage < 1 ) {
damage = 1;
}
take = damage;
targ->health = targ->health - take;
}
return;
}
// reduce damage by the attacker's handicap value
Expand Down
17 changes: 17 additions & 0 deletions source/game/g_mover.c
Original file line number Diff line number Diff line change
Expand Up @@ -1574,3 +1574,20 @@ void SP_func_pendulum(gentity_t *ent) {
ent->s.apos.trType = TR_SINE;
ent->s.apos.trDelta[2] = speed;
}


// BFP - Breakable map entities
void func_breakable_use( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
if ( ent->health <= 0 ) {
G_FreeEntity( ent );
}
}

void SP_func_breakable( gentity_t *ent ) {
trap_SetBrushModel( ent, ent->model );
ent->s.eType = ET_MOVER;
ent->r.contents = CONTENTS_SOLID;
ent->health = 100;
ent->takedamage = qtrue;
ent->use = func_breakable_use;
}
4 changes: 3 additions & 1 deletion source/game/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void SP_func_button (gentity_t *ent);
void SP_func_door (gentity_t *ent);
void SP_func_train (gentity_t *ent);
void SP_func_timer (gentity_t *self);
void SP_func_breakable (gentity_t *ent); // BFP - Breakable map entities

void SP_trigger_always (gentity_t *ent);
void SP_trigger_multiple (gentity_t *ent);
Expand Down Expand Up @@ -186,7 +187,7 @@ void SP_team_CTF_blueplayer( gentity_t *ent );
void SP_team_CTF_redspawn( gentity_t *ent );
void SP_team_CTF_bluespawn( gentity_t *ent );

void SP_item_botroam( gentity_t *ent ) {};
void SP_item_botroam( gentity_t *ent ) { (void)ent; }

spawn_t spawns[] = {
// info entities don't do anything at all, but provide positional
Expand All @@ -207,6 +208,7 @@ spawn_t spawns[] = {
{"func_pendulum", SP_func_pendulum},
{"func_train", SP_func_train},
{"func_group", SP_info_null},
{"func_breakable", SP_func_breakable}, // BFP - Breakable map entities
{"func_timer", SP_func_timer}, // rename trigger_timer?

// Triggers are brush objects that cause an effect when contacted
Expand Down
6 changes: 6 additions & 0 deletions source/game/g_weapon.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ qboolean CheckMeleeAttack( gentity_t *attacker ) { // BFP - Melee
return qfalse;
}

// avoid if the entity isn't a player (e.g. a breakable map entity)
if ( traceTarget->s.eType != ET_PLAYER ) {
attacker->client->ps.pm_flags &= ~PMF_MELEE;
return qfalse;
}

// the target's corpse is starting to sink, avoid interacting with a sinking corpse, nothing special happens
if ( traceTarget->physicsObject ) {
attacker->client->ps.pm_flags &= ~PMF_MELEE;
Expand Down

0 comments on commit 714c117

Please sign in to comment.