-
Notifications
You must be signed in to change notification settings - Fork 83
Separating weapon wave from head wave... #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ExtraDrowsy
wants to merge
2
commits into
luciusDXL:master
Choose a base branch
from
ExtraDrowsy:feat_separateWeaponWave
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1830,69 +1830,76 @@ namespace TFE_DarkForces | |
| //s_282344 = 34 - dH; | ||
| } | ||
|
|
||
| // Headwave | ||
| // Calculate the head and weapon wave offsets. | ||
| s32 xWpnWaveOffset = 0; | ||
| s_headwaveVerticalOffset = 0; | ||
| if (s_config.headwave && (player->flags & 2)) | ||
| s32 headwaveVerticalOffset = 0; | ||
| fixed16_16 playerSpeed = distApprox(0, 0, s_playerVelX, s_playerVelZ); | ||
| if (!moved) | ||
| { | ||
| playerSpeed = 0; | ||
| } | ||
| if ((s_playerSector->flags1 & SEC_FLAGS1_ICE_FLOOR) && !s_wearingCleats) | ||
| { | ||
| playerSpeed = 0; | ||
| } | ||
|
|
||
| if (playerSpeed != s_playerSpeed) | ||
| { | ||
| fixed16_16 playerSpeed = distApprox(0, 0, s_playerVelX, s_playerVelZ); | ||
| if (!moved) | ||
| fixed16_16 speedDelta = playerSpeed - s_playerSpeed; | ||
| fixed16_16 maxFrameChange = mul16(FIXED(32), s_deltaTime); | ||
|
|
||
| if (speedDelta > maxFrameChange) | ||
| { | ||
| playerSpeed = 0; | ||
| speedDelta = maxFrameChange; | ||
| } | ||
| if ((s_playerSector->flags1 & SEC_FLAGS1_ICE_FLOOR) && !s_wearingCleats) | ||
| else if (speedDelta < -maxFrameChange) | ||
| { | ||
| playerSpeed = 0; | ||
| speedDelta = -maxFrameChange; | ||
| } | ||
| s_playerSpeed += speedDelta; | ||
| } | ||
| sinCosFixed((s_curTick & 0xffff) << 7, &s_wpnSin, &s_wpnCos); | ||
|
|
||
| if (playerSpeed != s_playerSpeed) | ||
| { | ||
| fixed16_16 speedDelta = playerSpeed - s_playerSpeed; | ||
| fixed16_16 maxFrameChange = mul16(FIXED(32), s_deltaTime); | ||
|
|
||
| if (speedDelta > maxFrameChange) | ||
| { | ||
| speedDelta = maxFrameChange; | ||
| } | ||
| else if (speedDelta < -maxFrameChange) | ||
| { | ||
| speedDelta = -maxFrameChange; | ||
| } | ||
| s_playerSpeed += speedDelta; | ||
| } | ||
| sinCosFixed((s_curTick & 0xffff) << 7, &s_wpnSin, &s_wpnCos); | ||
|
|
||
| fixed16_16 playerSpeedFract = div16(s_playerSpeed, FIXED(32)); | ||
| s_headwaveVerticalOffset = mul16(mul16(s_wpnCos, PLAYER_HEADWAVE_VERT_SPD), playerSpeedFract); | ||
| fixed16_16 playerSpeedFract = div16(s_playerSpeed, FIXED(32)); | ||
| headwaveVerticalOffset = mul16(mul16(s_wpnCos, PLAYER_HEADWAVE_VERT_SPD), playerSpeedFract); | ||
|
|
||
| sinCosFixed((s_curTick & 0xffff) << 6, &s_wpnSin, &s_wpnCos); | ||
| xWpnWaveOffset = mul16(playerSpeedFract, s_wpnCos) >> 12; | ||
| sinCosFixed((s_curTick & 0xffff) << 6, &s_wpnSin, &s_wpnCos); | ||
| xWpnWaveOffset = mul16(playerSpeedFract, s_wpnCos) >> 12; | ||
|
|
||
| // Water... | ||
| if (s_playerSector->secHeight - 1 >= 0) | ||
| // Water... | ||
| if (s_playerSector->secHeight - 1 >= 0) | ||
| { | ||
| if (s_externalVelX || s_externalVelZ) | ||
| { | ||
| if (s_externalVelX || s_externalVelZ) | ||
| { | ||
| fixed16_16 externSpd = distApprox(0, 0, s_externalVelX, s_externalVelZ); | ||
|
|
||
| // Replace the fractional part with the current time fractional part. | ||
| // I think this is meant to add some "randomness" to the headwave while in water. | ||
| fixed16_16 speed = externSpd & (~0xffff); | ||
| speed |= (s_curTick & 0xffff); | ||
| // Then multiply by 16 and take the cosine - this is meant to be a small modification to the weapon motion | ||
| // (note that the base multiplier is 128). | ||
| sinCosFixed(speed << 4, &s_wpnSin, &s_wpnCos); | ||
| // Modify the headwave motion. | ||
| s_headwaveVerticalOffset += mul16(s_wpnCos, PLAYER_HEADWAVE_VERT_WATER_SPD); | ||
| } | ||
| fixed16_16 externSpd = distApprox(0, 0, s_externalVelX, s_externalVelZ); | ||
|
|
||
| // Replace the fractional part with the current time fractional part. | ||
| // I think this is meant to add some "randomness" to the headwave while in water. | ||
| fixed16_16 speed = externSpd & (~0xffff); | ||
| speed |= (s_curTick & 0xffff); | ||
| // Then multiply by 16 and take the cosine - this is meant to be a small modification to the weapon motion | ||
| // (note that the base multiplier is 128). | ||
| sinCosFixed(speed << 4, &s_wpnSin, &s_wpnCos); | ||
| // Modify the headwave motion. | ||
| headwaveVerticalOffset += mul16(s_wpnCos, PLAYER_HEADWAVE_VERT_WATER_SPD); | ||
| } | ||
| } | ||
| setCameraOffset(0, s_headwaveVerticalOffset, 0); | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code below is where the condition was moved to and what ultimately separates the head waving and weapon waving, as well as applying the new setting. |
||
| // Apply the weapon motion. | ||
| if (s_config.headwave && (player->flags & 2)) | ||
| { | ||
| // If head wave is enabled, store the offset and apply it. This offset also affects projectiles fired by the player so | ||
| // we must not store it if head waving is disabled. | ||
| s_headwaveVerticalOffset = headwaveVerticalOffset; | ||
| setCameraOffset(0, s_headwaveVerticalOffset, 0); | ||
| } | ||
|
|
||
| PlayerWeapon* weapon = s_curPlayerWeapon; | ||
| weapon->xWaveOffset = xWpnWaveOffset; // the x offset has 4 bits of sub-texel precision. | ||
| weapon->yWaveOffset = s_headwaveVerticalOffset >> 13; // the y offset is probably the same 4 bits of precision & multiplied by half. | ||
| if (TFE_Settings::getHudSettings()->weaponWave) | ||
| { | ||
| // If weapon wave is enabled, apply the offset. | ||
| weapon->xWaveOffset = xWpnWaveOffset; // the x offset has 4 bits of sub-texel precision. | ||
| weapon->yWaveOffset = headwaveVerticalOffset >> 13; // the y offset is probably the same 4 bits of precision & multiplied by half. | ||
| } | ||
|
|
||
| // The moves the player can make are restricted based on whether they are on the floor or not. | ||
| if (s_colCurLowestFloor == player->posWS.y) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff below looks big but all of the lines from this point to
:1844are unchanged except for the following:ifblock that starts on line:1836and thus all of the code within that block down to:1885was indented left-ward (hence why the diff looks large). I removed it because we now need to run these calculations regardless of whether head waving is on since these are used for weapon waving.s_headwaveVerticalOffsetin this range of code now assign to a new local variableheadwaveVerticalOffset(see:1835). I essentially avoid modifyings_headwaveVerticalOffsetuntil I know the head waving is on and needs to be applied since modifyings_headwaveVerticalOffsetalters how player projectiles (like lasers from the blaster) are calculated.