Adding perks via armor/weapon?

Post » Wed Aug 26, 2009 12:10 am

Okay, so here's what I want to do, need any tips/confirmation on how to go about it. Trying to make a weapon I'm creating give an issuance of a perk based on current situation. For example, when you lose X% of health, tier one of the perk(s) activate. Then when you get lower in health, tier two kicks in and turns off tier one. Setting this as perks because I don't want the bonus it grants to be static, and will scale across three perk tiers boosting the overall bonus as health drops.

I'm guessing I'll need to do this through a script, but I don't know how to add a perk silently (no pop up saying you got it like with companion perks), and I want to make sure that if the player unequips the item even if the perk would still be in effect it's removed properly.

[edit] Okay, looked at some stuff, at least realized that it'd be easier to do it as one perk with 3 ranks, but again I'd need to know how to temp assign the perk with weapon equipped and requirements reached, and then how to boost/subtract ranks when health is lost/gained or weapon removed.
User avatar
Holli Dillon
 
Posts: 3397
Joined: Wed Jun 21, 2006 4:54 am

Post » Tue Aug 25, 2009 11:15 pm

Okay, so here's what I want to do, need any tips/confirmation on how to go about it. Trying to make a weapon I'm creating give an issuance of a perk based on current situation. For example, when you lose X% of health, tier one of the perk(s) activate. Then when you get lower in health, tier two kicks in and turns off tier one. Setting this as perks because I don't want the bonus it grants to be static, and will scale across three perk tiers boosting the overall bonus as health drops.

I'm guessing I'll need to do this through a script, but I don't know how to add a perk silently (no pop up saying you got it like with companion perks), and I want to make sure that if the player unequips the item even if the perk would still be in effect it's removed properly.

[edit] Okay, looked at some stuff, at least realized that it'd be easier to do it as one perk with 3 ranks, but again I'd need to know how to temp assign the perk with weapon equipped and requirements reached, and then how to boost/subtract ranks when health is lost/gained or weapon removed.


Give the armor/weapons an OnEquip and OnUnEquip script where you add/remove the perks. Then add the perks in such a way that Perk #1 has X effect, Perks #2 has Y effect so you have a net X+Y, and #3 has Z with a net X+Y+Z. Look at the Nerd Rage perk if you need help with that.
User avatar
Lucky Girl
 
Posts: 3486
Joined: Wed Jun 06, 2007 4:14 pm

Post » Wed Aug 26, 2009 12:55 am

Something like this, change where appropriate:


scn scriptnameBegin OnEquip Playerplayer.addperk PerkIDEndBegin OnUnequipplayer.removeperk PerkIDEnd



Or you could create a quest that checks if health is low enough and certain armor is equipped it adds the perk.

use something like Player.getEquipped MS06LincolnsHat which check if that item is equipped. Dont know what function you'll need to use for checking health.
User avatar
Add Meeh
 
Posts: 3326
Joined: Sat Jan 06, 2007 8:09 am

Post » Wed Aug 26, 2009 4:37 am

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.
ref contbegin onequip   set cont to getcontainer   cont.addperk MyPerkendbegin onunequip   set cont to getcontainer   cont.addperk MyPerkendbegin gamemode   if(cont)   else      set cont to getcontainer      if(cont)         if(cont.getEquipped MyClothing)            cont.addperk MyPerk         endif      endif   endifendbegin ondrop   set cont to 0end


To change ranks when the player's health changes, you can potentially just use the conditions on perks- each perk entry can have conditions set for it to work. So you can have all the effects in the one perk, and simply set your 1st-stage entry to require GetHealthPercent <= 75 AND > 50, the 2nd-stage one to be < 50 AND >= 25, and so on.
User avatar
Juliet
 
Posts: 3440
Joined: Fri Jun 23, 2006 12:49 pm

Post » Wed Aug 26, 2009 1:32 am

Thanks for the tip on that Talkie, since I was gonna have an NPC rampaging around with the item before the player gets a hold of it. Though I don't seem to be able to use the gain conditions within the perk, as I'm not allowed to set seperate conditions per rank within the one perk, nor set up a proper X AND Y scenario for checks. The conditions for getting it seem purely baseline, so will have to work in health detection within the script.

[edit] Starting to not matter, as the NV Geck refuses to save scripts so I can't even put it in and test it.
User avatar
Andrew
 
Posts: 3521
Joined: Tue May 08, 2007 1:44 am

Post » Wed Aug 26, 2009 7:47 am

It's not that it won't save, it's that it doesn't display errors. There's a problem in your script and it won't compile so won't save. There's a fix on the GECK forum somewhere.
User avatar
leigh stewart
 
Posts: 3415
Joined: Mon Oct 23, 2006 8:59 am

Post » Tue Aug 25, 2009 9:51 pm

=| That's really dumb. Anyway, found the issue in it and fixed it. Now I just need to figure out how to make it assign the perk ranks as health is lost. I'd need to run it in the gamemode block, and scrap the onequip block I believe, still trying to work the details of that out. Unless there is a better method I'm not thinking of. Wanted to do it a conditions in the perk itself, but that seems lost because of what I mentioned.

So having the problem I always do, never understood how Gamebryo allows equations in scripts. (To my understanding it barely does) I want it do basically do the check in GameMode block like this:
  if(cont.getEquipped WeapNVEqualizer && cont.getAV healthpercent <= 76)    cont.addperk AdrenalineRush  endif

Nesting the second statement in parenthesis didn't seem to help, so I'm stuck again.
User avatar
Stryke Force
 
Posts: 3393
Joined: Fri Oct 05, 2007 6:20 am

Post » Wed Aug 26, 2009 4:33 am

The GECK is pretty reasonable about conditions, the only problem with them is line length. Your problem is that healthpercent isn't an actor value. Health is, and http://geck.gamesas.com/index.php/GetHealthPercentage is a function.
Only http://geck.gamesas.com/index.php/Actor_value can be used with GetActorValue.
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm

Post » Wed Aug 26, 2009 2:22 am

This is what I have so far
scn EqualizerPerkref contbegin onunequip   set cont to getcontainer   cont.removeperk AdrenalineRushendbegin gamemode   if(cont)   else      set cont to getcontainer      if(cont)         if(cont.getEquipped WeapNVEqualizer && cont.GetHealthPercentage < 76)            cont.addperk AdrenalineRush         endif      endif   endifendbegin ondrop   player.removeperk AdrenalineRushend

But now regardless of health it will never successfully pass the check. Using grenades to self inflict damage, and putting myself at less than 50% and will still never see the effects or Perk entry come up. Any ideas? And then I still gotta find a way to remove the perk if the player heals while still wearing the Equalizer, but one thing at a time.
User avatar
Casey
 
Posts: 3376
Joined: Mon Nov 12, 2007 8:38 am

Post » Wed Aug 26, 2009 7:27 am

...because as soon as Cont has a value (i.e. the item realises it is in a container of some kind), it stops running that section of the scripts? The bit you modified is the bit that is designed to handle NPCs equipping the weapon. It's just a replacement for the onEquip block.

Here's a version that keeps track of if it's in a container, if it's equipped by them, and switches between modes of "Perk, no perk" that you can easily expand.
short activeshort moderef contBegin onEquipset Cont to GetContainerset Active to 1EndBegin  onUnequipset Active to 0set Mode to 0Cont.RemovePerk MyPerk1EndBegin onDropset Cont to 0EndBegin Gamemodeif(Cont)   if(Active)            if(Mode == 1)         if(Cont.GetHealthPercentage > 50)            set Mode to 0            Cont.RemovePerk MyPerk1         endif      elseif(Mode == 0)         if(Cont.GetHealthPercentage < 50)            set Mode to 1            Cont.AddPerk MyPerk1         endif      endif   endifelse   set Cont to GetContainer   if (Cont)      set Active to Cont.GetEquipped MyWeapon   endifendifend

User avatar
Sheeva
 
Posts: 3353
Joined: Sat Nov 11, 2006 2:46 am

Post » Wed Aug 26, 2009 10:55 am

Oh durp, I feel stupid.

That looks like it'll do most of what I need, now to just fine tune it. I'm curious, does removeperk wholesale delete the perk like I assume it does? Will make lowering the ranks by gaining health back complicated. Thinking I may have to break it up into 3 perks again, time to experiment.
User avatar
Shaylee Shaw
 
Posts: 3457
Joined: Wed Feb 21, 2007 8:55 pm

Post » Wed Aug 26, 2009 12:17 pm

Okay, here's what I changed. Before I changed and just used the 50% value, it would apply when I dipped below the health, but wouldn't remove it when I went over that percent. I nested additional if statements for lower percentages of health to remove the previous rank and add the new one, and made sure OnUnequip removed all 3 tiers. (perk is now 3 perks with numerals breaking them up)
short activeshort moderef contBegin onEquipset Cont to GetContainerset Active to 1EndBegin  onUnequipset Active to 0set Mode to 0Cont.RemovePerk AdrenalineRushCont.RemovePerk AdrenalineRush2Cont.RemovePerk AdrenalineRush3EndBegin ondropset Cont to 0EndBegin Gamemodeif(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   endifelse   set Cont to GetContainer   if (Cont)      set Active to Cont.GetEquipped WeapNVEqualizer   endifendifend

Now upon testing it's going straight to the 3rd rank at any health when I equip the weapon.
User avatar
Jamie Moysey
 
Posts: 3452
Joined: Sun May 13, 2007 6:31 am

Post » Wed Aug 26, 2009 2:41 am

Thread done. Fixed it all up, working perfect. Apparently GetHealthPercentage works only as a decimal and not actual percentage feed out, so it was always resolve as true. Thanks for the help Talkie, on to the next TF2 themed weapon.
User avatar
Julie Serebrekoff
 
Posts: 3359
Joined: Sun Dec 24, 2006 4:41 am


Return to Fallout: New Vegas