NCArent Posted May 30, 2015 Share Posted May 30, 2015 tl;dr How can I make getav and setav commands in onequip blocks apply to any actor that equips the scripted weapon? I'm trying to work out a way to completely overhaul the basic combat mechanics in the game so that weapon skill level will impact critical hit chance. I've devised a (currently very poorly optimized) script that can do this using getav for guns and luck and setting up a series of conditionals that then use setav to change the critchance. Here's a small block as an example Begin Onequip player If player.getav luck ==1 && player.getav guns >=5 && player.getav guns <10 player.setav critchance 2 ElseIf player.getav luck ==1 && player.getav guns >=10 && player.getav guns <15 player.setav critchance 3 Etc. I have been able to apply this script to a weapon, recompile the scripts, and then play the game, equip the weapon, and have my critchance altered exactly as desired. However, I would like to make this effect general, so that any actor who equips the gun will have the same effect. I have a version of the script with all the "player" and "player." removed, so it reads Begin Onequip If getav luck ==1 && getav guns >=5 && getav guns <10 setav critchance 2 Etc. And the script saves and compiles just fine, which suggests that it's error free and contains only real commands (as it usually won't save if there are any errors of any kind). However, when I play the game and equip the weapon, there is no effect. So, after all that: here's my question: How can I implement getav and setav commands that will work on whatever actor happens to be equipping the weapon? I appreciate any help or feedback. Thanks! Link to comment Share on other sites More sharing options...
TheBlob2 Posted June 2, 2015 Share Posted June 2, 2015 I have also attempted to use an onequip script for NPCs, but it seems like no matter what I do it never works. I eventually just gave up and decided to make a global script instead Link to comment Share on other sites More sharing options...
Ladez Posted June 2, 2015 Share Posted June 2, 2015 First of all, I discourage the use of SetAV, since it sets a permanent override on the actor value you use it on. Use ModAV to increment or decrement the value instead, it works by adding a value to a pool and can always be undone by adding the same negative amount. Moving on, by removing the "player." part of the SetAV function calls, you're using implied reference syntax, which means that the functions will run on the scripted object itself, which is in this case the weapon. You need to get a reference to the actor that did the equipping and use that in place of the player reference. For this you can use GetContainer, like so: Begin OnEquip Set rActor to GetContainer rActor.ModAV End Link to comment Share on other sites More sharing options...
Recommended Posts