201 lines
4.0 KiB
Plaintext
201 lines
4.0 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_armor:NSRenderableEntity
|
|
{
|
|
void(void) item_armor;
|
|
|
|
virtual void(void) Spawned;
|
|
virtual void(void) Respawn;
|
|
virtual void(entity) Touch;
|
|
};
|
|
|
|
void
|
|
item_armor::Touch(entity eToucher)
|
|
{
|
|
if not (eToucher.flags & FL_CLIENT) {
|
|
return;
|
|
}
|
|
|
|
player pl = (player)eToucher;
|
|
Sound_Play(eToucher, CHAN_ITEM, strcat(noise, ".pickup"));
|
|
Logging_Pickup(eToucher, this, __NULL__);
|
|
|
|
/* TODO: if deathmatch is 4 and player invincible, don't pick up */
|
|
if (cvar("deathmatch") == 0 || cvar("deathmatch") == 2) {
|
|
Destroy();
|
|
} else {
|
|
Disappear();
|
|
ScheduleThink(Respawn, 20.0f);
|
|
}
|
|
}
|
|
|
|
void
|
|
item_armor::Respawn(void)
|
|
{
|
|
SetSolid(SOLID_TRIGGER);
|
|
SetMovetype(MOVETYPE_TOSS);
|
|
SetOrigin(GetSpawnOrigin());
|
|
SetModel(GetSpawnModel());
|
|
SetSize([-16,-16,0],[16,16,16]);
|
|
modelflags = MF_ROTATE;
|
|
|
|
ReleaseThink();
|
|
|
|
if (time > 20.0f)
|
|
Sound_Play(this, CHAN_ITEM, "dmc_item.respawn");
|
|
|
|
DropToFloor();
|
|
}
|
|
|
|
void
|
|
item_armor::Spawned(void)
|
|
{
|
|
super::Spawned();
|
|
|
|
Sound_Precache(strcat(noise, ".pickup"));
|
|
Sound_Precache("dmc_item.respawn");
|
|
precache_model(model);
|
|
}
|
|
|
|
void
|
|
item_armor::item_armor(void)
|
|
{
|
|
m_oldModel = model;
|
|
}
|
|
|
|
/*QUAKED item_armor1 (0 0 0.8) (-16 -16 0) (16 16 32)
|
|
|
|
DEATHMATCH CLASSIC (1999) ENTITY
|
|
|
|
Armor item that gives you 100 armor points.
|
|
It is the green armor.
|
|
|
|
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
|
|
model="models/armour_g.mdl"
|
|
*/
|
|
|
|
class
|
|
item_armor1:item_armor
|
|
{
|
|
void(void) item_armor1;
|
|
virtual void(entity) Touch;
|
|
};
|
|
|
|
void
|
|
item_armor1::item_armor1(void)
|
|
{
|
|
model = "models/armour_g.mdl";
|
|
noise = "armor_green";
|
|
}
|
|
|
|
void
|
|
item_armor1::Touch(entity eToucher)
|
|
{
|
|
if not (eToucher.flags & FL_CLIENT) {
|
|
return;
|
|
}
|
|
if (eToucher.classname == "player") {
|
|
player pl = (player)eToucher;
|
|
if (pl.armor < 100) {
|
|
pl.armor = 100;
|
|
item_armor::Touch(eToucher);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*QUAKED item_armor2 (0 0 0.8) (-16 -16 0) (16 16 32)
|
|
|
|
DEATHMATCH CLASSIC (1999) ENTITY
|
|
|
|
Armor item that gives you 150 armor points.
|
|
It is the yellow armor.
|
|
|
|
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
|
|
model="models/armour_y.mdl"
|
|
*/
|
|
|
|
class
|
|
item_armor2:item_armor
|
|
{
|
|
void(void) item_armor2;
|
|
virtual void(entity) Touch;
|
|
};
|
|
|
|
void
|
|
item_armor2::item_armor2(void)
|
|
{
|
|
model = "models/armour_y.mdl";
|
|
noise = "armor_yellow";
|
|
}
|
|
|
|
void
|
|
item_armor2::Touch(entity eToucher)
|
|
{
|
|
if not (eToucher.flags & FL_CLIENT) {
|
|
return;
|
|
}
|
|
if (eToucher.classname == "player") {
|
|
player pl = (player)eToucher;
|
|
if (pl.armor < 150) {
|
|
pl.armor = 150;
|
|
item_armor::Touch(eToucher);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*QUAKED item_armor3 (0 0 0.8) (-16 -16 0) (16 16 32)
|
|
|
|
DEATHMATCH CLASSIC (1999) ENTITY
|
|
|
|
Armor item that gives you 200 armor points.
|
|
It is the green armor.
|
|
|
|
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
|
|
model="models/armour_r.mdl"
|
|
*/
|
|
|
|
class item_armor3:item_armor
|
|
{
|
|
void(void) item_armor3;
|
|
virtual void(entity) Touch;
|
|
};
|
|
|
|
void
|
|
item_armor3::item_armor3(void)
|
|
{
|
|
model = "models/armour_r.mdl";
|
|
noise = "armor_red";
|
|
}
|
|
|
|
void
|
|
item_armor3::Touch(entity eToucher)
|
|
{
|
|
if not (eToucher.flags & FL_CLIENT) {
|
|
return;
|
|
}
|
|
if (eToucher.classname == "player") {
|
|
player pl = (player)eToucher;
|
|
if (pl.armor < 200) {
|
|
pl.armor = 200;
|
|
item_armor::Touch(eToucher);
|
|
}
|
|
}
|
|
}
|
|
CLASSEXPORT(item_armorInv, item_armor3) |