Jump to content

Script Assistance - Get Ammo List For Active Weapon


ThatOtherUser

Recommended Posts

 

Wasn't aware of that Fist weapon problem, though. I'll have to look into that one.

 

There's no problem, GetEquippedObject will never return fists. If no weapon is equipped it will return 0.

 

Although, knowing that there's a way to isolate certain entries in the ammo list is very nice. Will the vanilla ammo type (say, regular Missiles for a Missile Launcher) always appear at the top of the given ammo list? Or can mods get in the way of that?

 

The vanilla ammo lists all have the standard ammo type at the top of the list. I don't know if this is to be relied upon with ammunition mods, but I think it's safe to assume.

 

 

Much obliged, Ladez. I'll stick with the method of adding ammo I've got now, since it doesn't really sacrifice much in the way of processing speed, but at least I know that GetEquippedObject won't muck anything up.

Link to comment
Share on other sites

 

You CAN, however, use

GetEquippedObject != 0
as a condition to test that the guard has a weapon.
I never said otherwise. I'm not sure what you're trying to argue here, he's already testing whether the guard has a weapon in that exact way.
I'm not so much arguing as much as saying "This is true, but while we're on the subject, there's this related trick that's pretty useful to know." I could've been clearer, I can see that now.

With that said, the OP's original code snippet uses "if GetEquippedObject 5 == 1", which wouldn't have worked since GetEquippedObject doesn't return a boolean.

 

Wasn't aware of that Fist weapon problem, though. I'll have to look into that one.

There's no problem, GetEquippedObject will never return fists. If no weapon is equipped it will return 0.
Again, I could've been clearer; What I was trying to say was that I wasn't certain whether or not this was a problem. Apparently, it isn't. Good to know.
Link to comment
Share on other sites

With that said, the OP's original code snippet uses "if GetEquippedObject 5 == 1", which wouldn't have worked since GetEquippedObject doesn't return a boolean.

Oh, dang, you're right about that, that slipped past me. It wasn't clear from your previous post what you meant, thanks for clearing it up. :)

Link to comment
Share on other sites

 

With that said, the OP's original code snippet uses "if GetEquippedObject 5 == 1", which wouldn't have worked since GetEquippedObject doesn't return a boolean.

Oh, dang, you're right about that, that slipped past me. It wasn't clear from your previous post what you meant, thanks for clearing it up. :smile:

 

 

Yeah, thanks to you both! Still got a lot to learn about scripting, so I'm glad to see there's two informed adepts at the art on this forum.

Edited by ThatOtherUser
Link to comment
Share on other sites

Take note that a weapon's ammo can be a form list, or it can be a single AMMO form. Always check the type of the object returned by GetWeaponAmmo.

Oh, good catch, I should've got that one.

 

The way to do that is with the GetIsObjectType function;

if rAmmo.GetIsObjectType 85
	; rAmmo is a Form List, so go from there.
elseif rAmmo.GetIsObjectType 41
	; rAmmo is a single Ammo form, not a list.
endif
http://geck.bethsoft.com/index.php?title=Form_Type_IDs has the full list of all the IDs to use; the page on GetIsObjectType is a little confusing though. It says you can use the full name of the type as it appears in GECK but then what if you want to find a Talking Activator? Presumably it MEANS you can use the name as it appears on the Form Type IDs article, but that's not what it says. I'm going to carry on using the numeric values just to be on the safe side.
Link to comment
Share on other sites

http://geck.bethsoft.com/index.php?title=Form_Type_IDs has the full list of all the IDs to use; the page on GetIsObjectType is a little confusing though. It says you can use the full name of the type as it appears in GECK but then what if you want to find a Talking Activator? Presumably it MEANS you can use the name as it appears on the Form Type IDs article, but that's not what it says. I'm going to carry on using the numeric values just to be on the safe side.

 

Seems to me like you must use the full name of the type and that you cant use the numerical IDs as you did in your example. It also says that these names appear in the ALL section of the object window, but what appears there is the 4 character string that is to be used with GetIsFormType. The 4 character name for a talking activator is TACT, for example.

 

But I usually use GetType from NVSE instead. That seems to be the only one of them with which you can use the numerical type IDs.

Link to comment
Share on other sites

okay, so apparently GetIsFormType is a better choice for this. It seems to perform the same purpose, but it's a lot less ambiguous - as you say, you use the four-character string, not a numeric value nor full words which fall apart when there's spaces involved - no confusion. Personally, while sometimes I've got to use NVSE because the stock engine can't handle what I want to do, (who was it decided the scripting engine would ship without loops?!) I tend to err towards using stock functions when I can, rather than NVSE ones, for the sake of compatibility. So I'd err towards GetIsFormType rather than GetType. Doesn't hurt that GetIsFormType doesn't require me to memorise a long list of numbers and strings, or look that list up every single time I want to use it.

Link to comment
Share on other sites

Heh, yeah the lack of proper loops is definitely surprising to me as well. :)

 

On the topic of NVSE, I understand the want to avoid it if it proves unnecessary and if I find during development, that I can redo what I've done without NVSE, I usually will. However, if you're going to use NVSE, you might as well use it to the best of its capabilities.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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