ew-progs/ew/ewmultiplayer.qc

273 lines
6.4 KiB
C++
Raw Normal View History

2011-09-06 00:00:00 +00:00
/*
=============================
ewmultiplayer.qc
coded by
Michael Rogers a.k.a Xsniper
ssj_xsniper@yahoo.com
http://www.xsniper.net/
Description:
This file contains code for the different multiplayer modes
in EW. Mainly Flood Co-op mode.
=============================
*/
void(float delaytime) delay_xsniper;
void() FloodCoop;
void(entity spot) create_demon_portal;
//==========================================================================
//General Multiplayer Code Below
//Show info_player_deathmatch starting points
void() ShowSpawnSpots =
{
local entity spot, spotlight;
local float spotcount;
//initialize spotcount
spotcount = 0;
//find an info_player_deathmatch
spot = find(world, classname, "info_player_deathmatch");
while(spot != world)
{
if (spot.classname == "info_player_deathmatch")
{
spotlight = spawn();
setorigin(spotlight,spot.origin);
setmodel (spotlight, "progs/s_bubble.spr");
spotlight.solid = SOLID_NOT;
spotlight.movetype = MOVETYPE_NONE;
//make it glow purple
spotlight.glow_size = 250;
spotlight.glow_red = 0.6;
spotlight.glow_green = 0;
spotlight.glow_blue = 1;
//increment spotcount
spotcount = spotcount + 1;
}
spot = nextent(spot);
}
//couldn't find a spot
if (spotcount == 0)
bprint("Couldn't Find A Spawn Spot\n");
};
//Message Of The Day
void() CheckMOTD =
{
//print a difficulty msg when first starting the game or after beating the game on single player
if (cvar("deathmatch") == 0)
{
if ((self.motd_count < 6) && (self.motd_time < time)) // 6 == seconds MOTD will display
{
self.motd_time = time + 1;
self.motd_count = self.motd_count + 1;
//check for start map or ending map
if (mapname == "start")
PrintDifficulty();
else if (mapname == "ending")
PrintDifficulty();
}
}
//new ending battle stuff
if (mapname == "ewend" && num_bots == 0)
{
//spawn a few angel bots to fight off the demons
delay_xsniper(4);
delay_xsniper(9);
delay_xsniper(14);
num_bots = 3;
}
//don't display message if we aren't in deathmatch
if (cvar("deathmatch") == 1)
{
if ((self.motd_count < 10) && (self.motd_time < time)) // 10 == seconds MOTD will display
{
self.motd_time = time + 1;
self.motd_count = self.motd_count + 1;
centerprint(self, "Flood Co-op Mode\n");
//check for bot spawnage
if (num_bots < parm10 && self.motd_count > 1)
{
//make sure we have admin status to prevent overflow of bots
if (self.admin == 1)
{
//create a bot and increment num_bots
xsniper();
num_bots = num_bots + 1;
}
}
}
}
//display message for co-op mode
if (cvar("coop") > 0)
{
if ((self.motd_count < 10) && (self.motd_time < time)) // 10 == seconds MOTD will display
{
self.motd_time = time + 1;
self.motd_count = self.motd_count + 1;
centerprint(self, "Single Player Co-op Mode\n");
//check for bot spawnage
if (num_bots < parm10 && self.motd_count > 1)
{
//make sure we have admin status to prevent overflow of bots
if (self.admin == 1)
{
//create a bot and increment num_bots
xsniper();
num_bots = num_bots + 1;
}
}
}
}
};
void() CheckPlayMode =
{
//check for Flood Co-op Mode
if (cvar("deathmatch") == 1 || mapname == "ewend")
FloodCoop();
};
//===========================================================================
//Flood Co-op Mode Code Below
void() reset_spawn_spot =
{
local entity spot;
//check for info_portal_start's
spot = find(world, classname, "info_portal_start");
if (spot != world)
{
//rename this spot so players can use it again
spot.classname = "info_player_deathmatch";
}
};
void() reset_old_spots =
{
local entity spot;
//check for info_player_deathmatch's
spot = find(world, classname, "info_player_deathmatch");
while(spot != world)
{
if (spot.classname == "info_player_deathmatch")
spot.oldspot = 0;
spot = nextent(spot);
}
};
void() find_portal_spawn_spot =
{
local entity spot;
local float spotcount;
//initialize spotcount
spotcount = 0;
//find an info_player_deathmatch
spot = find(world, classname, "info_player_deathmatch");
while(spot != world)
{
if (spot.classname == "info_player_deathmatch" && spot.oldspot != 1)
{
//set up angles
makevectors(spot.angles);
//lets clear the area before we spawn in
create_explosion((spot.origin - (v_right * 20)),0.1,0,100);
create_explosion((spot.origin + (v_right * 20)),0.2,0,100);
create_explosion((spot.origin - (v_forward * 20)),0.3,0,100);
create_explosion((spot.origin + (v_forward * 20)),0.4,0,100);
//found a spot, so create a demon portal here
create_demon_portal(spot);
//set this spot to our old spot
spot.oldspot = 1;
//reset any old portal spawn spots
reset_spawn_spot();
//rename this spot so players can't use it anymore
spot.classname = "info_portal_start";
//remove the delay entity
remove(self);
return;
}
else if (spot.classname == "info_player_deathmatch" && spot.oldspot == 1)
spotcount = spotcount + 1;
spot = nextent(spot);
}
//we've used all the spots before so reset them and recall this function
if (spotcount > 0)
{
reset_old_spots();
self.nextthink = time + 1;
self.think = find_portal_spawn_spot;
}
else
{
bprint("Couldn't Find A Spawn Spot\n");
//reset num_portals
num_portals = 0;
//remove the delay entity
remove(self);
}
};
void() delay_portal =
{
local entity delayholder;
//create a delay entity and put it into the world
delayholder = spawn();
delayholder.solid = SOLID_NOT;
delayholder.movetype = MOVETYPE_NONE;
setorigin (delayholder, self.origin);
setmodel (delayholder, "");
//set up its thinking
if (mapname == "ewend")
delayholder.nextthink = time + 8;
else
delayholder.nextthink = time + 6;
delayholder.think = find_portal_spawn_spot;
};
/*
==================
FloodCoop
This is the main controlling function when in
Flood Co-op mode. It will spawn new demon portals
if there are none in the game.
==================
*/
void() FloodCoop =
{
//check to see if there are any portal's in the world
if (num_portals == 0) //no portals so make one
{
//increment num_portals
num_portals = num_portals + 1;
delay_portal();
}
};