player_weaponstrip: Initial implementation; func_breakable: warn when key 'spawnobject' defines an out-of-bounds spawn id.
This commit is contained in:
parent
2c4f602195
commit
bdfb040bc2
7 changed files with 98 additions and 13 deletions
|
@ -46,6 +46,7 @@ server/func_pendulum.cpp
|
|||
server/light.cpp
|
||||
server/stubs.cpp
|
||||
server/infodecal.cpp
|
||||
server/player_weaponstrip.cpp
|
||||
server/trigger_auto.cpp
|
||||
server/trigger_autosave.cpp
|
||||
server/trigger_cdaudio.cpp
|
||||
|
|
|
@ -329,7 +329,14 @@ void func_breakable::func_breakable(void)
|
|||
m_flExplodeMag = stof(argv(i+1));
|
||||
break;
|
||||
case "spawnobject":
|
||||
m_strBreakSpawn = funcbreakable_objtable[stoi(argv(i+1))];
|
||||
int oid = stoi(argv(i+1));
|
||||
|
||||
if (oid >= funcbreakable_objtable.length) {
|
||||
print(sprintf("^1func_breakable^7: spawnobject %i out of bounds! fix your mod!\n", oid));
|
||||
m_strBreakSpawn = "";
|
||||
} else {
|
||||
m_strBreakSpawn = funcbreakable_objtable[oid];
|
||||
}
|
||||
break;
|
||||
case "spawnonbreak":
|
||||
m_strBreakSpawn = argv(i+1);
|
||||
|
|
53
src/gs-entbase/server/player_weaponstrip.cpp
Normal file
53
src/gs-entbase/server/player_weaponstrip.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <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.
|
||||
*/
|
||||
|
||||
/*QUAKED player_weaponstrip (1 0 0) (-8 -8 -8) (8 8 8)
|
||||
"targetname" Name
|
||||
|
||||
Strips the activator of all of its weapons.
|
||||
*/
|
||||
|
||||
class player_weaponstrip:CBaseTrigger
|
||||
{
|
||||
void(void) player_weaponstrip;
|
||||
virtual void(void) Trigger;
|
||||
};
|
||||
|
||||
void
|
||||
player_weaponstrip::Trigger(void)
|
||||
{
|
||||
base_player pl;
|
||||
|
||||
if (!(eActivator.flags & FL_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
pl = (base_player)eActivator;
|
||||
|
||||
for (int i = 1; i < Weapon_GetCount(); i++) {
|
||||
pl.g_items &= ~Weapon_GetBitID(i);
|
||||
pl.activeweapon = 0;
|
||||
pl.a_ammo1 = 0;
|
||||
pl.a_ammo2 = 0;
|
||||
pl.a_ammo3 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
player_weaponstrip::player_weaponstrip(void)
|
||||
{
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
}
|
|
@ -136,7 +136,6 @@ CSGameRules::PlayerPostFrame(base_player pp)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CSGameRules::LevelDecodeParms(base_player pp)
|
||||
{
|
||||
|
|
|
@ -34,10 +34,11 @@ void item_healthkit::touch(void)
|
|||
if (other.classname != "player") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (other.health >= other.max_health) {
|
||||
return;
|
||||
}
|
||||
|
||||
Damage_Apply(other, this, -20, 0, DMG_GENERIC);
|
||||
Sound_Play(this, CHAN_ITEM, "item.healthkit");
|
||||
Logging_Pickup(other, this, __NULL__);
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
#ifdef SERVER
|
||||
void Weapons_PickupNotify(base_player pl, int w)
|
||||
int
|
||||
Weapon_GetCount(void)
|
||||
{
|
||||
return g_weapons.length;
|
||||
}
|
||||
|
||||
int
|
||||
Weapon_GetBitID(int i)
|
||||
{
|
||||
return g_weapons[i].id;
|
||||
}
|
||||
|
||||
void
|
||||
Weapons_PickupNotify(base_player pl, int w)
|
||||
{
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EV_WEAPON_PICKUP);
|
||||
|
@ -8,14 +21,16 @@ void Weapons_PickupNotify(base_player pl, int w)
|
|||
multicast([0,0,0], MULTICAST_ONE);
|
||||
}
|
||||
|
||||
void Weapons_RefreshAmmo(base_player pl)
|
||||
void
|
||||
Weapons_RefreshAmmo(base_player pl)
|
||||
{
|
||||
if (g_weapons[pl.activeweapon].updateammo != __NULL__) {
|
||||
g_weapons[pl.activeweapon].updateammo((player)pl);
|
||||
}
|
||||
}
|
||||
|
||||
void Weapons_SwitchBest(base_player pl)
|
||||
void
|
||||
Weapons_SwitchBest(base_player pl)
|
||||
{
|
||||
entity oldself = self;
|
||||
self = pl;
|
||||
|
@ -31,7 +46,8 @@ void Weapons_SwitchBest(base_player pl)
|
|||
}
|
||||
|
||||
/* returns TRUE if weapon pickup gets removed from this world */
|
||||
int Weapons_AddItem(base_player pl, int w, int startammo)
|
||||
int
|
||||
Weapons_AddItem(base_player pl, int w, int startammo)
|
||||
{
|
||||
int value;
|
||||
entity oldself = self;
|
||||
|
@ -99,20 +115,23 @@ int Weapons_AddItem(base_player pl, int w, int startammo)
|
|||
return value;
|
||||
}
|
||||
|
||||
void Weapons_RemoveItem(base_player pl, int w)
|
||||
void
|
||||
Weapons_RemoveItem(base_player pl, int w)
|
||||
{
|
||||
pl.g_items &= ~g_weapons[w].id;
|
||||
Weapons_SwitchBest(pl);
|
||||
}
|
||||
|
||||
void Weapons_InitItem(int w)
|
||||
void
|
||||
Weapons_InitItem(int w)
|
||||
{
|
||||
item_pickup it = (item_pickup)self;
|
||||
spawnfunc_item_pickup();
|
||||
it.SetItem(w);
|
||||
}
|
||||
|
||||
void Weapons_UpdateAmmo(base_player pl, int a1, int a2, int a3)
|
||||
void
|
||||
Weapons_UpdateAmmo(base_player pl, int a1, int a2, int a3)
|
||||
{
|
||||
/* no change */
|
||||
if (a1 == -1) {
|
||||
|
@ -131,7 +150,8 @@ void Weapons_UpdateAmmo(base_player pl, int a1, int a2, int a3)
|
|||
pl.a_ammo3 = bound(0, a3, 255);
|
||||
}
|
||||
|
||||
void Weapons_ReloadWeapon(base_player pl, .int mag, .int ammo, int max)
|
||||
void
|
||||
Weapons_ReloadWeapon(base_player pl, .int mag, .int ammo, int max)
|
||||
{
|
||||
int iNeed = max - pl.(mag);
|
||||
int iHave = pl.(ammo);
|
||||
|
@ -145,7 +165,8 @@ void Weapons_ReloadWeapon(base_player pl, .int mag, .int ammo, int max)
|
|||
}
|
||||
}
|
||||
|
||||
void Weapon_DropCurrentWeapon(base_player pl)
|
||||
void
|
||||
Weapon_DropCurrentWeapon(base_player pl)
|
||||
{
|
||||
|
||||
static void DropWeapon_Enable(void)
|
||||
|
@ -174,7 +195,8 @@ void Weapon_DropCurrentWeapon(base_player pl)
|
|||
Weapons_RemoveItem(pl, pl.activeweapon);
|
||||
}
|
||||
|
||||
void CSEv_DropWeapon(void)
|
||||
void
|
||||
CSEv_DropWeapon(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
Weapon_DropCurrentWeapon(pl);
|
||||
|
|
|
@ -8,3 +8,5 @@ void Weapons_InitItem(int w);
|
|||
void Weapons_UpdateAmmo(base_player pl, int a1, int a2, int a3);
|
||||
void Weapons_ReloadWeapon(base_player pl, .int mag, .int ammo, int max);
|
||||
void Weapon_DropCurrentWeapon(base_player pl);
|
||||
int Weapon_GetCount();
|
||||
int Weapon_GetBitID(int);
|
||||
|
|
Loading…
Reference in a new issue