@@ -299,6 +299,11 @@ namespace TFE_DarkForces
299
299
// TFE - constants which can be overridden
300
300
s32 s_weaponSuperchargeDuration;
301
301
s32 s_shieldSuperchargeDuration;
302
+
303
+ // Scripting
304
+ JBool s_disablePlayerMovement = JFALSE;
305
+ JBool s_disablePlayerRotation = JFALSE;
306
+ JBool s_disablePlayerFire = JFALSE;
302
307
303
308
// /////////////////////////////////////////
304
309
// Forward Declarations
@@ -890,6 +895,9 @@ namespace TFE_DarkForces
890
895
s_playerPrimaryFire = JFALSE;
891
896
s_playerSecFire = JFALSE;
892
897
s_playerJumping = JFALSE;
898
+ s_disablePlayerMovement = JFALSE;
899
+ s_disablePlayerRotation = JFALSE;
900
+ s_disablePlayerFire = JFALSE;
893
901
894
902
s_crushSoundId = 0 ;
895
903
s_kyleScreamSoundId = 0 ;
@@ -1449,11 +1457,16 @@ namespace TFE_DarkForces
1449
1457
{
1450
1458
ProjectileLogic* proj = (ProjectileLogic*)s_msgEntity;
1451
1459
vec3_fixed pushVel;
1452
- computeDamagePushVelocity (proj, &pushVel);
1460
+
1461
+ // TFE: Don't push the player if movement disabled
1462
+ if (!s_disablePlayerMovement)
1463
+ {
1464
+ computeDamagePushVelocity (proj, &pushVel);
1453
1465
1454
- s_playerVelX += pushVel.x ;
1455
- s_playerUpVel2 += pushVel.y ;
1456
- s_playerVelZ += pushVel.z ;
1466
+ s_playerVelX += pushVel.x ;
1467
+ s_playerUpVel2 += pushVel.y ;
1468
+ s_playerVelZ += pushVel.z ;
1469
+ }
1457
1470
1458
1471
if (s_invincibility || s_config.superShield )
1459
1472
{
@@ -1474,10 +1487,14 @@ namespace TFE_DarkForces
1474
1487
vec3_fixed pushDir;
1475
1488
computeExplosionPushDir (&pos, &pushDir);
1476
1489
1477
- fixed16_16 force = s_msgArg2;
1478
- s_playerVelX += mul16 (force, pushDir.x );
1479
- s_playerUpVel2 += mul16 (force, pushDir.y );
1480
- s_playerVelZ += mul16 (force, pushDir.z );
1490
+ // TFE: Don't push the player if movement disabled
1491
+ if (!s_disablePlayerMovement)
1492
+ {
1493
+ fixed16_16 force = s_msgArg2;
1494
+ s_playerVelX += mul16 (force, pushDir.x );
1495
+ s_playerUpVel2 += mul16 (force, pushDir.y );
1496
+ s_playerVelZ += mul16 (force, pushDir.z );
1497
+ }
1481
1498
1482
1499
if (s_invincibility || s_config.superShield )
1483
1500
{
@@ -1534,6 +1551,9 @@ namespace TFE_DarkForces
1534
1551
s_playerCrouchSpd = 0 ;
1535
1552
s_prevDistFromFloor = 0 ;
1536
1553
s_playerObject->worldHeight = 0x5cccc ; // 5.8
1554
+ s_disablePlayerMovement = JFALSE;
1555
+ s_disablePlayerRotation = JFALSE;
1556
+ s_disablePlayerFire = JFALSE;
1537
1557
}
1538
1558
1539
1559
void player_changeSector (RSector* newSector)
@@ -1707,7 +1727,7 @@ namespace TFE_DarkForces
1707
1727
InputConfig* inputConfig = TFE_Input::inputMapping_get ();
1708
1728
1709
1729
// Yaw change
1710
- if (inputConfig->mouseMode == MMODE_TURN || inputConfig->mouseMode == MMODE_LOOK)
1730
+ if (( inputConfig->mouseMode == MMODE_TURN || inputConfig->mouseMode == MMODE_LOOK) && !s_disablePlayerRotation )
1711
1731
{
1712
1732
s_playerYaw += s32 (f32 (mdx * PLAYER_MOUSE_TURN_SPD) * inputMapping_getHorzMouseSensitivity ());
1713
1733
s_playerYaw &= ANGLE_MASK;
@@ -1722,7 +1742,7 @@ namespace TFE_DarkForces
1722
1742
}
1723
1743
1724
1744
// Controls
1725
- if (s_automapLocked)
1745
+ if (s_automapLocked && !s_disablePlayerMovement )
1726
1746
{
1727
1747
if (inputMapping_getActionState (IADF_FORWARD))
1728
1748
{
@@ -1810,7 +1830,7 @@ namespace TFE_DarkForces
1810
1830
1811
1831
JBool wasJumping = s_playerJumping;
1812
1832
s_playerJumping = JFALSE;
1813
- if (inputMapping_getActionState (IADF_JUMP))
1833
+ if (inputMapping_getActionState (IADF_JUMP) && !s_disablePlayerMovement )
1814
1834
{
1815
1835
if (!s_onFloor || wasJumping)
1816
1836
{
@@ -1838,12 +1858,10 @@ namespace TFE_DarkForces
1838
1858
s_playerUpVel2 = 0 ;
1839
1859
}
1840
1860
1841
- // ////////////////////////////////////////
1842
1861
// Pitch and Roll controls.
1843
- // ////////////////////////////////////////
1844
1862
if (s_automapLocked)
1845
1863
{
1846
- if (inputMapping_getActionState (IADF_TURN_LT))
1864
+ if (inputMapping_getActionState (IADF_TURN_LT) && !s_disablePlayerRotation )
1847
1865
{
1848
1866
fixed16_16 turnSpeed = PLAYER_KB_TURN_SPD; // angle units per second.
1849
1867
fixed16_16 dYaw = mul16 (turnSpeed, s_deltaTime);
@@ -1853,7 +1871,7 @@ namespace TFE_DarkForces
1853
1871
s_playerYaw -= dYaw;
1854
1872
s_playerYaw &= ANGLE_MASK;
1855
1873
}
1856
- else if (inputMapping_getActionState (IADF_TURN_RT))
1874
+ else if (inputMapping_getActionState (IADF_TURN_RT) && !s_disablePlayerRotation )
1857
1875
{
1858
1876
fixed16_16 turnSpeed = PLAYER_KB_TURN_SPD; // angle units per second.
1859
1877
fixed16_16 dYaw = mul16 (turnSpeed, s_deltaTime);
@@ -1863,7 +1881,7 @@ namespace TFE_DarkForces
1863
1881
s_playerYaw += dYaw;
1864
1882
s_playerYaw &= ANGLE_MASK;
1865
1883
}
1866
- else if (inputMapping_getAnalogAxis (AA_LOOK_HORZ))
1884
+ else if (inputMapping_getAnalogAxis (AA_LOOK_HORZ) && !s_disablePlayerRotation )
1867
1885
{
1868
1886
fixed16_16 turnSpeed = mul16 (mul16 (PLAYER_CONTROLLER_TURN_SPD, s_deltaTime), floatToFixed16 (inputMapping_getAnalogAxis (AA_LOOK_HORZ)));
1869
1887
s_playerYaw += turnSpeed;
@@ -1901,17 +1919,18 @@ namespace TFE_DarkForces
1901
1919
s_playerRoll = 0 ;
1902
1920
}
1903
1921
1904
- if (inputMapping_getActionState (IADF_STRAFE_RT))
1922
+ // Strafe movement
1923
+ if (inputMapping_getActionState (IADF_STRAFE_RT) && !s_disablePlayerMovement)
1905
1924
{
1906
1925
fixed16_16 speed = mul16 (PLAYER_STRAFE_SPEED, s_deltaTime);
1907
1926
s_strafeSpd = max (speed, s_strafeSpd);
1908
1927
}
1909
- else if (inputMapping_getActionState (IADF_STRAFE_LT))
1928
+ else if (inputMapping_getActionState (IADF_STRAFE_LT) && !s_disablePlayerMovement )
1910
1929
{
1911
1930
fixed16_16 speed = -mul16 (PLAYER_STRAFE_SPEED, s_deltaTime);
1912
1931
s_strafeSpd = min (speed, s_strafeSpd);
1913
1932
}
1914
- else if (inputMapping_getAnalogAxis (AA_STRAFE))
1933
+ else if (inputMapping_getAnalogAxis (AA_STRAFE) && !s_disablePlayerMovement )
1915
1934
{
1916
1935
fixed16_16 speed = mul16 (mul16 (PLAYER_STRAFE_SPEED, s_deltaTime), floatToFixed16 (clamp (inputMapping_getAnalogAxis (AA_STRAFE), -1 .0f , 1 .0f )));
1917
1936
if (speed < 0 )
@@ -1930,11 +1949,11 @@ namespace TFE_DarkForces
1930
1949
s_playerUse = JTRUE;
1931
1950
}
1932
1951
1933
- if (inputMapping_getActionState (IADF_PRIMARY_FIRE))
1952
+ if (inputMapping_getActionState (IADF_PRIMARY_FIRE) && !s_disablePlayerFire )
1934
1953
{
1935
1954
s_playerPrimaryFire = JTRUE;
1936
1955
}
1937
- else if (inputMapping_getActionState (IADF_SECONDARY_FIRE))
1956
+ else if (inputMapping_getActionState (IADF_SECONDARY_FIRE) && !s_disablePlayerFire )
1938
1957
{
1939
1958
s_playerSecFire = JTRUE;
1940
1959
}
@@ -2141,8 +2160,16 @@ namespace TFE_DarkForces
2141
2160
// Then convert from player velocity to per-frame movement.
2142
2161
fixed16_16 moveX = adjustForwardSpeed (s_playerVelX);
2143
2162
fixed16_16 moveZ = adjustForwardSpeed (s_playerVelZ);
2144
- s_playerLogic.move .x = mul16 (moveX, s_deltaTime) + mul16 (s_externalVelX, s_deltaTime);
2145
- s_playerLogic.move .z = mul16 (moveZ, s_deltaTime) + mul16 (s_externalVelZ, s_deltaTime);
2163
+ if (s_disablePlayerMovement) // TFE scripting option
2164
+ {
2165
+ s_playerLogic.move .x = 0 ;
2166
+ s_playerLogic.move .z = 0 ;
2167
+ }
2168
+ else // normal behaviour
2169
+ {
2170
+ s_playerLogic.move .x = mul16 (moveX, s_deltaTime) + mul16 (s_externalVelX, s_deltaTime);
2171
+ s_playerLogic.move .z = mul16 (moveZ, s_deltaTime) + mul16 (s_externalVelZ, s_deltaTime);
2172
+ }
2146
2173
s_playerLogic.stepHeight = s_limitStepHeight ? PLAYER_STEP : PLAYER_INF_STEP;
2147
2174
fixed16_16 width = (s_smallModeEnabled) ? PLAYER_SIZE_SMALL : PLAYER_WIDTH;
2148
2175
player->worldWidth = width;
@@ -3329,6 +3356,10 @@ namespace TFE_DarkForces
3329
3356
setProjectileGravityAccel (projectileGravity);
3330
3357
}
3331
3358
3359
+ SERIALIZE (ObjState_DisablePlayerMovement, s_disablePlayerMovement, JFALSE);
3360
+ SERIALIZE (ObjState_DisablePlayerMovement, s_disablePlayerRotation, JFALSE);
3361
+ SERIALIZE (ObjState_DisablePlayerMovement, s_disablePlayerFire, JFALSE);
3362
+
3332
3363
s32 invSavedSize = 0 ;
3333
3364
if (serialization_getMode () == SMODE_WRITE && s_playerInvSaved)
3334
3365
{
@@ -3437,4 +3468,4 @@ namespace TFE_DarkForces
3437
3468
}
3438
3469
}
3439
3470
}
3440
- } // TFE_DarkForces
3471
+ } // TFE_DarkForces
0 commit comments