Update: The plugin now works with 2.9.2 map voting and includes pandaturd's fixes (thank you!)This plugin prevents players from leaving the spawn for 10 seconds (editable number) on all modes(except on arena and AD/CP), preventing annoying scenarios where the first team out of their gate will win.
This plugin changes the behavior of some fairly important entities, so if you find any bugs, please post.
Now updated, timers should refill after the countdown is complete.
Updated again, players should no longer be able to go through horizontal team doors, clients shouldn't have issues joining arena maps, and I did some code clean up.
Compatibility: All versions and maps
Version: All
//change the 10's in the below hud create events to however many seconds you want your map to have locked doors.
//we have to assign these hud values individually because all of the below override HUD's //create event.
// we still need to announce arena so that we can join servers playing arena without crashing
object_event_add(CTFHUD,ev_create,0, 'global.TimeLeftTillStart=10*global.game_fps ');
object_event_add(GeneratorHUD,ev_create,0, 'global.TimeLeftTillStart=10*global.game_fps ');
object_event_add(KothHUD,ev_create,0, 'global.TimeLeftTillStart=10*global.game_fps ');
object_event_add(DKothHUD,ev_create,0, 'global.TimeLeftTillStart=10*global.game_fps ');
object_event_add(ControlPointHUD,ev_create,0, 'global.TimeLeftTillStart=10*global.game_fps ');
//leave at zero, arena needs no wait. We need to declare this to prevent a crash if you join an arena match as a client.
object_event_add(ArenaHUD,ev_create,0, 'global.TimeLeftTillStart=0');
//If the time left isnt up, decrement the timer and ensure that teamgates are solid.
//Otherwise, unlock the gates.
object_event_add(HUD,ev_step,ev_step_begin,'
//run only as host.
if (global.isHost)
{
//decrease time left
if instance_exists(IntelligenceBaseBlue) || instance_exists(IntelligenceBaseRed) || instance_exists(IntelligenceRed) || instance_exists(IntelligenceBlue) {
if global.TimeLeftTillStart>0 {
global.TimeLeftTillStart-=1;
}
}
else if instance_exists(GeneratorBlue) || instance_exists(GeneratorRed) {
if global.TimeLeftTillStart>0 {
global.TimeLeftTillStart-=1;
}
}
else if instance_exists(KothControlPoint) {
if global.TimeLeftTillStart>0 {
global.TimeLeftTillStart-=1;
}
}
else if instance_exists(KothRedControlPoint) && instance_exists(KothBlueControlPoint) {
if global.TimeLeftTillStart>0 {
global.TimeLeftTillStart-=1;
}
}
else if instance_exists(ControlPoint) {
if global.TimeLeftTillStart>0 {
global.TimeLeftTillStart-=1;
//if we are playing AD/CP (or map voting, shameless compatibility plug), no wait to start. If you want a map to not to have a time limit
//on startup, just add another OR check with your maps name.
if (instance_exists(ControlPointSetupGate) || string_pos("map_voting", string_lower(global.currentMap)) != 0)
{global.TimeLeftTillStart=0;}
}
}
//Now that weve ensured its solid, make announcements every second so players know whats going on.
if global.TimeLeftTillStart>0 and global.TimeLeftTillStart mod global.game_fps = 0
{
ServerMessageString("Spawn doors will open in " + string(round(global.TimeLeftTillStart/global.game_fps)) + " seconds.",global.sendBuffer);
with NoticeO instance_destroy();
notice = instance_create(0, 0, NoticeO);
notice.notice = NOTICE_CUSTOM;
notice.message = "Spawn doors will open in " + string(round(global.TimeLeftTillStart/global.game_fps)) + " seconds.";
}
//announce opening at one instead of zero so that we dont need another variable to say weve already announced this
else if global.TimeLeftTillStart=1
{
ServerMessageString("Spawn doors are open! Fight!",global.sendBuffer);
with NoticeO instance_destroy();
notice = instance_create(0, 0, NoticeO);
notice.notice = NOTICE_CUSTOM;
notice.message = "Spawn doors are open! Fight!";
//refill game timers based on game mode.
if instance_exists(CTFHUD) {
CTFHUD.timer=CTFHUD.timeLimit;
GameServer.syncTimer=1;
}
if instance_exists(ControlPointHUD) {
ControlPointHUD.timer=ControlPointHUD.timeLimit;
GameServer.syncTimer=1;
}
if instance_exists(DKothHUD) {
DKothHUD.cpUnlock=900;
GameServer.syncTimer=1;
}
if instance_exists(KothHUD) {
KothHUD.cpUnlock=900;
GameServer.syncTimer=1;
}
if instance_exists(GeneratorHUD) {
GeneratorHUD.timer=GeneratorHUD.timeLimit;
GameServer.syncTimer=1;
}
}
}
//if you arent the host, set the timers to zero. This means that the actual hosts numbers wont overlap with yours or desync, and that you wont get
//trapped on doors when walking through them, and that you wont get random messages when entering lobbies as a client.
else
{
if global.TimeLeftTillStart!=0 {global.TimeLeftTillStart=0}
}
');
//Move outside of the walls if in contact.
object_event_add(Character,ev_collision,RedTeamGate,'
if global.TimeLeftTillStart>0
{
x=xprevious;
hspeed=0;
moveStatus = 0;
if(place_meeting(x,y,TeamGate)) {
if(not place_meeting(x+8,y,TeamGate)) {
move_contact_solid(0,8);
} else if(not place_meeting(x-8,y,TeamGate)) {
move_contact_solid(180,8);
}
}
}
');
//blue team walls
object_event_add(Character,ev_collision,BlueTeamGate,'
if global.TimeLeftTillStart>0
{
x=xprevious;
hspeed=0;
moveStatus = 0;
if(place_meeting(x,y,TeamGate)) {
if(not place_meeting(x+8,y,TeamGate)) {
move_contact_solid(0,8);
} else if(not place_meeting(x-8,y,TeamGate)) {
move_contact_solid(180,8);
}
}
}
');
//red floors
object_event_add(Character,ev_collision,RedTeamGate2,'
if global.TimeLeftTillStart>0
{
y=yprevious;
vspeed=0;
moveStatus = 0;
if(place_meeting(x,y,TeamGate)) {
if(not place_meeting(x,y-8,TeamGate)) {
move_contact_solid(90,8);
} else if(not place_meeting(x,y+8,TeamGate)) {
move_contact_solid(270,8);
}
}
}
');
//blue floors
object_event_add(Character,ev_collision,BlueTeamGate2,'
if global.TimeLeftTillStart>0
{
y=yprevious;
vspeed=0;
moveStatus = 0;
if(place_meeting(x,y,TeamGate)) {
if(not place_meeting(x,y-8,TeamGate)) {
move_contact_solid(90,8);
} else if(not place_meeting(x,y+8,TeamGate)) {
move_contact_solid(270,8);
}
}
}
');