hhdeath/src/server/item_battery.qc

94 lines
2.3 KiB
C++
Raw Normal View History

2021-02-11 18:06:14 +00:00
/*
2022-03-13 23:56:13 +00:00
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
2021-02-11 18:06:14 +00:00
*
* 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.
*/
/*QUAKED item_battery (0 0 0.8) (-16 -16 0) (16 16 36)
HALF-LIFE (1998) ENTITY
HEV Suit energy battery.
It adds the following energy values to the HEV Suit by default:
Skill 1 (Easy): 15
Skill 2 (Medium): 15
Skill 3 (Hard): 10
The values can be tweaked in the skill.cfg file.
*/
class item_battery:NSRenderableEntity
2021-02-11 18:06:14 +00:00
{
void(void) item_battery;
virtual void(void) Respawn;
2022-04-03 21:07:09 +00:00
virtual void(entity) Touch;
2021-02-11 18:06:14 +00:00
};
void
2022-04-03 21:07:09 +00:00
item_battery::Touch(entity eToucher)
2021-02-11 18:06:14 +00:00
{
if (other.classname != "player") {
return;
}
2022-05-11 19:50:45 +00:00
NSClientPlayer pl = (NSClientPlayer)other;
2021-02-11 18:06:14 +00:00
if (pl.armor >= 100) {
return;
}
/* Move this somewhere else? */
pl.armor += Skill_GetValue("battery", 10);
if (pl.armor > 100) {
pl.armor = 100;
}
Logging_Pickup(other, this, __NULL__);
Sound_Play(other, CHAN_ITEM, "item.battery");
if (cvar("sv_playerslots") == 1) {
2023-01-19 03:45:26 +00:00
Destroy();
2021-02-11 18:06:14 +00:00
} else {
2023-01-19 03:45:26 +00:00
Disappear();
ScheduleThink(Respawn,20.0f);
2021-02-11 18:06:14 +00:00
}
}
void
item_battery::Respawn(void)
2021-02-11 18:06:14 +00:00
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_NONE);
/* One of the models is transparent, and we need to set additive */
SetRenderMode(RM_ADDITIVE);
SetRenderAmt(255);
SetSize([-16,-16,0],[16,16,16]);
/* Always spawns a little above origin */
SetOrigin(GetSpawnOrigin() + [0,0,16]);
SetModel(GetSpawnModel());
2021-02-11 18:06:14 +00:00
think = __NULL__;
nextthink = -1;
Sound_Play(this, CHAN_ITEM, "item.respawn");
}
void
item_battery::item_battery(void)
2021-02-11 18:06:14 +00:00
{
Sound_Precache("item.armor");
Sound_Precache("item.respawn");
/* TODO actually uses two models... */
model = "models/armor.mdl";
super::NSRenderableEntity();
2021-02-11 18:06:14 +00:00
item_healthkit::Respawn();
}