dmc/src/server/threewave.qc

209 lines
4.3 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.
*/
/* This file adds support for Threewave CTF items and rules */
/** Flag abstract superclass */
class
DMC3WaveFlag:NSRenderableEntity
{
float m_teamAlliance;
void DMC3WaveFlag(void);
virtual void Respawn(void);
virtual void Touch(entity);
virtual void ReturnTakenFlag(player);
virtual void CaptureFlag(player);
virtual void StealFlag(player);
};
void
DMC3WaveFlag::DMC3WaveFlag(void)
{
m_teamAlliance = 0;
}
void
DMC3WaveFlag::ReturnTakenFlag(player flagCarrier)
{
NSEntity theFlag;
if (flagCarrier.GetTeam() == 1) {
theFlag = (NSEntity)find(world, ::classname, "item_flag_team2");
} else {
theFlag = (NSEntity)find(world, ::classname, "item_flag_team1");
}
theFlag.Respawn();
theFlag.Show();
}
void
DMC3WaveFlag::Respawn(void)
{
SetOrigin(GetSpawnOrigin());
SetModel("models/flag.mdl");
SetSolid(SOLID_TRIGGER);
SetSize([-16, -16, 0], [16, 16, 74]);
DropToFloor();
}
void
DMC3WaveFlag::CaptureFlag(player capturingClient)
{
ReturnTakenFlag(capturingClient);
capturingClient.RemoveFlags(FL_GOALITEM);
capturingClient.frags += 10;
NSLog("%s of team %d has captured a flag!", capturingClient.netname, capturingClient.GetTeam());
}
void
DMC3WaveFlag::StealFlag(player stealingClient)
{
Disappear();
stealingClient.AddFlags(FL_GOALITEM);
NSLog("%s of team %d has stolen a flag!", stealingClient.netname, stealingClient.GetTeam());
}
void
DMC3WaveFlag::Touch(entity eToucher)
{
player theToucher;
if (eToucher.classname != "player")
return;
theToucher = (player)eToucher;
/* ignore your own flag */
if (theToucher.GetTeam() == m_teamAlliance) {
if (theToucher.HasFlags(FL_GOALITEM) == false)
return;
CaptureFlag(theToucher);
return;
}
StealFlag(theToucher);
}
/*!QUAKED item_flag_team1 (1.0 0.0 0.0) (-16 -16 0) (16 16 74)
# OVERVIEW
Flag for the team 1 in Threewave CTF (RED)
# TRIVIA
This entity was introduced in Threewave CTF (1996).
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
model="models/flag.mdl"
skin="1"
*/
class
item_flag_team1:DMC3WaveFlag
{
void item_flag_team1(void);
virtual void Respawn(void);
};
void
item_flag_team1::item_flag_team1(void)
{
}
void
item_flag_team1::Respawn(void)
{
super::Respawn();
SetSkin(1);
m_teamAlliance = 1;
SetRenderFX(RFX_GLOWSHELL);
SetRenderColor([1.0, 0.0, 0.0]);
SetRenderAmt(1.0f);
}
/*!QUAKED item_flag_team2 (0.0 0.0 1.0) (-16 -16 0) (16 16 74)
# OVERVIEW
Flag for the team 2 in Threewave CTF (BLUE)
# TRIVIA
This entity was introduced in Threewave CTF (1996).
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
model="models/flag.mdl"
skin="2"
*/
class
item_flag_team2:DMC3WaveFlag
{
void item_flag_team2(void);
virtual void Respawn(void);
};
void
item_flag_team2::item_flag_team2(void)
{
}
void
item_flag_team2::Respawn(void)
{
super::Respawn();
SetSkin(2);
m_teamAlliance = 2;
SetRenderFX(RFX_GLOWSHELL);
SetRenderColor([0.0, 0.0, 1.0]);
SetRenderAmt(1.0f);
}
/*!QUAKED info_player_team1 (1.0 0.0 0.0) (-16 -16 -36) (16 16 36)
# OVERVIEW
Spawn point for players of team 1 (RED)
# TRIVIA
This entity was introduced in Threewave CTF (1996).
*/
class
info_player_team1:NSRenderableEntity
{
void info_player_team1(void);
};
void
info_player_team1::info_player_team1(void)
{
}
/*!QUAKED info_player_team2 (0.0 0.0 1.0) (-16 -16 -36) (16 16 36)
# OVERVIEW
Spawn point for players of team 2 (BLUE)
# TRIVIA
This entity was introduced in Threewave CTF (1996).
*/
class
info_player_team2:NSRenderableEntity
{
void info_player_team2(void);
};
void
info_player_team2::info_player_team2(void)
{
}