Spinner385 Posted July 31, 2012 Share Posted July 31, 2012 (edited) Hmm while this script should work in theory, when I unequip/equip my weapon it stops the spell. I could tell it would work if the spell doesn't stop. Scriptname WeaponChargerScript extends activemagiceffect int property charge = 5 auto int property cost = 10 auto bool property casting = True auto Event OnEffectStart(Actor akTarget, Actor akCaster) float current = akTarget.GetAV("RightItemCharge") akTarget.SetAV("RightItemCharge", 99999) weapon RHItem = akTarget.GetEquippedWeapon() as weapon akTarget.UnequipItem(RHItem, false, true) akTarget.equipItem(RHItem, false, true) float max = akTarget.GetAV("RightItemCharge") int currentint = current as int int maxint = max as int akTarget.SetAV("RightItemCharge", currentint) While casting current = akTarget.GetAV("RightItemCharge") currentint = current as int If currentint > maxint casting = False elseif currentint > maxint - 5 charge = maxint - currentint endif akTarget.DamageActorValue("Magicka", cost) akTarget.ModAV("RightItemCharge", charge) utility.wait(0.1) endwhile endevent Event OnEffectFinish(Actor akTarget, Actor akCaster) casting = false endevent Edited July 31, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Spinner385 Posted July 31, 2012 Share Posted July 31, 2012 (edited) Hmm while this script should work in theory, when I unequip/equip my weapon it stops the spell. I could tell it would work if the spell doesn't stop. Scriptname WeaponChargerScript extends activemagiceffect int property charge = 5 auto int property cost = 10 auto bool property casting = True auto Event OnEffectStart(Actor akTarget, Actor akCaster) float current = akTarget.GetAV("RightItemCharge") akTarget.SetAV("RightItemCharge", 99999) weapon RHItem = akTarget.GetEquippedWeapon() as weapon akTarget.UnequipItem(RHItem, false, true) akTarget.equipItem(RHItem, false, true) float max = akTarget.GetAV("RightItemCharge") int currentint = current as int int maxint = max as int akTarget.SetAV("RightItemCharge", currentint) While casting current = akTarget.GetAV("RightItemCharge") currentint = current as int If currentint > maxint casting = False elseif currentint > maxint - 5 charge = maxint - currentint endif akTarget.DamageActorValue("Magicka", cost) akTarget.ModAV("RightItemCharge", charge) utility.wait(0.1) endwhile endevent Event OnEffectFinish(Actor akTarget, Actor akCaster) casting = false endevent Almost like you would need two spells one to test the weapon and one to charge it. Oops Edit fail Edited July 31, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Syfor Posted July 31, 2012 Author Share Posted July 31, 2012 (edited) I think I know what's the problem weapon RHItem = akTarget.GetEquippedWeapon() as weapon akTarget.UnequipItem(RHItem, false, true) akTarget.equipItem(RHItem, false, true) In the first line you don't specify which hand is checked. It could be the spell itself is stored as the weapon and unequiped, breaking the spell at that point.I don't know what the syntax for GetEquippedWeapon() is. I couldn't find it on the creation kit site either. I guess it must be something like: weapon RHItem = akTarget.GetEquippedWeapon(false) as weapon akTarget.UnequipItem(RHItem, false, true) akTarget.equipItem(RHItem, false, true) Edited July 31, 2012 by Syfor Link to comment Share on other sites More sharing options...
Spinner385 Posted July 31, 2012 Share Posted July 31, 2012 (edited) If you don't specify it defaults to false or right hand Here's the wiki on ithttp://www.creationkit.com/GetEquippedWeapon_-_Actor It doesn't necessarily unequip the spell just deactivates it when you do the weapon unequip. Good to keep your eyes open though, I make stupid errors all the time. I've stared at script for a long time because I didn't realize I put "=" instead of "==" in an if condition. Edit: What about a fire and forget spell that charges until its cast again? Kinda like concentration but you cast once to start and once to stop. That would work if your okay with the setup. Or the option to unequip/equip to get rid of extra charge using the concentration spell in the left hand so it looks more natural. Edited July 31, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Syfor Posted August 1, 2012 Author Share Posted August 1, 2012 (edited) That the spell can only be left handed isn't a problem. I don't think the fire and forget spell will be usefull. I wanted it to be a concentration spell so the player has more control over the amount of charge he wants in the weapon. I tested the script. The problem is the unequiping and equiping. I tried it with the flames spell and whenever you unequip a weapon, the concentration spell stops. I think we must force the player to recast when the weapon is re-equiped.Maybe we can do something like this: Scriptname WeaponChargerScript extends activemagiceffect int property charge = 5 auto int property cost = 10 auto bool property casting = True auto Spell property WeaponChargerSpell auto Event OnEffectStart(Actor akTarget, Actor akCaster) float current = akTarget.GetAV("RightItemCharge") akTarget.SetAV("RightItemCharge", 99999) weapon RHItem = akTarget.GetEquippedWeapon() as weapon akTarget.UnequipItem(RHItem, false, true) akTarget.equipItem(RHItem, false, true) float max = akTarget.GetAV("RightItemCharge") int currentint = current as int int maxint = max as int akTarget.SetAV("RightItemCharge", currentint) cast(WeaponChargerSpell, akTarget) While casting current = akTarget.GetAV("RightItemCharge") ... endwhile endevent ... This most likely won't work, I don't know much about scripting and it most likely will trigger a loop (if those 2 lines of code are correct), because when the spell is recast the script might restart and unequip the weapon again. I hope you get the idea. Edited August 1, 2012 by Syfor Link to comment Share on other sites More sharing options...
Spinner385 Posted August 2, 2012 Share Posted August 2, 2012 (edited) I see what your thinking. I'd have to look into how forcing the casting of a concentration spell is handled (not sure how to stop it). Your best bet for now is probably using this and making the spell left hand only. Assuming magicka use and weapon check are handled outside the script as discussed earlier. It should look relatively smooth to the user and trying to be greedy wont pay off for them =] Scriptname WeaponChargerScript extends activemagiceffect int property charge = 5 auto bool property casting = True auto Event OnEffectStart(Actor akTarget, Actor akCaster) While casting akTarget.ModAV("RightItemCharge", charge) utility.wait(0.1) endwhile weapon RHItem = akTarget.GetEquippedWeapon() as weapon akTarget.UnequipItem(RHItem, false, true) akTarget.EquipItem(RHItem, false, true) endevent Event OnEffectFinish(Actor akTarget, Actor akCaster) casting = false endevent As far as the fire and forget. You probably do, but I just want to make sure you knew what I was talking about. You fire the spell then the script keeps working and you see the charge/mana exchange going on. Then when it is where you want you fire it again and the script/spell stops. Would have to modify the script a bit but not much. And I could use the max charge in this one. BTW if you were wondering, in that script from the earlier post, I had to change the variables from floats (decimals) to int (integers). The GetAV for charges returns floats while the SetAV and ModAV only accepts integers, strangely enough. Edited August 2, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Syfor Posted August 2, 2012 Author Share Posted August 2, 2012 I think that this is the best option. It would be a lot of work to make such a relatively simple effect. I still wonder why the actorvalues LeftItemCharge and RightItemCharge behave this way. I've seen some other topics about other values were broken as well. Thank you for explaining Papyrus. Where did you learn to use Papyrus or was it just some trial and (lots of) error before you could understand it? Link to comment Share on other sites More sharing options...
Spinner385 Posted August 3, 2012 Share Posted August 3, 2012 About three days of bashing my head against the wall. Help from steve40 and scrivener07 is the only way I got through it. Once you learn the language its just programming, but man was it frustrating. I never dealt with anything like it. If you ever need help with a script let me know. I'm no master but I like to help when I can. Link to comment Share on other sites More sharing options...
Recommended Posts