Implement item_health, adjust the sounds played by the various item_armor pickups and add an alias for item_armorInv
This commit is contained in:
parent
6074c787b5
commit
eed46f362e
9 changed files with 170 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -31,7 +31,7 @@ item_armor::Touch(entity eToucher)
|
||||||
}
|
}
|
||||||
|
|
||||||
player pl = (player)eToucher;
|
player pl = (player)eToucher;
|
||||||
Sound_Play(eToucher, CHAN_ITEM, "armor.pickup");
|
Sound_Play(eToucher, CHAN_ITEM, strcat(noise, ".pickup"));
|
||||||
Weapons_RefreshAmmo(pl);
|
Weapons_RefreshAmmo(pl);
|
||||||
Logging_Pickup(eToucher, this, __NULL__);
|
Logging_Pickup(eToucher, this, __NULL__);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ item_armor::Respawn(void)
|
||||||
ReleaseThink();
|
ReleaseThink();
|
||||||
|
|
||||||
if (real_owner && time > 30.0f)
|
if (real_owner && time > 30.0f)
|
||||||
Sound_Play(this, CHAN_ITEM, "armor.respawn");
|
Sound_Play(this, CHAN_ITEM, "dmc_item.respawn");
|
||||||
|
|
||||||
droptofloor();
|
droptofloor();
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ item_armor::Spawned(void)
|
||||||
{
|
{
|
||||||
super::Spawned();
|
super::Spawned();
|
||||||
|
|
||||||
Sound_Precache("armor.pickup");
|
Sound_Precache(strcat(noise, ".pickup"));
|
||||||
Sound_Precache("armor.respawn");
|
Sound_Precache("dmc_item.respawn");
|
||||||
precache_model(model);
|
precache_model(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,7 @@ void
|
||||||
item_armor1::item_armor1(void)
|
item_armor1::item_armor1(void)
|
||||||
{
|
{
|
||||||
model = "models/armour_g.mdl";
|
model = "models/armour_g.mdl";
|
||||||
|
noise = "armor_green";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -138,6 +139,7 @@ void
|
||||||
item_armor2::item_armor2(void)
|
item_armor2::item_armor2(void)
|
||||||
{
|
{
|
||||||
model = "models/armour_y.mdl";
|
model = "models/armour_y.mdl";
|
||||||
|
noise = "armor_yellow";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -178,6 +180,7 @@ void
|
||||||
item_armor3::item_armor3(void)
|
item_armor3::item_armor3(void)
|
||||||
{
|
{
|
||||||
model = "models/armour_r.mdl";
|
model = "models/armour_r.mdl";
|
||||||
|
noise = "armor_red";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -194,3 +197,4 @@ item_armor3::Touch(entity eToucher)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CLASSEXPORT(item_armorInv, item_armor3)
|
124
src/server/item_health.qc
Normal file
124
src/server/item_health.qc
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enumflags
|
||||||
|
{
|
||||||
|
IT_HEALTH_SMALL,
|
||||||
|
IT_HEALTH_LARGE
|
||||||
|
};
|
||||||
|
|
||||||
|
/*QUAKED item_health (0 0 0.8) (-16 -16 0) (16 16 32) SMALL LARGE
|
||||||
|
|
||||||
|
DEATHMATCH CLASSIC (1999) ENTITY
|
||||||
|
|
||||||
|
Armor item that gives you health.
|
||||||
|
It heals you 25 health points by default.
|
||||||
|
If spawnflags bit 1 (SMALL) is set, it'll heal 15.
|
||||||
|
If spawnflags bit 2 (LARGE) is set, it'll heal 100.
|
||||||
|
|
||||||
|
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
|
||||||
|
model="models/armour_r.mdl"
|
||||||
|
*/
|
||||||
|
class item_health:NSRenderableEntity
|
||||||
|
{
|
||||||
|
void(void) item_health;
|
||||||
|
|
||||||
|
virtual void(void) Spawned;
|
||||||
|
virtual void(void) Respawn;
|
||||||
|
virtual void(entity) Touch;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
item_health::Touch(entity eToucher)
|
||||||
|
{
|
||||||
|
if not (eToucher.flags & FL_CLIENT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player pl = (player)eToucher;
|
||||||
|
|
||||||
|
if (HasSpawnFlags(IT_HEALTH_SMALL)) {
|
||||||
|
if (pl.health >= 100)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Sound_Play(eToucher, CHAN_ITEM, "item_health_rotten.pickup");
|
||||||
|
pl.health = bound(0, pl.health + 15, 100);
|
||||||
|
} else if (HasSpawnFlags(IT_HEALTH_LARGE)) {
|
||||||
|
if (pl.health >= 200)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Sound_Play(eToucher, CHAN_ITEM, "item_health_mega.pickup");
|
||||||
|
pl.health = bound(0, pl.health + 100, 200);
|
||||||
|
} else {
|
||||||
|
if (pl.health >= 100)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Sound_Play(eToucher, CHAN_ITEM, "item_health.pickup");
|
||||||
|
pl.health = bound(0, pl.health + 15, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging_Pickup(eToucher, this, __NULL__);
|
||||||
|
|
||||||
|
if (real_owner || cvar("sv_playerslots") == 1) {
|
||||||
|
Destroy();
|
||||||
|
} else {
|
||||||
|
Disappear();
|
||||||
|
ScheduleThink(Respawn, 20.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
item_health::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, "dmc_item.respawn");
|
||||||
|
|
||||||
|
droptofloor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
item_health::Spawned(void)
|
||||||
|
{
|
||||||
|
super::Spawned();
|
||||||
|
|
||||||
|
if (HasSpawnFlags(IT_HEALTH_SMALL)) {
|
||||||
|
Sound_Precache("item_health_rotten.pickup");
|
||||||
|
m_oldModel = model = "models/w_medkits.mdl";
|
||||||
|
} else if (HasSpawnFlags(IT_HEALTH_LARGE)) {
|
||||||
|
Sound_Precache("item_health_mega.pickup");
|
||||||
|
m_oldModel = model = "models/w_medkitl.mdl";
|
||||||
|
} else {
|
||||||
|
Sound_Precache("item_health.pickup");
|
||||||
|
m_oldModel = model = "models/w_medkit.mdl";
|
||||||
|
}
|
||||||
|
|
||||||
|
Sound_Precache("dmc_item.respawn");
|
||||||
|
precache_model(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
item_health::item_health(void)
|
||||||
|
{
|
||||||
|
m_oldModel = model;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -69,6 +69,7 @@ item_weaponbox.qc
|
||||||
../../../valve/src/server/xen_plantlight.qc
|
../../../valve/src/server/xen_plantlight.qc
|
||||||
ammo.qc
|
ammo.qc
|
||||||
item_armor.qc
|
item_armor.qc
|
||||||
|
item_health.qc
|
||||||
|
|
||||||
../../../src/botlib/include.src
|
../../../src/botlib/include.src
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2022 Marco Cawthorne <marco@icculus.org>
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
armor.pickup
|
armor_green.pickup
|
||||||
{
|
{
|
||||||
|
sample items/armor1.wav
|
||||||
}
|
}
|
||||||
|
|
||||||
armor.respawn
|
armor_yellow.pickup
|
||||||
{
|
{
|
||||||
|
sample items/armor1.wav
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
armor_red.pickup
|
||||||
|
{
|
||||||
|
sample items/armor1.wav
|
||||||
}
|
}
|
||||||
|
|
||||||
ammo.pickup
|
ammo.pickup
|
||||||
|
@ -17,3 +23,23 @@ ammo.respawn
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item_health_rotten.pickup
|
||||||
|
{
|
||||||
|
sample items/r_item1.wav
|
||||||
|
}
|
||||||
|
|
||||||
|
item_health_mega.pickup
|
||||||
|
{
|
||||||
|
sample items/r_item2.wav
|
||||||
|
}
|
||||||
|
|
||||||
|
item_health.pickup
|
||||||
|
{
|
||||||
|
sample items/health1.wav
|
||||||
|
}
|
||||||
|
|
||||||
|
dmc_item.respawn
|
||||||
|
{
|
||||||
|
sample items/itembk2.wav
|
||||||
|
}
|
Loading…
Reference in a new issue