]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into samual/mutator_ctf
authorSamual <samual@xonotic.org>
Sat, 31 Mar 2012 16:13:43 +0000 (12:13 -0400)
committerSamual <samual@xonotic.org>
Sat, 31 Mar 2012 16:13:43 +0000 (12:13 -0400)
23 files changed:
defaultXonotic.cfg
qcsrc/client/announcer.qc
qcsrc/common/items.qh
qcsrc/server/attic/nexball.qc
qcsrc/server/autocvars.qh
qcsrc/server/bot/havocbot/role_ctf.qc
qcsrc/server/cheats.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/constants.qh
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/g_triggers.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/base.qh
qcsrc/server/mutators/gamemode_ctf.qc [new file with mode: 0644]
qcsrc/server/mutators/gamemode_ctf.qh [new file with mode: 0644]
qcsrc/server/mutators/gamemode_nexball.qc
qcsrc/server/mutators/mutators.qh
qcsrc/server/portals.qc
qcsrc/server/progs.src
qcsrc/server/teamplay.qc
qcsrc/server/vehicles/vehicles.qc

index 89edddfe0d7fc8d194872bef6babbc2feb034c71..34ebb314213a64716843b249b8e6024cd312940d 100644 (file)
@@ -591,15 +591,25 @@ set gamecfg 1     // "deathmatch"
 
 // ctf
 set g_ctf 0 "Capture The Flag: take the enemy flag and bring it to yours at your base to score"
-set g_ctf_flag_returntime 30
+set g_ctf_flag_returntime 15
 set g_ctf_flagcarrier_selfdamage 1
 set g_ctf_flagcarrier_selfforce 1
 set g_ctf_fullbrightflags 0
 set g_ctf_dynamiclights 0
+set g_ctf_flag_damageforcescale 2
 set g_ctf_allow_drop 1 "dropping allows circumventing carrierkill score, so enable this with care!"
 set g_ctf_reverse 0    "if enabled, flags positions are switched: you have to capture the enemy's flag from your own base by bringing it to your own flag in the enemy base"
-set g_balance_ctf_delay_collect 1.0
-set g_balance_ctf_damageforcescale 1
+set g_ctf_flag_collect_delay 1
+set g_ctf_flag_health 0
+set g_ctf_flag_take_damage 0
+set g_ctf_flag_dropped_waypoint 2 "show dropped flag waypointsprite when a flag is lost. 1 = team only, 2 = for all players"
+set g_ctf_flag_pickup_verbosename 1 "show the name of the person who picked up the flag too"
+set g_ctf_flag_return_when_unreachable 1 "automatically return the flag if it falls into lava/slime/trigger hurt"
+set g_ctf_throw_velocity 500 "how far a player can throw the flag"
+set g_ctf_allow_pass 1 "allow passing of flags to nearby team mates"
+set g_ctf_pass_radius 200 "maximum radius that you can pass to a team mate in"
+set g_ctf_dropped_capture_radius 100 "allow dropped flags to be automatically captured by base flags if the dropped flag is within this radius of it"
+
 
 set g_ctf_shield_max_ratio 0   "shield at most this percentage of a team from the enemy flag (try: 0.4 for 40%)"
 set g_ctf_shield_min_negscore 20       "shield the player from the flag if he's got this negative amount of points or less"
index 3e109e78052036fd77f33f88b5138e12844f4418..db1ae41336d5e1eb54d30c437975b7323b330739 100644 (file)
@@ -134,52 +134,10 @@ void Announcer_Time()
        }
 }
 
-float redflag_prev;
-float blueflag_prev;
-void carrierAnnouncer() {
-       float stat_items, redflag, blueflag;
-       float pickup;
-       string item;
-
-       if not(autocvar_cl_notify_carried_items)
-               return;
-
-       stat_items = getstati(STAT_ITEMS);
-
-       redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
-       blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
-
-       if (redflag == 3 && redflag != redflag_prev) {
-               item = _("^1RED^7 flag");
-               pickup = (redflag_prev == 2);
-       }
-
-       if (blueflag == 3 && blueflag != blueflag_prev) {
-               item = _("^4BLUE^7 flag");
-               pickup = (blueflag_prev == 2);
-       }
-
-       if (item)
-       {
-               if (pickup) {
-                       if (autocvar_cl_notify_carried_items & 2)
-                               centerprint_hud(sprintf(_("You picked up the %s!"), item));
-               }
-               else {
-                       if (autocvar_cl_notify_carried_items & 1)
-                               centerprint_hud(sprintf(_("You got the %s!"), item));
-               }
-       }
-
-       blueflag_prev = blueflag;
-       redflag_prev = redflag;
-}
-
 void Announcer()
 {
        Announcer_Gamestart();
        Announcer_Time();
-       carrierAnnouncer();
 }
 
 void Announcer_Precache () 
index 07a7625345dcddeb80745a044bebbaf9b57536a1..21c115fa38140767ed3fdf85a6492354e7b8ccb2 100644 (file)
@@ -30,16 +30,16 @@ float   IT_STRENGTH                  = 8192;
 float   IT_INVINCIBLE                = 16384;
 float   IT_HEALTH                    = 32768;
 // union:
-        // for items:
-        float   IT_KEY1              = 131072;
-        float   IT_KEY2              = 262144;
-        // for players:
-        float   IT_RED_FLAG_TAKEN    = 32768;
-        float   IT_RED_FLAG_LOST     = 65536;
-        float   IT_RED_FLAG_CARRING  = 98304;
-        float   IT_BLUE_FLAG_TAKEN   = 131072;
-        float   IT_BLUE_FLAG_LOST    = 262144;
-        float   IT_BLUE_FLAG_CARRING = 393216;
+       // for items:
+       float   IT_KEY1                                 = 131072;
+       float   IT_KEY2                                 = 262144;
+       // for players:
+       float   IT_RED_FLAG_TAKEN               = 32768;
+       float   IT_RED_FLAG_LOST                = 65536;
+       float   IT_RED_FLAG_CARRYING            = 98304;
+       float   IT_BLUE_FLAG_TAKEN              = 131072;
+       float   IT_BLUE_FLAG_LOST               = 262144;
+       float   IT_BLUE_FLAG_CARRYING   = 393216;
 // end
 float   IT_5HP                       = 524288;
 float   IT_25HP                      = 1048576;
index a068a33a54e236017194c3ec5ac05e5caa0b9df1..d3f4b55f4a49acf42693df6e04df24942a1b99f3 100644 (file)
@@ -28,6 +28,9 @@ float nb_teams;
 
 .float teamtime;
 
+.float nb_dropperid;
+.float nb_droptime;
+
 void nb_delayedinit();
 void nb_init() // Called early (worldspawn stage)
 {
@@ -155,7 +158,7 @@ void GiveBall (entity plyr, entity ball)
        ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
        ball.team = plyr.team;
        plyr.ballcarried = ball;
-       ball.dropperid = plyr.playerid;
+       ball.nb_dropperid = plyr.playerid;
 
        plyr.effects |= g_nexball_basketball_effects_default;
        ball.effects &~= g_nexball_basketball_effects_default;
@@ -188,7 +191,7 @@ void DropBall (entity ball, vector org, vector vel)
        ball.flags &~= FL_ONGROUND;
        ball.scale = ball_scale;
        ball.velocity = vel;
-       ball.ctf_droptime = time;
+       ball.nb_droptime = time;
        ball.touch = basketball_touch;
        ball.think = ResetBall;
        ball.nextthink = min(time + g_nexball_delay_idle, ball.teamtime);
@@ -302,7 +305,7 @@ void basketball_touch (void)
                football_touch();
                return;
        }
-       if (!self.cnt && other.classname == "player" && (other.playerid != self.dropperid || time > self.ctf_droptime + autocvar_g_nexball_delay_collect)) {
+       if (!self.cnt && other.classname == "player" && (other.playerid != self.nb_dropperid || time > self.nb_droptime + autocvar_g_nexball_delay_collect)) {
                if (other.health <= 0)
                        return;
                LogNB("caught", other);
index 002cce33082a26cd1b68b0862d6065fb7fc3db3c..f08c88e53ff95ad01898052345b5da9bc955a639 100644 (file)
@@ -179,8 +179,6 @@ float autocvar_g_balance_crylink_secondary_speed;
 float autocvar_g_balance_crylink_secondary_spread;
 float autocvar_g_balance_crylink_reload_ammo;
 float autocvar_g_balance_crylink_reload_time;
-float autocvar_g_balance_ctf_damageforcescale;
-float autocvar_g_balance_ctf_delay_collect;
 float autocvar_g_balance_curse_empathy_minhealth;
 float autocvar_g_balance_curse_empathy_takedamage;
 float autocvar_g_balance_curse_slow_atkrate;
@@ -762,23 +760,38 @@ float autocvar_g_chat_flood_spl_team;
 float autocvar_g_chat_flood_spl_tell;
 float autocvar_g_chat_nospectators;
 float autocvar_g_chat_teamcolors;
+float autocvar_g_ctf_allow_drop;
+float autocvar_g_ctf_allow_pass;
+float autocvar_g_ctf_pass_radius;
+float autocvar_g_ctf_throw_velocity;
 float autocvar_g_ctf_captimerecord_always;
 float autocvar_g_ctf_dynamiclights;
 string autocvar_g_ctf_flag_blue_model;
 float autocvar_g_ctf_flag_blue_skin;
 float autocvar_g_ctf_flag_capture_effects;
+float autocvar_g_ctf_flag_collect_delay;
+float autocvar_g_ctf_flag_damageforcescale;
+float autocvar_g_ctf_flag_dropped_waypoint;
 float autocvar_g_ctf_flag_glowtrails;
+float autocvar_g_ctf_flag_health;
 float autocvar_g_ctf_flag_pickup_effects;
+float autocvar_g_ctf_flag_pickup_verbosename;
 string autocvar_g_ctf_flag_red_model;
 float autocvar_g_ctf_flag_red_skin;
 float autocvar_g_ctf_flag_returntime;
-float autocvar_g_ctf_flagcarrier_selfdamage;
-float autocvar_g_ctf_flagcarrier_selfforce;
+float autocvar_g_ctf_flag_return_when_unreachable;
+float autocvar_g_ctf_flag_take_damage;
+float autocvar_g_ctf_flagcarrier_selfdamagefactor;
+float autocvar_g_ctf_flagcarrier_selfforcefactor;
+float autocvar_g_ctf_flagcarrier_damagefactor;
+float autocvar_g_ctf_flagcarrier_forcefactor;
 float autocvar_g_ctf_fullbrightflags;
 float autocvar_g_ctf_ignore_frags;
 float autocvar_g_ctf_shield_force;
 float autocvar_g_ctf_shield_max_ratio;
 float autocvar_g_ctf_shield_min_negscore;
+float autocvar_g_ctf_reverse;
+float autocvar_g_ctf_dropped_capture_radius;
 float autocvar_g_cts_finish_kill_delay;
 float autocvar_g_cts_selfdamage;
 float autocvar_g_debug_bot_commands;
index 74c611ea18ddf6bdfe8f54dc94c3de1c29c59c57..74be6e766465f4443258d9ce958b29eb16cb2248 100644 (file)
@@ -23,7 +23,7 @@ void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplay
 .float havocbot_cantfindflag;
 .float havocbot_role_timeout;
 .entity ctf_worldflagnext;
-.entity basewaypoint;
+.entity bot_basewaypoint;
 
 entity ctf_worldflaglist;
 vector havocbot_ctf_middlepoint;
@@ -102,7 +102,7 @@ void havocbot_goalrating_ctf_ourbase(float ratingscale)
        if not(head)
                return;
 
-       navigation_routerating(head.basewaypoint, ratingscale, 10000);
+       navigation_routerating(head.bot_basewaypoint, ratingscale, 10000);
 }
 
 void havocbot_goalrating_ctf_enemyflag(float ratingscale)
@@ -134,7 +134,7 @@ void havocbot_goalrating_ctf_enemybase(float ratingscale)
        if not(head)
                return;
 
-       navigation_routerating(head.basewaypoint, ratingscale, 10000);
+       navigation_routerating(head.bot_basewaypoint, ratingscale, 10000);
 }
 
 void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)
@@ -143,7 +143,7 @@ void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)
 
        mf = havocbot_ctf_find_flag(self);
 
-       if(mf.cnt == FLAG_BASE)
+       if(mf.ctf_status == FLAG_BASE)
                return;
 
        if(mf.tag_entity)
@@ -157,7 +157,7 @@ void havocbot_goalrating_ctf_droppedflags(float ratingscale, vector org, float r
        while (head)
        {
                // flag is out in the field
-               if(head.cnt != FLAG_BASE)
+               if(head.ctf_status != FLAG_BASE)
                if(head.tag_entity==world)      // dropped
                {
                        if(radius)
@@ -295,7 +295,7 @@ void havocbot_role_ctf_escort()
 
        // If enemy flag is back on the base switch to previous role
        ef = havocbot_ctf_find_enemy_flag(self);
-       if(ef.cnt==FLAG_BASE)
+       if(ef.ctf_status==FLAG_BASE)
        {
                self.havocbot_role = self.havocbot_previous_role;
                self.havocbot_role_timeout = 0;
@@ -304,7 +304,7 @@ void havocbot_role_ctf_escort()
 
        // If the flag carrier reached the base switch to defense
        mf = havocbot_ctf_find_flag(self);
-       if(mf.cnt!=FLAG_BASE)
+       if(mf.ctf_status!=FLAG_BASE)
        if(vlen(ef.origin - mf.dropped_origin) < 300)
        {
                havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_DEFENSE);
@@ -359,7 +359,7 @@ void havocbot_role_ctf_offense()
        ef = havocbot_ctf_find_enemy_flag(self);
 
        // Own flag stolen
-       if(mf.cnt!=FLAG_BASE)
+       if(mf.ctf_status!=FLAG_BASE)
        {
                if(mf.tag_entity)
                        pos = mf.tag_entity.origin;
@@ -375,7 +375,7 @@ void havocbot_role_ctf_offense()
        }
 
        // Escort flag carrier
-       if(ef.cnt!=FLAG_BASE)
+       if(ef.ctf_status!=FLAG_BASE)
        {
                if(ef.tag_entity)
                        pos = ef.tag_entity.origin;
@@ -437,7 +437,7 @@ void havocbot_role_ctf_retriever()
 
        // If flag is back on the base switch to previous role
        mf = havocbot_ctf_find_flag(self);
-       if(mf.cnt==FLAG_BASE)
+       if(mf.ctf_status==FLAG_BASE)
        {
                havocbot_ctf_reset_role(self);
                return;
@@ -484,7 +484,7 @@ void havocbot_role_ctf_middle()
        }
 
        mf = havocbot_ctf_find_flag(self);
-       if(mf.cnt!=FLAG_BASE)
+       if(mf.ctf_status!=FLAG_BASE)
        {
                havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_RETRIEVER);
                return;
@@ -536,7 +536,7 @@ void havocbot_role_ctf_defense()
 
        // If own flag was captured
        mf = havocbot_ctf_find_flag(self);
-       if(mf.cnt!=FLAG_BASE)
+       if(mf.ctf_status!=FLAG_BASE)
        {
                havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_RETRIEVER);
                return;
@@ -635,14 +635,14 @@ void havocbot_ctf_reset_role(entity bot)
        ef = havocbot_ctf_find_enemy_flag(bot);
 
        // Retrieve stolen flag
-       if(mf.cnt!=FLAG_BASE)
+       if(mf.ctf_status!=FLAG_BASE)
        {
                havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_RETRIEVER);
                return;
        }
 
        // If enemy flag is taken go to the middle to intercept pursuers
-       if(ef.cnt!=FLAG_BASE)
+       if(ef.ctf_status!=FLAG_BASE)
        {
                havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_MIDDLE);
                return;
index 5ba860940a014344a3338f27551448ddbce0ad31..d52e33b0c3a62ffae0178a15a1abaf1f5cb8d534 100644 (file)
@@ -194,7 +194,7 @@ float CheatImpulse(float i)
                                        if(self.flagcarried)
                                        {
                                                bprint("The ", self.flagcarried.netname, " was returned to base by its carrier\n");
-                                               ReturnFlag(self.flagcarried);
+                                               ctf_RespawnFlag(self); // FIXCTF
                                        }
                                }
                                if(g_ctf)
index 848cbe030ade9d591442d107acd5095a1db1cdda..d80770f97b00202b7f2e4adadd68772db7110b57 100644 (file)
@@ -417,9 +417,6 @@ void PutObserverInServer (void)
        if(self.vehicle)
            vehicles_exit(VHEF_RELESE);
 
-       if(self.flagcarried)
-               DropFlag(self.flagcarried, world, world);
-
        WaypointSprite_PlayerDead();
 
        if not(g_ca)  // don't reset teams when moving a ca player to the spectators
@@ -1652,8 +1649,6 @@ void ClientDisconnect (void)
        Portal_ClearAll(self);
 
        RemoveGrapplingHook(self);
-       if(self.flagcarried)
-               DropFlag(self.flagcarried, world, world);
 
        // Here, everything has been done that requires this player to be a client.
 
@@ -2518,7 +2513,6 @@ void SpectatorThink()
        self.flags |= FL_CLIENT | FL_NOTARGET;
 }
 
-float ctf_usekey();
 void PlayerUseKey()
 {
        if(self.classname != "player")
@@ -2531,9 +2525,6 @@ void PlayerUseKey()
        }
        
        // a use key was pressed; call handlers
-       if(ctf_usekey())
-               return;
-
        MUTATOR_CALLHOOK(PlayerUseKey);
 }
 
@@ -2547,7 +2538,7 @@ Called every frame for each client before the physics are run
 =============
 */
 .float usekeypressed;
-void() ctf_setstatus;
+//void() ctf_setstatus;
 void() nexball_setstatus;
 .float items_added;
 void PlayerPreThink (void)
@@ -2845,8 +2836,8 @@ void PlayerPreThink (void)
                if(frametime)
                        player_anim();
 
-               if(g_ctf)
-                       ctf_setstatus();
+               //if(g_ctf)
+               //      ctf_setstatus();
 
                if(g_nexball)
                        nexball_setstatus();
index 334474966e2cf0a431154545e37953048c74e5d1..475171161c153309733d323553d4d28074ed9320 100644 (file)
@@ -693,15 +693,6 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
 
                RemoveGrapplingHook(self);
 
-               if(self.flagcarried)
-               {
-                       if(attacker.classname != "player")
-                               DropFlag(self.flagcarried, self, attacker); // penalty for flag loss by suicide
-                       else if(attacker.team == self.team)
-                               DropFlag(self.flagcarried, attacker, attacker); // penalty for flag loss by suicide/teamkill
-                       else
-                               DropFlag(self.flagcarried, world, attacker);
-               }
                Portal_ClearAllLater(self);
 
                if(clienttype(self) == CLIENTTYPE_REAL)
index b95c7261366b099902f2bb67ac4730661c024db7..aec1e3256b020878305579b179dfeea42a18e67e 100644 (file)
@@ -142,11 +142,6 @@ float      MSG_ENTITY                              = 5; // csqc
 
 float TE_BEAM                                  = 13;           // grappling hook
 
-// CTF
-float FLAG_BASE = 1;
-float FLAG_CARRY = 2;
-float FLAG_DROPPED = 3;
-
 float COLOR_TEAM1      = 5;  // red
 float COLOR_TEAM2      = 14; // blue
 float COLOR_TEAM3      = 13; // yellow
index a46c8f7e7119aad27b12b28b3692b657c0372ee0..8ba6659c810ec00455d180bc2439b27d08371e9a 100644 (file)
@@ -16,14 +16,10 @@ noref float require_spawnfunc_prefix; // if this float exists, only functions wi
 
 // Globals
 
-float ctf_score_value(string parameter);
-
 float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_midair, g_minstagib, g_pinata, g_norecoil, g_minstagib_invis_alpha, g_bloodloss;
 float g_warmup_limit;
 float g_warmup_allguns;
 float g_warmup_allow_timeout;
-float g_ctf_ignore_frags;
-float g_ctf_reverse;
 float g_race_qualifying;
 float inWarmupStage;
 float g_pickup_respawntime_weapon;
@@ -200,6 +196,8 @@ void setanim(entity e, vector anim, float looping, float override, float restart
 .float watersound_finished;
 .float iscreature;
 .float damagedbycontents;
+.float damagedbytriggers;
+.float pushable;
 .vector oldvelocity;
 
 .float pauseregen_finished;
@@ -341,7 +339,6 @@ string gamemode_name;
 
 float startitem_failed;
 
-void DropFlag(entity flag, entity penalty_receiver, entity attacker);
 void DropAllRunes(entity pl);
 
 
@@ -569,7 +566,6 @@ float servertime, serverprevtime, serverframetime;
 
 string matchid;
 .float hitplotfh;
-.string noise4;
 
 .float last_pickup;
 
index f80e3e133c9924b49843c499ec227ef99ec4e58c..7c5afac8a68e0a3e2a63eac14bf197511498d2ae 100644 (file)
@@ -209,11 +209,6 @@ void GiveFrags (entity attacker, entity targ, float f, float deathtype)
                        }
                        f = 0;
                }
-               else if(g_ctf)
-               {
-                       if(g_ctf_ignore_frags)
-                               f = 0;
-               }
        }
 
        attacker.totalfrags += f;
@@ -429,7 +424,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
 
                                if(g_ctf && targ.flagcarried)
                                {
-                                       UpdateFrags(attacker, ctf_score_value("score_kill"));
+                                       UpdateFrags(attacker, ctf_ReadScore("score_kill")); // FIXCTF
                                        PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
                                        GiveFrags(attacker, targ, 0, deathtype); // for logging
                                }
@@ -750,15 +745,6 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                                damage = damage * autocvar_g_balance_selfdamagepercent; // Partial damage if the attacker hits himself
                }
 
-               // CTF: reduce damage/force
-               if(g_ctf)
-               if(targ == attacker)
-               if(targ.flagcarried)
-               {
-                       damage = damage * autocvar_g_ctf_flagcarrier_selfdamage;
-                       force = force * autocvar_g_ctf_flagcarrier_selfforce;
-               }
-
                if(g_runematch)
                {
                        // apply strength rune
index 4e97136ce8b45354b0a1f695ff36ba9f06fad634..ab12fc326569d45f164c4f7d4e6ca2863e4886a0 100644 (file)
@@ -466,16 +466,19 @@ void trigger_hurt_touch()
                        Damage (other, self, own, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
                }
        }
+       else if(other.damagedbytriggers)
+       {
+               if(other.takedamage)
+               {
+                       EXACTTRIGGER_TOUCH;
+                       Damage(other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
+               }
+       }
        else
        {
                if (!other.owner)
                {
-                       if (other.items & IT_KEY1 || other.items & IT_KEY2)     // reset flag
-                       {
-                               EXACTTRIGGER_TOUCH;
-                               other.pain_finished = min(other.pain_finished, time + 2);
-                       }
-                       else if (other.classname == "rune")                     // reset runes
+                       if (other.classname == "rune")                  // reset runes
                        {
                                EXACTTRIGGER_TOUCH;
                                other.nextthink = min(other.nextthink, time + 1);
index 1359c056692298f68ce457d95d13537e1398a9b8..00849718eb511887df5d7568e287f3b9e7977ddd 100644 (file)
@@ -1128,7 +1128,6 @@ void readlevelcvars(void)
        g_bloodloss = cvar("g_bloodloss");
        sv_maxidle = cvar("sv_maxidle");
        sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
-       g_ctf_reverse = cvar("g_ctf_reverse");
        sv_autotaunt = cvar("sv_autotaunt");
        sv_taunt = cvar("sv_taunt");
 
@@ -2749,6 +2748,8 @@ float isPushable(entity e)
 {
        if(e.iscreature)
                return TRUE;
+       if(e.pushable)
+               return TRUE;
        switch(e.classname)
        {
                case "body":
index 137eebadb87edc1e56719e1e4be70dc6ce93fad0..f2d740c39ed9b63f4593790d435e55f57d1eac43 100644 (file)
@@ -205,3 +205,8 @@ MUTATOR_HOOKABLE(SV_StartFrame);
 MUTATOR_HOOKABLE(SetModname);
        // OUT
        string modname; // name of the mutator/mod if it warrants showing as such in the server browser
+
+MUTATOR_HOOKABLE(PortalTeleport);
+       // called whenever a player goes through a portal gun teleport
+       // allows you to strip a player of an item if they go through the teleporter to help prevent cheating
+       entity self;
\ No newline at end of file
diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc
new file mode 100644 (file)
index 0000000..110f201
--- /dev/null
@@ -0,0 +1,1061 @@
+// ================================================================
+//  Official capture the flag game mode coding, reworked by Samual
+//  Last updated: March 30th, 2012
+// ================================================================
+
+float ctf_ReadScore(string parameter) // make this obsolete
+{
+       //if(g_ctf_win_mode != 2)
+               return cvar(strcat("g_ctf_personal", parameter));
+       //else
+       //      return cvar(strcat("g_ctf_flag", parameter));
+}
+
+void ctf_FakeTimeLimit(entity e, float t)
+{
+       msg_entity = e;
+       WriteByte(MSG_ONE, 3); // svc_updatestat
+       WriteByte(MSG_ONE, 236); // STAT_TIMELIMIT
+       if(t < 0)
+               WriteCoord(MSG_ONE, autocvar_timelimit);
+       else
+               WriteCoord(MSG_ONE, (t + 1) / 60);
+}
+
+void ctf_EventLog(string mode, float flagteam, entity actor) // use an alias for easy changing and quick editing later
+{
+       if(autocvar_sv_eventlog)
+               GameLogEcho(strcat(":ctf:", mode, ":", ftos(flagteam), ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
+}
+
+
+// =======================
+// CaptureShield Functions 
+// =======================
+
+float ctf_CaptureShield_CheckStatus(entity p) 
+{
+       float s, se;
+       entity e;
+       float players_worseeq, players_total;
+
+       if(ctf_captureshield_max_ratio <= 0)
+               return FALSE;
+
+       s = PlayerScore_Add(p, SP_SCORE, 0);
+       if(s >= -ctf_captureshield_min_negscore)
+               return FALSE;
+
+       players_total = players_worseeq = 0;
+       FOR_EACH_PLAYER(e)
+       {
+               if(e.team != p.team)
+                       continue;
+               se = PlayerScore_Add(e, SP_SCORE, 0);
+               if(se <= s)
+                       ++players_worseeq;
+               ++players_total;
+       }
+
+       // player is in the worse half, if >= half the players are better than him, or consequently, if < half of the players are worse
+       // use this rule here
+       
+       if(players_worseeq >= players_total * ctf_captureshield_max_ratio)
+               return FALSE;
+
+       return TRUE;
+}
+
+void ctf_CaptureShield_Update(entity player, float wanted_status)
+{
+       float updated_status = ctf_CaptureShield_CheckStatus(player);
+       if((wanted_status == player.ctf_captureshielded) && (updated_status != wanted_status)) // 0: shield only, 1: unshield only
+       {
+               if(updated_status) // TODO csqc notifier for this // Samual: How?
+                       Send_CSQC_Centerprint_Generic(player, CPID_CTF_CAPTURESHIELD, "^3You are now ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Make some defensive scores before trying again.", 5, 0);
+               else
+                       Send_CSQC_Centerprint_Generic(player, CPID_CTF_CAPTURESHIELD, "^3You are now free.\n\n^3Feel free to ^1try to capture^3 the flag again\n^3if you think you will succeed.", 5, 0);
+                       
+               player.ctf_captureshielded = updated_status;
+       }
+}
+
+float ctf_CaptureShield_Customize()
+{
+       if not(other.ctf_captureshielded) { return FALSE; }
+       if(self.team == other.team) { return FALSE; }
+       
+       return TRUE;
+}
+
+void ctf_CaptureShield_Touch()
+{
+       if not(other.ctf_captureshielded) { return; }
+       if(self.team == other.team) { return; }
+       
+       vector mymid = (self.absmin + self.absmax) * 0.5;
+       vector othermid = (other.absmin + other.absmax) * 0.5;
+
+       Damage(other, self, self, 0, DEATH_HURTTRIGGER, mymid, normalize(othermid - mymid) * ctf_captureshield_force);
+       Send_CSQC_Centerprint_Generic(other, CPID_CTF_CAPTURESHIELD, "^3You are ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Get some defensive scores before trying again.", 5, 0);
+}
+
+void ctf_CaptureShield_Spawn(entity flag)
+{
+       entity shield = spawn();
+       
+       shield.enemy = self;
+       shield.team = self.team;
+       shield.touch = ctf_CaptureShield_Touch;
+       shield.customizeentityforclient = ctf_CaptureShield_Customize;
+       shield.classname = "ctf_captureshield";
+       shield.effects = EF_ADDITIVE;
+       shield.movetype = MOVETYPE_NOCLIP;
+       shield.solid = SOLID_TRIGGER;
+       shield.avelocity = '7 0 11';
+       shield.scale = 0.5;
+       
+       setorigin(shield, self.origin);
+       setmodel(shield, "models/ctf/shield.md3");
+       setsize(shield, shield.scale * shield.mins, shield.scale * shield.maxs);
+}
+
+
+// ==============
+// Event Handlers
+// ==============
+
+void ctf_Handle_Pass(entity player, entity reciever)
+{
+       entity tmp_player; // temporary entity which the FOR_EACH_PLAYER loop uses to scan players
+       entity flag = player.flagcarried;
+       if(!flag) { return; }
+       
+       // reset player
+       player.flagcarried = world;
+       WaypointSprite_Ping(player.wps_flagcarrier);
+       WaypointSprite_Kill(player.wps_flagcarrier);
+       
+       // transfer flag to reciever
+       flag.owner = reciever;
+       flag.owner.flagcarried = flag;
+       flag.ctf_pickupid = reciever.playerid;
+       setattachment(flag, reciever, "");
+       setorigin(flag, FLAG_CARRY_OFFSET);
+
+       // messages and sounds
+       sound(player, CH_TRIGGER, flag.snd_flag_touch, VOL_BASE, ATTN_NORM);
+       ctf_EventLog("pass", flag.team, player);
+       ctf_EventLog("recieve", flag.team, reciever);
+       FOR_EACH_PLAYER(tmp_player)
+               if(tmp_player == player)
+                       centerprint(tmp_player, strcat("You passed the ", flag.netname, " to ", reciever.netname));
+               else if(tmp_player == reciever)
+                       centerprint(tmp_player, strcat("You recieved the ", flag.netname, " from ", player.netname));
+               else if(tmp_player.team == player.team)
+                       centerprint(tmp_player, strcat(player.netname, " passed the ", flag.netname, " to ", reciever.netname));
+                       
+       // effects
+       te_lightning2(world, reciever.origin, player.origin);
+       
+       // create new waypoint
+       WaypointSprite_Spawn("flagcarrier", 0, 0, reciever, '0 0 64', world, reciever.team, reciever, wps_flagcarrier, FALSE, RADARICON_FLAG, '1 1 0');
+       WaypointSprite_UpdateMaxHealth(reciever.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent) * 2);
+       WaypointSprite_UpdateHealth(reciever.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(reciever.health, reciever.armorvalue, autocvar_g_balance_armor_blockpercent));
+       WaypointSprite_UpdateTeamRadar(reciever.wps_flagcarrier, RADARICON_FLAGCARRIER, '1 1 0');
+}
+
+void ctf_Handle_Drop(entity player, float droptype)
+{
+       entity flag = player.flagcarried;
+       if(!flag) { return; }
+       
+       if(flag.speedrunning) { ctf_RespawnFlag(flag); return; }
+       
+       // reset the flag
+       setattachment(flag, world, "");
+       setorigin(flag, player.origin + FLAG_DROP_OFFSET);
+       flag.owner.flagcarried = world;
+       flag.owner = world;
+       flag.movetype = MOVETYPE_TOSS;
+       flag.solid = SOLID_TRIGGER;
+       flag.takedamage = DAMAGE_YES;
+       flag.health = flag.max_flag_health;
+       
+       switch(droptype)
+       {
+               case DROPTYPE_THROWN:
+               {
+                       makevectors((player.v_angle_y * '0 1 0') + (player.v_angle_x * '0.5 0 0'));
+                       flag.velocity = W_CalculateProjectileVelocity(player.velocity, ('0 0 200' + (v_forward * autocvar_g_ctf_throw_velocity)), FALSE);
+                       break;
+               }
+               
+               default:
+               case DROPTYPE_NORMAL:
+               {
+                       flag.velocity = ('0 0 200' + ('0 100 0' * crandom()) + ('100 0 0' * crandom()));
+                       break;
+               }
+       }
+       
+       flag.ctf_droptime = time;
+       flag.ctf_dropperid = player.playerid;
+       flag.ctf_status = FLAG_DROPPED;
+
+       // messages and sounds
+       Send_KillNotification(player.netname, flag.netname, "", INFO_LOSTFLAG, MSG_INFO);
+       sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTN_NONE);
+       ctf_EventLog("dropped", player.team, player);
+       
+       // scoring
+       PlayerTeamScore_AddScore(player, -ctf_ReadScore("penalty_drop"));       
+       PlayerScore_Add(player, SP_CTF_DROPS, 1);
+
+       // waypoints
+       if(autocvar_g_ctf_flag_dropped_waypoint)
+               WaypointSprite_Spawn("flagdropped", 0, 0, flag, '0 0 64', world, ((autocvar_g_ctf_flag_dropped_waypoint == 2) ? 0 : player.team), flag, wps_flagdropped, FALSE, RADARICON_FLAG, '0 0.5 0' + ((flag.team == COLOR_TEAM1) ? '0.75 0 0' : '0 0 0.75')); // (COLOR_TEAM1 + COLOR_TEAM2 - flag.team)
+       
+       WaypointSprite_Ping(player.wps_flagcarrier);
+       WaypointSprite_Kill(player.wps_flagcarrier);
+
+       if(autocvar_g_ctf_flag_returntime || (autocvar_g_ctf_flag_take_damage && autocvar_g_ctf_flag_health))
+       {
+               WaypointSprite_UpdateMaxHealth(flag.wps_flagdropped, flag.max_flag_health);
+               WaypointSprite_UpdateHealth(flag.wps_flagdropped, flag.health);
+       }
+
+       // captureshield
+       ctf_CaptureShield_Update(player, 0); // shield only
+
+       // check if the flag will fall off the map
+       trace_startsolid = FALSE;
+       tracebox(flag.origin, flag.mins, flag.maxs, flag.origin, TRUE, flag);
+       if(trace_startsolid)
+               dprint("FLAG FALLTHROUGH will happen SOON\n");
+}
+
+void ctf_Handle_Dropped_Capture(entity flag, entity enemy_flag)
+{
+       /*
+       // declarations
+       float cap_time, cap_record, success;
+       string cap_message, refername;
+       
+       entity player = enemy_flag.dropperid;
+
+       // records
+       if((autocvar_g_ctf_captimerecord_always) || (player_count - currentbots)) {
+               cap_record = ctf_captimerecord;
+               cap_time = (time - player.flagcarried.ctf_pickuptime);
+
+               refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
+               refername = ((refername == player.netname) ? "their" : strcat(refername, "^7's"));
+
+               if(!ctf_captimerecord) 
+                       { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds"); success = TRUE; }
+               else if(cap_time < cap_record) 
+                       { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds, breaking ", refername, " previous record of ", ftos_decimals(cap_record, 2), " seconds"); success = TRUE; }
+               else
+                       { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds, failing to break ", refername, " record of ", ftos_decimals(cap_record, 2), " seconds"); success = FALSE; }
+
+               if(success) {
+                       ctf_captimerecord = cap_time;
+                       db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(cap_time));
+                       db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), player.netname);
+                       write_recordmarker(player, (time - cap_time), cap_time); } }
+       
+       // messages and sounds
+       Send_KillNotification(player.netname, player.flagcarried.netname, cap_message, INFO_CAPTUREFLAG, MSG_INFO);
+       sound(player, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTN_NONE); // "ctf/*_capture.wav"
+       ctf_EventLog("capture", player.flagcarried.team, player);
+       
+       // scoring
+       PlayerTeamScore_AddScore(player, ctf_ReadScore("score_capture"));
+       PlayerTeamScore_Add(player, SP_CTF_CAPS, ST_CTF_CAPS, 1);
+
+       // effects
+       if (autocvar_g_ctf_flag_capture_effects) 
+       {
+               pointparticles(particleeffectnum((player.team == COLOR_TEAM1) ? "red_ground_quake" : "blue_ground_quake"), flag.origin, '0 0 0', 1);
+               //shockwave_spawn("models/ctf/shockwavetransring.md3", flag.origin - '0 0 15', -0.8, 0, 1);
+       }
+
+       // waypointsprites
+       WaypointSprite_Kill(player.wps_flagcarrier);
+
+       // reset the flag
+       if(flag.speedrunning) { ctf_FakeTimeLimit(player, -1); }
+       
+       */
+       
+       sound(flag, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTN_NONE);
+       print("dropped capture! :D\n");
+       
+       ctf_RespawnFlag(enemy_flag);
+}
+
+void ctf_Handle_Capture(entity flag, entity player)
+{
+       // declarations
+       float cap_time, cap_record, success;
+       string cap_message, refername;
+
+       // records
+       if((autocvar_g_ctf_captimerecord_always) || (player_count - currentbots)) {
+               cap_record = ctf_captimerecord;
+               cap_time = (time - player.flagcarried.ctf_pickuptime);
+
+               refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
+               refername = ((refername == player.netname) ? "their" : strcat(refername, "^7's"));
+
+               if(!ctf_captimerecord) 
+                       { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds"); success = TRUE; }
+               else if(cap_time < cap_record) 
+                       { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds, breaking ", refername, " previous record of ", ftos_decimals(cap_record, 2), " seconds"); success = TRUE; }
+               else
+                       { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds, failing to break ", refername, " record of ", ftos_decimals(cap_record, 2), " seconds"); success = FALSE; }
+
+               if(success) {
+                       ctf_captimerecord = cap_time;
+                       db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(cap_time));
+                       db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), player.netname);
+                       write_recordmarker(player, (time - cap_time), cap_time); } }
+       
+       // messages and sounds
+       Send_KillNotification(player.netname, player.flagcarried.netname, cap_message, INFO_CAPTUREFLAG, MSG_INFO);
+       sound(player, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTN_NONE); // "ctf/*_capture.wav"
+       ctf_EventLog("capture", player.flagcarried.team, player);
+       
+       // scoring
+       PlayerTeamScore_AddScore(player, ctf_ReadScore("score_capture"));
+       PlayerTeamScore_Add(player, SP_CTF_CAPS, ST_CTF_CAPS, 1);
+
+       // effects
+       if (autocvar_g_ctf_flag_capture_effects) 
+       {
+               pointparticles(particleeffectnum((player.team == COLOR_TEAM1) ? "red_ground_quake" : "blue_ground_quake"), flag.origin, '0 0 0', 1);
+               //shockwave_spawn("models/ctf/shockwavetransring.md3", flag.origin - '0 0 15', -0.8, 0, 1);
+       }
+
+       // waypointsprites
+       WaypointSprite_Kill(player.wps_flagcarrier);
+
+       // reset the flag
+       if(flag.speedrunning) { ctf_FakeTimeLimit(player, -1); }
+       
+       ctf_RespawnFlag(player.flagcarried);
+}
+
+void ctf_Handle_Return(entity flag, entity player)
+{
+       // messages and sounds
+       //centerprint(player, strcat("You returned ", flag.netname));
+       Send_KillNotification (player.netname, flag.netname, "", INFO_RETURNFLAG, MSG_INFO);
+       sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTN_NONE);
+       ctf_EventLog("return", flag.team, player);
+
+       // scoring
+       PlayerTeamScore_AddScore(player, ctf_ReadScore(strcat("score_return", ((player.playerid == flag.playerid) ? "_by_killer" : "")))); // reward for return
+       PlayerScore_Add(player, SP_CTF_RETURNS, 1); // add to count of returns
+
+       TeamScore_AddToTeam(((flag.team == COLOR_TEAM1) ? COLOR_TEAM2 : COLOR_TEAM1), ST_SCORE, -ctf_ReadScore("penalty_returned")); // punish the team who was last carrying it
+       FOR_EACH_PLAYER(player) if(player.playerid == flag.ctf_dropperid) // punish the player who dropped the flag
+       {
+               PlayerScore_Add(player, SP_SCORE, -ctf_ReadScore("penalty_returned"));
+               ctf_CaptureShield_Update(player, 0); // shield only
+       }
+       
+       // reset the flag
+       ctf_RespawnFlag(flag);
+}
+
+void ctf_Handle_Pickup_Base(entity flag, entity player)
+{
+       entity tmp_player; // temporary entity which the FOR_EACH_PLAYER loop uses to scan players
+       string verbosename; // holds the name of the player OR no name at all for printing in the centerprints
+
+       // attach the flag to the player
+       flag.owner = player;
+       player.flagcarried = flag;
+       setattachment(flag, player, "");
+       setorigin(flag, FLAG_CARRY_OFFSET);
+       
+       // set up the flag
+       flag.movetype = MOVETYPE_NONE;
+       flag.takedamage = DAMAGE_NO;
+       flag.solid = SOLID_NOT;
+       flag.angles = '0 0 0';
+       flag.ctf_pickuptime = time; // used for timing runs
+       flag.ctf_pickupid = player.playerid;
+       flag.ctf_status = FLAG_CARRY;
+       
+       // messages and sounds
+       Send_KillNotification (player.netname, flag.netname, "", INFO_GOTFLAG, MSG_INFO);
+       sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTN_NONE);
+       ctf_EventLog("steal", flag.team, player);
+       verbosename = ((autocvar_g_ctf_flag_pickup_verbosename) ? strcat(Team_ColorCode(player.team), "(^7", player.netname, Team_ColorCode(player.team), ") ") : "");
+       FOR_EACH_PLAYER(tmp_player)
+               if(tmp_player == player)
+                       centerprint(tmp_player, strcat("You got the ", flag.netname, "!"));
+               else if(tmp_player.team == player.team)
+                       centerprint(tmp_player, strcat("Your ", Team_ColorCode(player.team), "team mate ", verbosename, "^7got the flag! Protect them!"));
+               else if(tmp_player.team == flag.team)
+                       centerprint(tmp_player, strcat("The ", Team_ColorCode(player.team), "enemy ", verbosename, "^7got your flag! Retrieve it!"));
+       
+       // scoring
+       PlayerTeamScore_AddScore(player, ctf_ReadScore("score_pickup_base"));
+       PlayerScore_Add(player, SP_CTF_PICKUPS, 1);
+       
+       // speedrunning
+       flag.speedrunning = player.speedrunning; // if speedrunning, flag will flag-return and teleport the owner back after the record
+       if((player.speedrunning) && (ctf_captimerecord))
+               ctf_FakeTimeLimit(player, time + ctf_captimerecord);
+               
+       // effects
+       if (autocvar_g_ctf_flag_pickup_effects)
+       {
+               pointparticles(particleeffectnum("smoke_ring"), 0.5 * (flag.absmin + flag.absmax), '0 0 0', 1);
+       }
+       
+       // waypoints 
+       WaypointSprite_Spawn("flagcarrier", 0, 0, player, '0 0 64', world, player.team, player, wps_flagcarrier, FALSE, RADARICON_FLAG, '1 1 0'); // (COLOR_TEAM1 + COLOR_TEAM2 - flag.team)
+       WaypointSprite_UpdateMaxHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent) * 2);
+       WaypointSprite_UpdateHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(player.health, player.armorvalue, autocvar_g_balance_armor_blockpercent));
+       WaypointSprite_UpdateTeamRadar(player.wps_flagcarrier, RADARICON_FLAGCARRIER, '1 1 0');
+       WaypointSprite_Ping(player.wps_flagcarrier);
+}
+void ctf_Handle_Pickup_Dropped(entity flag, entity player)
+{
+       // declarations
+       float returnscore = (autocvar_g_ctf_flag_returntime ? bound(0, ((flag.ctf_droptime + autocvar_g_ctf_flag_returntime) - time) / autocvar_g_ctf_flag_returntime, 1) : 1);
+       entity tmp_player; // temporary entity which the FOR_EACH_PLAYER loop uses to scan players
+       string verbosename; // holds the name of the player OR no name at all for printing in the centerprints
+
+       // attach the flag to the player
+       flag.owner = player;
+       player.flagcarried = flag;
+       setattachment(flag, player, "");
+       setorigin(flag, FLAG_CARRY_OFFSET);
+       
+       // set up the flag
+       flag.movetype = MOVETYPE_NONE;
+       flag.takedamage = DAMAGE_NO;
+       flag.health = flag.max_flag_health;
+       flag.solid = SOLID_NOT;
+       flag.angles = '0 0 0';
+       //flag.ctf_pickuptime = time; // don't update pickuptime since this isn't a real steal. 
+       flag.ctf_pickupid = player.playerid;
+       flag.ctf_status = FLAG_CARRY;
+
+       // messages and sounds
+       Send_KillNotification (player.netname, flag.netname, "", INFO_PICKUPFLAG, MSG_INFO);
+       sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTN_NONE);
+       ctf_EventLog("pickup", flag.team, player);
+       verbosename = ((autocvar_g_ctf_flag_pickup_verbosename) ? strcat(Team_ColorCode(player.team), "(^7", player.netname, Team_ColorCode(player.team), ") ") : "");
+       FOR_EACH_PLAYER(tmp_player)
+               if(tmp_player == player)
+                       centerprint(tmp_player, strcat("You got the ", flag.netname, "!"));
+               else if(tmp_player.team == player.team)
+                       centerprint(tmp_player, strcat("Your ", Team_ColorCode(player.team), "team mate ", verbosename, "^7got the flag! Protect them!"));
+               else if(tmp_player.team == flag.team)
+                       centerprint(tmp_player, strcat("The ", Team_ColorCode(player.team), "enemy ", verbosename, "^7got your flag! Retrieve it!"));
+                       
+       // scoring
+       returnscore = floor((ctf_ReadScore("score_pickup_dropped_late") * (1-returnscore) + ctf_ReadScore("score_pickup_dropped_early") * returnscore) + 0.5);
+       print("score is ", ftos(returnscore), "\n");
+       PlayerTeamScore_AddScore(player, returnscore);
+       PlayerScore_Add(player, SP_CTF_PICKUPS, 1);
+
+       // effects
+       if (autocvar_g_ctf_flag_pickup_effects) // field pickup effect
+       {
+               pointparticles(particleeffectnum("smoke_ring"), 0.5 * (flag.absmin + flag.absmax), '0 0 0', 1); 
+       }
+
+       // waypoints
+       WaypointSprite_Kill(flag.wps_flagdropped);
+       WaypointSprite_Spawn("flagcarrier", 0, 0, player, '0 0 64', world, player.team, player, wps_flagcarrier, FALSE, RADARICON_FLAG, '1 1 0'); // (COLOR_TEAM1 + COLOR_TEAM2 - flag.team)
+       WaypointSprite_UpdateMaxHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent) * 2);
+       WaypointSprite_UpdateHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(player.health, player.armorvalue, autocvar_g_balance_armor_blockpercent));
+       WaypointSprite_UpdateTeamRadar(player.wps_flagcarrier, RADARICON_FLAGCARRIER, '1 1 0');
+       WaypointSprite_Ping(player.wps_flagcarrier);
+}
+
+
+// ===================
+// Main Flag Functions
+// ===================
+
+void ctf_CheckFlagReturn(entity flag)
+{
+       if(flag.wps_flagdropped) { WaypointSprite_UpdateHealth(flag.wps_flagdropped, flag.health); }
+       
+       if((flag.health <= 0) || (time > flag.ctf_droptime + autocvar_g_ctf_flag_returntime))
+       {
+               bprint("The ", flag.netname, " has returned to base\n");
+               sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTN_NONE);
+               ctf_EventLog("returned", flag.team, world);
+               ctf_RespawnFlag(flag);
+       }
+}
+
+void ctf_FlagDamage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+{
+       if(deathtype == DEATH_HURTTRIGGER || deathtype == DEATH_SLIME || deathtype == DEATH_LAVA)
+       {
+               // automatically kill the flag and return it
+               self.health = 0;
+               ctf_CheckFlagReturn(self);
+       }
+       
+       if(autocvar_g_ctf_flag_take_damage) 
+       {
+               self.health = self.health - damage;
+               ctf_CheckFlagReturn(self);
+       }
+}
+
+void ctf_FlagThink()
+{
+       // declarations
+       entity tmp_entity;
+
+       self.nextthink = time + FLAG_THINKRATE; // only 5 fps, more is unnecessary.
+
+       // captureshield
+       if(self == ctf_worldflaglist) // only for the first flag
+               FOR_EACH_CLIENT(tmp_entity)
+                       ctf_CaptureShield_Update(tmp_entity, 1); // release shield only
+
+       // sanity checks
+       if(self.mins != FLAG_MIN || self.maxs != FLAG_MAX) { // reset the flag boundaries in case it got squished
+               dprint("wtf the flag got squashed?\n");
+               tracebox(self.origin, FLAG_MIN, FLAG_MAX, self.origin, MOVE_NOMONSTERS, self);
+               if(!trace_startsolid) // can we resize it without getting stuck?
+                       setsize(self, FLAG_MIN, FLAG_MAX); }
+
+       // main think method
+       switch(self.ctf_status)
+       {       
+               case FLAG_BASE:
+               {
+                       if(autocvar_g_ctf_dropped_capture_radius)
+                       {
+                               for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
+                                       if(tmp_entity.ctf_status == FLAG_DROPPED)
+                                               if(vlen(self.origin - tmp_entity.origin) < autocvar_g_ctf_dropped_capture_radius)
+                                                       ctf_Handle_Dropped_Capture(self, tmp_entity);
+                       }
+                       return;
+               }
+               
+               case FLAG_DROPPED:
+               {
+                       if(autocvar_g_ctf_flag_returntime)
+                       {
+                               self.health -= ((self.max_flag_health / autocvar_g_ctf_flag_returntime) * FLAG_THINKRATE);
+                               ctf_CheckFlagReturn(self);
+                       } 
+                       return;
+               }
+                       
+               case FLAG_CARRY:
+               {
+                       if((self.owner) && (self.speedrunning) && (ctf_captimerecord) && (time >= self.ctf_pickuptime + ctf_captimerecord)) 
+                       {
+                               bprint("The ", self.netname, " became impatient after ", ftos_decimals(ctf_captimerecord, 2), " seconds and returned itself\n");
+                               sound(self, CH_TRIGGER, self.snd_flag_respawn, VOL_BASE, ATTN_NONE);
+                               ctf_EventLog("returned", self.team, world);
+                               ctf_RespawnFlag(tmp_entity);
+
+                               tmp_entity = self;
+                               self = self.owner;
+                               self.impulse = CHIMPULSE_SPEEDRUN; // move the player back to the waypoint they set
+                               ImpulseCommands();
+                               self = tmp_entity;
+                       }
+                       return;
+               }
+
+               default: // this should never happen
+               {
+                       dprint("ctf_FlagThink(): Flag exists with no status?\n");
+                       return;
+               }
+       }
+}
+
+void ctf_FlagTouch()
+{
+       if(gameover) { return; }
+       if(!self) { return; }
+       if(other.deadflag != DEAD_NO) { return; }
+       
+       if(other.classname != "player") // The flag just touched an object, most likely the world
+       {
+               if(time > self.wait) // if we haven't in a while, play a sound/effect
+               {
+                       pointparticles(particleeffectnum("kaball_sparks"), self.origin, '0 0 0', 1);
+                       sound(self, CH_TRIGGER, self.snd_flag_touch, VOL_BASE, ATTN_NORM);
+               }
+               return;
+       }
+
+       switch(self.ctf_status) 
+       {       
+               case FLAG_BASE:
+               {
+                       if((other.team == self.team) && (other.flagcarried) && (other.flagcarried.team != self.team))
+                               ctf_Handle_Capture(self, other); // other just captured the enemies flag to his base
+                       else if((other.team != self.team) && (!other.flagcarried) && (!other.ctf_captureshielded))
+                               ctf_Handle_Pickup_Base(self, other); // other just stole the enemies flag
+                       break;
+               }
+               
+               case FLAG_DROPPED:
+               {
+                       if(other.team == self.team)
+                               ctf_Handle_Return(self, other); // other just returned his own flag
+                       else if((!other.flagcarried) && ((other.playerid != self.ctf_dropperid) || (time > self.ctf_droptime + autocvar_g_ctf_flag_collect_delay)))
+                               ctf_Handle_Pickup_Dropped(self, other); // other just picked up a dropped enemy flag
+                       break;
+               }
+                       
+               case FLAG_CARRY:
+               {
+                       dprint("Someone touched a flag even though it was being carried?\n");
+                       break;
+               }
+               
+               default: // this should never happen
+               {
+                       dprint("Touch: Flag exists with no status?\n");
+                       break;
+               }
+       }
+       
+       self.wait = time + FLAG_TOUCHRATE;
+}
+
+void ctf_RespawnFlag(entity flag)
+{
+       // reset the player (if there is one)
+       if((flag.owner) && (flag.owner.flagcarried == flag))
+       {
+               WaypointSprite_Kill(flag.wps_flagcarrier);
+               flag.owner.flagcarried = world;
+
+               if(flag.speedrunning)
+                       ctf_FakeTimeLimit(flag.owner, -1);
+       }
+
+       if((flag.ctf_status == FLAG_DROPPED) && (flag.wps_flagdropped))
+               { WaypointSprite_Kill(flag.wps_flagdropped); }
+
+       // reset the flag
+       setattachment(flag, world, "");
+       setorigin(flag, flag.ctf_spawnorigin); // replace with flag.ctf_spawnorigin
+       flag.movetype = ((flag.noalign) ? MOVETYPE_NONE : MOVETYPE_TOSS);
+       flag.takedamage = DAMAGE_NO;
+       flag.health = flag.max_flag_health;
+       flag.solid = SOLID_TRIGGER;
+       flag.velocity = '0 0 0';
+       flag.angles = flag.mangle;
+       flag.ctf_status = FLAG_BASE;
+       flag.flags = FL_ITEM | FL_NOTARGET;
+       flag.owner = world;
+}
+
+void ctf_Reset()
+{
+       if(self.owner)
+               if(self.owner.classname == "player")
+                       ctf_Handle_Drop(self.owner, DROPTYPE_NORMAL);
+                       
+       ctf_RespawnFlag(self);
+}
+
+void ctf_DelayedFlagSetup(void) // called after a flag is placed on a map by ctf_FlagSetup()
+{
+       // declarations
+       float teamnumber = ((self.team == COLOR_TEAM1) ? TRUE : FALSE); // if we were originally 1, this will become 0. If we were originally 0, this will become 1. 
+
+       // bot waypoints
+       waypoint_spawnforitem_force(self, self.origin);
+       self.nearestwaypointtimeout = 0; // activate waypointing again
+       self.bot_basewaypoint = self.nearestwaypoint;
+
+       // waypointsprites
+       WaypointSprite_SpawnFixed(((teamnumber) ? "redbase" : "bluebase"), self.origin + '0 0 64', self, wps_flagbase, RADARICON_FLAG, colormapPaletteColor(((teamnumber) ? COLOR_TEAM1 : COLOR_TEAM2) - 1, FALSE));
+       WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, colormapPaletteColor(((teamnumber) ? COLOR_TEAM1 : COLOR_TEAM2) - 1, FALSE));
+
+       // captureshield setup
+       ctf_CaptureShield_Spawn(self);
+}
+
+void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc 
+{      
+       // declarations
+       teamnumber = fabs(teamnumber - bound(0, autocvar_g_ctf_reverse, 1)); // if we were originally 1, this will become 0. If we were originally 0, this will become 1. 
+       self = flag; // for later usage with droptofloor()
+       
+       // main setup
+       flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist
+       ctf_worldflaglist = flag;
+
+       setattachment(flag, world, ""); 
+
+       flag.netname = ((teamnumber) ? "^1RED^7 flag" : "^4BLUE^7 flag");
+       flag.team = ((teamnumber) ? COLOR_TEAM1 : COLOR_TEAM2); // COLOR_TEAM1: color 4 team (red) - COLOR_TEAM2: color 13 team (blue)
+       flag.items = ((teamnumber) ? IT_KEY2 : IT_KEY1); // IT_KEY2: gold key (redish enough) - IT_KEY1: silver key (bluish enough)
+       flag.classname = "item_flag_team";
+       flag.target = "###item###"; // wut?
+       flag.flags = FL_ITEM | FL_NOTARGET;
+       flag.solid = SOLID_TRIGGER;
+       flag.takedamage = DAMAGE_NO;
+       flag.damageforcescale = autocvar_g_ctf_flag_damageforcescale;   
+       flag.max_flag_health = ((autocvar_g_ctf_flag_take_damage && autocvar_g_ctf_flag_health) ? autocvar_g_ctf_flag_health : 100);
+       flag.health = flag.max_flag_health;
+       flag.event_damage = ctf_FlagDamage;
+       flag.pushable = TRUE;
+       flag.damagedbytriggers = autocvar_g_ctf_flag_return_when_unreachable;
+       flag.damagedbycontents = autocvar_g_ctf_flag_return_when_unreachable;
+       flag.velocity = '0 0 0';
+       flag.mangle = flag.angles;
+       flag.reset = ctf_Reset;
+       flag.touch = ctf_FlagTouch;
+       flag.think = ctf_FlagThink;
+       flag.nextthink = time + FLAG_THINKRATE;
+       flag.ctf_status = FLAG_BASE;
+       
+       if(!flag.model) { flag.model = ((teamnumber) ? autocvar_g_ctf_flag_red_model : autocvar_g_ctf_flag_blue_model); }
+       if(!flag.scale) { flag.scale = FLAG_SCALE; }
+       if(!flag.skin) { flag.skin = ((teamnumber) ? autocvar_g_ctf_flag_red_skin : autocvar_g_ctf_flag_blue_skin); }
+       
+       // sound 
+       if(!flag.snd_flag_taken) { flag.snd_flag_taken  = ((teamnumber) ? "ctf/red_taken.wav" : "ctf/blue_taken.wav"); }
+       if(!flag.snd_flag_returned) { flag.snd_flag_returned = ((teamnumber) ? "ctf/red_returned.wav" : "ctf/blue_returned.wav"); }
+       if(!flag.snd_flag_capture) { flag.snd_flag_capture = ((teamnumber) ? "ctf/red_capture.wav" : "ctf/blue_capture.wav"); } // blue team scores by capturing the red flag
+       if(!flag.snd_flag_respawn) { flag.snd_flag_respawn = "ctf/flag_respawn.wav"; } // if there is ever a team-based sound for this, update the code to match.
+       if(!flag.snd_flag_dropped) { flag.snd_flag_dropped = ((teamnumber) ? "ctf/red_dropped.wav" : "ctf/blue_dropped.wav"); }
+       if(!flag.snd_flag_touch) { flag.snd_flag_touch = "keepaway/touch.wav"; } // again has no team-based sound // FIXME
+       
+       // precache
+       precache_sound(flag.snd_flag_taken);
+       precache_sound(flag.snd_flag_returned);
+       precache_sound(flag.snd_flag_capture);
+       precache_sound(flag.snd_flag_respawn);
+       precache_sound(flag.snd_flag_dropped);
+       precache_sound(flag.snd_flag_touch);
+       precache_model(flag.model);
+       precache_model("models/ctf/shield.md3");
+       precache_model("models/ctf/shockwavetransring.md3");
+
+       // appearence
+       setmodel(flag, flag.model); // precision set below
+       setsize(flag, FLAG_MIN, FLAG_MAX);
+       setorigin(flag, (flag.origin + FLAG_SPAWN_OFFSET));
+       
+       if(autocvar_g_ctf_flag_glowtrails)
+       {
+               flag.glow_color = ((teamnumber) ? 251 : 210); // 251: red - 210: blue
+               flag.glow_size = 25;
+               flag.glow_trail = 1;
+       }
+       
+       flag.effects |= EF_LOWPRECISION;
+       if(autocvar_g_ctf_fullbrightflags) { flag.effects |= EF_FULLBRIGHT; }
+       if(autocvar_g_ctf_dynamiclights)   { flag.effects |= ((teamnumber) ? EF_RED : EF_BLUE); }
+       
+       // flag placement
+       if((flag.spawnflags & 1) || flag.noalign) // don't drop to floor, just stay at fixed location
+       {       
+               flag.dropped_origin = flag.origin; 
+               flag.noalign = TRUE;
+               flag.movetype = MOVETYPE_NONE;
+       }
+       else // drop to floor, automatically find a platform and set that as spawn origin
+       { 
+               flag.noalign = FALSE;
+               self = flag;
+               droptofloor();
+               flag.movetype = MOVETYPE_TOSS; 
+       }       
+       
+       InitializeEntity(flag, ctf_DelayedFlagSetup, INITPRIO_SETLOCATION);
+}
+
+
+// ==============
+// Hook Functions
+// ==============
+
+MUTATOR_HOOKFUNCTION(ctf_HookedDrop)
+{
+       if(self.flagcarried) { ctf_Handle_Drop(self, DROPTYPE_NORMAL); }
+       return 0;
+}
+
+MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink)
+{
+       entity flag;
+       
+       // initially clear items so they can be set as necessary later.
+       self.items &~= (IT_RED_FLAG_CARRYING | IT_RED_FLAG_TAKEN | IT_RED_FLAG_LOST 
+               | IT_BLUE_FLAG_CARRYING | IT_BLUE_FLAG_TAKEN | IT_BLUE_FLAG_LOST | IT_CTF_SHIELDED);
+
+       // item for stopping players from capturing the flag too often
+       if(self.ctf_captureshielded)
+               self.items |= IT_CTF_SHIELDED;
+
+       // scan through all the flags and notify the client about them 
+       for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext)
+       {
+               if(flag.ctf_status == FLAG_CARRY)
+                       if(flag.owner == self)
+                               self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_CARRYING : IT_BLUE_FLAG_CARRYING); // carrying: self is currently carrying the flag
+                       else 
+                               self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_TAKEN : IT_BLUE_FLAG_TAKEN); // taken: someone on self's team is carrying the flag
+               else if(flag.ctf_status == FLAG_DROPPED) 
+                       self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_LOST : IT_BLUE_FLAG_LOST); // lost: the flag is dropped somewhere on the map
+       }
+       
+       if(self.wps_flagcarrier) { WaypointSprite_UpdateHealth(self.wps_flagcarrier, self.health); }
+       
+       return 0;
+}
+
+MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values that are applied to players in g_damage.qc
+{
+       if(frag_attacker.flagcarried) // if the attacker is a flagcarrier
+       {
+               if(frag_target == frag_attacker) // damage done to yourself
+               {
+                       frag_damage *= autocvar_g_ctf_flagcarrier_selfdamagefactor;
+                       frag_force *= autocvar_g_ctf_flagcarrier_selfforcefactor;
+               }
+               else // damage done everyone else
+               {
+                       frag_damage *= autocvar_g_ctf_flagcarrier_damagefactor;
+                       frag_force *= autocvar_g_ctf_flagcarrier_forcefactor;
+               }
+       }
+       return 0;
+}
+
+MUTATOR_HOOKFUNCTION(ctf_GiveFragsForKill)
+{
+       frag_score = 0; // no frags counted in ctf
+       return (autocvar_g_ctf_ignore_frags); // you deceptive little bugger ;3 This needs to be true in order for this function to even count. 
+}
+
+MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
+{
+       entity player = self;
+
+       if((player.flagcarried) && !(player.speedrunning))
+       {
+               if(autocvar_g_ctf_allow_pass)
+               {
+                       entity head, closest_target;
+                       head = findradius(player.origin, autocvar_g_ctf_pass_radius);
+                       
+                       while(head) // find the closest acceptable target to pass to
+                       {
+                               if(head.classname == "player" && head.deadflag == DEAD_NO)
+                               if(head != player && !IsDifferentTeam(head, player))
+                               {
+                                       if(closest_target)
+                                       {
+                                               if(vlen(player.origin - head.origin) < vlen(player.origin - closest_target.origin))
+                                                       closest_target = head;
+                                       }
+                                       else 
+                                               closest_target = head;
+                               }
+                               head = head.chain;
+                       }
+                       
+                       if(closest_target) { ctf_Handle_Pass(player, closest_target); return 0; }
+               }
+               
+               if(autocvar_g_ctf_allow_drop) { ctf_Handle_Drop(player, DROPTYPE_THROWN); }
+       }
+               
+       return 0;
+}
+
+// ==========
+// Spawnfuncs
+// ==========
+
+/*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
+CTF Starting point for a player in team one (Red).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team1()
+{
+       if(g_assault) { remove(self); return; }
+       
+       self.team = COLOR_TEAM1; // red
+       spawnfunc_info_player_deathmatch();
+}
+
+
+/*QUAKED spawnfunc_info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
+CTF Starting point for a player in team two (Blue).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team2()
+{
+       if(g_assault) { remove(self); return; }
+       
+       self.team = COLOR_TEAM2; // blue
+       spawnfunc_info_player_deathmatch();
+}
+
+/*QUAKED spawnfunc_info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24)
+CTF Starting point for a player in team three (Yellow).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team3()
+{
+       if(g_assault) { remove(self); return; }
+       
+       self.team = COLOR_TEAM3; // yellow
+       spawnfunc_info_player_deathmatch();
+}
+
+
+/*QUAKED spawnfunc_info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24)
+CTF Starting point for a player in team four (Purple).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team4()
+{
+       if(g_assault) { remove(self); return; }
+       
+       self.team = COLOR_TEAM4; // purple
+       spawnfunc_info_player_deathmatch();
+}
+
+/*QUAKED spawnfunc_item_flag_team1 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
+CTF flag for team one (Red).
+Keys: 
+"angle" Angle the flag will point (minus 90 degrees)... 
+"model" model to use, note this needs red and blue as skins 0 and 1...
+"noise" sound played when flag is picked up...
+"noise1" sound played when flag is returned by a teammate...
+"noise2" sound played when flag is captured...
+"noise3" sound played when flag is lost in the field and respawns itself... 
+"noise4" sound played when flag is dropped by a player...
+"noise5" sound played when flag touches the ground... */
+void spawnfunc_item_flag_team1()
+{
+       if(!g_ctf) { remove(self); return; }
+
+       ctf_FlagSetup(1, self); // 1 = red
+}
+
+/*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
+CTF flag for team two (Blue).
+Keys: 
+"angle" Angle the flag will point (minus 90 degrees)... 
+"model" model to use, note this needs red and blue as skins 0 and 1...
+"noise" sound played when flag is picked up...
+"noise1" sound played when flag is returned by a teammate...
+"noise2" sound played when flag is captured...
+"noise3" sound played when flag is lost in the field and respawns itself... 
+"noise4" sound played when flag is dropped by a player...
+"noise5" sound played when flag touches the ground... */
+void spawnfunc_item_flag_team2()
+{
+       if(!g_ctf) { remove(self); return; }
+
+       ctf_FlagSetup(0, self); // the 0 is misleading, but -- 0 = blue.
+}
+
+/*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
+Team declaration for CTF gameplay, this allows you to decide what team names and control point models are used in your map.
+Note: If you use spawnfunc_ctf_team entities you must define at least 2!  However, unlike domination, you don't need to make a blank one too.
+Keys:
+"netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
+"cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
+void spawnfunc_ctf_team()
+{
+       if(!g_ctf) { remove(self); return; }
+       
+       self.classname = "ctf_team";
+       self.team = self.cnt + 1;
+}
+
+
+// ==============
+// Initialization
+// ==============
+
+// code from here on is just to support maps that don't have flag and team entities
+void ctf_SpawnTeam (string teamname, float teamcolor)
+{
+       entity oldself;
+       oldself = self;
+       self = spawn();
+       self.classname = "ctf_team";
+       self.netname = teamname;
+       self.cnt = teamcolor;
+
+       spawnfunc_ctf_team();
+
+       self = oldself;
+}
+
+void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.
+{
+       // if no teams are found, spawn defaults
+       if(find(world, classname, "ctf_team") == world)
+       {
+               print("No ""ctf_team"" entities found on this map, creating them anyway.\n");
+               ctf_SpawnTeam("Red", COLOR_TEAM1 - 1);
+               ctf_SpawnTeam("Blue", COLOR_TEAM2 - 1);
+       }
+       
+       ScoreRules_ctf();
+}
+
+void ctf_Initialize()
+{
+       ctf_captimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time")));
+
+       ctf_captureshield_min_negscore = autocvar_g_ctf_shield_min_negscore;
+       ctf_captureshield_max_ratio = autocvar_g_ctf_shield_max_ratio;
+       ctf_captureshield_force = autocvar_g_ctf_shield_force;
+       
+       InitializeEntity(world, ctf_DelayedInit, INITPRIO_GAMETYPE);
+}
+
+
+MUTATOR_DEFINITION(gamemode_ctf)
+{
+       MUTATOR_HOOK(MakePlayerObserver, ctf_HookedDrop, CBC_ORDER_ANY);
+       MUTATOR_HOOK(ClientDisconnect, ctf_HookedDrop, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerDies, ctf_HookedDrop, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PortalTeleport, ctf_HookedDrop, CBC_ORDER_ANY);
+       MUTATOR_HOOK(GiveFragsForKill, ctf_GiveFragsForKill, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerPreThink, ctf_PlayerPreThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerDamage_Calculate, ctf_PlayerDamage, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerUseKey, ctf_PlayerUseKey, CBC_ORDER_ANY);
+
+       MUTATOR_ONADD
+       {
+               if(time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               g_ctf = 1;
+               ctf_Initialize();
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               g_ctf = 0;
+               error("This is a game type and it cannot be removed at runtime.");
+       }
+
+       return 0;
+}
diff --git a/qcsrc/server/mutators/gamemode_ctf.qh b/qcsrc/server/mutators/gamemode_ctf.qh
new file mode 100644 (file)
index 0000000..c089b99
--- /dev/null
@@ -0,0 +1,77 @@
+// these are needed since mutators are compiled last
+
+// used in cheats.qc
+void ctf_RespawnFlag(entity flag)
+
+// used in portals.qc
+void ctf_Handle_Drop(entity player, float droptype);
+
+// used in g_damage.qc
+float ctf_ReadScore(string parameter); // SOON WON'T BE NEEDED. // FIXCTF
+
+// used in t_quake3.qc
+void spawnfunc_info_player_team1();
+void spawnfunc_info_player_team2();
+void spawnfunc_info_player_team3();
+void spawnfunc_info_player_team4();
+void spawnfunc_item_flag_team1();
+void spawnfunc_item_flag_team2();
+void spawnfunc_ctf_team();
+
+// flag constants 
+#define FLAG_MIN (PL_MIN + '0 0 -13')
+#define FLAG_MAX (PL_MAX + '0 0 -13')
+#define FLAG_SCALE 0.6
+
+#define FLAG_THINKRATE 0.2
+#define FLAG_TOUCHRATE 0.5
+
+#define FLAG_DROP_OFFSET ('0 0 32')
+#define FLAG_CARRY_OFFSET ('-15 0 7')
+#define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13))
+#define FLAG_WAYPOINT_OFFSET ('0 0 64')
+
+// sounds 
+.string noise4;
+.string noise5;
+
+#define snd_flag_taken noise
+#define snd_flag_returned noise1
+#define snd_flag_capture noise2
+#define snd_flag_respawn noise3
+#define snd_flag_dropped noise4
+#define snd_flag_touch noise5
+
+// list of flags on the map
+entity ctf_worldflaglist;
+.entity ctf_worldflagnext;
+
+// waypoint sprites
+.entity bot_basewaypoint; // flag waypointsprite
+.entity wps_flagbase; 
+.entity wps_flagcarrier;
+.entity wps_flagdropped;
+
+// statuses
+#define FLAG_BASE 1
+#define FLAG_CARRY 2
+#define FLAG_DROPPED 3
+
+#define DROPTYPE_NORMAL 1
+#define DROPTYPE_THROWN 2
+
+// flag properties
+#define ctf_spawnorigin dropped_origin
+float ctf_captimerecord; // record time for capturing the flag
+.float ctf_pickuptime;
+.float ctf_pickupid;
+.float ctf_dropperid; // don't allow spam of dropping the flag
+.float ctf_droptime;
+.float ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
+.float max_flag_health;
+
+// CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
+.float ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
+float ctf_captureshield_min_negscore; // punish at -20 points
+float ctf_captureshield_max_ratio; // punish at most 30% of each team
+float ctf_captureshield_force; // push force of the shield
\ No newline at end of file
index 8554a12238f08c2aea42b1bec64e5017de5f2492..da3fd75f1dced90a2b8edee2a77757b2b6d56920 100644 (file)
@@ -117,7 +117,7 @@ void GiveBall(entity plyr, entity ball)
        ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
        ball.team = plyr.team;
        plyr.ballcarried = ball;
-       ball.dropperid = plyr.playerid;
+       ball.ctf_dropperid = plyr.playerid;
 
        plyr.effects |= autocvar_g_nexball_basketball_effects_default;
        ball.effects &~= autocvar_g_nexball_basketball_effects_default;
@@ -287,7 +287,7 @@ void basketball_touch(void)
                football_touch();
                return;
        }
-       if(!self.cnt && other.classname == "player" && (other.playerid != self.dropperid || time > self.ctf_droptime + autocvar_g_nexball_delay_collect))
+       if(!self.cnt && other.classname == "player" && (other.playerid != self.ctf_dropperid || time > self.ctf_droptime + autocvar_g_nexball_delay_collect))
        {
                if(other.health <= 0)
                        return;
index bc3c3fbd4446a5283d841a5a24ee1c6b3893981b..debdae989636107f8ec356897a34fa99f70a465e 100644 (file)
@@ -1,6 +1,7 @@
 MUTATOR_DECLARATION(gamemode_keyhunt);
 MUTATOR_DECLARATION(gamemode_freezetag);
 MUTATOR_DECLARATION(gamemode_keepaway);
+MUTATOR_DECLARATION(gamemode_ctf);
 MUTATOR_DECLARATION(gamemode_nexball);
 
 MUTATOR_DECLARATION(mutator_invincibleprojectiles);
index 76af253dca5c0f3bd3b5785134f9c378687fdf8c..75dae14bf5f28d666e9beb91e820e912389a1a54 100644 (file)
@@ -154,8 +154,11 @@ float Portal_TeleportPlayer(entity teleporter, entity player)
        // factor -1 allows chaining portals, but may be weird
        player.right_vector = -1 * AnglesTransform_Apply(transform, player.right_vector);
 
-       if(player.flagcarried)
-               DropFlag(player.flagcarried, player, world);
+       entity oldself = self;
+       self = player;
+       MUTATOR_CALLHOOK(PortalTeleport);
+       player = self;
+       self = oldself;
 
        if not(teleporter.enemy)
        {
index 0dbe5378186ab296c6cff094d0dfce718d9dfdd4..c20090022f54d163e3a9c137d8c92483174e31f6 100644 (file)
@@ -29,6 +29,7 @@ defs.qh               // Should rename this, it has fields and globals
 
 mutators/base.qh
 mutators/mutators.qh
+mutators/gamemode_ctf.qh
 mutators/gamemode_keyhunt.qh // TODO fix this
 mutators/gamemode_nexball.qh 
 mutators/mutator_dodging.qh
@@ -138,7 +139,7 @@ cl_client.qc
 t_plats.qc
 antilag.qc
 
-ctf.qc
+//ctf.qc
 domination.qc
 mode_onslaught.qc
 //nexball.qc
@@ -205,10 +206,11 @@ playerstats.qc
 ../common/explosion_equation.qc
 
 mutators/base.qc
-mutators/gamemode_nexball.qc
-mutators/gamemode_keyhunt.qc
+mutators/gamemode_ctf.qc
 mutators/gamemode_freezetag.qc
+mutators/gamemode_keyhunt.qc
 mutators/gamemode_keepaway.qc
+mutators/gamemode_nexball.qc
 mutators/mutator_invincibleproj.qc
 mutators/mutator_nix.qc
 mutators/mutator_dodging.qc
index 960e59d67492f8ddf5ad3959515d303932c9f043..de6fe352a4bc3c1d7327dee2ed482df2afc57a1f 100644 (file)
@@ -68,7 +68,7 @@ string TeamNoName(float t)
 }
 
 void dom_init();
-void ctf_init();
+//void ctf_init();
 void runematch_init();
 void tdm_init();
 void entcs_init();
@@ -157,10 +157,9 @@ void InitGameplayMode()
        if(g_ctf)
        {
                ActivateTeamplay();
-               g_ctf_ignore_frags = autocvar_g_ctf_ignore_frags;
                fraglimit_override = autocvar_capturelimit_override;
                leadlimit_override = autocvar_captureleadlimit_override;
-               ctf_init();
+               MUTATOR_ADD(gamemode_ctf);
                have_team_spawns = -1; // request team spawns
        }
 
index 20c74d3a17e24deb0012882c634c9d527d4747d0..97784315d1f0ba14e33cfca06913c0b8811e3ceb 100644 (file)
@@ -520,6 +520,7 @@ void vehicles_enter()
 
     CSQCVehicleSetup(self.owner, self.hud);
     
+    /* FIXCTF // THIS IS A BIG NO-NO, NO GAME MODE SPECIFIC CODE IN VEHICLES.
     if(other.flagcarried)
     {
         if(!autocvar_g_vehicles_allow_flagcarry)
@@ -531,6 +532,7 @@ void vehicles_enter()
             setorigin(other, '0 0 96');
         }
     }
+    */
     
     self.vehicle_enter();
     antilag_clear(other);
@@ -647,12 +649,14 @@ void vehicles_exit(float eject)
     else
         self.team = self.tur_head.team;
     
+    /* FIXCTF // THIS IS A BIG NO-NO, NO GAME MODE SPECIFIC CODE IN VEHICLES.
     if(self.owner.flagcarried)
     {
         self.owner.flagcarried.scale = 0.6;
         setattachment(self.owner.flagcarried, self.owner, ""); 
         setorigin(self.owner.flagcarried, FLAG_CARRY_POS);
     }
+    */
     
     sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM);
     self.vehicle_exit(eject);