djcev.com

//

Git Repos / fte_dogmode / qc / triggers / usekey.qc

Last update to this file was on 2024-03-24 at 02:40.

Show usekey.qc

//==============================================================================
// trigger_usekey
//==============================================================================

/*
Trigger QuickC program
By Jim Dose' 12/2/96
Copyright (c)1996 Hipnotic Interactive, Inc.
All rights reserved.
Distributed (unsupported) on 3.12.97
*/

//======================================================================
// constants
//======================================================================

const float TRIGGER_USEKEY_SILV_KEY = 8;
const float TRIGGER_USEKEY_GOLD_KEY = 16;

//======================================================================
// forward declarations
//======================================================================

void() trigger_usekey_unlock;
void() trigger_usekey_use;
void() trigger_usekey_touch;
void(entity e) trigger_usekey_init;
void() trigger_usekey;

//------------------------------------------------------------------------------

/*
QUAKED trigger_usekey (0 .5 0) ? X X X
TRIGGER_USEKEY_SILV_KEY TRIGGER_USEKEY_GOLD_KEY X X X
NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH
NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Variable sized single use trigger that requires a key to trigger
targets. Must be targeted at one or more entities.

"cnt" if 1, leave a used key in the player's inventory (0 default).
"keyname" if set, this is the keyname of the item_key_custom which unlocks
this entity.
"message" is printed when the trigger is touched without having the right key.
"noise1" sound file for the "key required" sound (default is per worldtype).
"noise2" sound file for the "key used" sound (default is per worldtype).
*/
//----------------------------------------------------------------------
// class trigger_usekey: base_trigger
// {
//--------------------------------------------------------------
// trigger_usekey_unlock
//
// Perform the actions which should be performed when self is
// successfully unlocked with a key.
//
// This function exists so that it can be passed as an argument
// to the new keylock_try_to_unlock function. This code was
// previously part of the trigger_usekey_use function. -- iw
//--------------------------------------------------------------
void() trigger_usekey_unlock =
{
// we can't just remove (self) here, because this is a
// touch function called while C code is looping through
// area links...
self.message = "";

sub_usetargets ();

self.think = sub_remove;
self.touch = sub_null;
self.use = sub_null;
self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
void() trigger_usekey_use =
{
// from Copper -- dumptruck_ds
if (sub_checkvalidtouch(other) == FALSE)
return;

if (self.attack_finished > time)
return;

self.attack_finished = time + 2;
keylock_try_to_unlock (other, self.message,
trigger_usekey_unlock);
};

//--------------------------------------------------------------
void() trigger_usekey_touch =
{
trigger_usekey_use ();
};

//--------------------------------------------------------------
void(entity e) trigger_usekey_init =
{
e.classname = "trigger_usekey";
e.classtype = CT_TRIGGER_USEKEY;

// the keylock_* functions use self.noise3 and self.noise4
// internally, but trigger_usekey doesn't use the self.noise1
// or self.noise2 fields for anything, so we allow the mapper
// to specify custom sound files by setting self.noise1 and
// self.noise2, but we move those values into self.noise3 and
// self.noise4 -- iw
e.noise3 = e.noise1;
e.noise4 = e.noise2;
e.noise1 = "";
e.noise2 = "";

keylock_init (e);

if (e.spawnflags & TRIGGER_USEKEY_SILV_KEY)
{
// dumptruck_ds
keylock_set_silver_key (e);

if (e.keyname != "")
{
e.netname = e.keyname;
e.keyname = "";
}
}

if (e.spawnflags & TRIGGER_USEKEY_GOLD_KEY)
{
// dumptruck_ds
keylock_set_gold_key (e);

if (e.keyname != "")
{
e.netname = e.keyname;
e.keyname = "";
}
}

// support for item_key_custom -- iw
if (e.keyname != "")
{
keylock_set_custom_key (e, e.keyname);
// this should not be referenced again
e.keyname = "";
}

if (!keylock_has_key_set(e))
{
objerror ("no key specified!");
return;
}

e.touch = trigger_usekey_touch;
e.use = trigger_usekey_use;

base_trigger_init (e);
sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_usekey =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trigger_usekey_init (self);
};
// };

Return to the top of this page or return to the overview of this repo.

Log usekey.qc

Date Commit Message Author + -
2024-03-24 2nd pass refactor, rework QC class structure cev +68 -52
2024-01-31 Class based monster refactor & start projectiles cev +3 -3
2024-01-09 Continue OO / Class-based refactor cev +31 -24
2023-12-09 Start OO / class-based refactor, work on items cev +117 -100
2023-11-20 changes to movement, build environment, file reorg cev +130  

Return to the top of this page or return to the overview of this repo.