Skip to content

Commit

Permalink
added 'physics' cvar; closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
XaserAcheron committed May 21, 2017
1 parent 81b112e commit 76187c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/cvarinfo.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
server int dam_font = 0;
server int dam_color = -1;
server int dam_spray = 0;
server bool dam_enabled = true;
server int dam_physics = 0;
server bool dam_enabled = true;
13 changes: 10 additions & 3 deletions src/menudef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ OptionValue "DamFonts"
2, "Modern Doom"
}

OptionValue "DamPhysics"
{
0, "Toss"
1, "Float"
}

OptionValue "DamEnabled"
{
0, "Disabled"
Expand Down Expand Up @@ -50,7 +56,8 @@ OptionMenu "DamNumsOptions"
Option "Mod Enabled" , "dam_enabled", "DamEnabled"
StaticText ""
StaticText "Number Display Settings", 1
Option "Font" , "dam_font" , "DamFonts"
Option "Color" , "dam_color", "DamColors"
Option "Shotgun Spray", "dam_spray", "YesNo"
Option "Font" , "dam_font" , "DamFonts"
Option "Color" , "dam_color" , "DamColors"
Option "Physics" , "dam_physics", "DamPhysics"
Option "Shotgun Spray", "dam_spray" , "YesNo"
}
6 changes: 6 additions & 0 deletions src/zscript/damnums/constants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ enum DamNum_Fonts
DAM_FONT_SMALL = 1,
DAM_FONT_MODERN = 2,
};

enum DamNum_Physics
{
DAM_PHYSICS_TOSS = 0,
DAM_PHYSICS_FLOAT = 1,
};
34 changes: 26 additions & 8 deletions src/zscript/damnums/damnum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ class DamNum : Actor
*/
action void A_DamNumMovement(double fade = 0)
{
// [TODO] switch movement types here
self.vel.z -= self.Gravity;
// gravity is a fundamental force, yo
if(!self.bNoGravity) {
self.vel.z -= self.Gravity;
}

// fade to nothing
if(fade) {
Expand Down Expand Up @@ -109,8 +111,24 @@ class DamNum : Actor
Vector3 posDiff = (curPlayer.pos - position);
double ang = ((atan2(posDiff.y, posDiff.x) + 360.0) % 360.0) + frandom(-20, 20);

// pre-calculate velocity so we can apply it to all spawned nums.
vector3 nvel = (1.0 * cos(ang), 1.0 * sin(ang), frandom(3.0, 4.0));
// determine the physics style pre-spawn, so the cvar doesn't
// have to be checked every single tic (and the physics style
// doesn't abruptly shift if the user changes it later).
Cvar cv = CVar.FindCvar("dam_physics");
int physics = (cv) ? cv.GetInt() : 0;
vector3 nvel;
bool noGravity;
switch(physics)
{
case DAM_PHYSICS_TOSS:
nvel = (1.0 * cos(ang), 1.0 * sin(ang), frandom(3.0, 4.0));
noGravity = false;
break;

case DAM_PHYSICS_FLOAT:
nvel = (0, 0, 1.0);
noGravity = true;
}

// figure out which font to use. This is done here so it doesn't have to
// be determined for every single digit.
Expand All @@ -129,12 +147,11 @@ class DamNum : Actor
double fontAlpha;
int fontRender;

CVar cv = CVar.FindCvar("dam_font");
int cval = (cv) ? cv.GetInt() : 0;
cv = CVar.FindCvar("dam_font");
int font = (cv) ? cv.GetInt() : 0;

switch(cval)
switch(font)
{

case DAM_FONT_SMALL:
fontPrefix = "NS";
fontTrans = "DamRed";
Expand Down Expand Up @@ -179,6 +196,7 @@ class DamNum : Actor
if(damnum) {
damnum.vel = nvel;
damnum.angle = ang;
damnum.bNoGravity = noGravity;
damnum.A_SetScale(fontScale, fontScale);
damnum.A_SetRenderStyle(fontAlpha, fontRender);
damnum.A_SetTranslation(fontTrans);
Expand Down

0 comments on commit 76187c8

Please sign in to comment.