luthienanarion Posted June 30, 2013 Share Posted June 30, 2013 You can use this method for perks rather easily if you keep reference variables pointing to them. scn ExampleScript short modindex ; Mod index for BuildRef ref Perk1 ; Reference variables that act as handles to perks that you can't reference by EditorID. ref Perk2 ref Perk3 ref Perk4 ref Perk5 short variable1 ; Some variables to do stuff with. float variable2 begin gamemode if(getgamerestarted) ; You only need to build your references when the game is started. if(ismodloaded "PerkMod1.esm") set modindex to getmodindex "PerkMod1.esm" set Perk1 to buildref modindex 12345 ; FormID of a perk, converted to decimal. set Perk2 to buildref modindex 12346 else set Perk1 to 0 set Perk2 to 0 endif if(ismodloaded "PerkMod2.esm") set modindex to getmodindex "PerkMod2.esm" set Perk3 to buildref modindex 21233 else set Perk3 to 0 endif if(ismodloaded "PerkMod3.esm") set modindex to getmodindex "PerkMod3.esm" set Perk4 to buildref modindex 34431 set Perk5 to buildref modindex 34432 else set Perk4 to 0 set Perk5 to 0 endif endif if(Perk1) ; Check if the perk has been retrieved from its mod before trying to call functions with it. if(player.hasperk Perk1) set variable1 to variable1 + 1 elseif(Perk2) if(player.hasperk Perk2) set variable1 to variable1 + 2 endif endif endif if(Perk3) if(player.hasperk Perk3) set variable1 to variable1 * 2 endif endif if(Perk4) if(player.hasperk Perk4) set variable2 to variable2 * 1.1 else set variable2 to variable2 * 0.8 endif endif if(Perk5) if(player.hasperk Perk5) set variable2 to 3 - variable1 endif endif player.setscale (variable1 / variable2) ; Do something with these variables. end ; gamemode Link to comment Share on other sites More sharing options...
jazzisparis Posted June 30, 2013 Share Posted June 30, 2013 (edited) EDIT: Ninja'd by Lutana. :) That's a nice way for the ammo but I won't be able to do perks this way.Why not? BuildRef also works with perks. In this case, instead of a form list, use a reference variable for each perk added by any optional mods. You already know which perks you are after, and by what mod they are added. This is how it could work: short iIndex ref rDMHobbler ref rHHGrunt begin GameMode if GetGameRestarted set iIndex to GetModIndex "DeadMoney.esm" if iIndex < 255 set rDMHobbler to BuildRef iIndex 70761 else set rDMHobbler to 0 endif set iIndex to GetModIndex "HonestHearts.esm" if iIndex < 255 set rHHGrunt to BuildRef iIndex 63095 else set rHHGrunt to 0 endif endif ; (...) if rDMHobbler if player.HasPerk rDMHobbler set PerkBonus to PerkBonus * 1.2 endif endif if rHHGrunt if player.HasPerk rHHGrunt if player.IsMoving set PerkBonus to PerkBonus * 0.8 else set PerkBonus to PerkBonus * 1.2 endif endif endif end Edited June 30, 2013 by jazzisparis Link to comment Share on other sites More sharing options...
luthienanarion Posted June 30, 2013 Share Posted June 30, 2013 EDIT: Ninja'd by Lutana. :smile: That's me, the script ninja! Your example makes more sense for this specific case, though. Link to comment Share on other sites More sharing options...
Cyborgking Posted July 1, 2013 Author Share Posted July 1, 2013 Sorry, I must have overlooked a part of your post about the buildref function. This will work great, thanks a lot both of you. :smile: I do have two questions:-To get the form ID of perks that have been added by plugins, do I have to load the plugin alone with its master files to get the correct form ID?-What is the use of: if iIndex < 255 When the addon can't be found iIndex gets a value of above 255, I guess? Thanks again. Link to comment Share on other sites More sharing options...
jazzisparis Posted July 1, 2013 Share Posted July 1, 2013 -To get the form ID of perks that have been added by plugins, do I have to load the plugin alone with its master files to get the correct form ID?A Form ID of an object is composed of eight digits in base 16 (hexadecimal). The first two digits indicate the file's index in the load order and are non-persistent (subject to changes, depending on where the file is placed in the load order). The other 6 digits are the actual Form ID and are persistent.Take the Grunt perk, for example: Load Honest Hearts in the GECK and find the Grunt perk. It's Form ID is XX00F677. You only need the 00F677, which equals 63095 in base 10. When the addon can't be found iIndex gets a value of above 255, I guess?Yep. If the mod was not loaded with the game, GetModIndex returns 255. Link to comment Share on other sites More sharing options...
luthienanarion Posted July 2, 2013 Share Posted July 2, 2013 When the addon can't be found iIndex gets a value of above 255, I guess?Yep. If the mod was not loaded with the game, GetModIndex returns 255. I did not know this. I wonder if it's really more efficient than calling IsModLoaded or if it's just faster to code... Efficiency doesn't really matter on code that runs once, I suppose. Thanks for the tip. Link to comment Share on other sites More sharing options...
jazzisparis Posted July 2, 2013 Share Posted July 2, 2013 I did not know this. I wonder if it's really more efficient than calling IsModLoaded or if it's just faster to code... Efficiency doesn't really matter on code that runs once, I suppose. Thanks for the tip. Doesn't matter, really. Instead of calling both IsModLoaded and GetModIndex, I only call the later. Link to comment Share on other sites More sharing options...
Cyborgking Posted July 16, 2013 Author Share Posted July 16, 2013 -To get the form ID of perks that have been added by plugins, do I have to load the plugin alone with its master files to get the correct form ID?A Form ID of an object is composed of eight digits in base 16 (hexadecimal). The first two digits indicate the file's index in the load order and are non-persistent (subject to changes, depending on where the file is placed in the load order). The other 6 digits are the actual Form ID and are persistent.Take the Grunt perk, for example: Load Honest Hearts in the GECK and find the Grunt perk. It's Form ID is XX00F677. You only need the 00F677, which equals 63095 in base 10. When the addon can't be found iIndex gets a value of above 255, I guess?Yep. If the mod was not loaded with the game, GetModIndex returns 255. Thanks, it's clear now. :) I tried this method for the gun runners arsenal DLC and it worked perfectly. Will probably release the first version in a week or two. Link to comment Share on other sites More sharing options...
Recommended Posts