Skip to content

Commit

Permalink
pass the flag mode c++
Browse files Browse the repository at this point in the history
  • Loading branch information
gscottmalibu committed Nov 18, 2016
1 parent 8c2994a commit ac6ba24
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion config/server-init.cfg
Expand Up @@ -21,6 +21,9 @@ defaultmap "turbine"
//maps can also be uploaded using /sendmap, they will automatically download
autosendmap 1

//allows passing of the flag in team game modes
enable_passflag 1

//mimics insta (rifle/100 health) in edit mode
//allows sending of custom maps to play insta/effic on
//play-only mode. Map rotation should be changed as well
Expand Down Expand Up @@ -54,7 +57,7 @@ exec "config/users.cfg"
serverflagruns 1
//Damage
notkdamage 1 //disables teamkill damage (death)
notkdamage 0 //disables teamkill damage (death)
nodamage 0 //disables damage (death)
//Timers
Expand Down
23 changes: 21 additions & 2 deletions fpsgame/ctf.h
Expand Up @@ -20,12 +20,13 @@ struct ctfclientmode : clientmode
static const int HOLDSECS = 20;
static const int HOLDFLAGS = 1;
static const int RESPAWNSECS = 5;

struct flag
{
int id, version, spawnindex;
vec droploc, spawnloc;
int team, droptime, owntime;

#ifdef SERVMODE
int owner, dropcount, dropper, invistime;
#else
Expand Down Expand Up @@ -60,7 +61,7 @@ struct ctfclientmode : clientmode
team = 0;
droptime = owntime = 0;
}

#ifndef SERVMODE
const vec &pos()
{
Expand All @@ -70,6 +71,22 @@ struct ctfclientmode : clientmode
}
#endif
};

void dopassflagsequence(clientinfo *actor, clientinfo *target)
{
loopv(flags)
{
flag &f = flags[i];
if(flags[i].owner == actor->clientnum) {
returnflag(i);
dropflag(actor);
loopv(flags) if(flags[i].dropper == actor->clientnum) { flags[i].dropper = -1; flags[i].dropcount = 0; }
takeflag(target, i, f.version);
update();
out(ECHO_SERV, "%s passed the flag to %s", colorname(actor), colorname(target));
}
}
}

struct holdspawn
{
Expand Down Expand Up @@ -1211,6 +1228,8 @@ struct ctfclientmode : clientmode
}
};


extern void dropflag(clientinfo *ci, clientinfo *dropper = NULL);
extern ctfclientmode ctfmode;
ICOMMAND(dropflag, "", (), { ctfmode.trydropflag(); });

Expand Down
2 changes: 2 additions & 0 deletions fpsgame/server.cpp
Expand Up @@ -402,6 +402,7 @@ namespace server {
VAR(autosendmap, 0, 1, 1); //automatically sends map in edit mode
VAR(instacoop, 0, 0, 1); //insta like characteristics of edit mode
VAR(instacoop_gamelimit, 1000, 600000, 9999999);
VAR(enable_passflag, 0, 1, 1);

VARF(publicserver, 0, 0, 2, {
switch(publicserver)
Expand Down Expand Up @@ -2534,6 +2535,7 @@ best.add(clients[i]); \
if(!isteam(actor->team, target->team))
ts.dodamage(damage);
}
else if(enable_passflag && actor!=target && isteam(actor->team, target->team)) ctfmode.dopassflagsequence(actor,target);
else if(nodamage) {}
else ts.dodamage(damage);
if(target!=actor && !isteam(target->team, actor->team)) actor->state.damage += damage;
Expand Down

0 comments on commit ac6ba24

Please sign in to comment.