diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index f5eddf380b7b1436994a376ba5cfd6aa3f57b051..e74d4978e43f7c53387158e435887f0bed4e3df1 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -2542,6 +2542,24 @@ udmf
 			}
 		}
 
+		309
+		{
+			title = "CTF Team";
+			prefix = "(309)";
+			arg0
+			{
+				title = "Trigger type";
+				type = 11;
+				enum = "triggertype";
+			}
+			arg1
+			{
+				title = "Team";
+				type = 11;
+				enum = "team";
+			}
+		}
+
 		313
 		{
 			title = "No More Enemies - Once";
diff --git a/extras/conf/udb/Includes/SRB222_misc.cfg b/extras/conf/udb/Includes/SRB222_misc.cfg
index 2f2992b0d23f656e2904f52d05b541481d8f1efc..4b37d4628b832c03645e7f8df078b037e747bcf4 100644
--- a/extras/conf/udb/Includes/SRB222_misc.cfg
+++ b/extras/conf/udb/Includes/SRB222_misc.cfg
@@ -503,6 +503,12 @@ enums
 		2 = "Each time on entry";
 		3 = "Each time on entry/exit";
 	}
+
+	team
+	{
+		0 = "Red";
+		1 = "Blue";
+	}
 }
 
 //Default things filters
diff --git a/src/p_setup.c b/src/p_setup.c
index add37c25b47187563070924e05cf9aa1cb056a49..4b567d324d3a5b391b25656a5c5176b78ec9e3a4 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -3737,6 +3737,17 @@ static void P_ConvertBinaryMap(void)
 			lines[i].args[3] = !!(lines[i].flags & ML_EFFECT4);
 			lines[i].special = 303;
 			break;
+		case 309: //CTF red team - continuous
+		case 310: //CTF red team - each time
+		case 311: //CTF blue team - continuous
+		case 312: //CTF blue team - each time
+			if (lines[i].special % 2 == 1)
+				lines[i].args[0] = (lines[i].flags & ML_BOUNCY) ? TMT_EACHTIMEENTERANDEXIT : TMT_EACHTIMEENTER;
+			else
+				lines[i].args[0] = TMT_CONTINUOUS;
+			lines[i].args[1] = (lines[i].special > 310) ? TMT_BLUE : TMT_RED;
+			lines[i].special = 309;
+			break;
 		case 313: //No more enemies - once
 			lines[i].args[0] = tag;
 			break;
diff --git a/src/p_spec.c b/src/p_spec.c
index ca084750b88285eabdb28e77f02de35210a332e5..f75cd5419bca36047d74cd97c9bce6ae79330686 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -1752,16 +1752,11 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
 			if (!(actor && actor->player && actor->player->charability == dist/10))
 				return false;
 			break;
-		case 309: // continuous
-		case 310: // each time
-			// Only red team members can activate this.
-			if (!(actor && actor->player && actor->player->ctfteam == 1))
+		case 309:
+			// Only red/blue team members can activate this.
+			if (!(actor && actor->player))
 				return false;
-			break;
-		case 311: // continuous
-		case 312: // each time
-			// Only blue team members can activate this.
-			if (!(actor && actor->player && actor->player->ctfteam == 2))
+			if (actor->player->ctfteam != ((triggerline->args[1] == TMT_RED) ? 1 : 2))
 				return false;
 			break;
 		case 314:
@@ -1851,6 +1846,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
 	 || (specialtype == 303 && triggerline->args[0] == TMT_ONCE)  // Ring count
 	 || specialtype == 307  // Character ability - Once
 	 || specialtype == 308  // Race only - Once
+	 || (specialtype == 309 && triggerline->args[0] == TMT_ONCE)  // CTF team
 	 || specialtype == 313  // No More Enemies - Once
 	 || (specialtype == 314 && triggerline->args[0] == TMT_ONCE)  // No of pushables
 	 || (specialtype == 317 && triggerline->args[0] == TMT_ONCE)  // Unlockable trigger
@@ -6662,6 +6658,14 @@ void P_SpawnSpecials(boolean fromnetsave)
 				}
 				break;
 
+				// Linedef executor triggers for CTF teams.
+			case 309:
+				if (!(gametyperules & GTR_TEAMFLAGS))
+				{
+					lines[i].special = 0;
+					break;
+				}
+				/* FALLTHRU */
 			case 300: // Trigger linedef executor
 			case 303: // Count rings
 			case 314: // Pushable linedef executors (count # of pushables)
@@ -6681,17 +6685,8 @@ void P_SpawnSpecials(boolean fromnetsave)
 					lines[i].special = 0;
 				break;
 
-			// Linedef executor triggers for CTF teams.
-			case 309:
-			case 311:
-				if (!(gametyperules & GTR_TEAMFLAGS))
-					lines[i].special = 0;
-				break;
-
 			// Each time executors
 			case 306:
-			case 310:
-			case 312:
 			case 332:
 			case 335:
 				P_AddEachTimeThinker(&lines[i], !!(lines[i].flags & ML_BOUNCY));
diff --git a/src/p_spec.h b/src/p_spec.h
index b7968432c30a5237650edb531ee2b7be43e5de58..0ed5ad8d48e6c0ed8c95a35c66796237623de167 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -114,6 +114,12 @@ typedef enum
 	TMT_EACHTIMEENTERANDEXIT = 3,
 } textmaptriggertype_t;
 
+typedef enum
+{
+	TMT_RED  = 0,
+	TMT_BLUE = 1,
+} textmapteam_t;
+
 typedef enum
 {
 	TMC_EQUAL = 0,