Skip to content

Commit

Permalink
remove weight, reduce force
Browse files Browse the repository at this point in the history
  • Loading branch information
chaserli committed Mar 15, 2024
1 parent c2635cb commit 41450ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ FeedbackWeapon= ; WeaponType
### Recoil force

- You can now tilt a voxel unit after firing to simulate the recoil force.
- The body's moment of inertia is simplified and normalized to take only the body's weight and the body voxel's size ratio into account.
- The body's pseudo "moment of inertia" is simplified to be linearly proportional to the body voxel's size ratio instead of quadratically.

In `rulesmd.ini`:
```ini
Expand Down
7 changes: 2 additions & 5 deletions src/Ext/Unit/Hooks.Jumpjet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,13 @@ DEFINE_HOOK(0x7413DD, UnitClass_Fire_RecoilForce, 0x6)

auto force = WeaponTypeExt::ExtMap.Find(pTraj->WeaponType)->RecoilForce.Get();

if (std::abs(force) < 0.005)
return 0;
force /= std::max(pThis->Type->Weight, 0.05);
if (std::abs(force) < 0.002)
return 0;

const double theta = pThis->GetRealFacing().GetRadian<32>() - pThis->PrimaryFacing.Current().GetRadian<32>();

pThis->RockingForwardsPerFrame = (float)(-force * Math::cos(theta));
pThis->RockingSidewaysPerFrame = (float)(force * Math::sin(theta) * std::pow(pThis->Type->VoxelScaleX / pThis->Type->VoxelScaleY, 2));
pThis->RockingForwardsPerFrame = (float)(-force * Math::cos(theta) * Math::cos(pThis->AngleRotatedForwards));
pThis->RockingSidewaysPerFrame = (float)(force * Math::sin(theta) * Math::cos(pThis->AngleRotatedSideways) * (pThis->Type->VoxelScaleX / pThis->Type->VoxelScaleY));

return 0;
}

0 comments on commit 41450ae

Please sign in to comment.