Adding a Perk to a Weapon?

Post » Thu May 26, 2011 11:22 pm

So I have a Problem: I tried to add a Perk to a weapon with a Script, unfortunately it didn't work as it did nothing when I equipped it.
So would anyone help me and tell me how it's done correctly?
Maybe even with an example script so I can see what I've done wrong and learn from my mistakes?
User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am

Post » Thu May 26, 2011 8:32 pm

scn MyWeaponScriptref contbegin onequipset cont to getcontainerif(cont == player)   player.addperk MyPerkendifendbegin onunequipif(cont == player)   player.removeperk MyPerkendifend

The getcontainer check isn't necessary, I think. You could just use "begin onequip player", but this structure makes it easier to expand to other things.

For example, the script below would make a weapon that both added a perk, and prevented you from taking fall damage whilst equipped, and also worked on NPCs (the getcontainer block in gamemode is necessary for that, as NPCs don't run onequip blocks for gear they spawn equipped with). You can expand something of this format with more or less anything in the gamemode block.

scn MyWeaponScriptref contshort activebegin onequipset cont to getcontainerif(cont == player)   player.addperk MyPerkendifset active to 1endbegin gamemodeif(cont)   if(active)      cont.ResetFallDamageTimer   endifelse   set cont to getcontainer   if(cont)      set active to cont.getequipped MyWeapon   endifendifendbegin onunequipif(cont == player)   player.removeperk MyPerkendifset active to 0end

User avatar
Zoe Ratcliffe
 
Posts: 3370
Joined: Mon Feb 19, 2007 12:45 am

Post » Fri May 27, 2011 5:56 am

scn MyWeaponScriptref contbegin onequipset cont to getcontainerif(cont == player)   player.addperk MyPerkendifendbegin onunequipif(cont == player)   player.removeperk MyPerkendifend



God I feel stupid after reading that example xD which made me notice that the only thing that was wrong with my script is that I forgot to add the "player." in front of addperk and removeperk xD
still thank you for making me notice :P
User avatar
Gen Daley
 
Posts: 3315
Joined: Sat Jul 08, 2006 3:36 pm


Return to Fallout: New Vegas