malernah Posted September 27, 2017 Share Posted September 27, 2017 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 More sharing options...
ThoraldGM Posted September 27, 2017 Share Posted September 27, 2017 AddItem(FusionCoreFragment, (h * 100) as Int)So you are saying if h == 0, you are getting 0 fragments? Link to comment Share on other sites More sharing options...
shavkacagarikia Posted September 27, 2017 Share Posted September 27, 2017 AkItemReference is always none if object is not persistent ref Link to comment Share on other sites More sharing options...
malernah Posted September 27, 2017 Author Share Posted September 27, 2017 @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 More sharing options...
Recommended Posts