Jump to content

FOSE GetWeaponAmmo Use


vforvic

Recommended Posts

New to scripting with FOSE and can't get this script to work. This is a simple test script for a larger script. I am trying to get the ammo type of the weapon the Player is carrying when the object is activated. I thought I could just use GetEquipedObject 5 to get the Weapon and then use GetWeaponAmmo on the returned ref to get the ammotype, but FinishMessage never shows so I can only imagine that it is not completing because it is either not getting the ammotype or I am using the wrong code for MicrofusionCell 00004485 or who knows why.

 

Scriptname WeaponTest
ref curRef
int type
int ammotype
int Active

begin Onactivate
    if active == 0
         set Active to 1
    Endif
End

Begin Gamemode
    if Active == 1
         Set curRef to player.GetEquippedObject  5
         Set ammotype to curRef.GetWeaponAmmo
              if ammotype == 00004485	;MicroFusionCell
                   ShowMessage FinishMessage
                   Set Active to 0
              Endif
    Endif
End

Link to comment
Share on other sites

Ammotype needs to be a REF variable since GetWeaponAmmo is returning a form.

You should be able to just do

set Ammotype to player.GetWeaponAmmo

You may run into problems with the script compiler here and there if you have a habit of using form IDs instead of just using the EditorID of objects.

When the script is compiled,

if ammotype == AmmoMicroFusionCell

AmmoMicroFusionCell is converted to 00004485 for you.

 

 

Edit:

If you want to use GetWeaponAmmo on the weapon itself, then you call the function in base form format:

 

set Ammotype to GetWeaponAmmo curRef

Link to comment
Share on other sites

  • Recently Browsing   0 members

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