Skip to content
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

[lua] Move pdif calculations out of weaponskills.lua #6871

Merged

Conversation

WinterSolstice8
Copy link
Member

@WinterSolstice8 WinterSolstice8 commented Jan 28, 2025

I affirm:

  • I understand that if I do not agree to the following points by completing the checkboxes my PR will be ignored.
  • I understand I should leave resolving conversations to the LandSandBoat team so that reviewers won't miss what was said.
  • I have read and understood the Contributing Guide and the Code of Conduct.
  • I have tested my code and the things my code has changed since the last commit in the PR and will test after any later commits.

What does this pull request do?

Move pdif calculations out of weaponskills.lua, to use the physical utilities ones that already exist
Trusts can't SC anymore if they miss

Misc fixes to make the pdif junk work

Steps to test these changes

Apply this patch;
check ranged ws such as hot shot (hybrid), split shot (def ignore), detonator (attack bonus)
check physical ws such as blade: chi (hybrid), wheeling thrust (def ignore), howling fist (attack bonus)
finally, check viper bite on dancer with building flourish (2+ FMs)

viper bite with 2x FMs + 2 merits:
image

Make sure your ratt matches the debug prints:
image

diff --git a/scripts/globals/combat/physical_utilities.lua b/scripts/globals/combat/physical_utilities.lua
index 897e02561c..c5a40f97d0 100644
--- a/scripts/globals/combat/physical_utilities.lua
+++ b/scripts/globals/combat/physical_utilities.lua
@@ -414,13 +414,28 @@ xi.combat.physical.calculateMeleePDIF = function(actor, target, weaponType, wsAt
     -- TODO: it is unknown if ws attack mod and flourish bonus are additive or multiplicative
     actorAttack = math.max(1, math.floor(actor:getStat(xi.mod.ATT, weaponSlot) * wsAttackMod * flourishBonus))
 
+    if isWeaponskill then
+        print("===")
+        print(string.format("tpIgnoresDefense: %s, tpFactor %f", tpIgnoresDefense and "true" or "false", tpFactor))
+        print(string.format("Base attack: %d, wsAttackMod: %f, flourishBonus: %f, post modifier attack: %f", actor:getStat(xi.mod.ATT, weaponSlot), wsAttackMod, flourishBonus, actorAttack))
+    end
+
     -- Target Defense Modifiers.
     if tpIgnoresDefense then
         local ignoreDefenseFactor = 1 - tpFactor
 
+        print(string.format("targetDef before: %d, ignoreDefenseFactor: %f", targetDefense, ignoreDefenseFactor))
+
         targetDefense = math.floor(targetDefense * ignoreDefenseFactor)
     end
 
+
+    if isWeaponskill then
+        print(string.format("targetDef after: %d", targetDefense))
+
+        print("===")
+    end
+
     -- Actor Attack / Target Defense ratio
     baseRatio = actorAttack / targetDefense
 
@@ -540,15 +555,30 @@ xi.combat.physical.calculateRangedPDIF = function(actor, target, weaponType, wsA
     -- TODO: it is unknown if ws attack mod and flourish bonus are additive or multiplicative
     actorAttack = math.max(1, math.floor(actor:getStat(xi.mod.RATT) * wsAttackMod * flourishBonus))
 
+    print(actorAttack)
+    if isWeaponskill then
+        print("===")
+        print(string.format("tpIgnoresDefense: %s, tpFactor %f", tpIgnoresDefense and "true" or "false", tpFactor))
+        print(string.format("Base attack: %d, wsAttackMod: %f, flourishBonus: %f, post modifier attack: %f", actor:getStat(xi.mod.RATT), wsAttackMod, flourishBonus, actorAttack))
+    end
+
     -- Target Defense Modifiers.
     local ignoreDefenseFactor = 1
 
     if tpIgnoresDefense then
         ignoreDefenseFactor = 1 - tpFactor
+
+         print(string.format("targetDef before: %d, ignoreDefenseFactor: %f", targetDefense, ignoreDefenseFactor))
     end
 
     targetDefense = math.floor(targetDefense * ignoreDefenseFactor)
 
+    if isWeaponskill then
+        print(string.format("targetDef after: %d", targetDefense))
+
+        print("===")
+    end
+
     baseRatio = actorAttack / targetDefense
 
     -- Apply cap to baseRatio.

@WinterSolstice8 WinterSolstice8 force-pushed the cleanup_weaponskills_more branch 2 times, most recently from 9bd21e6 to 765b9df Compare January 28, 2025 02:56
@WinterSolstice8 WinterSolstice8 force-pushed the cleanup_weaponskills_more branch from 765b9df to 983c901 Compare January 28, 2025 03:42
zach2good
zach2good previously approved these changes Jan 28, 2025
@WinterSolstice8 WinterSolstice8 force-pushed the cleanup_weaponskills_more branch 3 times, most recently from 91ec00a to a6d25be Compare January 30, 2025 20:38
@WinterSolstice8 WinterSolstice8 marked this pull request as ready for review January 30, 2025 20:42
@WinterSolstice8
Copy link
Member Author

Alright, tested things, found some bugs and fixed them while I was here

ready for review

@WinterSolstice8 WinterSolstice8 force-pushed the cleanup_weaponskills_more branch from a6d25be to b9e39ef Compare January 30, 2025 20:50
@zach2good zach2good merged commit 4c0b4b2 into LandSandBoat:base Feb 1, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants