2003-10-24 21:43:32 +00:00
|
|
|
#include "common.qh"
|
|
|
|
|
|
|
|
#include "misc.qh"
|
|
|
|
#include "override.qh"
|
|
|
|
|
2003-10-27 22:27:29 +00:00
|
|
|
#include "mapents.qh"
|
|
|
|
|
2003-10-24 21:43:32 +00:00
|
|
|
#include "mdl.qh"
|
|
|
|
#include "mdl_player.qh"
|
|
|
|
#include "mdl_void.qh"
|
|
|
|
|
|
|
|
#include "act_player.qh"
|
|
|
|
#include "act_dead.qh"
|
|
|
|
|
|
|
|
#include "equip.qh"
|
|
|
|
#include "items.qh"
|
|
|
|
#include "menu.qh"
|
|
|
|
|
|
|
|
#include "weapon.qh"
|
|
|
|
#include "server.qh"
|
|
|
|
#include "damage.qh"
|
|
|
|
|
|
|
|
#include "teleport.qh"
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
client_init =
|
|
|
|
{
|
|
|
|
precache_model ("progs/player.mdl");
|
|
|
|
precache_model ("progs/eyes.mdl");
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This is the first function called by C code for a new player.
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
SetNewParms =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
parm1 = CONFIG_START_CURRENCY;
|
|
|
|
|
|
|
|
parm2 = parm3 = parm4 = parm5 = 0;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
parm6 = CONFIG_START_HEALTH + CONFIG_START_ARMOR * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
parm7 = CONFIG_START_ARMOR_TYPE;
|
2004-02-08 07:34:17 +00:00
|
|
|
parm8 = CONFIG_MAX_HEALTH + CONFIG_MAX_ARMOR * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
parm9 = CONFIG_START_SHELLS + CONFIG_START_NAILS * 999;
|
|
|
|
parm10 = CONFIG_START_ROCKETS + CONFIG_START_CELLS * 999;
|
|
|
|
parm11 = CONFIG_MAX_SHELLS + CONFIG_MAX_NAILS * 999;
|
|
|
|
parm12 = CONFIG_MAX_ROCKETS + CONFIG_MAX_CELLS * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
parm15 = weapon_player_parm1_default ();
|
2003-10-24 21:43:32 +00:00
|
|
|
parm16 = EQUIP_STATE_CHOOSE;
|
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
SetDeadParms =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
SetNewParms();
|
|
|
|
};
|
|
|
|
|
|
|
|
// Called when about to change maps
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
SetChangeParms =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
/* Currency */
|
|
|
|
parm1 = self.currency;
|
|
|
|
|
|
|
|
/* Purchased items */
|
|
|
|
parm2 = self.itemfield_1;
|
|
|
|
parm3 = self.itemfield_2;
|
|
|
|
parm4 = self.itemfield_3;
|
|
|
|
parm5 = self.itemfield_4;
|
|
|
|
|
|
|
|
/* Health and such */
|
2004-02-08 07:34:17 +00:00
|
|
|
if (self.health < 0)
|
|
|
|
self.health = 0;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
parm6 = self.health + self.armorvalue * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
parm7 = self.armortype;
|
2004-02-08 07:34:17 +00:00
|
|
|
parm8 = self.max_health + self.max_armor * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
/* Ammo */
|
2004-02-08 07:34:17 +00:00
|
|
|
parm9 = self.ammo_shells + self.ammo_nails * 999;
|
|
|
|
parm10 = self.ammo_rockets + self.ammo_cells * 999;
|
|
|
|
parm11 = self.max_ammo_shells + self.max_ammo_nails * 999;
|
|
|
|
parm12 = self.max_ammo_rockets + self.max_ammo_cells * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
/* Wheeee */
|
2004-02-08 07:34:17 +00:00
|
|
|
parm15 = weapon_player_parm1 ();
|
2003-10-24 21:43:32 +00:00
|
|
|
parm16 = self.equip_state;
|
|
|
|
|
|
|
|
/* H4x0r */
|
|
|
|
if (self.deadflag)
|
2004-02-08 07:34:17 +00:00
|
|
|
SetDeadParms ();
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
DecodeParms =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
/* Currency */
|
|
|
|
self.currency = parm1;
|
|
|
|
|
|
|
|
/* Purchased items */
|
|
|
|
self.itemfield_1 = parm2;
|
|
|
|
self.itemfield_2 = parm3;
|
|
|
|
self.itemfield_3 = parm4;
|
|
|
|
self.itemfield_4 = parm5;
|
|
|
|
|
|
|
|
equip_grant(self, EQUIPID_SHOTGUN);
|
|
|
|
|
|
|
|
/* Health and such */
|
2004-02-08 07:34:17 +00:00
|
|
|
self.armorvalue = floor (parm6 / 999);
|
2003-10-24 21:43:32 +00:00
|
|
|
self.armortype = parm7;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
self.health = parm6 - self.armorvalue * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
self.max_armor = floor (parm8 / 999);
|
|
|
|
self.max_health = parm8 - self.max_armor * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
/* Ammo */
|
2004-02-08 07:34:17 +00:00
|
|
|
self.ammo_nails = floor (parm9 / 999);
|
|
|
|
self.ammo_shells = parm9 - self.ammo_nails * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
self.ammo_rockets = floor (parm10 / 999);
|
|
|
|
self.ammo_cells = parm10 - self.ammo_rockets * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
self.max_ammo_nails = floor (parm11 / 999);
|
|
|
|
self.max_ammo_shells = parm11 - self.max_ammo_nails * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
self.max_ammo_rockets = floor (parm12 / 999);
|
|
|
|
self.max_ammo_cells = parm12 - self.max_ammo_rockets * 999;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
/* Wheeee */
|
2004-02-08 07:34:17 +00:00
|
|
|
weapon_player_parm1_decode (parm15);
|
2003-10-24 21:43:32 +00:00
|
|
|
self.equip_state = parm16;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
SetDeadParms ();
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
RemoveClientFromGame =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
self.classname = "player_outofgame";
|
2004-02-08 07:34:17 +00:00
|
|
|
mdl_setup_void ();
|
|
|
|
act_setup_dead ();
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
PutClientInGame =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
local entity ent;
|
|
|
|
local float spawncount;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
menu_set (NOTHING_function);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
self.classname = "player";
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
DecodeParms ();
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
mdl_setup_player ();
|
|
|
|
act_setup_player ();
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
self.velocity = '0 0 0';
|
|
|
|
self.flags &= ~FL_INWATER;
|
|
|
|
|
|
|
|
/* FIXME: Hack to avoid jumping on spawn.... */
|
|
|
|
self.velocity_z = -270;
|
|
|
|
|
|
|
|
/* Select a spawn point.. */
|
|
|
|
for (spawncount = 5; spawncount > 0; spawncount--) {
|
2004-02-08 07:34:17 +00:00
|
|
|
spawn_head = random_enemy_chain (spawn_head);
|
|
|
|
ent = findradius (spawn_head.origin, 100);
|
2003-10-24 21:43:32 +00:00
|
|
|
while (ent) {
|
|
|
|
if (ent.classname == "player")
|
|
|
|
break;
|
|
|
|
ent = ent.chain;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ent)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
teleport (self, spawn_head);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Called right after ClientConnect, and on new maps.
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
PutClientInServer =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
local entity spot;
|
|
|
|
|
|
|
|
/* Hack to get pmodel for servers that check it */
|
|
|
|
self.model = "progs/player.mdl";
|
|
|
|
self.modelindex = 0;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
intermission_head = spot = random_enemy_chain (intermission_head);
|
2003-10-24 21:43:32 +00:00
|
|
|
self.origin = spot.origin;
|
|
|
|
self.angles = spot.angles;
|
|
|
|
self.fixangle = TRUE;
|
|
|
|
|
|
|
|
self.velocity = '0 0 0';
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
weapon_player_init ();
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
menu_set (menu_intro);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
RemoveClientFromGame ();
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
_deathmsg_suicide =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
local float r;
|
|
|
|
local string nname;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
nname = name (self);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
r = random();
|
2004-02-08 07:34:17 +00:00
|
|
|
if (r < 0.25)
|
|
|
|
bprint (PRINT_DEATH, nname, " says good bye to this cruel world.\n");
|
|
|
|
else if (r < 0.5)
|
|
|
|
bprint (PRINT_DEATH, nname, " takes the easy way out.\n");
|
|
|
|
else if (r < 0.75)
|
|
|
|
bprint (PRINT_DEATH, nname, " suicides.\n");
|
|
|
|
else
|
|
|
|
bprint (PRINT_DEATH, nname,
|
|
|
|
" stands at the wrong end of his shotgun.\n");
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// C Code calls this when the player issues a 'kill' command.
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
2003-10-24 21:43:32 +00:00
|
|
|
ClientKill = {
|
2004-02-08 07:34:17 +00:00
|
|
|
damage (self, self, self, DAMAGE_MUSTDIE, _deathmsg_suicide);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
_client_th_kill =
|
|
|
|
{
|
|
|
|
if (other == self)
|
|
|
|
self.frags--;
|
|
|
|
else
|
|
|
|
self.frags++;
|
|
|
|
logfrag (self, other);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Called after the client is fully connected
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
ClientConnect = {
|
|
|
|
bprint (PRINT_HIGH, name (self), " connected\n");
|
2003-10-24 21:43:32 +00:00
|
|
|
self.flags |= FL_CLIENT;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
override_set_th_kill (self, _client_th_kill);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Called when the client disconnects
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
ClientDisconnect =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
self.flags = 0;
|
2004-02-08 07:34:17 +00:00
|
|
|
bprint (PRINT_HIGH, name(self), " disconnected with ", ftos(self.frags),
|
|
|
|
" frags\n");
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
override_set_th_kill (self, NOTHING_function);
|
2003-10-27 22:27:29 +00:00
|
|
|
self.deathmsg1 = NIL;
|
2004-02-08 07:34:17 +00:00
|
|
|
damage (self, self, self, DAMAGE_MUSTDIE, NOTHING_function);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|