Jump to content

How can I fake a "backstab from any angle" sort of effect with NearInfinity?


Recommended Posts

I'm trying to figure out how can I make use of the "backstab every hit" effect to "fake" a backstab from any angle sort of thing (like how NPCs do).

My idea is this: I have a spell that for a few seconds allows me, among other things, to backstab ONCE from any angle WHILE INIVISIBLE. If I have the backstab every hit effect, then that is indeed possible. However, how can I make sure that the effect is immediately dispelled after a backstab (after invisibility is broken), to make sure that it affects only one attack and no more?

That is, this effect should only exist if I'm invisible, and when I'm not it should be inactive.

Thank you

Edited by RoyalProtector
Link to comment

I don't think there's an elegant way to do what you want to do. At least I am not aware of any, but there are ways to achieve something similar, depending on your tolerance for delays in checking the conditions.

To ensure that you backstab only once, you can simply use #340 (0x154) Spell Effect: Change Backstab Effect to cast a spell that will dispel your original spell/effect, when the backstab is performed.

To check if your character is invisible, you could probably use #272 (0x110) Spell: Apply Repeating EFF coupled with opcode 326. But that would work only once per second (and might be affected by slow).

The second option, that I personally don't like, but deem necessary in some situations, is to add some checks to your baldur.bcs and baldur25.bcs script files. This script is fired more often than once per second (once per game tick?), so the delay will be much shorter.

Link to comment
2 hours ago, moggadeet said:

If you want to look at another mod's code for ideas, Artisan Kitpack's Invisible Blade has a feint ability that, at level 12+, can backstab from any angle (without stealth) while feint is active. I have no idea how it works under the hood, but it's very impressive.

I'm looking at the kitpack but I can't figure out how he did it looking at the effects. Might take a while.

When I do I'll drop a comment explaining how it works.

Link to comment

You could try the following option:

SPL: Special ability "Auto-Backstab once" (target "Caster/Self")
  - Add "Immunity to resource and message" (op324)
    - with creature type "If NOT Invisible or Improved Invisible" (entry 143 in BG2EE)
    - with resource set to this resource
    - Note: This will only check visibility state when the special ability is cast.
  - Add "backstab every hit" (op303)
  - Add "Melee hit effect" (op248)
    - set resource to EFF "Ability removal"
  - (optionally) Add "Ranged hit effect" (op249)
    - set resource to EFF "Ability removal"

EFF: "Ability removal" (target "Self")
  - Set "Cast spell" (op146)
    - set resource to SPL "Ability removal"

SPL: "Ability removal" (target "Caster/Self")
  - Add "Remove effects by resource" (op321)
    - set resource to SPL "Auto-Backstab once" ability

The "hit effect" opcodes and "Ability removal" spells ensure that you can only auto-backstab the target once while the ability is active.

Edited by argent77
Link to comment

Hmm, well. Now at least it doesn't crash my game when I cast the spell.

This spell (I'm essentially making a new Shadowstep ability) makes you invisible immediately. Much lower in the effect list I have a cast spell effect that points to the "Auto-backstab once" spell. Doesn't seem to work yet (although after casting it says something like "unaffected by effects from [empty]". I'm probably missing something, I'll have to tinker a bit more.

Thanks

EDIT1: On further inspection, I chose the 142 entry in the opcode 324 by mistake, I changed it to 143 and now the message about being unaffected does not appear. However it's still not working.

Edited by RoyalProtector
Link to comment
On 7/18/2023 at 2:30 PM, argent77 said:

Note: This will only check visibility state when the special ability is cast.

Sorry for the necro, but I think I have a similar issue...

If you add op326 (target=1, p2=140) as an on-hit effect to a melee weapon (say "dagg01.itm") in order to cast a spell only if the attacker is invisible, nothing happens... This is easily reproducible by editing your weapon to always hit (i.e. by setting thac0_bonus to 32767)... Is this intended or what...?

Link to comment
1 hour ago, Luke said:

Sorry for the necro, but I think I have a similar issue...

If you add op326 (target=1, p2=140) as an on-hit effect to a melee weapon (say "dagg01.itm") in order to cast a spell only if the attacker is invisible, nothing happens... This is easily reproducible by editing your weapon to always hit (i.e. by setting thac0_bonus to 32767)... Is this intended or what...?

How are you structuring the invisibility check? For on-hit effects most spells will target the victim of the attack - you need to use target mode 9 to check the attacker’s stats. See here for an example to work from. 

Link to comment
20 hours ago, subtledoctor said:

How are you structuring the invisibility check? For on-hit effects most spells will target the victim of the attack - you need to use target mode 9 to check the attacker’s stats. See here for an example to work from. 

Will try... Anyway, target mode 1 works fine with other checks... I fear there is something specific to the invisibility check that I am missing... Thing is that the on-hit check is done after base damage, so of course this cannot work as I expected...

Edited by Luke
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...