Jump to content

[Help] Problems with formlists and containers


Recommended Posts

Dear Forum,

 

I am having problems with a personal mod project of mine. The idea of the mod is that my power armor loadout would be automatically added to my inventory upon entering my power amour. What you would do is add the items you would want in your loadout into the BOS player box which would trigger an onItemAdded event and would add the items that were actually added to a formlist, then when you get into your power armour and equip one of the 5 power armour helmets, the items from the formlist would be added to your inventory and then removed again once you exit the armour/take off the helmet

 

Here is my code:

Scriptname PA_Loadout extends ObjectReference

FormList Property ORC_PA_loadout auto
Ammo Property AmmoFusionCore auto
Keyword Property ObjectTypeWeapon auto
Keyword Property ObjectTypeAmmo	Auto

Event OnActivate(ObjectReference akActionRef)
    AddInventoryEventFilter(ObjectTypeAmmo)
    AddInventoryEventFilter(ObjectTypeWeapon)
    AddInventoryEventFilter(AmmoFusionCore)
endevent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

    While aiItemCount > 0
        ORC_PA_loadout.AddForm(akBaseItem)
        aiItemCount -= 1
    EndWhile

EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)

    While aiItemCount > 0
        ORC_PA_loadout.RemoveAddedForm(akBaseItem)
        aiItemCount -= 1
    EndWhile

EndEvent  

This is attached to the BOS player box

Scriptname PA_Loadout_switch2 extends objectreference
FormList Property ORC_PA_loadout auto

Event OnEquipped(Actor akActor)
    if (akActor == game.getplayer())
        int i = 0
        form item
        while(i < ORC_PA_loadout.GetSize())
            Item = ORC_PA_loadout.GetAt(i)
            Game.GetPlayer().AddItem(Item)
            i += 1
        endwhile
    endif
endevent

Event OnUnequipped(Actor akActor)
    if (akActor == game.getplayer())
        int k = 0
        form itemR
        while(k < ORC_PA_loadout.GetSize())
            ItemR = ORC_PA_loadout.GetAt(k)
            Game.GetPlayer().RemoveItem(ItemR)
            k += 1
        endwhile
    endif
endevent  

This is attached to the 5 power amour helmets

 

I have done some rudimentary debugging, as I do not have access to the full debugging suite as I am testing this on my Xbox. As far as I can tell, the OnItemAdded event is triggering, I am not sure if it is actually adding anything to the formlist though. Also, Even if I do add something to the formlist manually through the CK, getting into my power armour still achieves no result.

 

I am hoping you can help me with this issue.

 

/FactualOrc

 

(EDIT: I think I fixed the white bars on the code bits)

Edited by FactualOrc
Link to comment
Share on other sites

  • Recently Browsing   0 members

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