Using items from inventory

Post » Mon May 16, 2011 11:11 pm

if I am making a suite of armor that automatically heals radiation of the wearer using radaway if in inventory, how would I go about doing that?

this is what I have come up with so far and it's not activating...

;used within the begin GameMode blockif GetAV radiationrads >= 200	if player.GetItemCount RadAway > 0		player.EquipItem RadAway 1	endifendif

User avatar
Antony Holdsworth
 
Posts: 3387
Joined: Tue May 29, 2007 4:50 am

Post » Tue May 17, 2011 6:22 am

nevermind, found the answer looking at the prototype medic power armor

nevermind that nevermind...

I set up a Actor Effect with the same settings that Radaway has, then put this in the script for the armor

		if GetAV radiationrads > 150		if player.GetItemCount RadAway > 0		player.CastImmediateOnSelf ArmorRadAway		player.RemoveItem RadAway 1	endif


and it still doesn't appear to trigger anything.

is there an easy way to force the player to consume an item, such as radaway or a stimpak, in a script?
User avatar
xxLindsAffec
 
Posts: 3604
Joined: Sun Jan 14, 2007 10:39 pm

Post » Tue May 17, 2011 8:03 am

Where did you place the scirpt? As an object script on the armor?

By the way, you should probably change the line if GetAV radiationrads > 150 to if player.GetAV radiationrads > 150.
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Tue May 17, 2011 7:52 am

Not enough endifs (you need one Endif per If). Plus, like Zumbs said you need to call GetAV RadiationRads on the player- currently it's checking to see if the armour has more than 150 rads, which is pretty unlikely to happen.

I'd suggest sticking to the Equip if it works once you've fixed the conditions, and you'd need to add in a check to make sure the player isn't under the effects of RadAway (player.isspelltarget RadAway==0) to maintain compatibility with mods that alter radaway to be heal over time, otherwise the PC would chug their whole supply of radaway before it had time to kick in properly.

You can also check "Is not zero" using statements like if(GetItemCount RadAway), rather than if(GetItemCount RadAway != 0), as they're slightly faster.

For an example:
if(player.getAV RadiationRads > 150)   if (player.isSpellTarget RadAway)      ;Do nothing until it's finished applying   elseif(player.GetItemCount RadAway)      player.EquipItem RadAway 1   endifendif

User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Tue May 17, 2011 1:08 am

Not enough endifs (you need one Endif per If). Plus, like Zumbs said you need to call GetAV RadiationRads on the player- currently it's checking to see if the armour has more than 150 rads, which is pretty unlikely to happen.

I'd suggest sticking to the Equip if it works once you've fixed the conditions, and you'd need to add in a check to make sure the player isn't under the effects of RadAway (player.isspelltarget RadAway==0) to maintain compatibility with mods that alter radaway to be heal over time, otherwise the PC would chug their whole supply of radaway before it had time to kick in properly.

You can also check "Is not zero" using statements like if(GetItemCount RadAway), rather than if(GetItemCount RadAway != 0), as they're slightly faster.

For an example:
if(player.getAV RadiationRads > 150)   if (player.isSpellTarget RadAway)      ;Do nothing until it's finished applying   elseif(player.GetItemCount RadAway)      player.EquipItem RadAway 1   endifendif



thanks a TON! that works like a charm, but applying the same method to a stimpak doesn't seem to work out. this is what I worked out from what you posted, but it doesn't seem to trigger

	if player.GetHealthPercentage < 0.50		if  player.isSpellTarget Stimpak      			;Do nothing until it's finished applying		elseif player.GetItemCount Stimpak			player.EquipItem Stimpak		endif	endif


I tested a message in the health check part and it's fine, so it's just an issue with the application of the stimpak. I read somewhere that there's a built in check if you are in the menu (pipboy) and have to exit before it's applied. Any idea on a work around?

I went with GetHealthPercentage instead of GetAV.Health because that seems to be an absolute value, which would varry substantially from player to player, as well as through the levels.

if I remove the "if player.isSpellTarget Stimpak", it does spam the application of stimpaks, but never actually adds any health from it

I also notived the "1" after equipping the aid of choice is not needed, being that that would set it as unequippable.

EDIT: ok, my bad... in a previous attempt on the script I appearantly burned through my entire stock of stimpaks, so spent 1/2 the day trying to find out what was wrong, only to find out I was out of stimpaks -_-.........
the above script segment works fine :facepalm:
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am


Return to Fallout 3