1389 lines
28 KiB
C++
1389 lines
28 KiB
C++
//ew prototypes
|
|
void() pray;
|
|
void() terminate_xsniper;
|
|
|
|
|
|
// prototypes
|
|
void () W_WeaponFrame;
|
|
void() W_SetCurrentAmmo;
|
|
void() player_pain;
|
|
void() player_stand1;
|
|
void (vector org) spawn_tfog;
|
|
void (vector org, entity death_owner) spawn_tdeath;
|
|
|
|
float modelindex_eyes, modelindex_player;
|
|
|
|
//administrator stuff
|
|
void() search_for_admin =
|
|
{
|
|
local entity player;
|
|
local float admincount;
|
|
|
|
//initialize
|
|
admincount = 0;
|
|
|
|
//find clients
|
|
player = find(world,classname,"player");
|
|
|
|
while(player)
|
|
{
|
|
if (player.admin == 1)
|
|
admincount = admincount + 1;
|
|
player = find(player,classname,"player");
|
|
}
|
|
|
|
//make a new administrator
|
|
if (admincount == 0)
|
|
{
|
|
self.admin = 1;
|
|
//let everyone know who the new admin is
|
|
bprint(self.netname);
|
|
bprint(" is the new administrator.\n");
|
|
}
|
|
};
|
|
|
|
/*
|
|
=============================================================================
|
|
|
|
LEVEL CHANGING / INTERMISSION
|
|
|
|
=============================================================================
|
|
*/
|
|
|
|
float intermission_running;
|
|
float intermission_exittime;
|
|
|
|
/*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
|
|
This is the camera point for the intermission.
|
|
Use mangle instead of angle, so you can set pitch or roll as well as yaw. 'pitch roll yaw'
|
|
*/
|
|
void() info_intermission =
|
|
{
|
|
};
|
|
|
|
|
|
|
|
void() SetChangeParms =
|
|
{
|
|
if (self.health <= 0)
|
|
{
|
|
SetNewParms ();
|
|
return;
|
|
}
|
|
|
|
// remove items
|
|
self.items = self.items - (self.items &
|
|
(IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
|
|
|
|
// cap super health
|
|
if (self.health > 100)
|
|
self.health = 100;
|
|
if (self.health < 50)
|
|
self.health = 50;
|
|
parm1 = self.items;
|
|
parm2 = self.health;
|
|
parm3 = self.armorvalue;
|
|
if (self.ammo_bolts < 25)
|
|
parm4 = 25;
|
|
else
|
|
parm4 = self.ammo_bolts;
|
|
parm5 = self.ammo_mana_blue;
|
|
parm6 = self.ammo_mana_green;
|
|
parm7 = self.ammo_mana_grey;
|
|
parm8 = self.weapon;
|
|
parm9 = self.armortype * 100;
|
|
|
|
//testing
|
|
parm10 = get_numbots();
|
|
};
|
|
|
|
void() SetNewParms =
|
|
{
|
|
parm1 = IT_CROSSBOW | IT_DAGGER;
|
|
parm2 = 100;
|
|
parm3 = 0;
|
|
parm4 = 25;
|
|
parm5 = 0;
|
|
parm6 = 0;
|
|
parm7 = 0;
|
|
parm8 = 1;
|
|
parm9 = 0;
|
|
|
|
//testing
|
|
parm10 = get_numbots();
|
|
};
|
|
|
|
void() DecodeLevelParms =
|
|
{
|
|
if (serverflags)
|
|
{
|
|
if (world.model == "maps/start.bsp")
|
|
SetNewParms (); // take away all stuff on starting new episode
|
|
}
|
|
|
|
self.items = parm1;
|
|
self.health = parm2;
|
|
self.armorvalue = parm3;
|
|
self.ammo_bolts = parm4;
|
|
self.ammo_mana_blue = parm5;
|
|
self.ammo_mana_green = parm6;
|
|
self.ammo_mana_grey = parm7;
|
|
self.weapon = parm8;
|
|
self.armortype = parm9 * 0.01;
|
|
};
|
|
|
|
/*
|
|
============
|
|
FindIntermission
|
|
|
|
Returns the entity to view from
|
|
============
|
|
*/
|
|
entity() FindIntermission =
|
|
{
|
|
local entity spot;
|
|
local float cyc;
|
|
|
|
// look for info_intermission first
|
|
spot = find (world, classname, "info_intermission");
|
|
if (spot)
|
|
{ // pick a random one
|
|
cyc = random() * 4;
|
|
while (cyc > 1)
|
|
{
|
|
spot = find (spot, classname, "info_intermission");
|
|
if (!spot)
|
|
spot = find (spot, classname, "info_intermission");
|
|
cyc = cyc - 1;
|
|
}
|
|
return spot;
|
|
}
|
|
|
|
// then look for the start position
|
|
spot = find (world, classname, "info_player_start");
|
|
if (spot)
|
|
return spot;
|
|
|
|
// testinfo_player_start is only found in regioned levels
|
|
spot = find (world, classname, "testplayerstart");
|
|
if (spot)
|
|
return spot;
|
|
|
|
objerror ("FindIntermission: no spot");
|
|
};
|
|
|
|
|
|
string nextmap;
|
|
|
|
void() GotoNextMap =
|
|
{
|
|
if (cvar("samelevel")) // if samelevel is set, stay on same level
|
|
changelevel (mapname);
|
|
|
|
changelevel (nextmap);
|
|
};
|
|
|
|
|
|
void() ExitIntermission =
|
|
{
|
|
// skip any text in deathmatch
|
|
if (deathmatch)
|
|
{
|
|
GotoNextMap ();
|
|
return;
|
|
}
|
|
|
|
intermission_exittime = time + 1;
|
|
intermission_running = intermission_running + 1;
|
|
|
|
GotoNextMap();
|
|
};
|
|
|
|
/*
|
|
============
|
|
IntermissionThink
|
|
|
|
When the player presses attack or jump, change to the next level
|
|
============
|
|
*/
|
|
void() IntermissionThink =
|
|
{
|
|
if (time < intermission_exittime)
|
|
return;
|
|
|
|
if (!self.button0 && !self.button1 && !self.button2)
|
|
return;
|
|
|
|
ExitIntermission ();
|
|
};
|
|
|
|
void() execute_changelevel =
|
|
{
|
|
local entity pos;
|
|
|
|
intermission_running = 1;
|
|
|
|
// enforce a wait time before allowing changelevel
|
|
if (deathmatch)
|
|
intermission_exittime = time + 5;
|
|
else
|
|
intermission_exittime = time + 2;
|
|
|
|
WriteByte (MSG_ALL, SVC_CDTRACK);
|
|
WriteByte (MSG_ALL, 3);
|
|
WriteByte (MSG_ALL, 3);
|
|
|
|
pos = FindIntermission ();
|
|
|
|
other = find (world, classname, "player");
|
|
while (other != world)
|
|
{
|
|
other.view_ofs = '0 0 0';
|
|
other.angles = other.v_angle = pos.mangle;
|
|
other.fixangle = TRUE; // turn this way immediately
|
|
other.nextthink = time + 0.5;
|
|
other.takedamage = DAMAGE_NO;
|
|
other.solid = SOLID_NOT;
|
|
other.movetype = MOVETYPE_NONE;
|
|
other.modelindex = 0;
|
|
setorigin (other, pos.origin);
|
|
other = find (other, classname, "player");
|
|
}
|
|
|
|
WriteByte (MSG_ALL, SVC_INTERMISSION);
|
|
};
|
|
|
|
|
|
void() changelevel_touch =
|
|
{
|
|
local entity pos;
|
|
|
|
if (other.classname != "player")
|
|
return;
|
|
|
|
if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) && (mapname != "start")))
|
|
{
|
|
T_Damage (other, self, self, 50000);
|
|
return;
|
|
}
|
|
|
|
if (coop || deathmatch)
|
|
{
|
|
bprint (other.netname);
|
|
bprint (" exited the level\n");
|
|
}
|
|
|
|
nextmap = self.map;
|
|
|
|
SUB_UseTargets ();
|
|
|
|
if ( (self.spawnflags & 1) && (deathmatch == 0) )
|
|
{ // NO_INTERMISSION
|
|
GotoNextMap();
|
|
return;
|
|
}
|
|
|
|
self.touch = SUB_Null;
|
|
|
|
// we can't move people right now, because touch functions are called
|
|
// in the middle of C movement code, so set a think time to do it
|
|
self.think = execute_changelevel;
|
|
self.nextthink = time + 0.1;
|
|
};
|
|
|
|
/*EWED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
|
|
When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
|
|
*/
|
|
void() trigger_changelevel =
|
|
{
|
|
if (!self.map)
|
|
objerror ("chagnelevel trigger doesn't have map");
|
|
|
|
InitTrigger ();
|
|
self.touch = changelevel_touch;
|
|
};
|
|
|
|
|
|
/*
|
|
=============================================================================
|
|
|
|
PLAYER GAME EDGE FUNCTIONS
|
|
|
|
=============================================================================
|
|
*/
|
|
|
|
void() set_suicide_frame;
|
|
|
|
// called by ClientKill and DeadThink
|
|
void() respawn =
|
|
{
|
|
local string strtemp;
|
|
|
|
if (coop)
|
|
{
|
|
// make a copy of the dead body for appearances sake
|
|
CopyToBodyQue (self);
|
|
// get the spawn parms as they were at level start
|
|
setspawnparms (self);
|
|
// respawn
|
|
PutClientInServer ();
|
|
}
|
|
else if (deathmatch)
|
|
{
|
|
// make a copy of the dead body for appearances sake
|
|
CopyToBodyQue (self);
|
|
// set default spawn parms
|
|
SetNewParms ();
|
|
// respawn
|
|
PutClientInServer ();
|
|
if (cvar("deathmatch") == 1) //Flood Co-op Mode
|
|
{
|
|
strtemp = strcat("Demon Score: ",ftos(demon_score));
|
|
centerprint(self,strtemp);
|
|
}
|
|
}
|
|
else
|
|
{ // restart the entire server
|
|
localcmd ("restart\n");
|
|
}
|
|
};
|
|
|
|
|
|
/*
|
|
============
|
|
ClientKill
|
|
|
|
Player entered the suicide command
|
|
============
|
|
*/
|
|
void() ClientKill = //Koolio, don't allow suicide
|
|
{
|
|
sprint(self, "Suicide not allowed\n");
|
|
return;
|
|
};
|
|
|
|
float(vector v) CheckSpawnPoint =
|
|
{
|
|
return FALSE;
|
|
};
|
|
|
|
/*
|
|
============
|
|
SelectSpawnPoint
|
|
|
|
Returns the entity to spawn at
|
|
============
|
|
*/
|
|
entity() SelectSpawnPoint =
|
|
{
|
|
local entity spot;
|
|
local entity thing;
|
|
local float pcount;
|
|
|
|
// testinfo_player_start is only found in regioned levels
|
|
spot = find (world, classname, "testplayerstart");
|
|
if (spot)
|
|
return spot;
|
|
|
|
// choose a info_player_deathmatch point
|
|
if (coop)
|
|
{
|
|
lastspawn = find(lastspawn, classname, "info_player_coop");
|
|
if (lastspawn == world)
|
|
lastspawn = find (lastspawn, classname, "info_player_start");
|
|
if (lastspawn != world)
|
|
return lastspawn;
|
|
}
|
|
else if (deathmatch)
|
|
{
|
|
spot = lastspawn;
|
|
while (1)
|
|
{
|
|
spot = find(spot, classname, "info_player_deathmatch");
|
|
if (spot != world)
|
|
{
|
|
if (spot == lastspawn)
|
|
return lastspawn;
|
|
pcount = 0;
|
|
thing = findradius(spot.origin, 32);
|
|
while(thing)
|
|
{
|
|
if (thing.classname == "player")
|
|
pcount = pcount + 1;
|
|
thing = thing.chain;
|
|
}
|
|
if (pcount == 0)
|
|
{
|
|
lastspawn = spot;
|
|
return spot;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (serverflags)
|
|
{ // return with a rune to start
|
|
spot = find (world, classname, "info_player_start2");
|
|
if (spot)
|
|
return spot;
|
|
}
|
|
|
|
spot = find (world, classname, "info_player_start");
|
|
if (!spot)
|
|
error ("PutClientInServer: no info_player_start on level");
|
|
|
|
return spot;
|
|
};
|
|
|
|
/*
|
|
===========
|
|
PutClientInServer
|
|
|
|
called each time a player is spawned
|
|
============
|
|
*/
|
|
void() DecodeLevelParms;
|
|
void() PlayerDie;
|
|
|
|
void() PutClientInServer =
|
|
{
|
|
|
|
local entity spot;
|
|
|
|
spot = SelectSpawnPoint ();
|
|
|
|
self.classname = "player";
|
|
self.health = 100;
|
|
self.movetype = MOVETYPE_WALK;
|
|
self.takedamage = DAMAGE_AIM;
|
|
self.solid = SOLID_SLIDEBOX;
|
|
|
|
self.show_hostile = 0;
|
|
self.max_health = 100;
|
|
self.flags = FL_CLIENT;
|
|
self.air_finished = time + 12;
|
|
self.dmg = 2; // initial water damage
|
|
self.super_damage_finished = 0;
|
|
self.radsuit_finished = 0;
|
|
self.invisible_finished = 0;
|
|
self.invincible_finished = 0;
|
|
// self.effects = 0;
|
|
self.invincible_time = 0;
|
|
|
|
//a few other things
|
|
self.onfire = 0;
|
|
self.wmode = set_wmode(1);
|
|
|
|
StandardGlow(); //Just a white glow
|
|
|
|
DecodeLevelParms ();
|
|
|
|
W_SetCurrentAmmo ();
|
|
|
|
self.attack_finished = time;
|
|
self.th_pain = player_pain;
|
|
self.th_die = PlayerDie;
|
|
|
|
self.deadflag = DEAD_NO;
|
|
// paustime is set by teleporters to keep the player from moving a while
|
|
self.pausetime = 0;
|
|
|
|
// spot = SelectSpawnPoint ();
|
|
|
|
self.origin = spot.origin + '0 0 1';
|
|
self.angles = spot.angles;
|
|
self.fixangle = TRUE; // turn this way immediately
|
|
|
|
// oh, this is a hack!
|
|
setmodel (self, "progs/eyes.mdl");
|
|
modelindex_eyes = self.modelindex;
|
|
|
|
// setmodel (self, "progs/player.mdl");
|
|
setmodel (self, "models/players/mike/player.md2"); //Koolio, Mike! Whee
|
|
modelindex_player = self.modelindex;
|
|
|
|
setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
|
|
|
|
self.view_ofs = '0 0 22';
|
|
|
|
player_stand1 ();
|
|
|
|
if (deathmatch || coop)
|
|
{
|
|
makevectors(self.angles);
|
|
spawn_tfog (self.origin + v_forward*20);
|
|
}
|
|
|
|
spawn_tdeath (self.origin, self);
|
|
|
|
// reset game speed
|
|
reset_speed();
|
|
Init_Protection();
|
|
|
|
if (gamemode == ((FILE_WRITE + FILE_APPEND) * 2))
|
|
CheckMap999();
|
|
|
|
// search for administrator
|
|
search_for_admin();
|
|
|
|
// setup weapon mode
|
|
self.wmode = set_wmode(1);
|
|
};
|
|
|
|
|
|
/*
|
|
=============================================================================
|
|
|
|
QUAKED FUNCTIONS
|
|
|
|
=============================================================================
|
|
*/
|
|
|
|
|
|
/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
|
|
The normal starting point for a level.
|
|
*/
|
|
void() info_player_start =
|
|
{
|
|
};
|
|
|
|
|
|
/*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
|
|
Only used on start map for the return point from an episode.
|
|
*/
|
|
void() info_player_start2 =
|
|
{
|
|
};
|
|
|
|
|
|
/*
|
|
saved out by quaked in region mode
|
|
*/
|
|
void() testplayerstart =
|
|
{
|
|
};
|
|
|
|
/*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
|
|
potential spawning position for deathmatch games
|
|
*/
|
|
void() info_player_deathmatch =
|
|
{
|
|
};
|
|
|
|
/*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
|
|
potential spawning position for coop games
|
|
*/
|
|
void() info_player_coop =
|
|
{
|
|
};
|
|
|
|
/*
|
|
===============================================================================
|
|
|
|
RULES
|
|
|
|
===============================================================================
|
|
*/
|
|
|
|
/*
|
|
===================
|
|
GetNextLevel
|
|
|
|
Function used to return the next map in the default multiplayer map list.
|
|
===================
|
|
*/
|
|
string() GetNextLevel =
|
|
{
|
|
string oldmapname, tempmap;
|
|
float r;
|
|
|
|
//intialize tempmap
|
|
tempmap = mapname;
|
|
|
|
//remember the map we were on
|
|
oldmapname = mapname;
|
|
|
|
//keep choosing map until we are on a different one than current map
|
|
while(tempmap == oldmapname)
|
|
{
|
|
//set up random variable
|
|
r = random();
|
|
|
|
//pick map at random
|
|
if (r <= 0.14)
|
|
tempmap = "floodmp1";
|
|
else if (r <= 0.28)
|
|
tempmap = "floodmp2";
|
|
else if (r <= 0.42)
|
|
tempmap = "floodmp3";
|
|
else if (r <= 0.56)
|
|
tempmap = "floodmp4";
|
|
else if (r <= 0.70)
|
|
tempmap = "floodmp5";
|
|
else if (r <= 0.84)
|
|
tempmap = "floodmp6";
|
|
else
|
|
tempmap = "floodmp7";
|
|
}
|
|
|
|
return tempmap;
|
|
};
|
|
|
|
/*
|
|
go to the next level for deathmatch
|
|
only called if a time or frag limit has expired
|
|
*/
|
|
void() NextLevel =
|
|
{
|
|
local entity o;
|
|
|
|
// find a trigger changelevel
|
|
o = find(world, classname, "trigger_changelevel");
|
|
|
|
// pick a random map if no trigger_changelevel
|
|
if (!o)
|
|
{
|
|
mapname = GetNextLevel();
|
|
o = spawn();
|
|
o.map = mapname;
|
|
}
|
|
|
|
nextmap = o.map;
|
|
gameover = TRUE;
|
|
|
|
if (o.nextthink < time)
|
|
{
|
|
o.think = execute_changelevel;
|
|
o.nextthink = time + 0.1;
|
|
}
|
|
};
|
|
|
|
/*
|
|
================
|
|
FloodMsg
|
|
|
|
Prints an appropriate msg at the end of a Flood Co-op
|
|
game telling which side has won.
|
|
================
|
|
*/
|
|
void(float vtype) FloodMsg =
|
|
{
|
|
local entity player;
|
|
|
|
player = find(world, classname, "player");
|
|
|
|
if (vtype == 0) //Angels Win
|
|
{
|
|
while(player)
|
|
{
|
|
centerprint(player,"Angels Win!\n");
|
|
sound (player, CHAN_WEAPON, "misc/win.wav", 1, ATTN_NORM);
|
|
player = find(player, classname, "player");
|
|
}
|
|
}
|
|
else if (vtype == 1)
|
|
{
|
|
while(player)
|
|
{
|
|
centerprint(player,"Demons Defeat The Angels!\n");
|
|
sound (player, CHAN_WEAPON, "misc/lose.wav", 1, ATTN_NORM);
|
|
player = find(player, classname, "player");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
while(player)
|
|
{
|
|
centerprint(player,"Time Limit Reached!\n");
|
|
sound (player, CHAN_WEAPON, "misc/draw.wav", 1, ATTN_NORM);
|
|
player = find(player, classname, "player");
|
|
}
|
|
}
|
|
};
|
|
|
|
void() DelayNextLevelThink =
|
|
{
|
|
//go to next level
|
|
NextLevel();
|
|
|
|
//remove ourself
|
|
remove(self);
|
|
};
|
|
|
|
/*
|
|
=================================
|
|
DelayNextLevel
|
|
|
|
Delays the change to nextlevel by numdelay seconds.
|
|
=================================
|
|
*/
|
|
void(float numdelay) DelayNextLevel =
|
|
{
|
|
local entity dlevel;
|
|
|
|
dlevel = spawn();
|
|
dlevel. think = DelayNextLevelThink;
|
|
dlevel.nextthink = time + numdelay;
|
|
};
|
|
|
|
/*
|
|
============
|
|
CheckRules
|
|
|
|
Exit deathmatch games upon conditions
|
|
============
|
|
*/
|
|
void() CheckRules =
|
|
{
|
|
local float timelimit;
|
|
local float fraglimit;
|
|
|
|
if (gameover) // someone else quit the game already
|
|
return;
|
|
|
|
timelimit = cvar("timelimit") * 60;
|
|
fraglimit = cvar("fraglimit");
|
|
|
|
if (timelimit && time >= timelimit)
|
|
{
|
|
DelayNextLevel(5);
|
|
FloodMsg(2);
|
|
return;
|
|
}
|
|
|
|
if (fraglimit && self.frags >= fraglimit)
|
|
{
|
|
DelayNextLevel(5);
|
|
FloodMsg(0);
|
|
return;
|
|
}
|
|
|
|
if (fraglimit && demon_score >= fraglimit)
|
|
{
|
|
DelayNextLevel(5);
|
|
FloodMsg(1);
|
|
return;
|
|
}
|
|
};
|
|
|
|
//============================================================================
|
|
|
|
void() PlayerDeathThink =
|
|
{
|
|
local entity old_self;
|
|
local float forward;
|
|
|
|
if ((self.flags & FL_ONGROUND))
|
|
{
|
|
forward = vlen (self.velocity);
|
|
forward = forward - 20;
|
|
if (forward <= 0)
|
|
self.velocity = '0 0 0';
|
|
else
|
|
self.velocity = forward * normalize(self.velocity);
|
|
}
|
|
|
|
// wait for all buttons released
|
|
if (self.deadflag == DEAD_DEAD)
|
|
{
|
|
if (self.button2 || self.button1 || self.button0)
|
|
return;
|
|
self.deadflag = DEAD_RESPAWNABLE;
|
|
return;
|
|
}
|
|
|
|
// wait for any button down
|
|
if (!self.button2 && !self.button1 && !self.button0)
|
|
return;
|
|
|
|
self.button0 = 0;
|
|
self.button1 = 0;
|
|
self.button2 = 0;
|
|
respawn();
|
|
};
|
|
|
|
|
|
void() PlayerJump =
|
|
{
|
|
local vector start, end;
|
|
|
|
if (self.flags & FL_WATERJUMP)
|
|
return;
|
|
|
|
if (self.waterlevel >= 2)
|
|
{
|
|
if (self.watertype == CONTENT_WATER)
|
|
self.velocity_z = 100;
|
|
else if (self.watertype == CONTENT_SLIME)
|
|
self.velocity_z = 80;
|
|
else
|
|
self.velocity_z = 50;
|
|
|
|
// play swiming sound
|
|
if (self.swim_flag < time)
|
|
{
|
|
self.swim_flag = time + 1;
|
|
if (random() < 0.5)
|
|
sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
|
|
else
|
|
sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (!(self.flags & FL_ONGROUND))
|
|
return;
|
|
|
|
if ( !(self.flags & FL_JUMPRELEASED) )
|
|
return; // don't pogo stick
|
|
|
|
self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
|
|
|
|
self.flags = self.flags - FL_ONGROUND; // don't stairwalk
|
|
|
|
self.button2 = 0;
|
|
// player jumping sound
|
|
sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
|
|
self.velocity_z = self.velocity_z + 270;
|
|
};
|
|
|
|
|
|
/*
|
|
===========
|
|
WaterMove
|
|
|
|
============
|
|
*/
|
|
.float dmgtime;
|
|
|
|
void() WaterMove =
|
|
{
|
|
//dprint (ftos(self.waterlevel));
|
|
if (self.movetype == MOVETYPE_NOCLIP)
|
|
return;
|
|
if (self.health < 0)
|
|
return;
|
|
|
|
if (self.waterlevel != 3)
|
|
{
|
|
if (self.air_finished < time)
|
|
sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
|
|
else if (self.air_finished < time + 9)
|
|
sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
|
|
self.air_finished = time + 12;
|
|
self.dmg = 2;
|
|
}
|
|
else if (self.air_finished < time)
|
|
{ // drown!
|
|
if (self.pain_finished < time)
|
|
{
|
|
self.dmg = self.dmg + 2;
|
|
if (self.dmg > 15)
|
|
self.dmg = 10;
|
|
T_Damage (self, world, world, self.dmg);
|
|
self.pain_finished = time + 1;
|
|
}
|
|
}
|
|
|
|
if (!self.waterlevel)
|
|
{
|
|
if (self.flags & FL_INWATER)
|
|
{
|
|
// play leave water sound
|
|
sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
|
|
self.flags = self.flags - FL_INWATER;
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (self.watertype == CONTENT_LAVA)
|
|
{ // do damage
|
|
if (self.dmgtime < time)
|
|
{
|
|
if (self.radsuit_finished > time)
|
|
self.dmgtime = time + 1;
|
|
else
|
|
self.dmgtime = time + 0.2;
|
|
|
|
T_Damage (self, world, world, 10*self.waterlevel);
|
|
}
|
|
}
|
|
else if (self.watertype == CONTENT_SLIME)
|
|
{ // do damage
|
|
if (self.dmgtime < time && self.radsuit_finished < time)
|
|
{
|
|
self.dmgtime = time + 1;
|
|
T_Damage (self, world, world, 4*self.waterlevel);
|
|
}
|
|
}
|
|
|
|
if ( !(self.flags & FL_INWATER) )
|
|
{
|
|
|
|
// player enter water sound
|
|
|
|
if (self.watertype == CONTENT_LAVA)
|
|
sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
|
|
if (self.watertype == CONTENT_WATER)
|
|
sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
|
|
if (self.watertype == CONTENT_SLIME)
|
|
sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
|
|
|
|
self.flags = self.flags + FL_INWATER;
|
|
self.dmgtime = 0;
|
|
}
|
|
|
|
if (! (self.flags & FL_WATERJUMP) )
|
|
self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
|
|
};
|
|
|
|
void() CheckWaterJump =
|
|
{
|
|
local vector start, end;
|
|
|
|
// check for a jump-out-of-water
|
|
makevectors (self.angles);
|
|
start = self.origin;
|
|
start_z = start_z + 8;
|
|
v_forward_z = 0;
|
|
normalize(v_forward);
|
|
end = start + v_forward*24;
|
|
traceline (start, end, TRUE, self);
|
|
if (trace_fraction < 1)
|
|
{ // solid at waist
|
|
start_z = start_z + self.maxs_z - 8;
|
|
end = start + v_forward*24;
|
|
self.movedir = trace_plane_normal * -50;
|
|
traceline (start, end, TRUE, self);
|
|
if (trace_fraction == 1)
|
|
{ // open at eye level
|
|
self.flags = self.flags | FL_WATERJUMP;
|
|
self.velocity_z = 225;
|
|
self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
|
|
self.teleport_time = time + 2; // safety net
|
|
return;
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
/*
|
|
================
|
|
PlayerPreThink
|
|
|
|
Called every frame before physics are run
|
|
================
|
|
*/
|
|
void() PlayerPreThink =
|
|
{
|
|
local float mspeed, aspeed;
|
|
local float r, tvar;
|
|
|
|
if (intermission_running)
|
|
{
|
|
IntermissionThink (); // otherwise a button could be missed between
|
|
return; // the think tics
|
|
}
|
|
|
|
if (self.view_ofs == '0 0 0')
|
|
return; // intermission or finale
|
|
|
|
//Updating the clients viewpoint when there's no model set. Fix by Raymond Martineau, found on QIP
|
|
if (self.modelindex == 0)
|
|
{
|
|
local float bits;
|
|
|
|
msg_entity = self;
|
|
bits = 128 + 32 + 1024 + 2 + 4 + 8; // U_SIGNAL + U_NOLERP + U_MODEL + U_ORIGIN1 + U_ORIGIN2 + U_ORIGIN3
|
|
WriteByte (MSG_ONE,bits);
|
|
WriteByte (MSG_ONE,1); // The model
|
|
WriteCoord (MSG_ONE, self.origin_x);
|
|
WriteCoord (MSG_ONE, self.origin_y);
|
|
WriteCoord (MSG_ONE, self.origin_z);
|
|
}
|
|
|
|
//update our engine ammo variables
|
|
ammo_update();
|
|
|
|
makevectors (self.v_angle); // is this still used
|
|
|
|
CheckRules ();
|
|
WaterMove ();
|
|
|
|
if (self.waterlevel == 2)
|
|
CheckWaterJump ();
|
|
|
|
if (self.deadflag >= DEAD_DEAD)
|
|
{
|
|
PlayerDeathThink ();
|
|
return;
|
|
}
|
|
|
|
if (self.deadflag == DEAD_DYING)
|
|
return; // dying, so do nothing
|
|
|
|
if (self.button2)
|
|
{
|
|
PlayerJump ();
|
|
}
|
|
else
|
|
self.flags = self.flags | FL_JUMPRELEASED;
|
|
|
|
// teleporters can force a non-moving pause time
|
|
if (time < self.pausetime)
|
|
self.velocity = '0 0 0';
|
|
|
|
if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_DAGGER && self.weapon != IT_SWORD) //Koolio, don't look for cells
|
|
{
|
|
self.weapon = W_BestWeapon ();
|
|
W_SetCurrentAmmo ();
|
|
}
|
|
|
|
if (gamemode != IT_DAGGER / IT_SMITE)
|
|
{
|
|
if (cvar("deathmatch") >= 1)
|
|
{
|
|
stuffcmd(self,"deathmatch 0\n");
|
|
stuffcmd (self,"restart\n");
|
|
}
|
|
}
|
|
|
|
// see if we are on fire
|
|
AmBurning();
|
|
};
|
|
|
|
/*
|
|
================
|
|
CheckPowerups
|
|
|
|
Check for turning off powerups
|
|
================
|
|
*/
|
|
void() CheckPowerups =
|
|
{
|
|
if (self.health <= 0)
|
|
return;
|
|
|
|
// invisibility
|
|
if (self.invisible_finished)
|
|
{
|
|
// sound and screen flash when items starts to run out
|
|
if (self.invisible_sound < time)
|
|
{
|
|
sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
|
|
self.invisible_sound = time + ((random() * 3) + 1);
|
|
}
|
|
|
|
|
|
if (self.invisible_finished < time + 3)
|
|
{
|
|
if (self.invisible_time == 1)
|
|
{
|
|
sprint (self, "Your Cloak Is Fading Away!\n");
|
|
stuffcmd (self, "bf\n");
|
|
sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
|
|
self.invisible_time = time + 1;
|
|
}
|
|
|
|
if (self.invisible_time < time)
|
|
{
|
|
self.invisible_time = time + 1;
|
|
stuffcmd (self, "bf\n");
|
|
}
|
|
}
|
|
|
|
if (self.invisible_finished < time)
|
|
{ // just stopped
|
|
self.items = self.items - IT_INVISIBILITY;
|
|
self.invisible_finished = 0;
|
|
self.invisible_time = 0;
|
|
}
|
|
|
|
// use the eyes
|
|
self.frame = 0;
|
|
self.modelindex = modelindex_eyes;
|
|
}
|
|
else
|
|
self.modelindex = modelindex_player; // don't use eyes
|
|
|
|
// invincibility
|
|
if (self.invincible_finished)
|
|
{
|
|
// sound and screen flash when items starts to run out
|
|
if (self.invincible_finished < time + 3)
|
|
{
|
|
if (self.invincible_time == 1)
|
|
{
|
|
sprint (self, "Protection Is Almost Burned Out!\n");
|
|
stuffcmd (self, "bf\n");
|
|
sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
|
|
self.invincible_time = time + 1;
|
|
}
|
|
|
|
if (self.invincible_time < time)
|
|
{
|
|
self.invincible_time = time + 1;
|
|
stuffcmd (self, "bf\n");
|
|
}
|
|
}
|
|
|
|
if (self.invincible_finished < time)
|
|
{ // just stopped
|
|
self.items = self.items - IT_INVULNERABILITY;
|
|
self.invincible_time = 0;
|
|
self.invincible_finished = 0;
|
|
}
|
|
if (self.invincible_finished > time)
|
|
self.effects = self.effects | EF_DIMLIGHT;
|
|
else
|
|
self.effects = self.effects - (self.effects & EF_DIMLIGHT);
|
|
}
|
|
|
|
// super damage
|
|
if (self.super_damage_finished)
|
|
{
|
|
|
|
// sound and screen flash when items starts to run out
|
|
|
|
if (self.super_damage_finished < time + 3)
|
|
{
|
|
if (self.super_time == 1)
|
|
{
|
|
sprint (self, "Power Artifact Is Nearly Drained!\n");
|
|
stuffcmd (self, "bf\n");
|
|
sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
|
|
self.super_time = time + 1;
|
|
}
|
|
|
|
if (self.super_time < time)
|
|
{
|
|
self.super_time = time + 1;
|
|
stuffcmd (self, "bf\n");
|
|
}
|
|
}
|
|
|
|
if (self.super_damage_finished < time)
|
|
{ // just stopped
|
|
self.items = self.items - IT_QUAD;
|
|
self.super_damage_finished = 0;
|
|
self.super_time = 0;
|
|
}
|
|
if (self.super_damage_finished > time)
|
|
self.effects = self.effects | EF_DIMLIGHT;
|
|
else
|
|
self.effects = self.effects - (self.effects & EF_DIMLIGHT);
|
|
}
|
|
|
|
// suit
|
|
if (self.radsuit_finished)
|
|
{
|
|
self.air_finished = time + 12; // don't drown
|
|
|
|
// sound and screen flash when items starts to run out
|
|
if (self.radsuit_finished < time + 3)
|
|
{
|
|
if (self.rad_time == 1)
|
|
{
|
|
sprint (self, "The Eternal Breath Is About To Wear Off!\n");
|
|
stuffcmd (self, "bf\n");
|
|
sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
|
|
self.rad_time = time + 1;
|
|
}
|
|
|
|
if (self.rad_time < time)
|
|
{
|
|
self.rad_time = time + 1;
|
|
stuffcmd (self, "bf\n");
|
|
}
|
|
}
|
|
|
|
if (self.radsuit_finished < time)
|
|
{ // just stopped
|
|
self.items = self.items - IT_SUIT;
|
|
self.rad_time = 0;
|
|
self.radsuit_finished = 0;
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
/*
|
|
===================
|
|
JumpDamage
|
|
|
|
Checks how far we are falling and does different levels of damage based on this number.
|
|
===================
|
|
*/
|
|
void() JumpDamage =
|
|
{
|
|
float jumptemp, jumpdamage;
|
|
|
|
//set up our testing variable
|
|
jumptemp = self.jump_flag;
|
|
|
|
//do 5 damage plus 3% of the height
|
|
jumpdamage = 5 + (jumptemp * -0.03);
|
|
|
|
//if falling distance is over 900 then do another 30 damage
|
|
if (jumptemp < -900)
|
|
jumpdamage = jumpdamage + 30;
|
|
|
|
//do the damage
|
|
T_Damage (self, world, world, jumpdamage);
|
|
|
|
//make some noise
|
|
sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
|
|
|
|
//debug
|
|
//DebugMsg(3,"jumptemp = ",ftos(jumptemp),"\n","");
|
|
//DebugMsg(3,"jumpdamage = ",ftos(jumpdamage),"\n","");
|
|
};
|
|
|
|
/*
|
|
================
|
|
PlayerPostThink
|
|
|
|
Called every frame after physics are run
|
|
================
|
|
*/
|
|
void() PlayerPostThink =
|
|
{
|
|
local float mspeed, aspeed;
|
|
local float r;
|
|
|
|
if (self.view_ofs == '0 0 0')
|
|
return; // intermission or finale
|
|
if (self.deadflag)
|
|
return;
|
|
|
|
|
|
// do weapon stuff
|
|
|
|
W_WeaponFrame ();
|
|
|
|
// check to see if player landed and play landing sound
|
|
if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
|
|
{
|
|
if (self.watertype == CONTENT_WATER)
|
|
sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
|
|
else if (self.jump_flag < -500) //was -650
|
|
{
|
|
JumpDamage();
|
|
self.deathtype = "falling";
|
|
}
|
|
else
|
|
sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
|
|
|
|
self.jump_flag = 0;
|
|
}
|
|
|
|
if (!(self.flags & FL_ONGROUND))
|
|
self.jump_flag = self.velocity_z;
|
|
|
|
CheckPowerups ();
|
|
|
|
// check to see if we are praying
|
|
pray();
|
|
|
|
// check MOTD
|
|
CheckMOTD();
|
|
// check Play Mode
|
|
CheckPlayMode();
|
|
|
|
// Precache Debug
|
|
// bprint(ftos(num_mon_types));
|
|
// bprint(" monster types.\n");
|
|
};
|
|
|
|
|
|
/*
|
|
===========
|
|
ClientConnect
|
|
|
|
called when a player connects to a server
|
|
============
|
|
*/
|
|
void() ClientConnect =
|
|
{
|
|
bprint (self.netname);
|
|
bprint (" entered the game\n");
|
|
|
|
// a client connecting during an intermission can cause problems
|
|
if (intermission_running)
|
|
ExitIntermission ();
|
|
};
|
|
|
|
|
|
/*
|
|
===========
|
|
ClientDisconnect
|
|
|
|
called when a player disconnects from a server
|
|
============
|
|
*/
|
|
void() ClientDisconnect =
|
|
{
|
|
if (gameover)
|
|
return;
|
|
// if the level end trigger has been activated, just return
|
|
// since they aren't *really* leaving
|
|
|
|
// let everyone else know
|
|
bprint (self.netname);
|
|
bprint (" left the game with ");
|
|
bprint (ftos(self.frags));
|
|
bprint (" banishes\n");
|
|
sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
|
|
set_suicide_frame ();
|
|
};
|
|
|
|
/*
|
|
=====================================
|
|
give_frags
|
|
|
|
Will give numfrags number of frags to entity with
|
|
classname targ.
|
|
|
|
Hint: If you use a negative number it will subtract
|
|
that many frags.
|
|
=====================================
|
|
*/
|
|
void(string targ, float numfrags) give_frags =
|
|
{
|
|
local entity findme;
|
|
|
|
findme = find(world, classname, targ);
|
|
|
|
if (findme != world)
|
|
findme.frags = findme.frags + numfrags;
|
|
};
|
|
|
|
/*
|
|
===========
|
|
ClientObituary
|
|
|
|
called when a player dies
|
|
============
|
|
*/
|
|
void(entity targ, entity attacker) ClientObituary =
|
|
{
|
|
local float rnum;
|
|
local string deathstring, deathstring2;
|
|
rnum = random();
|
|
|
|
//player or bot dies
|
|
if (targ.classname == "player" || targ.classname == "xsniperbot")
|
|
{
|
|
targ.frags = targ.frags - 1;
|
|
|
|
// killed by a montser?
|
|
if (attacker.flags & FL_MONSTER)
|
|
{
|
|
//if we are playing Flood Co-op then give demon portal our frags
|
|
demon_score = demon_score + 1;
|
|
|
|
return;
|
|
}
|
|
}
|
|
};
|