PDA

View Full Version : Pathfinder: Attack roll under AC -> Lower damage



LootaBox
March 2nd, 2014, 05:14
Hey everyone!

We have this homebrew little rule that allows players (and enemies) to deal some damage even if they would have normally missed. Currently we do it manually but it's a little tiresome. I know my way around LUA and started digging the ruleset files, looking for an automatic solution.

What I'm trying to do:
Make an attack roll that falls short of targets AC by X amount cause a "glancing blow."
Glancing blow would deal halved damage.
X would be affected by targets armor and natural AC.

I'm not at all familiar with the ruleset script structure, but I believe I can make the ruleset notice a glancing blow in the onAttack() function in manager_action_attack.lua, and the damage calculations are handled in modDamage() in manager_action_damage.lua..?

I can't figure out how to deliver the information from the attack function to the damage calculations, and how to use targets armor/natural AC value in the onAttack function. Am I even looking in the right places?

I know there's documentation, and that what I'm trying to do is probably not such a difficult thing to mod, but unfortunately I have an exam week coming up and we have a session planned on the following weekend. I really must (or at least should..) focus my studies on my actual studies.

I would appreciate any help very much.

Moon Wizard
March 2nd, 2014, 06:38
Since this is a game system specific piece of coding, the documentation does not cover it. manager_action_attack is the right place to look for attack resolution.

Currently, the ruleset does not do half damage automatically, though it will do criticals automatically on a damage roll following a critical attack roll from an actor in the combat tracker to a target (also in the combat tracker).

There are two main sections of coding I see:

Building half damage support
Check out the setCritState, clearCritState and isCrit functions in the AttackManager script file (manager_action_attack) and the DamageManager script file (manager_action_damage) to see how that is handled. Half damage could potentially be added in a similar manner. However, you also need to make sure that the target is not deselected on a miss. (See code after notifyApplyAttack call.)

Determining armor and natural armor bonuses
The main issue I see is that you would need to write the functions to determine the X value, and figure out where the variables are for armor bonus and natural armor bonus. For PCs, it's fairly straightforward. For NPCs, you would need to string parse the AC field to see if the information exists, and make sure that this info exists for all your NPCs.

Cheers,
JPG

LootaBox
March 2nd, 2014, 18:54
Thanks. I pretty much copied the critical methods and I suppose it should work... The only problem is the automation doesn't even work for the critical. I can't test the glancing blow until I get this sorted out.

I don't understand what's wrong: I attack and get a critical, and then roll damage but the damage is not critical. I tried with the default PFRPG ruleset, same thing. I tried it on combat tracker, using the target system and dragging dice to tokens on an image map. Whats going on here?

Nickademus
March 2nd, 2014, 19:41
Out of curiosity, do you have automated criticals turned off in the options? That would stop the critical damage.

LootaBox
March 2nd, 2014, 21:21
I can't find an option like that..?

EDIT

Ok, if the option Critical Confirm is off or on NPC only, automatic criticals don't work.

EDIT 2

Alright, thanks both of you, I got it working now.