105 lines
2.8 KiB
Plaintext
105 lines
2.8 KiB
Plaintext
/*
|
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
|
*
|
|
* 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_backpack:NSRenderableEntity
|
|
{
|
|
|
|
int weapon_item;
|
|
|
|
void(void) item_backpack;
|
|
|
|
virtual void(void) Spawned;
|
|
virtual void(entity) Touch;
|
|
virtual void(player) setup;
|
|
};
|
|
|
|
void
|
|
item_backpack::Touch(entity eToucher)
|
|
{
|
|
if (eToucher.classname != "player") {
|
|
return;
|
|
}
|
|
|
|
player pl = (player)eToucher;
|
|
Logging_Pickup(eToucher, this, __NULL__);
|
|
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM);
|
|
|
|
pl.ammo_shells += ammo_shells;
|
|
pl.ammo_nails += ammo_nails;
|
|
pl.ammo_rockets += ammo_rockets;
|
|
pl.ammo_cells += ammo_cells;
|
|
|
|
/* cull */
|
|
pl.ammo_shells = min(pl.ammo_shells, MAX_A_SHELLS);
|
|
pl.ammo_nails = min(pl.ammo_nails, MAX_A_NAILS);
|
|
pl.ammo_rockets = min(pl.ammo_rockets, MAX_A_ROCKETS);
|
|
pl.ammo_cells = min(pl.ammo_cells, MAX_A_CELLS);
|
|
|
|
pl.g_items |= g_weapons[weapon_item].id;
|
|
Weapons_RefreshAmmo(pl);
|
|
|
|
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
|
WriteByte(MSG_MULTICAST, EV_DMC_PICKUPMSG);
|
|
WriteByte(MSG_MULTICAST, weapon_item);
|
|
WriteByte(MSG_MULTICAST, ammo_shells);
|
|
WriteByte(MSG_MULTICAST, ammo_nails);
|
|
WriteByte(MSG_MULTICAST, ammo_rockets);
|
|
WriteByte(MSG_MULTICAST, ammo_cells);
|
|
msg_entity = pl;
|
|
multicast([0,0,0], MULTICAST_ONE_R);
|
|
|
|
Destroy();
|
|
}
|
|
|
|
void
|
|
item_backpack::setup(player pl)
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
item_backpack::Spawned(void)
|
|
{
|
|
super::Spawned();
|
|
|
|
SetModel("models/backpack.mdl");
|
|
SetSize([-16,-16,0], [16,16,16]);
|
|
SetSolid(SOLID_TRIGGER);
|
|
SetMovetype(MOVETYPE_TOSS);
|
|
modelflags = MF_ROTATE;
|
|
}
|
|
|
|
void
|
|
item_backpack::item_backpack(void)
|
|
{
|
|
botinfo = BOTINFO_AMMO;
|
|
}
|
|
|
|
void
|
|
dmc_backpack_spawn(player spawner)
|
|
{
|
|
item_backpack weaponbox = spawn(item_backpack);
|
|
weaponbox.Spawned();
|
|
weaponbox.SetOrigin(spawner.origin);
|
|
|
|
weaponbox.ammo_shells = spawner.ammo_shells;
|
|
weaponbox.ammo_nails = spawner.ammo_nails;
|
|
weaponbox.ammo_rockets = spawner.ammo_rockets;
|
|
weaponbox.ammo_cells = spawner.ammo_cells;
|
|
weaponbox.weapon_item = spawner.activeweapon;
|
|
//bprint(PRINT_HIGH, sprintf("Dropped the %s, %d shells, %d nails, %d rockets, %d cells.\n", g_weapons[weapon_item].name, ammo_shells, ammo_nails, ammo_rockets, ammo_cells));
|
|
}
|