Jump to content

Problem with GetWeaponAmmo


LukeGevaerts

Recommended Posts

Hi guys,

 

I'm trying to determine the ammo used by a weapon carried by an NPC. For the player, "GetPlayerCurrentAmmo" works like a charm - but it seems I'm limited to GetWeaponAmmo for NPCs. The problem is that the output of this function is always "<no name>". Is this because NPCs have this magical ammo that never depletes, or because I'm doing something wrong?

 

Thanks in advance.

Link to comment
Share on other sites

In New Vegas, it returns a form list of ammo types usable by the weapon, not an ammo type in particular. That may be enough, depending on what you want to do with the information.

There is no function to get the specific ammo type equipped by an NPC--assuming that they equip ammo in the first place. It should be safe to assume that ammo in use by an NPC is the default type found at index 0 of the list returned by GetWeaponAmmo, though.

Link to comment
Share on other sites

How do I get the game to return the form list to begin with? All I ever get is "0" or "<no name>". Although that might be because I ran it on an NPC...

 

In any case, I worked around it by getting the ammunition type to identify itself at ScriptEffectStart (50MG, LargePistol, LargeRifle, Shotshell, SmallPistol, SmallRifle); I had to duplicate some scripts, which will be a pain in the ass if I ever need to update them, but it's the only way I could get anything to work reliably. I hope, anyway. You never really know with GameBryo.

 

For the moment, it seems as though lethal headshots now should work for anyone with the ability to fire gun ammunition. It doesn't break anything, at least. I'll have to run some more tests with NPCs who're actually skilled enough to pull off some headshots before dying, though. Come to think of it, the New Vegas Bounties ambushes should be able to help out with that.

 

Edit: Ha! I ironed out the last quirks, and now it works like a charm. The possibility of one-hit-kill headshots for everyone with a gun if the ammo caliber can penetrate the target's headgear. Sh*t just got real(ly dangerous).

Edited by LukeGevaerts
Link to comment
Share on other sites

See, that's the kind of stuff I should've known beforehand. :happy:

 

As for my workaround:

 

The original object effect script attached to every gun ammo type used PlayerGetCurrentAmmo to determine what gun ammo was fired during ScriptEffectStart. It would divide the gun ammo into categories (.308 and .45-70 Gov't as LargeRifle, for example) and then report the correct category to the main script for further use. Since PlayerGetCurrentAmmo only works for the player and I couldn't get GetWeaponAmmo to work at all, I decided to duplicate the original object effect script into six object effect scripts for each gun ammo category and attach those to the applicable gun ammo instead.

 

It's a little bulkier than I had intended, and it takes longer to update since I now have to update six individual scripts (or actually nine - since I had to create additional scripts to incorporate Obsidian's gun ammo effects, such as Dragon's Breath), but at least it works as intended. Now that I now how to get GetWeaponAmmo to work, I think I'll go back and see if I can get my original idea to work at a later time.

 

The net result is amazing, however. During playtesting I decided to punch a random Novac Settler in the face - and promptly got one-shotted by Manny Vargas, as his .308 round was (easily) able to penetrate the Fiend Helmet I was wearing at the time. It used to be that enemies like Cazadores were the player's biggest threat, but with this plugin those things actually give you a fighting chance; gun-wielding NPCs, on the other hand, can drop you in a split second if your headgear cannot stand up to their ammo. Of course, it also works the other way around.

 

As an FYI, I originally intended to use GetWeaponType to split the gun ammo into categories, but that function simply wasn't precise enough.

Link to comment
Share on other sites

It's one of the few functions that work differently from in FOSE, and NVSE documentation is non-existent, so don't worry about not knowing.

 

Yeah, I've used GetWeaponType before in a script that loaded a form list with all ammo usable by all the weapons you're carrying just to exclude weapons that don't use ammo. Another function to know is GetWeaponReloadAnim, which you can use to differentiate between some different types of guns that use the same ammo.

Link to comment
Share on other sites

Correction: it almost works as intended. For some reason, the game is being very arbitrary about dismemberment (as scripted, an explosion of the head should occur if the attacker has the Bloody Mess perk). I know for a fact that it worked perfectly when I still used rTarget.KillActor Player 1; but ever since I switched to a dummy killer (since using Player resulted in way more experience than any kill should be worth), dismemberment only occurs... Well, whenever it feels like it, I guess.

 

It's not a big concern; I guess I'll just chalk it up to yet another thing I don't understand about the GECK.

Edited by LukeGevaerts
Link to comment
Share on other sites

Bloody Mess isn't scripted--it's a hard-coded effect that I'm 99% sure only affects the player. You can use HasPerk to check if an actor has the perk and apply your own voodoo to make limbs explode, but I'd double-check the value that it returns on NPCs with a MessageEx popup or something since perks don't play well with NPCs some times.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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