Commits

Braden Obrzut  committed 11ef356

- Added player.movebob property which mutliplies the movement bob.

  • Participants
  • Parent commits 1ba3588

Comments (0)

Files changed (7)

File src/g_shared/a_playerpawn.cpp

 
 	ControlMovement(this);
 
-	static const fixed MAXBOB = 0x100000;
-	player->bob = thrustspeed << 8;
-	if(player->bob > MAXBOB)
-		player->bob = MAXBOB;
+	// [RH] Smooth transitions between bobbing and not-bobbing frames.
+	// This also fixes the bug where you can "stick" a weapon off-center by
+	// shooting it when it's at the peak of its swing.
+	static fixed curbob = 0;
+	const fixed movebob = GetClass()->Meta.GetMetaFixed(APMETA_MoveBob);
+
+	if(movebob)
+	{
+		static const fixed MAXBOB = 0x100000;
+		fixed bobtarget = FixedMul(thrustspeed << 8, movebob);
+		if(bobtarget > MAXBOB)
+			bobtarget = MAXBOB;
+
+		if (curbob != bobtarget)
+		{
+			if (abs (bobtarget - curbob) <= 1*FRACUNIT)
+			{
+				curbob = bobtarget;
+			}
+			else
+			{
+				fixed_t zoom = MAX<fixed_t> (1*FRACUNIT, abs (curbob - bobtarget) / 40);
+				if (curbob > bobtarget)
+				{
+					curbob -= zoom;
+				}
+				else
+				{
+					curbob += zoom;
+				}
+			}
+		}
+	}
+	else
+		curbob = 0;
+
+	player->bob = curbob;
 }
 
 void APlayerPawn::TickPSprites()

File src/g_shared/a_playerpawn.h

 	APMETA_Slot8,
 	APMETA_Slot9,
 	APMETA_StartInventory,
-	APMETA_DisplayName
+	APMETA_DisplayName,
+	APMETA_MoveBob
 };
 
 class APlayerPawn : public AActor

File src/thingdef/thingdef_properties.cpp

 	defaults->missilechance = chance;
 }
 
+HANDLE_PROPERTY(movebob)
+{
+	FLOAT_PARAM(strength, 0);
+
+	cls->Meta.SetMetaFixed(APMETA_MoveBob, strength*FRACUNIT);
+}
+
 HANDLE_PROPERTY(painchance)
 {
 	INT_PARAM(chance, 0);
 	DEFINE_PROP_PREFIX(maxhealth, PlayerPawn, Player, I),
 	DEFINE_PROP(missilechance, Actor, I),
 	DEFINE_PROP(MONSTER, Actor,),
+	DEFINE_PROP_PREFIX(movebob, PlayerPawn, Player, F),
 	DEFINE_PROP(painchance, Actor, I),
 	DEFINE_PROP(painsound, Actor, S),
 	DEFINE_PROP(pickupsound, Inventory, S),

File src/wl_agent.cpp

 
 void player_t::BobWeapon (fixed *x, fixed *y)
 {
-	static fixed_t curbob = 0;
-
 	AWeapon *weapon;
 	fixed bobtarget;
 
 
 	// Bob the weapon based on movement speed.
 	int angle = (bobspeed*35/TICRATE*gamestate.TimeCount)&FINEMASK;
-
-	// [RH] Smooth transitions between bobbing and not-bobbing frames.
-	// This also fixes the bug where you can "stick" a weapon off-center by
-	// shooting it when it's at the peak of its swing.
-	bobtarget = (flags & PF_WEAPONBOBBING) ? bob : 0;
-	if (curbob != bobtarget)
-	{
-		if (abs (bobtarget - curbob) <= 1*FRACUNIT)
-		{
-			curbob = bobtarget;
-		}
-		else
-		{
-			fixed_t zoom = MAX<fixed_t> (1*FRACUNIT, abs (curbob - bobtarget) / 40);
-			if (curbob > bobtarget)
-			{
-				curbob -= zoom;
-			}
-			else
-			{
-				curbob += zoom;
-			}
-		}
-	}
+	fixed curbob = (flags & PF_WEAPONBOBBING) ? bob : 0;
 
 	if (curbob != 0)
 	{

File src/wl_draw.cpp

 	lastside = -1;                  // the first pixel is on a new wall
 	viewshift = FixedMul(focallengthy, finetangent[(ANGLE_180+players[0].camera->pitch)>>ANGLETOFINESHIFT]);
 
-	static fixed curbob = 0;
+	
 	angle_t bobangle = ((gamestate.TimeCount<<13)/(20*TICRATE/35)) & FINEMASK;
-	// [RH] Smooth transitions between bobbing and not-bobbing frames.
-	// This also fixes the bug where you can "stick" a weapon off-center by
-	// shooting it when it's at the peak of its swing.
-	fixed bobtarget = FixedMul(players[0].bob>>1, finesine[bobangle]);
-	if (curbob != bobtarget)
-	{
-		if (abs (bobtarget - curbob) <= 1*FRACUNIT)
-		{
-			curbob = bobtarget;
-		}
-		else
-		{
-			fixed_t zoom = MAX<fixed_t> (1*FRACUNIT, abs (curbob - bobtarget) / 40);
-			if (curbob > bobtarget)
-			{
-				curbob -= zoom;
-			}
-			else
-			{
-				curbob += zoom;
-			}
-		}
-	}
+	fixed curbob = FixedMul(players[0].bob>>1, finesine[bobangle]);
+	
 	viewz = (32<<FRACBITS) + curbob;
 
 	AsmRefresh();

File wadsrc/static/actors/native.txt

 actor PlayerPawn native
 {
 	player.maxhealth 100
+	player.movebob 1.0
 	+SOLID
 	+SHOOTABLE
 	+PICKUP

File wadsrc/static/actors/wolf/wolfplayer.txt

 {
 	health 100
 	radius 22
+	player.movebob 0
 	player.displayname "BJ Blazkowicz"
 	player.startitem "Clip", 8
 	player.startitem "Pistol"