User talk:CITAlias3

From Calamity Mod Wiki
Jump to navigation Jump to search

Hey Alias thanks for taking the time to update the vanilla changes section on point-blank damage. https://calamitymod.wiki.gg/index.php?title=Vanilla_changes&oldid=prev&diff=253218

Are you a cal dev / did you get these numbers from a cal dev? The part about taking the inverse of duration and proximity ratios is interesting.

However, I don't understand where the 18f and 15 tile requirements are coming from then. Also, as I put in my original edit, 18 f and 15 t do not match up with any of my real results for either starting the bonus damage or maxxing it out. Marrow and Thermocline both require that I put less than 2 tiles between the target's hurtbox and myself before any damage boost is seen at all. The projectiles can be alive for either 1 or 2 frames before contacting the enemy and they will not get any bonus. I'm sure it's a low ratio of the proj's lifetime duration too. So what gives? Why do platinum bow / The Ballista with wooden arrows get a point-blank bonus from farther away than with ichor if the extraUpdates thing is false information like you say? Since the wooden arrows contact the enemy when they're later in their lifetime, the ratio should be higher and thus the point-blank bonus would be lower.

You can message me on discord if you want, @Kanaris. I'm in TML, cal, catalyst, fargo discords. --Kanaris (talk) 09:21, 28 June 2024 (UTC)

All values and information that I listed were taken directly from Calamity's source code. For relevant point-blank variables, including the 18 frame and 15 tile limits, see CalamityGlobalProjectile line 122: https://github.com/CalamityTeam/CalamityModPublic/blob/1.4.4/Projectiles/CalamityGlobalProjectile.cs#L122. For the actual point-blank damage calculation, see CalamityGlobalNPC line 5609: https://github.com/CalamityTeam/CalamityModPublic/blob/1.4.4/NPCs/CalamityGlobalNPC.cs#L5609.
All projectiles which can trigger point-blank damage have pointBlankShotDuration set to the value of DefaultPointBlankDuration when they are first spawned in, which is a constant of 18. This value ticks down by 1 for every update of the projectile, which does mean that extra updates will make it tick down faster. Once it reaches 0, the check in the actual calculation will not pass, disabling point-blank damage.
All projectiles use a variable pointBlankShotDistanceTravelled, which has the length of the projectile's velocity added to it on every update. If this value exceeds PointBlankShotDistanceLimit, a constant of 240 pixels or 15 tiles, the check in the actual calculation will not pass, disabling point-blank damage.
While performing the actual calculation, the game takes pointBlankShotDuration and divides it by DefaultPointBlankDuration, storing it in pointBlankShotDurationRatio. It then takes pointBlankShotDistanceTravelled, divides it by PointBlankShotDistanceLimit, and subtracts that from 1, storing it in pointBlankShotDistanceRatio. pointBlankShotDurationRatio and pointBlankShotDistanceRatio are then compared, with the lower of the two values being used for the multiplier. The lower value is then multiplied by 0.25 and added to 1, producing the final damage multiplier which is applied to the projectile through modifiers.SourceDamage.
So as stated, extra updates will affect this, and it is very simple for me to add a bullet point explaining that on the page. And since you asked, I am a Calamity developer, although as proven above with my links, the source code is public. CITAlias3 (talk) 15:57, 28 June 2024 (UTC)


Cool! Thanks for providing code and elaborating on the math. I've edited the vanilla changes page some more to make it clearer in layman's terms, and more practically applicable (many weapons have extra updates).
I find the extraUpdates interaction very unintuitive, and I think most people would agree. In fact, having a fast projectile require closer proximity (duration) to count as point-blank seems opposite to how one would expect it to work. A sniper rifle is only point-blank at 2 meters but a bow and arrow is point-blank at 10?
For everyone's sakes, couldn't the extraUpdates interaction simply be mitigated by decrementing pointBlankShotDuration by (1 / Projectile.totalUpdates) instead? This would be a great change, letting the whole point-blank mechanic actually make sense and be more predictable across weapons of varying proj speeds.
Something about point-blank always felt incredibly peculiar and now I know why, so thanks! Kanaris (talk) 02:45, 29 June 2024 (UTC)


Hmmm so extra updates turns out to not affect the duration ticker after all? Something else must be amiss then.
Would you be able to go in-game on Live version and test it the way I did? Just setup a dummy and try gradual distance changes with: Marrow, Thermocline Blaster, The Ballista, and Platinum Bow. For me, Marrow and Thermocline Blaster(+ichor) required that I stand almost on top of the dummy to get any bonus. Ballista (conversion from wooden) and Platinum (wooden) can point-blank from something like 12 tiles away. If I remember correctly, putting ichor arrows on the platinum bow forced me closer to the dummy if I wanted to keep getting point-blank, but that part's a bit hazy. I can't think of any reason for this other than extraUpdates. Kanaris (talk) 14:45, 29 June 2024 (UTC)


After doing more code-digging and in-game testing, I have discovered the real source of the discrepancy.
So duration is ticked down once per frame, which is normal, that works as expected. However, the distance the projectile travels is also incremented once per frame, and is multiplied by the projectile's max updates. This is why projectiles with extra updates appear to require a much smaller distance to trigger point-blank damage; the distance is incremented once per frame on the first update, as if the projectile has traveled the distance accrued by every update in that frame.
I have fixed this for next update by moving the code which increments the distance traveled from the PreAI hook to the PostAI hook, which runs on every update and will accurately track the distance traveled by the projectile at every update of its trajectory. I have already tested this in-game using projectiles with multiple extra updates, and they are now able to trigger point-blank damage at expected distances. Thank you for investigating through this alongside me, I don't think I would have found this without you. CITAlias3 (talk) 23:13, 29 June 2024 (UTC)


Fantastic! Glad we got to the bottom of it and I wasn't going crazy. Thanks for fixing! Kanaris (talk) 07:08, 30 June 2024 (UTC)