/* * Copyright (c) 2016-2020 Marco Cawthorne * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ class item_ammo:NSRenderableEntity { void(void) item_ammo; virtual void(void) Spawned; virtual void(void) Respawn; virtual void(entity) Touch; }; void item_ammo::Touch(entity eToucher) { if not (eToucher.flags & FL_CLIENT) { return; } player pl = (player)eToucher; Sound_Play(eToucher, CHAN_ITEM, "ammo.pickup"); Weapons_RefreshAmmo(pl); Logging_Pickup(eToucher, this, __NULL__); if (real_owner || cvar("sv_playerslots") == 1) { Destroy(); } else { Disappear(); ScheduleThink(Respawn, 30.0f); } } void item_ammo::Respawn(void) { SetSolid(SOLID_TRIGGER); SetMovetype(MOVETYPE_TOSS); SetOrigin(GetSpawnOrigin()); SetModel(GetSpawnModel()); SetSize([-16,-16,0],[16,16,16]); ReleaseThink(); if (real_owner && time > 30.0f) Sound_Play(this, CHAN_ITEM, "ammo.respawn"); droptofloor(); } void item_ammo::Spawned(void) { super::Spawned(); Sound_Precache("ammo.pickup"); Sound_Precache("ammo.respawn"); precache_model(model); } void item_ammo::item_ammo(void) { m_oldModel = model; } /*QUAKED item_shells (0 0 0.8) (-16 -16 0) (16 16 32) HALF-LIFE (1998) ENTITY Ammo for the .357 Magnum Revolver. A single ammo_shells will provide 6 bullets. -------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- model="models/w_357ammobox.mdl" */ class item_shells:item_ammo { void(void) item_shells; virtual void(entity) Touch; }; void item_shells::item_shells(void) { model = "models/w_shotbox_big.mdl"; } void item_shells::Touch(entity eToucher) { if not (eToucher.flags & FL_CLIENT) { return; } if (eToucher.classname == "player") { player pl = (player)eToucher; if (pl.ammo_shells < MAX_A_SHELLS) { pl.ammo_shells = bound(0, pl.ammo_shells + 6, MAX_A_SHELLS); item_ammo::Touch(eToucher); } } } /*QUAKED item_spikes (0 0 0.8) (-16 -16 0) (16 16 32) HALF-LIFE (1998) ENTITY Ammo for the .357 Magnum Revolver. A single ammo_nails will provide 6 bullets. -------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- model="models/w_357ammobox.mdl" */ class item_spikes:item_ammo { void(void) item_spikes; virtual void(entity) Touch; }; void item_spikes::item_spikes(void) { model = "models/b_nail1.mdl"; } void item_spikes::Touch(entity eToucher) { if not (eToucher.flags & FL_CLIENT) { return; } if (eToucher.classname == "player") { player pl = (player)eToucher; if (pl.ammo_nails < MAX_A_NAILS) { pl.ammo_nails = bound(0, pl.ammo_nails + 6, MAX_A_NAILS); item_ammo::Touch(eToucher); } } } /*QUAKED item_rockets (0 0 0.8) (-16 -16 0) (16 16 32) HALF-LIFE (1998) ENTITY Ammo for the .357 Magnum Revolver. A single ammo_rockets will provide 6 bullets. -------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- model="models/w_357ammobox.mdl" */ class item_rockets:item_ammo { void(void) item_rockets; virtual void(entity) Touch; }; void item_rockets::item_rockets(void) { model = "models/w_rpgammo.mdl"; } void item_rockets::Touch(entity eToucher) { if not (eToucher.flags & FL_CLIENT) { return; } if (eToucher.classname == "player") { player pl = (player)eToucher; if (pl.ammo_rockets < MAX_A_ROCKETS) { pl.ammo_rockets = bound(0, pl.ammo_rockets + 6, MAX_A_ROCKETS); item_ammo::Touch(eToucher); } } } /*QUAKED item_cells (0 0 0.8) (-16 -16 0) (16 16 32) HALF-LIFE (1998) ENTITY Ammo for the .357 Magnum Revolver. A single ammo_cells will provide 6 bullets. -------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- model="models/w_357ammobox.mdl" */ class item_cells:item_ammo { void(void) item_cells; virtual void(entity) Touch; }; void item_cells::item_cells(void) { model = "models/w_battery.mdl"; } void item_cells::Touch(entity eToucher) { if not (eToucher.flags & FL_CLIENT) { return; } if (eToucher.classname == "player") { player pl = (player)eToucher; if (pl.ammo_cells < MAX_A_CELLS) { pl.ammo_cells = bound(0, pl.ammo_cells + 6, MAX_A_CELLS); item_ammo::Touch(eToucher); } } }