Jump to content

Question about adding Perks to armor


trashgarbage666

Recommended Posts

Hey there!

 

Right now, I have a piece of armor that gives the player a perk whenever they equip it, and removes it whenever they unequip it -- which is a good start! But I'd like the perk to be given to NPCs that have the armor equipped as well. Here's what my script looks like at the moment:

scn MyScript

Begin OnEquip Player
    Player.AddPerk MyPerk
end

Begin OnUnequip Player
    Player.RemovePerk MyPerk
end

As you can see, the code doesn't give anything to NPCs at all. Google shows that plenty of people have asked similar questions in the past, but their solutions are usually a little too specific to their project to be helpful to me. One thread in particular caught my eye, though.

 

http://www.gamesas.com/adding-perks-via-armor-weapon-t12161.html

 

"Although that will mean only the player can get the perk. If you want to have it add the perk to NPCs too, you'd need to use something like the script below to work around the fact that OnEquip blocks don't fire for clothing that NPCs spawn wearing." -Juliet

 

Juliet then goes on to give example code that I don't really understand, but it lets me know that what I'm trying to do isn't impossible! Hopefully someone here will know what to do. Any help at all would be extremely appreciated!!

Edited by punchbattle
Link to comment
Share on other sites

No wonder you are having trouble reading that code. It's all run together because they didn't put it in < code blocks > and without indenting. See if this makes more sense (no changes except to split lines and indent):

scn SomeScriptNameGoesHere

short active
short mode
ref cont

Begin onEquip
    set Cont to GetContainer
    set Active to 1
End

Begin onUnequip
    set Active to 0
    set Mode to 0
    Cont.RemovePerk AdrenalineRush
    Cont.RemovePerk AdrenalineRush2
    Cont.RemovePerk AdrenalineRush3
End

Begin ondrop
    set Cont to 0
End

Begin Gamemode
if(Cont)
    if(Active)
        if(Mode == 1)
            if(Cont.GetHealthPercentage > 75)
                set Mode to 0
                Cont.RemovePerk AdrenalineRush
                Cont.RemovePerk AdrenalineRush2
                Cont.RemovePerk AdrenalineRush3
            endif
        elseif(Mode == 0)
            if(Cont.GetHealthPercentage <= 75)
                set Mode to 1
                Cont.AddPerk AdrenalineRush
                if(Cont.GetHealthPercentage <= 50)
                    Cont.AddPerk AdrenalineRush2
                    Cont.RemovePerk AdrenalineRush
                endif
                if(Cont.GetHealthPercentage <= 25)
                    Cont.AddPerk AdrenalineRush3
                    Cont.RemovePerk AdrenalineRush2
                endif
            endif
        endif
    endif
else
    set Cont to GetContainer
    if (Cont)
        set Active to Cont.GetEquipped WeapNVEqualizer
    endif
endif
end

As I interpret it, ref variable "Cont" is set to the reference to the NPC (or more probably it's armor) in question as a "container" rather than an Actor.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

After lots of digging around, I found out that it actually is impossible to give perks to NPCs.

Edited by punchbattle
Link to comment
Share on other sites

It's pretty well known that you can't give an NPC perks, at least not in the same way that you give them to the player. There are numerous threads about it here on the Nexus.

 

That said, according to J.E. Sawyer, there is an undocumented feature in FNV that allows you to give an NPC perks. I found this a while back in another thread here on the Nexus:

 


 

 

There is an undocumented feature in F:NV that some modders may find useful. It is the ability to give perks to companions. Or, more accurately, it is the ability to add perks to a special list on the player that will have an effect on any active followers. Here's how it works:


player.addperk XXXXXXXXXXXXX 1

The "1" means "put this on the special list for companions". Companions will still not store/keep perks, but we give the player a second list of non-displayed perks that only apply to companions. If you want the effect to apply to all companions, you do not need to conditionalize the perk owner conditions for the perk's entry points. If you want the perk to be special for the companion, check the NPC's ID or ref in the perk owner conditions.

I recommend making special companion versions of perks even if you want to use existing effects. E.g. if you want to give Raul the equivalent of Shotgun Surgeon for some reason, make a special "RaulShotgunSurgeonPerk" that's filtered just to him, and add it to the player with player.addperk RaulShotgunSurgeonPerk 1 the first time Raul is hired. Even if Raul leaves the party, you shouldn't have to worry about the perk hanging out on the player as long as the perk owner conditions are filtered properly.

N.B.: The effects will ONLY work while a companion is in the party. So in the above scenario, Raul would no longer have the benefits of RaulShotgunSurgeon if he left the party.

 

 

 

 

I haven't personally tried it to determine if it actually works as stated or not.

Link to comment
Share on other sites

What I was trying to do was give helmets a hidden perk that protected the wearer from headshots -- something like a one-time DT bonus against the incoming damage. Now that I know perks can't be applied to NPCs, I'm trying to add an object effect script to ammo, weapons, or whatever works. I keep hitting dead ends though, because GetHitLocation effects only take place after damage has already been applied.

 

Anyone have any ideas? I'm desperate to get this to work.

Edited by punchbattle
Link to comment
Share on other sites

It's pretty well known that you can't give an NPC perks, at least not in the same way that you give them to the player. There are numerous threads about it here on the Nexus.

 

That said, according to J.E. Sawyer, there is an undocumented feature in FNV that allows you to give an NPC perks. I found this a while back in another thread here on the Nexus: ...

That's seems pretty definitive. Added to the wiki "Getting started creating mods using GECK" article as "TIP: Perks for Companions" under the "Custom NPCs" section.

 

-Dubious-

Link to comment
Share on other sites

That's seems pretty definitive. Added to the wiki "Getting started creating mods using GECK" article as "TIP: Perks for Companions" under the "Custom NPCs" section.

 

-Dubious-

 

Did you read the section you're referring to? It's the very same quote from J. Sawyer Madmongo used to explain how normal NPCs can't be given perks. The distinction being that all companions are NPCs, but not all NPCs are companions.

Edited by punchbattle
Link to comment
Share on other sites

Sorry, I'm not picking up on your point. I quoted madmongo's quote of J. E. Sawyer as he didn't provide a link to the original post. My original preamble sentence used the term "companions", not "NPCs" as I do recognize the distinction. The only use of the word "NPC" is Sawyer's. I welcome any suggestions to make it clearer that don't alter his actual words.

 

Belatedly: Or are you objecting to placing that tip under the "Custom NPCs" section? That choice was because that article doesn't have a separate section for "Companions" for the same reason you pointed out: "all companions are NPCs, but not all NPCs are companions." However, taking that into consideration I have added some emphasis and that distinction.

 

-Dubious-

Link to comment
Share on other sites

Ya it's a shame the "Entry Point" feature of perk objects is not available via "Actor Effect"

 

But you can do some reverse entry point check to get the same effect ... if this is only for effecting who the player is shooting at.

 

Which would be done by giving the player a

"Perk / Entry Point / Calculate Weapon dmg / multiply value / .2 " for example.

 

Then on the condition field select "Target" tab and use:

 

"GetEquipped MyHelmet == 1 AND"

"GetHitLocation == 1 "

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...