Skip to content

Critical Hits

I'm trying to figure out how to check for critical hits on an object. If the last attack on the target was a critical hit I want to perform an action or create something, etc. Anyone know how this could be scripted? I can't seem to find a function for OnCriticalHits or something to that effect. Any help with even checking to see if the last hit was critical would be great. Thanks.

Comments

  • FreshLemonBunFreshLemonBun Member Posts: 909
    You can't do it with a function. You need nwnx for that, otherwise you can only estimate it by comparing damage taken with the damage a weapon does which works about as well as you can imagine.
  • Awas73Awas73 Member Posts: 66
    Thanks for the input. I am sure that doesn't work very well. I'll have to think of another way to get the results I need. Thanks for taking the time to answer.
  • FreshLemonBunFreshLemonBun Member Posts: 909
    Maybe you could also edit the 2da of the weapons and set their critical multiplied to 1. Then you could roll for critical threat range in an onhit event, since you hit you assume you already confirmed the threat, so like doing crits in reverse order, then multiply the damage yourself.
  • ShadooowShadooow Member Posts: 402

    Maybe you could also edit the 2da of the weapons and set their critical multiplied to 1. Then you could roll for critical threat range in an onhit event, since you hit you assume you already confirmed the threat, so like doing crits in reverse order, then multiply the damage yourself.

    unfortunately you cannot really edit damage being done, when the OnDamage event fires damage was already calculated and is about to applied, you can only apply another damage but that will not be precise at all because of reductions/resistances/immunities.
  • FreshLemonBunFreshLemonBun Member Posts: 909
    Yes I should have specified that but it's really the best you've got unless you use nwnx. I've asked for various combat hooking events too but they just say it might not be good for performance if you hook a combat event, but as I see it on the other hand the alternative is not pretty either.

    You can however get the target's dr and resistances and then boost the outgoing damage of the onhit effect to compensate. Then you can try to try to track the base weapon damage by doing a get/set compare and make a rough estimate of how much of the second part of the damage gets through. Really all of this stuff is so messy and ugly but without properly opening up combat to more scripting it's the best you can do.

    Now try to mess with the situational to-hit attack bonuses, apply them when you target the right target and not the wrong target. It's a mess without being able to override the combat mechanics.

    Without hooks or nwnx initiative scripting is a mess too. You have to roll your own and hope the player ignores the other.
  • ShadooowShadooow Member Posts: 402
    It is hard to decide whether this is the best or trying to calculate critical hit event by checking damage is the best (which will be missing some critical hits for dex-based builds)... but yeah those are the only options without nwnx...


    Btw what do you mean you asked for combat hooking? You asked nwnx developers? I have this functionality (and more) in nwnx_patch plugin, it works for both 1.69 and EE with same code (just the EE version is missing some functionalities). Obviously windows only though :hushed: ...

  • FreshLemonBunFreshLemonBun Member Posts: 909
    No, it was probably in one of those trello threads from a year ago. You know when we were still discussing things like combat events and sneak attack hooking. The trouble with nwnx is that you need to use it for it to work, which is obvious, but also single player modules.

    Even attempting to do a turn-based module like ToEE it's just ... it's not great.
  • ShadooowShadooow Member Posts: 402
    Oh, yeah. But whoever said that was wrong. I have this functionality as an extension for OnDamage event where you can read whether the attack was critical strike/sneak/death, if it was special attack (feat) etc. etc.

    So there are no such issues with efficiency... Maybe time to necro the original thread and notify them of this approach.
  • FreshLemonBunFreshLemonBun Member Posts: 909
    Right, I agree, even if it was taxing to run combat events it's still way cheaper than the work around we have to come up with. I could be forgetting some important details but still, you get the point.
  • Awas73Awas73 Member Posts: 66
    Well let me tell you why I asked. I think it is a good idea but maybe I am approaching it all wrong. What I have done is created a placeable rock, made it a plot item and indestructible. The PC can hit this rock all day and nothing happens to it. I wrote a script for the placeables "OnPhysicalAttacked" event where it checks to see if it was struct with a particular pick. If so it may randomly create a piece of ore on the ground. What I was hoping to do is if it detects a critical hit it would drop many more pieces at once instead of just 1 randomly. Not very exciting I am sure to most of you but that was my reason for originally asking about this question. How would you approach this?
  • FreshLemonBunFreshLemonBun Member Posts: 909
    Ahh that makes sense. What I would do in this case is I would abandon the critical hit idea entirely. Instead you could roll an ability check or skill check, for example rolling str + d20 vs dc 20. A high str character will get more but will also deal more damage to the rock causing it to be destroyed sooner. Alternatively just roll a d20 and on a 20 you award the extra bonus amount.

    It's more straight forward overall.
  • Awas73Awas73 Member Posts: 66
    Thanks for the tip, @FreshLemonBun . I will definitely give that a try. After reading all of the posts here though I am in agreement that BD really needs to allow for critical hit checks. So much can be retrieved by the community as it would open up many possibilities for sure. Thanks all for your input.
Sign In or Register to comment.