Jump to content

inconsistent GetItemHealthPercent() for Fusion Cores


malernah

Recommended Posts

I have a container with a custom script attached that fires the following event:

Scriptname FusionCoreCrateScript extends ObjectReference
{converts partial fusion cores into fusion core fragments and back}

Ammo Property AmmoFusionCore Auto
MiscObject Property FusionCoreFragment Auto

Event OnInit()
	AddInventoryEventFilter(AmmoFusionCore)
EndEvent

Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	Debug.TraceAndBox("detected item: " + akItemReference)
	Float h = akItemReference.GetItemHealthPercent()
	If h == -1.00
		Debug.TraceAndBox("brand new core")
	Else
		; 99/100 = 1.00, 98/100 = 0.99, 71/100 = 0.72
		Debug.TraceAndBox("health: " + h)
		Debug.TraceAndBox("health * 100: " + h * 100)
		Debug.TraceAndBox("health as Int: " + (h * 100) as Int)
		Debug.TraceAndBox("should add " + (h * 100) as Int + " fragments")
		AddItem(FusionCoreFragment, (h * 100) as Int)
		RemoveItem(akItemReference)
	EndIf
	RemoveInventoryEventFilter(AmmoFusionCore)
	While GetItemCount(FusionCoreFragment) > 100
		AddItem(AmmoFusionCore)
		RemoveItem(FusionCoreFragment, 100)
	EndWhile
	AddInventoryEventFilter(AmmoFusionCore)
EndEvent

the script behaves inconsistently. On some cores, it reads its health no problems and adds the Fragment items to the container. On other fusion cores, it reads it as no health at all, and just puts the original fusion core into the container. I can't figure out any pattern to the different types of cores.

Link to comment
Share on other sites

@shakacagarikia is correct, that is indeed what I am seeing. Some of the fusion cores show as None when added, and therefore read no attributes at all when I try to get its' health percentage, and some fusion cores read as [defaultdisablehavoconload <Item # in container (id here)>]

 

I guess my real question is how do I consistently get an ID for the fusion core?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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