non-pk3dir migration

This commit is contained in:
Marco Cawthorne 2025-01-31 12:40:32 -08:00
parent 543c478459
commit 7fc646492d
1602 changed files with 20748 additions and 1865 deletions

7
src/rules/Makefile Normal file
View file

@ -0,0 +1,7 @@
QCC=fteqcc
all:
mkdir -pv ../../progs/
$(QCC) $(CFLAGS) -I../../../src/server deathmatch.qc
$(QCC) $(CFLAGS) -I../../../src/server singleplayer.qc
$(QCC) $(CFLAGS) -I../../../src/server invasion.qc

166
src/rules/deathmatch.qc Normal file
View file

@ -0,0 +1,166 @@
/*
* Copyright (c) 2024 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.
*/
#pragma PROGS_DAT "../../progs/deathmatch.dat"
#include "../../../src/server/api.h"
#if 0
string g_stockHL2MPPlayerModels[] = {
"models/humans/group03/female_01.mdl",
"models/humans/group03/female_02.mdl",
"models/humans/group03/female_03.mdl",
"models/humans/group03/female_04.mdl",
"models/humans/group03/female_06.mdl",
"models/humans/group03/female_07.mdl",
"models/humans/group03/male_01.mdl",
"models/humans/group03/male_02.mdl",
"models/humans/group03/male_03.mdl",
"models/humans/group03/male_04.mdl",
"models/humans/group03/male_05.mdl",
"models/humans/group03/male_06.mdl",
"models/humans/group03/male_07.mdl",
"models/humans/group03/male_08.mdl",
"models/humans/group03/male_09.mdl",
"models/police.mdl",
"models/combine_soldier.mdl",
"models/combine_soldier_prisonguard.mdl",
"models/combine_super_soldier.mdl",
};
#else
string g_stockHL2MPPlayerModels[] = {
"models/humans/group01/male_cheaple.mdl",
};
#endif
bool
IsTeamplay(void)
{
return cvars.GetBool("mp_teamplay");
}
bool
AllowFlashlight(void)
{
return cvars.GetBool("mp_flashlight");
}
void
CodeCallback_StartGameType(void)
{
motd.LoadDefault();
if (IsTeamplay() == true) {
teams.SetUp(1, "Combine", [153, 204, 255], true);
teams.SetSpawnPoint(1, "info_player_deathmatch");
teams.SetUp(2, "Rebels", [255, 63, 63], true);
teams.SetSpawnPoint(2, "info_player_deathmatch");
}
game.SetSpawnPoint("info_player_deathmatch");
for (int i = 0; i < g_stockHL2MPPlayerModels.length; i++) {
precache.Model(g_stockHL2MPPlayerModels[i]);
}
}
void
CodeCallback_PlayerSpawn(entity playerEntity)
{
string playerModel;
if (IsTeamplay() == true) {
if (random() < 0.5) {
ents.ChangeToClass(playerEntity, "player_rebels");
playerModel = g_stockHL2MPPlayerModels[floor(random(0,15))];
} else {
ents.ChangeToClass(playerEntity, "player_combine");
playerModel = g_stockHL2MPPlayerModels[floor(random(15,19))];
}
} else {
ents.ChangeToClass(playerEntity, "player_mp");
playerModel = g_stockHL2MPPlayerModels[floor(random(0,g_stockHL2MPPlayerModels.length))];
}
playerEntity.modelindex = getmodelindex(playerModel); /* keep OG size */
game.TeleportToSpawn(playerEntity);
}
void
CodeCallback_PlayerDisconnect(entity playerEntity)
{
}
bool
CodeCallback_PlayerRequestRespawn(entity playerEntity)
{
CodeCallback_PlayerSpawn(playerEntity);
return (true);
}
void
CodeCallback_PlayerDamage(entity playerEntity, entity inflictor, entity attacker)
{
}
void
CodeCallback_PlayerKilled(entity playerEntity, entity inflictor, entity attacker, string weapon)
{
combat.Obituary(playerEntity.netname, attacker.netname, weapon, "");
/* death-counter */
playerEntity.deaths++;
/* update score-counter */
if (ents.isPlayer(attacker)) {
if (playerEntity == attacker) {
attacker.frags--;
} else {
attacker.frags++;
}
}
}
bool
CodeCallback_ClientCommand(entity playerEntity, string command)
{
float commandArgs = tokenize(command);
switch (argv(0)) {
default:
return (false);
}
return (true);
}
bool
CodeCallback_ImpulseCommand(entity playerEntity, float impulseNum)
{
switch (impulseNum) {
case 100:
if (AllowFlashlight() == true) {
ents.Input(playerEntity, "UseItem", "item_suit", playerEntity);
}
break;
default:
return (false);
}
return (true);
}

156
src/rules/invasion.qc Normal file
View file

@ -0,0 +1,156 @@
/*
* Copyright (c) 2024 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.
*/
#pragma PROGS_DAT "../../progs/invasion.dat"
#include "../../../src/server/api.h"
var string autocvar_invasion_monsterClass = "npc_zombie";
var int autocvar_invasion_monsterCount = 5;
void
WaveTimer_Tick(void)
{
int monsterCount = actor.TotalActors();
/* spawn a new monster */
if (monsterCount < autocvar_invasion_monsterCount) {
entity zombie = ents.Create(autocvar_invasion_monsterClass, [0,0,0]);
game.TeleportToSpawn(zombie);
ents.Input(zombie, "HordeOn", "", world);
}
self.nextthink = time + 2.0f;
}
bool
AllowFlashlight(void)
{
return cvars.GetBool("mp_flashlight");
}
void
CodeCallback_StartGameType(void)
{
precache.Entity(autocvar_invasion_monsterClass);
motd.LoadDefault();
game.SetSpawnPoint("info_player_deathmatch");
teams.SetUp(1, "Military", [0, 255, 0], false);
teams.SetUp(2, "Aliens", [255, 0, 0], false);
teams.SetUp(3, "Players", [255, 255, 255], false);
teams.SetSpawnPoint(1, "info_player_deathmatch");
teams.SetSpawnPoint(2, "info_player_deathmatch");
teams.SetSpawnPoint(3, "info_player_deathmatch");
entity tick = spawn();
tick.think = WaveTimer_Tick;
tick.nextthink = time + 1.0f;
}
void
CodeCallback_PlayerSpawn(entity playerEntity)
{
string playerModel;
ents.ChangeToClass(playerEntity, "player_mp");
ents.Input(playerEntity, "SetTeam", "3", world);
/* interpret the 'model' InfoKey */
playerModel = userinfo.GetString(playerEntity, "model");
if (playerModel != "") {
playerModel = sprintf("models/player/%s/%s.mdl", playerModel, playerModel);
}
/* fallback is always models/player.mdl for Half-Life */
if (!STRING_SET(playerModel) || exists.InVFS(playerModel) == false) {
playerModel = "models/humans/group01/male_cheaple.mdl";
}
playerEntity.modelindex = getmodelindex(playerModel); /* keep OG size */
game.TeleportToSpawn(playerEntity);
}
void
CodeCallback_PlayerDisconnect(entity playerEntity)
{
}
bool
CodeCallback_PlayerRequestRespawn(entity playerEntity)
{
CodeCallback_PlayerSpawn(playerEntity);
return (true);
}
void
CodeCallback_PlayerDamage(entity playerEntity, entity inflictor, entity attacker)
{
}
void
CodeCallback_PlayerKilled(entity playerEntity, entity inflictor, entity attacker, string weapon)
{
combat.Obituary(playerEntity.netname, attacker.netname, weapon, "");
/* death-counter */
playerEntity.deaths++;
/* update score-counter */
if (ents.isPlayer(attacker)) {
if (playerEntity == attacker) {
attacker.frags--;
} else {
attacker.frags++;
}
} else if (ents.isSentient(attacker)) {
teams.AddScore(attacker.team, 1);
}
}
void
CodeCallback_NPCKilled(entity npcEntity, entity inflictor, entity attacker, string weapon)
{
combat.Obituary(npcEntity.netname, attacker.netname, weapon, "");
/* update score-counter */
if (ents.isPlayer(attacker)) {
if (npcEntity == attacker) {
attacker.frags--;
} else {
attacker.frags++;
}
}
}
bool
CodeCallback_ImpulseCommand(entity playerEntity, float impulseNum)
{
switch (impulseNum) {
case 100:
if (AllowFlashlight() == true) {
ents.Input(playerEntity, "UseItem", "item_suit", playerEntity);
}
break;
default:
return (false);
}
return (true);
}

78
src/rules/singleplayer.qc Normal file
View file

@ -0,0 +1,78 @@
/*
* Copyright (c) 2024 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.
*/
#pragma PROGS_DAT "../../progs/singleplayer.dat"
#include "../../../src/server/api.h"
void
CodeCallback_PlayerSpawn(entity playerEntity)
{
ents.ChangeToClass(playerEntity, "player");
game.TeleportToSpawn(playerEntity);
}
bool
CodeCallback_PlayerRequestRespawn(entity playerEntity)
{
localcmd("load quick\n");
if (cvars.GetBool("sv_cheats")) {
CodeCallback_PlayerSpawn(playerEntity);
}
return (true);
}
bool
CodeCallback_ImpulseCommand(entity playerEntity, float impulseNum)
{
switch (impulseNum) {
case 100:
ents.Input(playerEntity, "UseItem", "item_suit", playerEntity);
break;
case 101:
ents.Input(playerEntity, "SetHealth", "100", world);
ents.Input(playerEntity, "SetArmor", "100", world);
ents.Input(playerEntity, "GiveItem", "item_suit", world);
ents.Input(playerEntity, "GiveItem", "weapon_357", world);
ents.Input(playerEntity, "GiveItem", "weapon_ar2", world);
ents.Input(playerEntity, "GiveItem", "weapon_bugbait", world);
ents.Input(playerEntity, "GiveItem", "weapon_crossbow", world);
ents.Input(playerEntity, "GiveItem", "weapon_crowbar", world);
ents.Input(playerEntity, "GiveItem", "weapon_frag", world);
ents.Input(playerEntity, "GiveItem", "weapon_physcannon", world);
ents.Input(playerEntity, "GiveItem", "weapon_pistol", world);
ents.Input(playerEntity, "GiveItem", "weapon_rpg", world);
ents.Input(playerEntity, "GiveItem", "weapon_shotgun", world);
ents.Input(playerEntity, "GiveItem", "weapon_smg1", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_357 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_ar2 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_ar2_altfire 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_buckshot 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_crossbow 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_grenade 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_pistol 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_smg1 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_smg1_grenade 255", world);
ents.Input(playerEntity, "GiveAmmo", "ammo_rpg 255", world);
break;
default:
return (false);
}
return (true);
}