Basically, I've been trying to mod an item of my own, and my idea was to allow it to counter with various proc attacks that would have a chance to trigger on counter or block. However, when I tried using counterBuff and blockBuff, it hit the PC with the procs instead of the enemy every time it countered. I'm having a tough time finding the proper code for this. So... yeah. How do I make it 'counter' with procs properly, if this is even possible? I may use this information for proper public mods as well.
Unless you accidentally have your effects set to self, there probably isn't a way to get the attacker directly. I think you could have it trigger an aoe though that hits all adjacent squares, which should hit the attacker. (sorry I haven't actually made mods recently so my memory might be rusty or I might've forgetten something)
I guess I'll clarify what I'm making- it's a mega-tome I call the Codex Gigas, which is inspired by Roguish Renovation's Dredmorpedia. Basically, it's crafted (I plan to make it unspawnable or late-game only if possible if I release it) by merging four artifact-level tomes, and it'll be purely defensive- one or two of every damage resistance, similarly for every buff, but no damage buff. Instead it'll have a gauntlet of procs- every single vanilla tome proc to be specific, but will trigger based on counters (maybe 25% or so... less?) and blocks (10%) to retaliate with various proc attacks. I wanted to make it single target retaliation, but I'm not sure how to do that. I can make it hit all adjacent squares, but that might be a little too much... I have other 'final tier' craftable mega-artifacts in mind as well, but I might have to ask llcorp2 about that since a lot of my ideas are based on his or even directly upgrade off a few of his stuff...
Wait do counter attacks trigger attack procs, and what order do they apply in, because you MIGHT be able to do something like have the counter buff give you a buff, and then a 100 percent attack proc that checks for that buff, removes it, and then triggers the effects you want. but that'd only work off counters, and idk if it'd actually work. (Although also even if that doesn't work you cuold probably use an effect like that to get something close to what you're going for; eg the item gives you an attack proc but only if you have a buff you get after a successful block or counter, which is consumed when you attack)
I believe the trick to this was to set a 0-turn buff that works on defense instead. So diggle attacks you, you block, you get an effect that knocks away things hitting you, the diggle gets knocked away. The problem is, this buff cannot subsequently be dispelled (removing the buff doesn't do anything until the next turn), so any subsequent attacks are also effected.
Actually, you can do something about it. Make it a two-step trigger, with the effect working only if there isn't another buff on you, with the other buff in question (a dummy one) placed as soon as the effect you want triggers.
Alright, so we end up with a comprehensive solution being to make eight different buffs, each second one shutting off the last but allowing the next to be triggered?
On the most basic level, pretty much, yes. One would only have to remember that it means it's necessary to have 8 different icons for the buffs, even if those icons are identical save for their filenames (due to that particular quirk with buff detection for trigger requirements). Well, one could instead go a different way and make it a bit more complicated (well, seemingly more complicated, I say; it only looks daunting but really isn't when you make a spider web out of it) if more entertaining in how it works, but that is not necessary.