RoyalProtector Posted June 11, 2022 Share Posted June 11, 2022 I know you can make them add damage based on what you're hiting (Werebane is an example), but can you change that based on who is wielding the weapon? Quote Link to comment
Graion Dilach Posted June 11, 2022 Share Posted June 11, 2022 op177 and moving the damage changes to the eff file. Think that acts weirdly on some aspects (like criticals) but it would still work (and maybe you can workaround criticals with op341 in the EFF file). Quote Link to comment
RoyalProtector Posted June 11, 2022 Author Share Posted June 11, 2022 Hmm. So far I've only been able to use that to add damage when targeting thieves as opposed to adding damage whenever a thief is wielding them. I used op177 inside item ability of a dagger and chained to an eff file that adds 15 flat piercing damage, but it's not checking the wielder is a thief, it's checking the target is a thief or not... Quote Link to comment
subtledoctor Posted June 11, 2022 Share Posted June 11, 2022 (edited) I've done: op248 equipping effect, applying EFF on hit EFF has op146, casting SPL_A at target 2 (preset) SPL_A has op326, casting SPL_B at target 9 (original caster), with condition class=x SPL_B has your extra damage It seems to me, looking at it now, that the op326 effect could have maybe gone into the EFF file, which would cut out one layer of subspells. It's possible I already tried that and it didn't work, but I can't recall for sure. EDIT - yeah, this will apply the damage to all hit if you are dual-wielding. Thinking about it now, you can probably just add an op146 effect to the item’s attack ability header, and have that subspell use op326 to conditionally cast the extra damage subspell based on the attacker’s class… Edited June 11, 2022 by subtledoctor Quote Link to comment
Bartimaeus Posted June 11, 2022 Share Posted June 11, 2022 (edited) The simplest (but not perfect) solution would probably be to add bonus damage to the equipped effects of the item via class-targeted .effs (opcode 177 on the equipped effects -> opcode 73 .eff), but it would unfortunately apply to both hands. Edited June 11, 2022 by Bartimaeus Quote Link to comment
RoyalProtector Posted June 11, 2022 Author Share Posted June 11, 2022 (edited) The problem with those two solutions seems that it becomes an effect for all melee attacks, so the only way to "fake" that it is an effect that only affects that weapon is if the weapon is two-handed, I guess...? Same would go for the backstab effect, I think... What I wanted to do is to make daggers have a 35% chance of adding 1d4+x extra damage, per hit, but only if the wielder was a rogue. I was even planning to call this talent "weapon finesse". Oh well... I'm not sure what else to try Edited June 11, 2022 by RoyalProtector Quote Link to comment
RoyalProtector Posted June 11, 2022 Author Share Posted June 11, 2022 1 hour ago, subtledoctor said: Thinking about it now, you can probably just add an op146 effect to the item’s attack ability header, and have that subspell use op326 to conditionally cast the extra damage subspell based on the attacker’s class… Maybe I'm doing something wrong but I only seem to be able to do that so that targeted thieves get the extra damage... Quote Link to comment
subtledoctor Posted June 11, 2022 Share Posted June 11, 2022 2 hours ago, Bartimaeus said: The simplest (but not perfect) solution would probably be to add bonus damage to the equipped effects of the item via class-targeted .effs (opcode 177 on the equipped effects -> opcode 73 .eff), but it would unfortunately apply to both hands. The problem there is how to make an effect target the victim of the attack, with a condition based on the attacker's status. This is why I needed two levels of subspells to make this work: one aimed at preset target (the victim) for the effect, and one aimed at original caster (the attacker) for the condition. In my case I conditioned it on a spellstate/proficiency, but a class condition should work just as well. 57 minutes ago, RoyalProtector said: Maybe I'm doing something wrong but I only seem to be able to do that so that targeted thieves get the extra damage... Maybe it only works through an .EFF? Maybe that's why I set it up that way. Not sure. I'm testing now. Quote Link to comment
Bartimaeus Posted June 11, 2022 Share Posted June 11, 2022 (edited) 10 minutes ago, subtledoctor said: The problem there is how to make an effect target the victim of the attack, with a condition based on the attacker's status. This is why I needed two levels of subspells to make this work: one aimed at preset target (the victim) for the effect, and one aimed at original caster (the attacker) for the condition. In my case I conditioned it on a spellstate/proficiency, but a class condition should work just as well. Maybe it only works through an .EFF? Maybe that's why I set it up that way. Not sure. I'm testing now. With RoyalProtector now further clarifying what kind of effect they intended, my solution is obviously even more inappropriate - definitely need to use a melee effect gated through a conditional self-targeting .eff for that sort of thing (but it still won't be limited to just one weapon). Edited June 11, 2022 by Bartimaeus Quote Link to comment
subtledoctor Posted June 11, 2022 Share Posted June 11, 2022 (edited) No, it's pretty simple, I have it working. Structure: Add an op146 effect to the melee hit header on the item: type = 1 target = 2, parameter2 = 1, timing = 1, resource = subspell_1 Create subspell_1 with op326, target = 9, parameter1 = 4, parameter2 = 105, timing = 1, resource = subspell_2 Create subspell_2 with whatever effects you want. I set this up very quickly with DAGG03.itm (Heart of the Golem), such that it casts Entangle on hit, but only when wielded by a mage/thief. Install this mod on BG2EE, give DAGG03 to Imoen and have her attack Charname. It will cast Entangle. Then have Charname (any class except M/T) strike Imoen. No Entangle. The code is simple: COPY_EXISTING ~dagg03.itm~ ~override~ LPF ADD_ITEM_EFFECT INT_VAR type = 1 opcode = 146 target = 2 timing = 1 parameter2 = 1 STR_VAR resource = ~d5_sp_a~ END COPY ~dagger_of_the_undergrowth/d5_base.spl~ ~override/d5_sp_a.spl~ LPF ALTER_SPELL_HEADER INT_VAR target = 1 END LPF ADD_SPELL_EFFECT INT_VAR opcode = 326 target = 9 parameter1 = 13 parameter2 = 105 timing = 1 STR_VAR resource = ~sppr105~ END EDIT - I should change me mod to work this way, it's more elegant. Edited June 11, 2022 by subtledoctor Quote Link to comment
RoyalProtector Posted June 11, 2022 Author Share Posted June 11, 2022 (edited) Yeah, but doesn't that make it cast Entangle on herself? I followed your instructions but it just causes the damage to hit the wielder. Edited June 11, 2022 by RoyalProtector Quote Link to comment
subtledoctor Posted June 11, 2022 Share Posted June 11, 2022 45 minutes ago, RoyalProtector said: Yeah, but doesn't that make it cast Entangle on herself? I followed your instructions but it just causes the damage to hit the wielder. Oh duh, my bad - my test didn’t test for that. In that case it probably has to run through the “melee hit effect” op248. I know for sure this works. Op248 must step in to differentiate the attacker and target. That still leaves the problem of it being applied by off-hand weapons. Quote Link to comment
RoyalProtector Posted June 11, 2022 Author Share Posted June 11, 2022 Hmm... I was thinking that perhaps a more elegant solution would have been to mod the thief class as such so they have by default a melee hit effect with the desired effect. If that's even possible, I don't know. Although I don't think that way would work as I would want it because it would cause a fixed amount of damage (piercing, slashing, what?) no matter what weapon they are wielding and would not be adaptable to the enchantment level of the weapon either. The way I'm envisioning the mod, it would, for example, cause a +5 dagger to have a 35% chance of causing 6-9 extra piercing damage. But for a normal dagger, it would only be 1-4 extra damage. For a ninja-to, it would have a 10% chance of causing 1d8+x slashing damage... Quote Link to comment
DavidW Posted June 11, 2022 Share Posted June 11, 2022 This works, I think. 326 on the weapon, to cast a spell carrying the intended payload, gated to only work if the caster is the requisite class. (#326 targets the original target even with target=self, but it does its 326 check on 'self'.) /* This function modifies the current item (assumed to be a weapon) so that its attacks have an additional effect if the wielder has a specific class. */ DEFINE_PATCH_FUNCTION weapon_damage_by_class INT_VAR header=0 // the weapon header to which the effect is applied probability1=100 // the probabilities for the effect to be applied probability2=0 STR_VAR class="" // the class which gets the effect (from class.ids) spell="" // a spell which is cast on the target on a successful hit, but only if the wielder is the correct class BEGIN LPF ADD_ITEM_EFFECT INT_VAR type=99 header probability1 probability2 opcode=326 target=1 timing=1 parameter1=IDS_OF_SYMBOL (class "%class%") parameter2=105 STR_VAR resource="%spell%" END END /* Example: this daggger casts Magic Missile on-hit, but only if the wielder is a mage. */ COPY_EXISTING "dagg01.itm" "override/dw-dagg.itm" LPF weapon_damage_by_class STR_VAR class=MAGE spell=SPWI112 END You just need to supply a spell that does however-much extra damage you want. Quote Link to comment
RoyalProtector Posted June 11, 2022 Author Share Posted June 11, 2022 (edited) I guess you're on the right track, thanks. For some reason it works perfectly well with Magic Missile (although the log in the game indicates you targeted yourself, oddly enough...), but not with my spell which adds damage with op12. Instead it ends up damaging my own character. Trying to figure out what is missing. Probably something obvious that I'm not seeing because I'm tired as heck. EDIT: Okay, looks like for some reason the default no projectile option is the problem... if I give it a projectile, it does work... I'm trying to find some sort of "empty projectile" that works for this. Edited June 11, 2022 by RoyalProtector Quote Link to comment
Recommended Posts
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.