Conversation
📝 WalkthroughWalkthroughThe changes enhance the weapon system by introducing animation configuration fields to WeaponBlueprint (charge and reload animations with rates), expanding Unit's GetTargetEntity return type to include Prop, refactoring projectile weapon distance calculations, adding public field declarations and state class annotations to DefaultProjectileWeapon, and exposing the __base reference in the State class. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lua/sim/weapons/DefaultProjectileWeapon.lua (1)
317-317:⚠️ Potential issue | 🟠 MajorPre-existing bug: Z-coordinate uses X values in
GetSurfaceHeightcall.Not introduced by this PR, but line 317 passes
projPosX + time * projVelXfor both the X and Z arguments toGetSurfaceHeight. The second argument should beprojPosZ + time * projVelZ.🐛 Proposed fix
- halfHeight = 0.5 * (projPosY - GetSurfaceHeight(projPosX + time * projVelX, projPosX + time * projVelX)) + halfHeight = 0.5 * (projPosY - GetSurfaceHeight(projPosX + time * projVelX, projPosZ + time * projVelZ))
🧹 Nitpick comments (2)
lua/sim/weapons/DefaultProjectileWeapon.lua (2)
236-259: Redundant velocity fetch for single-bomb path.Lines 236–239 already set
targetVelX/Y/Zwhentarget.IsUnitis true. Lines 250–253 re-fetch the exact same velocity within the same function call, with no intervening yield or tick. The second fetch is a no-op.♻️ Remove duplicate velocity fetch
if self.Blueprint.MuzzleSalvoSize <= 1 then -- do the calculation but skip any cache or salvo logic if not targetPos then return 4.9 end - if target and target.IsUnit then - ---@cast target Unit - targetVelX, targetVelY, targetVelZ = UnitGetVelocity(target) - end local targetPosX, targetPosZ = targetPos[1], targetPos[3]
586-586: Inconsistent nil guard:PlayFxWeaponPackSequencelacks the sameAudionil check.Line 586 accesses
self.unit.Blueprint.Audio.Closedirectly, whilePlayFxWeaponUnpackSequence(lines 547–556) now guards against a nilAudiotable. If the blueprint can lack anAudiofield, this path would also need a guard. Pre-existing, but worth aligning.🛡️ Proposed guard
PlayFxWeaponPackSequence = function(self) local bp = self.Blueprint - local close = self.unit.Blueprint.Audio.Close - if close then - self:PlaySound(close) + local unitBPAudio = self.unit.Blueprint.Audio + if unitBPAudio then + local close = unitBPAudio.Close + if close then + self:PlaySound(close) + end end
Description of the proposed changes
DefaultProjectileWeapon. They had no annotations at all previously.param-type-mismatchforGetFocusArmyon L1097.Testing done on the proposed changes
Checklist
Summary by CodeRabbit
New Features
Deprecations