Add func_nobuild, func_nogrenades.

This commit is contained in:
Marco Cawthorne 2022-07-10 09:06:53 -07:00
parent ece04dda38
commit 1dce4e12b1
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
8 changed files with 252 additions and 2 deletions

82
src/server/client.qc Normal file
View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2016-2022 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.
*/
/* called every input frame */
void
Game_RunClientCommand(void)
{
player pl = (player)self;
/* clear map triggers */
pl.gflags &= ~GF_NOBUILDZONE;
pl.gflags &= ~GF_NOGRENADEZONE;
Footsteps_Update();
pl.Physics_Run();
}
/* custom chat packet */
void
SV_SendChat(entity sender, string msg, entity eEnt, float fType)
{
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, fType == 0 ? EV_CHAT:EV_CHAT_TEAM);
WriteByte(MSG_MULTICAST, num_for_edict(sender) - 1);
WriteByte(MSG_MULTICAST, sender.team);
WriteString(MSG_MULTICAST, msg);
if (eEnt) {
msg_entity = eEnt;
multicast([0,0,0], MULTICAST_ONE);
} else {
multicast([0,0,0], MULTICAST_ALL);
}
localcmd(sprintf("echo [SERVER] %s: %s\n", sender.netname, msg));
}
/* client cmd overrides happen here */
void
Game_ParseClientCommand(string cmd)
{
tokenize(cmd);
if (argv(1) == "timeleft") {
string msg;
string timestring;
float timeleft;
timeleft = cvar("timelimit") - (time / 60);
timestring = Util_TimeToString(timeleft);
msg = sprintf("we have %s minutes remaining", timestring);
bprint(PRINT_CHAT, msg);
return;
}
if (argv(0) == "say") {
SV_SendChat(self, argv(1), world, 0);
return;
} else if (argv(0) == "say_team") {
entity a;
for (a = world; (a = find(a, ::classname, "player"));) {
if (a.team == self.team) {
SV_SendChat(self, argv(1), a, 1);
}
}
return;
}
clientcommand(self, cmd);
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2022 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.
*/
/*QUAKED func_nobuild (0 .5 .8) ?
TEAM FORTRESS (1996) ENTITY
Brush volume that when entered, will not allow you to deploy anything as an engineer.
-------- KEYS --------
"targetname" Name
*/
class
func_nobuild:NSBrushTrigger
{
void(void) func_nobuild;
virtual void(void) Respawn;
virtual void(entity) Touch;
};
void
func_nobuild::Touch(entity eToucher)
{
player pl = (player)eToucher;
if (!(eToucher.flags & FL_CLIENT))
return;
pl.gflags |= GF_NOBUILDZONE;
}
void
func_nobuild::Respawn(void)
{
InitBrushTrigger();
}
void
func_nobuild::func_nobuild(void)
{
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2022 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.
*/
/*QUAKED func_nogrenades (0 .5 .8) ?
TEAM FORTRESS (1996) ENTITY
Brush volume that when entered, will not allow you to deploy any grenades.
-------- KEYS --------
"targetname" Name
*/
class
func_nogrenades:NSBrushTrigger
{
void(void) func_nogrenades;
virtual void(void) Respawn;
virtual void(entity) Touch;
};
void
func_nogrenades::Touch(entity eToucher)
{
player pl = (player)eToucher;
if (!(eToucher.flags & FL_CLIENT))
return;
pl.gflags |= GF_NOGRENADEZONE;
}
void
func_nogrenades::Respawn(void)
{
InitBrushTrigger();
}
void
func_nogrenades::func_nogrenades(void)
{
}

View File

@ -26,6 +26,9 @@ dispenser.qc
sentry.qc
teleporter.qc
func_nobuild.qc
func_nogrenades.qc
vox.qc
../../../valve/src/server/items.qc
info_player_teamspawn.qc
@ -33,7 +36,7 @@ item_tfgoal.qc
info_tfgoal.qc
gamerules.qc
../../../valve/src/server/client.qc
client.qc
server.qc
../../../base/src/server/damage.qc
../../../valve/src/server/rules.qc

View File

@ -51,6 +51,13 @@ void weaponbox_spawn(player pl)
void
CSEv_TFCBuild_i(int type)
{
player pl = (player)self;
if (pl.gflags & GF_NOBUILDZONE) {
env_message_single(pl, "#Build_nobuild");
return;
}
switch (type) {
case 1:
TFCDispenser_Build();

View File

@ -17,6 +17,9 @@
void
Vox_Sentence_Broadcast(string msg)
{
if (!msg || msg == "")
return;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_TFC_VOXMSG);
WriteString(MSG_MULTICAST, msg);
@ -26,6 +29,9 @@ Vox_Sentence_Broadcast(string msg)
void
Vox_Sentence_Single(entity targ, string msg)
{
if (!msg || msg == "")
return;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_TFC_VOXMSG);
WriteString(MSG_MULTICAST, msg);

40
src/shared/flags.h Normal file
View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2016-2020 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.
*/
/* game flags */
#define GF_SEMI_TOGGLED (1<<0)
#define GF_FLASHLIGHT (1<<1)
#define GF_NOBUILDZONE (1<<2)
#define GF_NOGRENADEZONE (1<<3)
#define GF_UNUSED5 (1<<4)
#define GF_UNUSED6 (1<<5)
#define GF_UNUSED7 (1<<6)
#define GF_UNUSED8 (1<<7)
#define GF_UNUSED9 (1<<8)
#define GF_UNUSED10 (1<<9)
#define GF_UNUSED11 (1<<10)
#define GF_UNUSED12 (1<<11)
#define GF_UNUSED13 (1<<12)
#define GF_UNUSED14 (1<<14)
#define GF_UNUSED15 (1<<16)
#define GF_UNUSED16 (1<<13)
#define GF_UNUSED17 (1<<17)
#define GF_UNUSED18 (1<<18)
#define GF_UNUSED19 (1<<19)
#define GF_UNUSED20 (1<<20)
#define GF_UNUSED21 (1<<21)
#define GF_UNUSED22 (1<<22)
#define GF_UNUSED23 (1<<23)

View File

@ -3,7 +3,7 @@ defs.h
items.h
weapons.h
../../../valve/src/shared/flags.h
flags.h
events.h
player.qc
../../../base/src/shared/weapon_common.h