Skip to content

Commit

Permalink
added friction and colormap related properties from DSDA.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Oct 29, 2023
1 parent 4ddffd2 commit 9a94472
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions specs/udmf_zdoom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ Note: All <bool> fields default to false unless mentioned otherwise.
scroll_floor_x = <float>;
scroll_floor_y = <float>;
scroll_floor_type = <string>;

friction = <float>; // sets the sector's friction factor. Must be between 0 and 1.
movefactor = <float> // sets the sector's movement acceleration factor. Must be > 0.

colormap = <string>; // only provided for backwards compatibility. Do not use in GZDoom projects.

* Note about dropactors

Expand Down
1 change: 1 addition & 0 deletions src/maploader/maploader.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class MapLoader
void CreateScroller(EScroll type, double dx, double dy, sector_t *sect, side_t* side, int accel, EScrollPos scrollpos = EScrollPos::scw_all, int scrollmode = 15/*SCROLL_All*/);
void SpawnScrollers();
void SpawnFriction();
void SpawnUDMFFriction(double friction_factor, double move_factor, sector_t* sec);
void SpawnPushers();
AActor *GetPushThing (int s);
void SpawnPortal(line_t *line, int sectortag, int plane, int bytealpha, int linked);
Expand Down
26 changes: 25 additions & 1 deletion src/maploader/udmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,8 @@ class UDMFParser : public UDMFParserBase
double scroll_floor_y = 0;
int scroll_floor_type = 0;

double friction = -FLT_MAX, movefactor = -FLT_MAX;

const double scrollfactor = 1 / 3.2; // I hope this is correct, it's just a guess taken from Eternity's code.

memset(sec, 0, sizeof(*sec));
Expand Down Expand Up @@ -2110,7 +2112,19 @@ class UDMFParser : public UDMFParserBase
break;
}

// These two are used by Eternity for something I do not understand.
case NAME_colormap:
sec->selfmap = R_ColormapNumForName(CheckString(key));
break;

case NAME_frictionfactor:
friction = CheckFloat(key);
break;

case NAME_movefactor:
movefactor = CheckFloat(key);
break;

// These two are used by Eternity for something I do not understand.
//case NAME_portal_ceil_useglobaltex:
//case NAME_portal_floor_useglobaltex:

Expand Down Expand Up @@ -2236,6 +2250,16 @@ class UDMFParser : public UDMFParserBase
sec->Colormap.Desaturation = clamp(desaturation, 0, 255);
sec->Colormap.FogDensity = clamp(fogdensity, 0, 512) / 2;
}
if (friction > -FLT_MAX)
{
sec->friction = clamp(friction, 0., 1.);
sec->movefactor = FrictionToMoveFactor(sec->friction);
sec->Flags |= SECF_FRICTION;
}
if (movefactor > -FLT_MAX)
{
sec->movefactor = max(movefactor, 1 / 2048.);
}
}

//===========================================================================
Expand Down

0 comments on commit 9a94472

Please sign in to comment.