blazie151 Posted January 20, 2013 Share Posted January 20, 2013 (edited) I'm working on my Unlock Unique Enchantments mod, listed here...http://skyrim.nexusmods.com/mods/29059 I'm making an enchantment that allows the bow to use arrows made of magicka. It's a script magic effect that also applies an ability, that I'm using to call a second magic effect and script so that I can trigger all the script functions I need. I'm running into a small scripting issue. I have MOST of the effect working as intended, but am getting slightly stuck and using workarounds I'd prefer to avoid. Part one of the issue is finding out when an arrow has been fired so I can replace it. I can easily add an arrow and subtract the magicka from the script attached to the weapon magic effect, but since it is fire & forget on contact, it doesn't get called unless the user hits their target. Currently, I'm doing what the base game does and just adding more arrows than the user would fire and miss with, but if it's used all the time the user is either going to eventually run out of arrows or have thousands they aren't using. I'm removing arrows on unequip of the bow, but I'd rather not need to occasionally unequip and equip the item. Basically, I need a way to replace the arrow every time it's fired, even if the wielder misses. The second issue, oddly enough, is that EquipItem(MagicArrows, TRUE, TRUE) does not seem to be working properly. The arrows equip silently, but the user can select another quiver of arrows, which is very weird because the same function is used by the bound arrows script and works properly. The last issue I'm having is something I don't know exactly how to handle. Auto unequip ammo (the mod) automatically unequips the magic arrows because the magic effect "AUABoundWeaponCheckEffect" is not equipped on the player, so the mod automatically unequips the magic arrows and equips the last arrows the user was using. I think I can just create an identical magic effect with the same formID and add a new condition on the effect, but since I've never intentionally conflicted with another mod, I'm not sure if there's a better way to do that. EDIT: Ok, so after a lot more research and staring at some scripts with similar needs, I found that I might be able to handle problem #1 by registering for the animation event called by firing an arrow, or possibly the sound of the arrow firing. Since I've never used a script like that, I'm building one now. The issue is I don't know what animation events I can use reliably. EDIT2: Ok, so registering for the the animation event "BowRelease" seems to be the missing key for problem one, which I'm having a ton of success with. The enchantment now "makes" new arrows from the wielder's magicka. My script I'm working with is below, if anyone wants to give me some advice on possible negative effects or problems. Scriptname UnlockMagickaArrowsEquipScript extends ActiveMagicEffect Ammo Property MagicArrow Auto String BowAnimation = "ArrowRelease" Actor CasterRef bool OutofMagic = False Function AddArrow(Actor Target, Int Qty, Int MagicCost) Target.additem(MagicArrow, Qty, TRUE) Target.DamageAV("Magicka", MagicCost) ; Debug.Notification(Qty + " Arrow(s) Added and Equipped") EndFunction Event OnAnimationEvent(ObjectReference akSource, string asEventName) CasterRef = akSource as actor if (asEventName == BowAnimation) if OutofMagic if CasterRef.GetAV("Magicka") >= 50 OutofMagic = False AddArrow(CasterRef, 2, 15) CasterRef.equipItem(MagicArrow, TRUE, TRUE) endif else if CasterRef.GetAV("Magicka") <= 9 debug.Notification("You don't have enough Magicka") OutofMagic = true else if CasterRef.IsEquipped(MagicArrow) AddArrow(CasterRef, 1, 10) else debug.Notification("Re-equip your bow to begin using Magic Arrows again!") dispel() endif endif endif endif EndEvent EVENT OnEffectStart(Actor Target, Actor Caster) if Caster.GetAV("Magicka") <= 14 debug.Notification("You don't have enough Magicka") OutofMagic = true else AddArrow(Caster, 2, 15) RegisterForAnimationEvent(Caster, BowAnimation) Utility.Wait(0.5) Caster.equipItem(MagicArrow, TRUE, TRUE) endif endEVENT EVENT OnEffectFinish(Actor Target, Actor Caster) ; debug.Notification("Effect Finishing, remove any magic arrows") Caster.removeitem(MagicArrow,Caster.getItemCount(MagicArrow),TRUE) UnregisterForAnimationEvent(Caster, BowAnimation) endEVENT Edited January 21, 2013 by blazie151 Link to comment Share on other sites More sharing options...
blazie151 Posted January 21, 2013 Author Share Posted January 21, 2013 (edited) The above script has a new, small issue. When the user has regained enough magicka to use the effect again, the arrow previously shot drops out of thin air and does nothing. I think it has to do with another arrow type being equipped as the previous arrow is being fired. I think it's interrupting the animation. Also, does anyone have an idea on how to get the second issue I'm having with the equip command not working properly? Because I wouldn't need to use the equip command after each arrow is fired if I could keep them force equipped. EDIT: Never mind the new issue, fixed it by registering for the animation event "arrowRelease" instead of "bowRelease", which is called late enough to prevent it from making the arrow disappear or drop out of the air. So now my biggest issue is still not being able to make the arrows unequippable for some reason. It's weird because it works for the conjured arrows, and it works for apparel, but I can't get it to work with these arrows. EDIT2: Possible, though unlikable solution with the auto unequip ammo mod; the user is asked to select what type of ammo the new "Magicka Arrow" is, and if the user selects "Other" instead of "Arrow", the only side effect is that the first arrow fired after equipping the weapon this enchantment goes onto will be the regular user's arrow. Definitely not as bad as the old problem, where every time you select a new bow it would unequip all your ammo. Now, if there's a way to automatically do this for the user so they don't have to that'd be great. Found a fix for another issue; adding a 1/2 delay in my script to allow time for the AUA script to run and then re-equipping the Magicka Arrows stops it from firing the wrong arrows, and has no negative effect as the user doesn't have time to draw the arrow before it's changed back to the Magicka Arrow. So now the only thing left is not allowing the user to select another type of arrow unless they are out of Magicka Arrows, and to find a way to add the Magicka Arrows to the AUA "other" formlist without conflicting with that mod. I also updated the script above to what I'm currently using. Well, there goes another issue. I had my Magicka Arrow almost identical to a bound arrow except that the damage was 2 points lower, almost nothing at all. Bound Arrows are in the AUA "other" formlist by default, so by re-equipping them after the AUA script runs, as well as them already being on the the AUA "other" formlist, the conflicts with that mod are solved. I don't why I didn't check this, but even the stock Bound Bow spell summons arrows that aren't supposed to be unequipable, yet you can unequip them. I guess the equipitem function is somehow bugged. Edited January 21, 2013 by blazie151 Link to comment Share on other sites More sharing options...
blazie151 Posted January 21, 2013 Author Share Posted January 21, 2013 Ok, well, since the equiptem command can't lock in arrows so they can't be un-equipped, I figured I'd allow the user to use their own arrows if they wanted (don't know why anyone would do that, but whatever). Basically, if you select different arrows by choice while you have enough magicka to use magic arrows, now it will dispel the effect and the user needs to re-equip the bow again to begin using Magic Arrows again. I'm very happy with this setup, as it's the user's choice to use the enchantment all the time or only when they want to. I'll add another check on the weapon damage script to verify the wielder is using the magic arrows before applying the spells that rely on oblivion binding and soul stealer. Basically, if the user is firing magic arrows they will have all the effects, if they're using regular arrows with this it will simply dispel and not apply any additional effects. Link to comment Share on other sites More sharing options...
Recommended Posts