Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Need 2 Add Perk 2 Actor Via Script


SkyrimModHunter
 Share

Recommended Posts

The "Perk to Apply" magic effect drop down in the creation kit only works if the target is the player. 

 

I'm trying to give NPC's a temporarily spell de-bluff via a perk.  I could manually add the perk to every blasted actor in the game, by opening up each actor's associated ID and going to the "SPELLLIST" tab and then adding the perk to the perk box.  The perk could have a "HasKeyword" condition to make the perk unless, until my desired spell temporarily attaches the needed keyword, via a magic effect.

 

Nevertheless, there are thousands of actors in the game and mods add even more actors for which I cannot manually edit their spell list's perk box.  Therefore, I either need to scrap the idea or come up with a way to alter an actor's SPELLLIST perk box, via a script. 

 

Does anyone know how to do such a feat?

 

This is the most useful info I found using Google and it just confirmed that I cannot use aktarget.addperk(myperkhere) to dynamically add a perk via a script.  :sad:

Link to comment
Share on other sites

You would add the perk by having the pc use a spell? Did you add the perk to your magic effect anyway? How do you know that it applies only to the player?

1.) You would add the perk by having the pc use a spell?  I tried that method but the "perk to apply" doesn't work on NPC's.  The CK wiki confirms this problem and I also just managed to get a very knowledgeable spell maker also confirm that no method exists.  Based on his confirmation and my prior testing, I believe he's right too.

2.) Did you add the perk to your magic effect anyway?  In this case, I was using hazard to apply the magic effect, which works because the shader I have selected is showing up.  I then used the "perk to apply" option to attempt to give the NPC's that "debuff" perk.

3.) How do you know that it applies only to the player?  It's not that perk's apply only to the player, but rather that the game engine seems incapable of giving an NPC a perk via a script using "akTarget.addperk(akPerk)" or via a magic effect using the "perk to apply option."

 

Therefore, I guess my only option is to try to mimic the results of the perk, via a script.  I'm just new to papyrus, so this probably isn't something I can figure out in any short period of time.  Here's what I'm looking to do if anyone wants to help.

 

Racial Power: "Globe of Darkness" - When cast a globe of darkness is summoned at the targeted location.  Enemies inside the globe miss with X% of their attacks and have trouble finding their enemy.

 

To accomplish this sort of theme, I was going to use the following "Entry Point" types,

 

1.) Mod Detection Light: Set Value = 0

 

2.) Mod Detection Movement: Set Value = 0

 

3.) Mod Attack Power: Set Value = 0  AND add a "Perk Owner" condition "GetRandomPercent" less than or equal to X, which would be ran on the "Subject".  X represents whatever percent I want those inside to "miss" with their attacks.  Technically, the enemies would "hit" the player, but X% of the time, their damage would be reduced to zero, which I consider the same thing as dodging the attack.

 

I need the spell to not only work if cast by the player, but also if cast by and against other NPC's.  If anyone has any ideas on how to spice up the spell, please let me know.  Right now I've got the visuals (big orbiting dark ball) working successfully with a cooldown timer, and the magic effect triggers against those in the desire area of effect, but I need that magic effect to do something, so that it feels like a globe of darkness.

Edited by SkyrimModHunter
Link to comment
Share on other sites

So I've stopped trying to give a perk to an NPC through a magic effect.  Instead, I've attached the following script to my magic hazard spell.  This script will successfully "blind" (aka set incoming melee damage to zero), X% of the time.  Additionally, this racial power is going to unlock a "silence" effect when the caster's level is 30 and above.  In order to achieve such a feat, I was planning to capture the enemy's magicka amount and magicka regen rate, temporarily disable both, and then re-enable them after the effect wears off. 

 

PROBLEM: My problem is that variable's captured within one event, seem to get erased as soon as the event ends (even within the same script!).  I'd like to know how to get Papyrus to share those variables between the two events that I've got in the below script.  Can anyone help?  In particular, I want to drop those 9999 values listed below, and replace them with the previously captured float values of (fx1) and (fx2).  If that can be done, then I'd also be able to share the CasterLevel integer.  I guess global variables could be used, but that doesn't seem very intuitive.

Scriptname yyyRacialDrowGlobeDebluffs extends activemagiceffect

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...
        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)
    EndIf

endEvent

Event 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) ; 9999 just input for testing; need global variable? and can then use (fx1) in place of the value
        akTarget.RestoreAV("MagickaRate", 9999) ; 9999 just input for testing; need global variable? and can then use (fx2) in place of the value
        EndIf

endEvent

Int property MissChance auto

EDIT: nevermind... someone helped me figure this out.  YOu just need to declare the variables in the "main body" of the script, rather than within the events.  Then the script seems to retain them until it's finished.

Edited by SkyrimModHunter
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...