lesi123 Posted August 13, 2014 Posted August 13, 2014 I am sorely desperate for some help. I have spent weeks working a mod that applies a damage over time spell to enemies using perks, specifically the "Apply Combat Hit Spell" entry point. I come to find out that only one effect is applied per weapon type globally, so technically my mod breaks even vanilla perks because of this. I'm holding out on scrapping the mod completely in the hopes there is some sort of work around that won't cause massive amounts of conflicts. I'm not the greatest with scripting, but perhaps there is an event that functions the opposite of OnHit that is able to detect when you attack a target vs when a source hits you? I would be eternally thankful to anyone that can help with this.
Mattiewagg Posted August 13, 2014 Posted August 13, 2014 I am sorely desperate for some help. I have spent weeks working a mod that applies a damage over time spell to enemies using perks, specifically the "Apply Combat Hit Spell" entry point. I come to find out that only one effect is applied per weapon type globally, so technically my mod breaks even vanilla perks because of this. I'm holding out on scrapping the mod completely in the hopes there is some sort of work around that won't cause massive amounts of conflicts. I'm not the greatest with scripting, but perhaps there is an event that functions the opposite of OnHit that is able to detect when you attack a target vs when a source hits you? I would be eternally thankful to anyone that can help with this. Dynamically Attaching Scripts + OnHit The OnHit would look like this: Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) If akAggressor == Game.GetPlayer() Debug.Notification("The player hit us. What a jerk.") EndIf EndEvent
lofgren Posted August 13, 2014 Posted August 13, 2014 There are other options. For example you could make your spell only work on a timer, so that it can only be applied once every five seconds or so. That would mean that the first attack might apply your spell but then subsequent attacks would use the bleed or paralyze spells (I believe those are the only vanilla perks your mod conflicts with) until the timer ran out. To add a timer to your onhit perk, add an empty magic effect to your spell with a duration equal to however long you want the timer to last. Then add as a condition on your perk, in the target tab, HasMagicEffect -> (your dummy effect) == 0. As long as the target has your dummy effect on them, the game will ignore your perk and fire other On Combat Hit perks instead. Another option would be to make your effect hit randomly. Add GetRandomPercent < 50.0 as a condition on the Perk Owner tab and your perk will only fire 50% of the time, allowing other perks to get used the other 50% of the time. Finally, since your perk essentially duplicates and replaces the effect of the Bleed spell that fires with hack&slash or whatever the two-handed axe perk is, you could simply create a second version of your spell that works only with axes and duplicates the effects of the bleeding axe perks. Frankly since those perks are bugged the hell from here to New Jersey and back, most likely nobody will care, and those who do will be thankful.
Mattiewagg Posted August 13, 2014 Posted August 13, 2014 There are other options. For example you could make your spell only work on a timer, so that it can only be applied once every five seconds or so. That would mean that the first attack might apply your spell but then subsequent attacks would use the bleed or paralyze spells (I believe those are the only vanilla perks your mod conflicts with) until the timer ran out. To add a timer to your onhit perk, add an empty magic effect to your spell with a duration equal to however long you want the timer to last. Then add as a condition on your perk, in the target tab, HasMagicEffect -> (your dummy effect) == 0. As long as the target has your dummy effect on them, the game will ignore your perk and fire other On Combat Hit perks instead. Another option would be to make your effect hit randomly. Add GetRandomPercent < 50.0 as a condition on the Perk Owner tab and your perk will only fire 50% of the time, allowing other perks to get used the other 50% of the time. Finally, since your perk essentially duplicates and replaces the effect of the Bleed spell that fires with hack&slash or whatever the two-handed axe perk is, you could simply create a second version of your spell that works only with axes and duplicates the effects of the bleeding axe perks. Frankly since those perks are bugged the hell from here to New Jersey and back, most likely nobody will care, and those who do will be thankful. Probably listen to lofgren :laugh:. He's an expert on perks, which is far, far better than I am.
lofgren Posted August 13, 2014 Posted August 13, 2014 Probably listen to lofgren :laugh:. He's an expert on perks, which is far, far better than I am.Well shucks. It is only because I have been working on my own perk overhaul for far longer than should be legally allowed for any healthy adult. But really your solution is perfectly viable as well. It all depends on the effect that OP is trying to accomplish. For my own implementation I went with a mixture of all of these options, plus an MCM to allow players to move the perk entry up or down in priority. Lower numbered priority perk entries override higher numbered ones. By default all of my perks have the highest possible priority, which means that they may get overridden by other mods. By placing them at priority 0 you can get the effects of my perks as well as those of other mods, albeit only when my perks randomly do not fire.
lesi123 Posted August 13, 2014 Author Posted August 13, 2014 Thank you guys so much for your help! I will try them all and see which works best. :D Luckily I already have an OnHit event script made up so it's nice to know I can use that in reverse.
lesi123 Posted August 13, 2014 Author Posted August 13, 2014 So I got a dynamic script working to a degree; It recognizes every time I attack an actor with a bow perfectly. However, when I added in the spell I wanted to be applied to the actor, it's it's incredibly inconsistent, normally applying the first 2 or 3 actors I hit and then none afterwards, even though a message box still pops up every time I hit. Below is the script I'm using but I can't think there's anything wrong with it: Scriptname myMonitorScript extends activemagiceffect Actor Property PlayerRef Auto Keyword Property WeapTypeBow Auto Spell Property myDamageSpell Auto Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if ((akAggressor == PlayerRef) && (abHitBlocked != true) && ((akSource as Weapon).HasKeyword(WeapTypeBow))) myDamageSpell.cast(PlayerRef) ;not firing on every hit Debug.MessageBox("I just hit an NPC with a bow.") ;this always fires when an actor is attacked with a bow endif EndEvent For reference, the damage spell has multiple entries of the same magic effect with different durations and magnitudes that are controlled via global value conditions which are set using an MCM. I've never had this happen before using the script method seeing as I didn't change my spells at all.
lesi123 Posted August 14, 2014 Author Posted August 14, 2014 After some further testing, it seems like the spell will only cast if I am attacking within melee range of the actor. I am still trying to figure out why this is though.
lofgren Posted August 14, 2014 Posted August 14, 2014 The spell will not fire if you are out of melee range, but the message box will appear no matter the range? What is the range of the spell that gets cast by your script?
lesi123 Posted August 14, 2014 Author Posted August 14, 2014 It's a FIre and Forget, Contact spell. It worked as intended before I used the dynamic script method by applying the spell on the target when the arrow hit them. Now I have to fire the bow right next to the NPC for the OnHit to apply the spell.
Recommended Posts