Git Repos / fte_dogmode / qc / items / backpacks.qc
Last update to this file was on 2024-11-20 at 23:54.
Show backpacks.qc
//==============================================================================
// backpacks -- Player Backpacks
//==============================================================================
//======================================================================
// constants -- dumptruck_ds
//======================================================================
#ifdef SSQC
const float BACKPACK_DEFAULT = 1;
const float BACKPACK_SHELLS = 2;
const float BACKPACK_NAILS = 4;
const float BACKPACK_ROCKETS = 8;
const float BACKPACK_CELLS = 16;
const float BACKPACK_DROPPED = 32;
#endif
//======================================================================
// forward declarations
//======================================================================
#ifdef SSQC
// item_backpack
void() item_backpack_touch;
entity(entity src) item_backpack_drop;
entity(entity src, vector org, vector vel) spawn_item_backpack;
void(entity e) item_backpack_init;
void() item_backpack;
#endif
//------------------------------------------------------------------------------
// Some of this text is from Drake -- dumptruck_ds
#ifdef SSQC
/*QUAKED item_backpack (0 .5 .8) (-16 -16 0) (16 16 72) SHELLS NAILS ROCKETS CELLS X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR 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
{ model("progs/backpack.mdl"); }
By default, gives roughly half the ammo from the 4 standard pickups:
10 Shells
12 Nails
2 Rockets
3 Cells
Or you can use the spawnflags to mix and match types.
Override the spawnflags defaults by adding custom amounts to:
ammo_shells
ammo_nails
ammo_rockets
ammo_cells
Can trigger spawn and suspend in air, but not respawn. You can set a skin
index if you are using a custom model with skins.
The default pickup message is `You got a backpack.` But you can
set a custom message with the netname key. 'You got' will be the prefix
and the mapper chooses the rest of the message.
e.g. For 'You got a bunch of rockets!' the netname key would be
'a bunch of rockets!'
*/
//----------------------------------------------------------------------
// class item_backpack: base_item
// {
//--------------------------------------------------------------
void() item_backpack_touch =
{
if (sub_checkvalidtouch(other) == FALSE)
return;
// from Copper -- dumptruck_ds
if (other.movetype == MOVETYPE_NOCLIP)
return;
if (other.classtype != CT_PLAYER)
return;
if (other.health <= 0)
return;
if (self.spawnflags & BACKPACK_DROPPED)
{
local string s;
local float acount, best, old, new;
acount = 0;
sprint (other, "You get ");
if (self.items)
{
if ((other.items & self.items) == 0)
{
acount = 1;
sprint (other, "the ");
sprint (other, self.netname);
}
}
// if the player was using his best weapon, change
// up to the new one if better
if (other.classtype == CT_PLAYER &&
autocvar(cg_autoswitch, TRUE))
{
best = sub_runfloatas (other,
player_best_weapon);
}
// change weapons
other.ammo_shells += self.ammo_shells;
other.ammo_nails += self.ammo_nails;
other.ammo_rockets += self.ammo_rockets;
other.ammo_cells += self.ammo_cells;
new = self.items;
if (!new)
new = other.weapon;
old = other.items;
other.items = other.items | new;
bound_entity_ammo (other);
// hack to fix an issue with custom Grunt, Ogre
// and Enf ammo types. - dumptruck_ds
// if (self.ammo_shells < 100)
if (self.ammo_shells)
{
if (acount)
sprint (other, ", ");
acount = 1;
s = ftos (self.ammo_shells);
sprint (other, s);
sprint (other, " shells");
}
if (self.ammo_nails)
{
if (acount)
sprint (other, ", ");
acount = 1;
s = ftos (self.ammo_nails);
sprint (other, s);
sprint (other, " nails");
}
if (self.ammo_rockets)
{
if (acount)
sprint (other, ", ");
acount = 1;
s = ftos (self.ammo_rockets);
sprint (other, s);
sprint (other, " rockets");
}
if (self.ammo_cells)
{
if (acount)
sprint (other, ", ");
acount = 1;
s = ftos (self.ammo_cells);
sprint (other, s);
sprint (other, " cells");
}
sprint (other, "\n");
// backpack touch sound
sound (other, CHAN_ITEM, "items/backpack_pickup.wav",
VOL_HIGH, ATTN_NORM);
stuffcmd (other, "bf\n");
if (other.classtype == CT_PLAYER)
{
// change to the weapon
// 1997-12-23 Thunderbolt fix by Maddes start
/*
// don't separate between SinglePlayer/Coop
// and Deathmatch
if (!deathmatch)
self.weapon = new;
else
*/
// 1997-12-23 Thunderbolt fix by Maddes end
/*
// TODO CEV
self = other;
Deathmatch_Weapon (old, new);
PlayerSetCurrentAmmo ();
*/
sub_runvoidas (other, player_set_current_ammo);
}
// remove the backpack, change self to the player
remove (self);
}
else
{
// item_backpack_message -- CEV
other.ammo_shells += self.ammo_shells;
other.ammo_nails += self.ammo_nails;
other.ammo_rockets += self.ammo_rockets;
other.ammo_cells += self.ammo_cells;
if (self.netname != "")
{
sprint (other, "You got ");
sprint (other, self.netname);
sprint (other, "\n");
}
else
{
sprint (other, "You got a backpack!\n");
}
// backpack touch sound
// sound (other, CHAN_ITEM, "items/backpack_pickup.wav",
// VOL_HIGH, ATTN_NORM);
sound_misc (other, CHAN_ITEM, self.snd_misc,
VOL_HIGH, ATTN_NORM);
remove (self);
if (other.classtype == CT_PLAYER)
{
stuffcmd (other, "bf\n");
bound_entity_ammo (other);
sub_runvoidas (other, player_set_current_ammo);
}
}
};
//--------------------------------------------------------------
// DropBackpack
//--------------------------------------------------------------
entity(entity src) item_backpack_drop =
{
local entity pack = __NULL__;
local vector vel;
if (src.ammo_shells + src.ammo_nails + src.ammo_rockets +
src.ammo_cells <= 0)
{
// nothing in it
dprint ("item_backpack_drop: empty pack!\n");
return pack;
}
vel_z = 300;
vel_x = -100 + (random() * 200);
vel_y = -100 + (random() * 200);
pack = spawn_item_backpack (src, src.origin - '0 0 24', vel);
if (pack.items == IT_AXE)
pack.netname = "Axe";
else if (pack.items == IT_SHOTGUN)
pack.netname = "Shotgun";
else if (pack.items == IT_SUPER_SHOTGUN)
pack.netname = "Double-barrelled Shotgun";
else if (pack.items == IT_NAILGUN)
pack.netname = "Nailgun";
else if (pack.items == IT_SUPER_NAILGUN)
pack.netname = "Super Nailgun";
else if (pack.items == IT_GRENADE_LAUNCHER)
pack.netname = "Grenade Launcher";
else if (pack.items == IT_ROCKET_LAUNCHER)
pack.netname = "Rocket Launcher";
else if (pack.items == IT_LIGHTNING)
pack.netname = "Thunderbolt";
else
pack.netname = "";
return pack;
};
//--------------------------------------------------------------
entity(entity src, vector org, vector vel) spawn_item_backpack =
{
local entity e = spawn ();
e.owner = src;
e.origin = org;
e.spawnflags = BACKPACK_DROPPED,
e.items = src.weapon;
e.ammo_shells = src.ammo_shells;
e.ammo_nails = src.ammo_nails;
e.ammo_rockets = src.ammo_rockets;
e.ammo_cells = src.ammo_cells;
item_backpack_init (e);
return e;
};
//--------------------------------------------------------------
void(entity e) item_backpack_init =
{
e.classname = "item_backpack";
e.classtype = CT_ITEM_BACKPACK;
e.touch = item_backpack_touch;
e.flags = FL_ITEM;
e.solid = SOLID_TRIGGER;
e.movetype = MOVETYPE_TOSS;
if !(e.spawnflags)
{
objerror ("\bitem_backpack_init: NO SPAWNFLAG SET "
"ON item_backpack");
return;
}
if (e.spawnflags & BACKPACK_DEFAULT)
{
e.ammo_shells = 10;
e.ammo_nails = 12;
e.ammo_rockets = 2;
e.ammo_cells = 3;
}
if (e.spawnflags & BACKPACK_SHELLS)
{
if (!e.ammo_shells)
e.ammo_shells = 10;
}
if (e.spawnflags & BACKPACK_NAILS)
{
if (!e.ammo_nails)
e.ammo_nails = 12;
}
if (e.spawnflags & BACKPACK_ROCKETS)
{
if (!e.ammo_rockets)
e.ammo_rockets = 2;
}
if (e.spawnflags & BACKPACK_CELLS)
{
if (!e.ammo_cells)
e.ammo_cells = 3;
}
// set the custom noise in editor -- dumptruck_ds
if (!e.snd_misc)
e.snd_misc = "items/backpack_pickup.wav";
precache_sound_misc (e, e.snd_misc);
if (e.spawnflags & BACKPACK_DROPPED)
{
precache_body_model (e, "progs/backpack.mdl");
// setmodel (e, "progs/backpack.mdl");
body_model (e, "progs/backpack.mdl");
}
else
{
precache_body_model (e, "progs/pd_bpack.mdl");
body_model (e, "progs/pd_bpack.mdl");
}
// setmodel (e, "progs/backpack.mdl");
e.pos1 = '-16 -16 0';
e.pos2 = '16 16 56';
// StartItem
if (e.spawnflags & BACKPACK_DROPPED)
{
// don't delay, spawn immediately -- CEV
setsize (e, e.pos1, e.pos2);
e.think = sub_remove;
e.nextthink = time + 120;
}
else
{
setsize (e, e.pos1, e.pos2);
base_item_init (e);
}
};
//--------------------------------------------------------------
void() item_backpack =
{
item_backpack_init (self);
};
// };
#endif
Return to the top of this page or return to the overview of this repo.
Log backpacks.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-11-20 | pmove refactor into prepoc macros, view bobbing | cev | +12 | -13 |
2024-07-17 | pmove changes, smooth crouching | cev | -1 | |
2024-06-15 | Major update, committing as-is, will have bugs | cev | +12 | -6 |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +193 | -316 |
2024-02-18 | Client/player, projectiles, entrypoints refactor | cev | +46 | -49 |
2024-01-31 | Class based monster refactor & start projectiles | cev | +43 | -32 |
2024-01-13 | Refactored items into classes, fix teleporttrain | cev | +318 | -345 |
2024-01-09 | Continue OO / Class-based refactor | cev | +1 | -1 |
2023-12-09 | Start OO / class-based refactor, work on items | cev | +34 | -21 |
2023-12-02 | More refactoring & moving, begin adding mdls & snd | cev | +501 |
Return to the top of this page or return to the overview of this repo.