diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg
index f457fe9721000f0efc7b690b13250387a42cb355..4678563440263e50cd2ca77fbae5972e9f57185f 100644
--- a/extras/conf/SRB2-22.cfg
+++ b/extras/conf/SRB2-22.cfg
@@ -2009,6 +2009,14 @@ linedeftypes
 			flags8text = "[3] Set delay by backside sector";
 		}
 
+		408
+		{
+			title = "Set Tagged Sector's Flats";
+			prefix = "(408)";
+			flags64text = "[6] Don't set floor flat";
+			flags512text = "[9] Don't set ceiling flat";
+		}
+
 		409
 		{
 			title = "Change Tagged Sector's Tag";
diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index 4cf3159e25a81fcdc7a27cdb1663a85a435e2477..0e110cfb6ca267c7a661c1d70cceb0b00c90b1e4 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -765,6 +765,11 @@ doom
 			title = "Set Tagged Sector's Light Level";
 			prefix = "(402)";
 		}
+		408
+		{
+			title = "Set Tagged Sector's Flats";
+			prefix = "(408)";
+		}
 		409
 		{
 			title = "Change Tagged Sector's Tag";
@@ -2448,6 +2453,23 @@ udmf
 				}
 			}
 		}
+
+		408
+		{
+			title = "Set Tagged Sector's Flats";
+			prefix = "(408)";
+			arg0
+			{
+				title = "Target sector tag";
+				type = 13;
+			}
+			arg1
+			{
+				title = "Affected planes";
+				type = 11;
+				enum = "floorceiling";
+			}
+		}
 	}
 
 	linedefexecplane
diff --git a/src/p_setup.c b/src/p_setup.c
index 9c1a2d68cf43c20cf890e8f41602fd454f38a002..56c3ed78ba1182c150f0f3cbccc77d213e705379 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -3570,6 +3570,20 @@ static void P_ConvertBinaryMap(void)
 			lines[i].args[4] = !!(lines[i].flags & ML_NOCLIMB);
 			lines[i].special = 405;
 			break;
+		case 408: //Set flats
+			lines[i].args[0] = tag;
+			if ((lines[i].flags & (ML_NOCLIMB|ML_EFFECT4)) == (ML_NOCLIMB|ML_EFFECT4))
+			{
+				CONS_Alert(CONS_WARNING, M_GetText("Set flats linedef (tag %d) doesn't have anything to do.\nConsider changing the linedef's flag configuration or removing it entirely.\n"), tag);
+				lines[i].special = 0;
+			}
+			else if (lines[i].flags & ML_NOCLIMB)
+				lines[i].args[1] = 1;
+			else if (lines[i].flags & ML_EFFECT4)
+				lines[i].args[1] = 0;
+			else
+				lines[i].args[1] = 2;
+			break;
 		case 411: //Stop plane movement
 			lines[i].args[0] = tag;
 			break;
diff --git a/src/p_spec.c b/src/p_spec.c
index 723b71b9bd7dd14c269707ac3fbbd414e500b23a..66071d9c62b78cb25b4807cc833587796331565c 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -2284,6 +2284,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
 				EV_DoCeiling(line->args[0], line, moveCeilingByDistance);
 			break;
 
+		case 408: // Set flats
+		{
+			TAG_ITER_SECTORS(line->args[0], secnum)
+			{
+				if (line->args[1] != 1)
+					sectors[secnum].floorpic = line->frontsector->floorpic;
+				if (line->args[1] != 0)
+					sectors[secnum].ceilingpic = line->frontsector->ceilingpic;
+			}
+			break;
+		}
+
 		case 409: // Change tagged sectors' tag
 		// (formerly "Change calling sectors' tag", but behavior was changed)
 		{