Jump to content

Ammo refill script will unequip companions armor


ThalonMook

Recommended Posts

Hi all,

 

I wrote a script that will refill the ammo of my companions.

Atm I start the script via hotkey. Later I try to do this with quest and edit the settings with MCM.

Maybe with the MCM I need also some help :-)

 

I get a array of all followers and check the type of ammo they have equiped. Then I count how much they need and put the needed amount from players inventory to companions.

 

All works fine but after the refill all companions have their default armor equiped.

 

Here's my script:

Function CompAmmo(float waitTime)
    
    int AddAmmo = 0
    Actor player = Game.GetPlayer()
    Actor[] playerFollowers = Game.GetPlayerFollowers()
    int index = 0
    while (index < playerFollowers.Length)
        Actor akActor = playerFollowers[index]
        Weapon currentweapon = akActor.GetEquippedWeapon()
        Ammo companionammo = currentweapon.GetAmmo()
        String Ausgabe = akActor.GetDisplayName()
        String Waffe = currentweapon.GetName()
        String Muni = companionammo.GetName()
        int Anzahl = akActor.GetItemCount(companionammo)
        int CountPlayer = player.GetItemCount(companionammo)
        if (Ausgabe != "Dogmeat" && Ausgabe != "Deacon")
            If (Anzahl < 200)
                AddAmmo = 200 - Anzahl
                if (AddAmmo > 0)
                If (CountPlayer > 500)
                    player.RemoveItem(companionammo, AddAmmo)
                    Utility.Wait(0.1)
                    akActor.AddItem(companionammo, AddAmmo)
                    Debug.Messagebox("Name: " + Ausgabe + " Muni: " + Muni + " Anzahl: " + Anzahl + " Waffe: " + Waffe + " Hinzugefügt: " + AddAmmo)
                Endif
                Endif
            Endif

        Endif

        
        index += 1
    endWhile

EndFunction

I hope someone can help me with this.

 

*edit*

I checked it also ingame via console. When I use additem to the companion all items are unequiped.

 

Cu

Thalon

Edited by ThalonMook
Link to comment
Share on other sites

Hi,

 

I enhanced my script by copy all the worn armor in an array and equip it after adding the ammo. This works fine.

But now I have an other problem.

Some weapons have a mod that change the ammo type is used. My script will only refill the original ammo of the weapon.

So I will check if the weapon has a mod and the change the type of ammo that will be added.

 

I have some problems with this script. The compiler will not recognise the GetAllMods() command.

 

Heres my script:

Function WeaponMod(Weapon compWeapon)

    int ind = 0
    ObjectMod[] weMods = New ObjectMod[0] 
    Actor player = Game.GetPlayer()
    Weapon currentweapon = player.GetEquippedWeapon()
    weMods = currentweapon.GetAllMods()
    while (ind < weMods.Length)
    if (weMods[ind].HasKeyword("dn_HasReceiver_Converted"))
        Debug.Messagebox("Waffe: " + currentweapon.GetName() + "<br>" + "Mod: " + weMods[ind].GetDisplayName())
    Endif
    ind += 1
    EndWhile

EndFunction

Also I don know how to use the HasKeyword command right.

 

Cu Thalon

Link to comment
Share on other sites

You must use a property in your script for the keyword

Scriptname Whatever extends Whatever
Keyword Property dn_HasReceiver_Converted Auto

Function WeaponMod(Weapon compWeapon)

    int ind = 0
    ObjectMod[] weMods = New ObjectMod[0] 
    Actor player = Game.GetPlayer()
    Weapon currentweapon = player.GetEquippedWeapon()
    weMods = currentweapon.GetAllMods()
    while (ind < weMods.Length)
    if (weMods[ind].HasKeyword(dn_HasReceiver_Converted))
        Debug.Messagebox("Waffe: " + currentweapon.GetName() + "<br>" + "Mod: " + weMods[ind].GetDisplayName())
    Endif
    ind += 1
    EndWhile

EndFunction 



Then edit the script properties and use auto-fill, or fill it manually.

Edited by DieFeM
Link to comment
Share on other sites

  • Recently Browsing   0 members

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