djcev.com

//

Git Repos / fte_dogmode / qc / items / ammo.qc

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

Show ammo.qc

//==============================================================================
// AMMO -- was in items.qc
//==============================================================================

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

const float WEAPON_BIG2 = 1;

const float AMMO_RESPAWN_TIME = 30; // ammo respawn time; id1 30s
const float AMMO_CELLS_SMALL = 6; // id1 6; small box of cells
const float AMMO_CELLS_BIG = 12; // id1 12; large box of cells
const float AMMO_CELLS_MAX = 100; // id1 maximum 100
const float AMMO_NAILS_SMALL = 25; // id1 25; small box of nails
const float AMMO_NAILS_BIG = 50; // id1 50; large box of nails
const float AMMO_NAILS_MAX = 200; // id1 maximum 200
const float AMMO_ROCKETS_SMALL = 5; // id1 5; small box of rockets
const float AMMO_ROCKETS_BIG = 10; // id1 10; large box of rockets
const float AMMO_ROCKETS_MAX = 100; // id1 maximum 100
const float AMMO_SHELLS_SMALL = 20; // id1 20; small box of shells
const float AMMO_SHELLS_BIG = 40; // id1 40; large box of shells
const float AMMO_SHELLS_MAX = 100; // id1 maximum 100

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

// base_item_ammo
entity(entity src, vector org, float flags, void(entity) initfn)
spawn_item_ammo_n;
void() base_item_ammo_touch;
void(entity e) base_item_ammo_init;
strip void() base_item_ammo;

// item_shells
entity(entity src, vector org, float flags) spawn_item_shells;
void(entity e) item_shells_init;
void() item_shells;

// item_spikes
entity(entity src, vector org, float flags) spawn_item_spikes;
void(entity e) item_spikes_init;
void() item_spikes;

// item_rockets
entity(entity src, vector org, float flags) spawn_item_rockets;
void(entity e) item_rockets_init;
void() item_rockets;

// item_cells
entity(entity src, vector org, float flags) spawn_item_cells;
void(entity e) item_cells_init;
void() item_cells;

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

//----------------------------------------------------------------------
// class base_item_ammo: base_item
// {
//--------------------------------------------------------------
entity(entity src, vector org, float flags, void(entity) initfn)
spawn_item_ammo_n =
{
local entity e = spawn ();
e.owner = src;
e.origin = org;
e.spawnflags = flags;
initfn (e);
return e;
};

//--------------------------------------------------------------
// was ammo_touch -- CEV
//--------------------------------------------------------------
void() base_item_ammo_touch =
{
local float best = 0;

if (sub_checkvalidtouch(other) == FALSE)
return;

// 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);
}

// shotgun
if (self.weapon == 1)
{
if (other.ammo_shells >= AMMO_SHELLS_MAX)
return;
other.ammo_shells += self.aflag;
}

// spikes
if (self.weapon == 2)
{
if (other.ammo_nails >= AMMO_NAILS_MAX)
return;
other.ammo_nails += self.aflag;
}

// rockets
if (self.weapon == 3)
{
if (other.ammo_rockets >= AMMO_ROCKETS_MAX)
return;
other.ammo_rockets += self.aflag;
}

// cells
if (self.weapon == 4)
{
if (other.ammo_cells >= AMMO_CELLS_MAX)
return;
other.ammo_cells += self.aflag;
}

bound_entity_ammo (other);

sprint (other, sprintf("You got the %s\n", self.netname));
// ammo touch sound
sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");

// change to a better weapon if appropriate
if (other.classtype == CT_PLAYER && other.weapon == best &&
autocvar(cg_autoswitch, TRUE))
{
other.weapon = sub_runfloatas (other,
player_best_weapon);
sub_runvoidas (other, player_set_current_ammo);
}

// if changed current ammo, update it
if (other.classtype == CT_PLAYER)
{
sub_runvoidas (other, player_set_current_ammo);
}

// remove it in single player, or setup for respawning in DM
self.solid = SOLID_NOT;
self.model = __NULL__;
base_item_check_respawn (self,
AMMO_RESPAWN_TIME, AMMO_RESPAWN_TIME);

activator = other;
// fire all targets / killtargets
sub_usetargets ();
};

//--------------------------------------------------------------
void(entity e) base_item_ammo_init =
{
e.classgroup |= CG_ITEM_AMMO;
e.touch = base_item_ammo_touch;
base_item_init (e);
};

//--------------------------------------------------------------
strip void() base_item_ammo =
{
base_item_ammo_init (self);
};
// };

/*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X 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 RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ( {{ spawnflags & 1 -> { "path" : "maps/b_shell1.bsp" }, "maps/b_shell0.bsp" }} );
}
Box of 20 shells.
LARGE_BOX is a box of 40 shells.
*/
//----------------------------------------------------------------------
// class item_shells: base_item_ammo
// {
//--------------------------------------------------------------
entity(entity src, vector org, float flags) spawn_item_shells =
{
return spawn_item_ammo_n (src, org, flags, item_shells_init);
};

//--------------------------------------------------------------
void(entity e) item_shells_init =
{
e.classname = "item_shells";
e.classtype = CT_ITEM_AMMO_SHELLS;

if (e.spawnflags & WEAPON_BIG2)
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_shell2.mdl");
body_model (e, "progs/ammo/m_shell2.mdl");
}
else
{
precache_body_model (e, "maps/b_shell1.bsp");
body_model (e, "maps/b_shell1.bsp");
}

if !(e.particles_offset)
e.particles_offset = '16 16 16';
e.aflag = AMMO_SHELLS_BIG;
}
else
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_shell1.mdl");
body_model (e, "progs/ammo/m_shell1.mdl");
}
else
{
precache_body_model (e, "maps/b_shell0.bsp");
body_model (e, "maps/b_shell0.bsp");
}

if !(e.particles_offset)
e.particles_offset = '12 12 12';
e.aflag = AMMO_SHELLS_SMALL;
}

e.weapon = 1;
e.netname = "shells";
e.pos1 = '0 0 0';
e.pos2 = '32 32 56';

// StartItem
base_item_ammo_init (e);
};

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

item_shells_init (self);
};
// };

/*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X 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 RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ( {{ spawnflags & 1 -> { "path" : "maps/b_nail1.bsp" }, "maps/b_nail0.bsp" }} );
}
Box of 25 nails.
LARGE_BOX is a box of 50 nails.
*/
//----------------------------------------------------------------------
// class item_spikes: base_item_ammo
// {
//--------------------------------------------------------------
entity(entity src, vector org, float flags) spawn_item_spikes =
{
return spawn_item_ammo_n (src, org, flags, item_spikes_init);
};

//--------------------------------------------------------------
void(entity e) item_spikes_init =
{
e.classname = "item_spikes";
e.classtype = CT_ITEM_AMMO_SPIKES;
if (e.spawnflags & WEAPON_BIG2)
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_nails2.mdl");
body_model (e, "progs/ammo/m_nails2.mdl");
}
else
{
precache_body_model (e, "maps/b_nail1.bsp");
body_model (e, "maps/b_nail1.bsp");
}

if !(e.particles_offset)
e.particles_offset = '16 16 16';
e.aflag = AMMO_NAILS_BIG;
}
else
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_nails1.mdl");
body_model (e, "progs/ammo/m_nails1.mdl");
}
else
{
precache_body_model (e, "maps/b_nail0.bsp");
body_model (e, "maps/b_nail0.bsp");
}

if !(e.particles_offset)
e.particles_offset = '12 12 12';
e.aflag = AMMO_NAILS_SMALL;
}
e.weapon = 2;
e.netname = "nails";
e.pos1 = '0 0 0';
e.pos2 = '32 32 56';

// StartItem
base_item_ammo_init (e);
};

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

item_spikes_init (self);
};
// };

/*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X 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 RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ( {{ spawnflags & 1 -> { "path" : "maps/b_rock1.bsp" }, "maps/b_rock0.bsp" }} );
}
*/
//----------------------------------------------------------------------
// class item_rockets: base_item_ammo
// {
//--------------------------------------------------------------
entity(entity src, vector org, float flags) spawn_item_rockets =
{
return spawn_item_ammo_n (src, org, flags, item_rockets_init);
};

//--------------------------------------------------------------
void(entity e) item_rockets_init =
{
e.classname = "item_rockets";
e.classtype = CT_ITEM_AMMO_ROCKETS;
if (e.spawnflags & WEAPON_BIG2)
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_rock2.mdl");
body_model (e, "progs/ammo/m_rock2.mdl");
}
else
{
precache_body_model (e, "maps/b_rock1.bsp");
body_model (e, "maps/b_rock1.bsp");
}

e.particles_offset = '16 8 16';
e.aflag = AMMO_ROCKETS_BIG;
}
else
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_rock1.mdl");
body_model (e, "progs/ammo/m_rock1.mdl");
}
else
{
precache_body_model (e, "maps/b_rock0.bsp");
body_model (e, "maps/b_rock0.bsp");
}

if !(e.particles_offset)
e.particles_offset = '8 8 16';
e.aflag = AMMO_ROCKETS_SMALL;
}

e.weapon = 3;
e.netname = "rockets";
e.pos1 = '0 0 0';
e.pos2 = '32 32 56';

// StartItem
base_item_ammo_init (e);
};

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

item_rockets_init (self);
};
// };

/*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X 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 RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ( {{ spawnflags & 1 -> { "path" : "maps/b_batt1.bsp" }, "maps/b_batt0.bsp" }} );
}
Box of 6 cells.
LARGE_BOX is a box of 12 cells.
*/
//----------------------------------------------------------------------
// class item_cells: base_item_ammo
// {
//--------------------------------------------------------------
entity(entity src, vector org, float flags) spawn_item_cells =
{
return spawn_item_ammo_n (src, org, flags, item_cells_init);
};

//--------------------------------------------------------------
void(entity e) item_cells_init =
{
e.classname = "item_cells";
e.classtype = CT_ITEM_AMMO_CELLS;
if (e.spawnflags & WEAPON_BIG2)
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_cells2.mdl");
body_model (e, "progs/ammo/m_cells2.mdl");
}
else
{
precache_body_model (e, "maps/b_batt1.bsp");
body_model (e, "maps/b_batt1.bsp");
}

if !(e.particles_offset)
e.particles_offset = '16 16 16';
e.aflag = AMMO_CELLS_BIG;
}
else
{
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
precache_body_model (e,
"progs/ammo/m_cells2.mdl");
body_model (e, "progs/ammo/m_cells2.mdl");
}
else
{
precache_body_model (e, "maps/b_batt0.bsp");
body_model (e, "maps/b_batt0.bsp");
}

if !(e.particles_offset)
e.particles_offset = '12 12 12';
e.aflag = AMMO_CELLS_SMALL;
}

e.weapon = 4;
e.netname = "cells";
e.pos1 = '0 0 0';
e.pos2 = '32 32 56';

// StartItem
base_item_ammo_init (e);
};

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

item_cells_init (self);
};
// };

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

Log ammo.qc

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