James Bond Posted June 3, 2014 Posted June 3, 2014 So after a lot of testing and Googling, I'm quite certain that the creation kit is unable to apply perks to NPC's through the "perk to apply" magic effect drop down. Does anyone know of any work arounds via scripts or any other way to cause NPC's to have a perk? I only want them to have various perks temporarily while a specific magic effect is active on the NPC.
Heromaster Posted June 4, 2014 Posted June 4, 2014 Yep, there are ways to give NPC's perks. This way I tell you now only works for Perks which have an Entry Point. Copy the perk you want to have while a magic effect is active. Add this perk under the Actors Tab --> SpellList. Now edit that perk, delete everything from the Condition Functions. They do not work for NPC's. Double-Click the Entry Point in the lower section of the perk window. Under Perk Owner add the Conditions for your Active Magic Effect. If there are already some Condition Functions then you need to know if you want to keep them or delete them. That should do the trick.
James Bond Posted June 4, 2014 Author Posted June 4, 2014 Thank you for the replay Heromaster! That would work for me because I could use some sort of validation condition, such as "HasKeyword," into the perk owner conditions list. The actor would actually always have the perk, but my spell's magic effect could temporarily disable or enable the perk, by temporarily adding the needed keyword to the actor. My perk's type is "entry point," so that matches too. The downside I see to that method is that one would need to add the perk to every actor's spell list in the game. Since there are probably thousands of various actors in the creation kit, I'm hoping there might yet be another way. Also, with this method the perk wouldn't work with any new actors (monsters, races, ect.) that are introduced by other mods. Is there any way to achieve the same result of adding a perk to an actor's spell list via a script, rather than through the CK? If I could script a function to add the perk, then it should work with actors from other people's mods; not to mention save a ton of time. Anyone have any ideas?
Heromaster Posted June 5, 2014 Posted June 5, 2014 Nope there is no other way, Actor.AddPerk() only works for the player not for the NPC. What you can do is adding spells at runtime so if you can rewrite your perk to behave like a spell then go this route.
James Bond Posted June 8, 2014 Author Posted June 8, 2014 I've kind of been able to simulate the perk effect's in a script! However, I don't know how to share variables between events within the same script. Can anyone help? In particular, I need int fx1 and int fx2 to get temporarily saved and then recalled later in the EventOnEffectFinish, so that I can restore the enemies magicka regeneration rate and magicka amount. Scriptname yyyRacialDrowGlobeDebluffs extends activemagiceffectEvent OnEffectStart(Actor akTarget, Actor akCaster) Int CasterLevel = akCaster.getlevel() Int RandomInt = Utility.RandomInt(0, 100) If (RandomInt <= (MissChance)) ; adds a x% chance for attacks to "miss" (aka deal zero damage) akTarget.SetAV("attackDamageMult", 0.0) ; temporarily set's target's damage to zero EndIf If CasterLevel > 29 ;these will be needed later to restore values BUT seem to need to be a GLOBAL variable, since the EventOnEffectFinish cannot find them... Float fx1 = akTarget.GetAV("Magicka") Float fx2 = akTarget.GetAV("MagickaRate") ; no magicka regeneration and setting magika bar to zero effectively silences casters unless their spells magicka cost is zero akTarget.ForceAV("MagickaRate", 0.0) akTarget.ForceAV("Magicka", 0.0) EndIfendEventEvent OnEffectFinish(Actor akTarget, Actor akCaster) akTarget.SetAV("attackDamageMult", 1) Int CasterLevelAgain = akCaster.getlevel() ; since I don't know how to get PAPYRUS to keep previous value... If CasterLevelAgain > 29 akTarget.RestoreAV("Magicka", 9999) ; do I need to have made and imported a global variable to be able to swap out 9999 with (fx1)??? akTarget.RestoreAV("MagickaRate", 9999) ; do I need to have made and imported a global variable to be able to swap out 9999 with (fx2)??? EndIfendEventInt property MissChance auto
Heromaster Posted June 8, 2014 Posted June 8, 2014 I've kind of been able to simulate the perk effect's in a script! However, I don't know how to share variables between events within the same script. Can anyone help? In particular, I need int fx1 and int fx2 to get temporarily saved and then recalled later in the EventOnEffectFinish, so that I can restore the enemies magicka regeneration rate and magicka amount.<snip> Scriptname yyyRacialDrowGlobeDebluffs extends activemagiceffect Float fx1 Float fx2 Int CasterLevel Int property MissChance auto Event OnEffectStart(Actor akTarget, Actor akCaster) Int CasterLevel = akCaster.getlevel() Int RandomInt = Utility.RandomInt(0, 100) If (RandomInt <= (MissChance)) ; adds a x% chance for attacks to "miss" (aka deal zero damage) akTarget.SetAV("attackDamageMult", 0.0) ; temporarily set's target's damage to zero EndIf If CasterLevel > 29 ;these will be needed later to restore values BUT seem to need to be a GLOBAL variable, since the EventOnEffectFinish cannot find them... fx1 = akTarget.GetAV("Magicka") fx2 = akTarget.GetAV("MagickaRate") ; no magicka regeneration and setting magika bar to zero effectively silences casters unless their spells magicka cost is zero akTarget.ForceAV("MagickaRate", 0.0) akTarget.ForceAV("Magicka", 0.0) EndIf endEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) akTarget.SetAV("attackDamageMult", 1) If CasterLevel > 29 akTarget.RestoreAV("Magicka", fx1) ; do I need to have made and imported a global variable to be able to swap out 9999 with (fx1)??? akTarget.RestoreAV("MagickaRate", fx2) ; do I need to have made and imported a global variable to be able to swap out 9999 with (fx2)??? EndIf endEvent
James Bond Posted June 8, 2014 Author Posted June 8, 2014 Thanks a lot Heromaster! Those changes worked like a charm and I think I now have a better understand of how to call out variables. It seems like if you call them within some sort of event, then they only exist until that event is over, while if you call them within the "main body" of a script, then they should last until the script has ended. If you're interested, here's the mod for which you helped me on the racial power "Globe of Darkness." I'll be sure to mention you in my credit section when it's finally complete. http://www.loverslab.com/topic/22033-wip-dhaerrow-traitor-of-the-underdark/?p=543181
Recommended Posts
Archived
This topic is now archived and is closed to further replies.