Skip to content

Commit

Permalink
Clean up key consumption a little and make players keep their key if …
Browse files Browse the repository at this point in the history
…in a QDoom level
  • Loading branch information
MarioSMB committed Oct 31, 2024
1 parent 2a2d29e commit fc1526d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 49 deletions.
11 changes: 3 additions & 8 deletions mod/quake/common/triggers/func/button.qc
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,9 @@ void button_touch(entity this, entity toucher)
}
else
{
// Yoder Sept24, 2021 Horde merge
if(horde_ent || autocvar_sv_quake_globalkeys)
{
horde_key_spend(this.items);
settouch(this, func_null);
}
else // standard behaviour
toucher.items &= ~this.items;
key_spend(toucher, this.items);

settouch(this, func_null);
}
}
this.enemy = toucher;
Expand Down
9 changes: 1 addition & 8 deletions mod/quake/common/triggers/func/door.qc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#ifdef SVQC

//Yoder Sept24 Horde Merge
void horde_key_spend(int key_item);

/*
Doors are similar to buttons, but can spawn a fat trigger field around them
Expand Down Expand Up @@ -354,11 +351,7 @@ void door_touch(entity this, entity toucher)
return;
}

// Yoder sept24, 2021, horde merge
if(horde_ent || autocvar_sv_quake_globalkeys)
horde_key_spend(this.owner.items);
else // standard behaviour
toucher.items &= ~this.owner.items;
key_spend(toucher, this.owner.items);
settouch(this.owner, func_null);
entity t = this.owner.enemy;
while(t != this.owner)// get paired doors
Expand Down
5 changes: 1 addition & 4 deletions mod/quake/common/triggers/trigger/usekey.qc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ void keytrigger_use(entity this, entity actor, entity trigger)
return;
}

if(horde_ent || autocvar_sv_quake_globalkeys)
horde_key_spend(this.items);
else
actor.items &= ~this.items;
key_spend(actor, this.items);

// we can't just remove (this) here, because this is a touch function
// called while C code is looping through area links...
Expand Down
48 changes: 19 additions & 29 deletions mod/quake/server/items.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,21 @@ void key_setsounds(entity this)
}
}

void key_spend(entity player, int key_item)
{
// attempt to catch QDoom levels which do not consume keys
if(substring(world.model, -7, 7) == "_q1.bsp")
return; // keep the key!

// Yoder Sept24, 2021 Horde merge
if(horde_ent || autocvar_sv_quake_globalkeys)
{
horde_key_spend(key_item);
}
else // standard behaviour
player.items &= ~key_item;
}

/*QUAKED item_key1(0 .5 .8)(-16 -16 -24)(16 16 32)
SILVER key
In order for keys to work
Expand Down Expand Up @@ -2990,23 +3005,11 @@ bool target_items_takeinv(entity this, entity e, entity actor)

if(it & IT_KEY1)
{
if(autocvar_sv_quake_globalkeys)
{
horde_key_spend(IT_KEY1);
//delete(this);
}
else
e.items &= ~IT_KEY1;
key_spend(e, IT_KEY1);
}
if(it & IT_KEY2)
{
if(autocvar_sv_quake_globalkeys)
{
horde_key_spend(IT_KEY2);
//delete(this);
}
else
e.items &= ~IT_KEY2;
key_spend(e, IT_KEY2);
}
}

Expand Down Expand Up @@ -3080,21 +3083,8 @@ void target_items_setinv(entity this, entity e, entity actor)
else
StatusEffects_remove(STATUSEFFECT_Quad, e, STATUSEFFECT_REMOVE_CLEAR);

if(autocvar_sv_quake_globalkeys)
{
horde_key_spend(IT_KEY1);
//delete(this);
}
else
e.items &= ~IT_KEY1;

if(autocvar_sv_quake_globalkeys)
{
horde_key_spend(IT_KEY2);
//delete(this);
}
else
e.items &= ~IT_KEY2;
key_spend(e, IT_KEY1);
key_spend(e, IT_KEY2);

e.worldtype = 0;
if(it & IT_KEY1)
Expand Down
2 changes: 2 additions & 0 deletions mod/quake/server/items.qh
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ bool T_Heal(entity e, float healamount, bool ignore);
void bound_other_ammo(entity this);

int GetAmmoLimit(entity this, int itemid);

void key_spend(entity player, int key_item);

0 comments on commit fc1526d

Please sign in to comment.