iRetrospect Posted September 19, 2019 Share Posted September 19, 2019 (edited) I have been trying to figure out a script to change the equipped "bound" type weapon to another type without needing the player to manually equip and recast the next spell by attaching the following to a lesser power for the player to use and cycle through: Event OnEffectStart(Actor akTarget, Actor akCaster) if akCaster.GetEquippedWeapon() == BloodWeaponGreatsword akCaster.DispelSpell(BloodGreatsword) BloodBattleAxe.Cast(akCaster) elseif akCaster.GetEquippedWeapon() == BloodWeaponBattleAxe akCaster.DispelSpell(BloodBattleAxe) BloodWarhammer.Cast(akCaster) elseif akCaster.GetEquippedWeapon() == BloodWeaponWarhammer akCaster.DispelSpell(BloodWarhammer) BloodBow.Cast(akCaster) elseif akCaster.GetEquippedWeapon() == BloodWeaponBow akCaster.DispelSpell(BloodBow) BloodGreatsword.Cast(akCaster) elseif akCaster.GetEquippedWeapon() == BloodWeaponDagger akCaster.DispelSpell(BloodDagger) BloodSword.Cast(akCaster) elseif akCaster.GetEquippedWeapon() == BloodWeaponSword akCaster.DispelSpell(BloodSword) BloodWarAxe.Cast(akCaster) elseif akCaster.GetEquippedWeapon() == BloodWeaponWarAxe akCaster.DispelSpell(BloodWarAxe) BloodMace.Cast(akCaster) elseif akCaster.GetEquippedWeapon() == BloodWeaponMace akCaster.DispelSpell(BloodMace) BloodDagger.Cast(akCaster) endif endEvent Testing it in game so far has shown that it works as expected but there are however issues that I am not sure how to address: After using the power, the new spell (if its a 1-h weapon type) casted through the script seems to also duplicates to the left hand but with an invisible version The newly casted spells from the script do not behave like the original "bound" type spells would as they do not automatically dispel when sheathedIf anyone know why this is happening and could help me figure out how I can fix these 2 issues, I'd greatly appreciate the help. Edited September 19, 2019 by iRetrospect Link to comment Share on other sites More sharing options...
ReDragon2013 Posted September 19, 2019 Share Posted September 19, 2019 There are different methods to control a spell effect, attached script itself or conditions made in CK related to spell and/or effect.Maybe next code is helpful, I am using two formlist (you have to create that) instead of single properties, keep in mind. irtBloodWeaponEffectScript Scriptname irtBloodWeaponEffectScript extends ActiveMagicEffect ; https://forums.nexusmods.com/index.php?/topic/7997798-script-for-switching-bound-type-weapons/ FormList PROPERTY mySpells auto ; created with CK, hold all your spells in order to cast a blood weapon ; 0 = BloodGreatsword (2h) ; 1 = BloodBattleAxe (2h) ; 2 = BloodWarhammer (2h) ; 3 = BloodBow (2h) ; 4 = BloodDagger (1h) ; 5 = BloodSword (1h) ; 6 = BloodWarAxe (1h) ; 7 = BloodMace (1h) FormList PROPERTY myWeapons auto ; created with CK, hold all your blood weapons ; 0 = BloodWeaponGreatsword (2h) ; 1 = BloodWeaponBattleAxe (2h) ; 2 = BloodWeaponWarhammer (2h) ; 3 = BloodWeaponBow (2h) ; 4 = BloodWeaponDagger (1h) ; 5 = BloodWeaponSword (1h) ; 6 = BloodWeaponWarAxe (1h) ; 7 = BloodWeaponMace (1h) Int iPos Actor player ; -- EVENTs -- 3 ; https://www.creationkit.com/index.php?title=IsWeaponDrawn_-_Actor ; https://www.creationkit.com/index.php?title=GetEquippedWeapon_-_Actor EVENT OnEffectStart(Actor akTarget, Actor akCaster) IF (akCaster == Game.GetPlayer()) ELSE gotoState("Done") ; ### STATE ### self.Dispel() RETURN ; - STOP - caster is different to player, remove spell effect immediately ENDIF ;--------------------- player = akCaster myF_Spell() ENDEVENT EVENT OnUpdate() IF ( player ) ; safety first weapon w = player.GetEquippedWeapon(False) ; right hand IF (w == myWeapons.GetAt(iPos) as Weapon) && player.IsWeaponDrawn() ; player has weapon (equipped and drawn) try again in two seconds RegisterForSingleUpdate(2.0) ELSE player.DispelSpell( mySpells.GetAt(iPos) as Spell ) ENDIF ENDIF ENDEVENT EVENT OnEffectFinish(Actor akTarget, Actor akCaster) Debug.Trace("Blood weapon effect has been finished! " +self) player = None ENDEVENT ;============================= state Done ; nothing here ;========= EVENT OnEffectFinish(Actor akTarget, Actor akCaster) ENDEVENT ;======= endState ; -- FUNCTION -- ;------------------- FUNCTION myF_Spell() ;------------------- weapon w = player.GetEquippedWeapon(False) ; get currently equipped weapon on players right-hand ;;; weapon w = player.GetEquippedWeapon(TRUE) ; left-hand int i = myWeapons.Find(w as Form) int n IF (i >= 0) player.DispelSpell( mySpells.GetAt(i) as Spell ) IF (i < 4) ; two-hand weapons IF (i == 3) n = 0 ELSE n = i + 1 ENDIF ELSE ; one-hand weapons IF (i == 7) n = 4 ELSE n = i + 1 ENDIF ENDIF spell sp = mySpells.GetAt(n) as Spell ; get the spell sp.Cast(player as ObjectReference) ; to cast next weapon ELSE iPos = i ; store the formlist position of the current spell/weapon RegisterForSingleUpdate(1.0) ; try to handle sheating ENDIF ENDFUNCTION Link to comment Share on other sites More sharing options...
iRetrospect Posted September 20, 2019 Author Share Posted September 20, 2019 (edited) Wow, thank you so much! I am glad I was able to receive your advice on this since I would have never realize the usage of the formlist given my inexperience with the ck in general. I will test it out to see if it works and update here. EDIT: So I tested out the new script and it seems that the issues I listed in the op still persists. Just wondering if those things might perhaps be linked to how the original spells work or not or if its related to something else entirely? Edited September 20, 2019 by iRetrospect Link to comment Share on other sites More sharing options...
Recommended Posts