Jump to content

Counting companion items w/getitemcount()


Greslin

Recommended Posts

Loaded last save, removed mod, resaved. Mod completely cleared out. Reload with latest version of mod.

 

Piper shot. Correct number reported.

 

It was the game save. My best guess is that while the script itself correctly updated, the properties in the game save didn't, and they were then left undefined. Then, as vkz89q suggested, they were populated by junk data. For some reason, changing the properties in the ESP didn't update in the save, and I was dealing with a cached bad property definition.

 

Well okay then. That was interesting. Thanks again, guys. Will report if anything new happens.

Link to comment
Share on other sites

So YAY TEAM!

 

Behold: an NPC-attached script that enables companions to Stim themselves out of bleedout. If they have stims in their inventory, on bleedout they use one, and get 12 seconds of bleedout recovery before going back to no-recover. If they don't have stims, they just lay there as usual until you can fix them up.

Scriptname CA_AutoStimpak extends Actor

Potion Property Stimpak Auto Const
Int curStims

Event OnEnterBleedout()
	StimpakCheck()
endEvent

function StimpakCheck()

	Actor tempActor = Self as Actor
	curStims = tempActor.getItemCount(Stimpak)
		
	if (curStims > 0)
		if (tempActor != None)
			tempActor.removeItem(Stimpak, 1)
			tempActor.SetNoBleedoutRecovery(False)
			Utility.Wait(12)
			tempActor.SetNoBleedoutRecovery(True)
		EndIf
	endif
endFunction

Still planning to do a bunch more with this, but I'm really happy right now with how well this works. Thanks again, guys!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...