Jump to content

Problem with GetWeaponAmmo


LukeGevaerts

Recommended Posts

Bloodymess is an actor value. You just set to non zero on the actor. Works in FO3 at least for NPCs. Have not tried it for FNV.

 

The perk, which only works on the player, additionally adds a multiplier for weapon damage in addition to setting the actor value. But for NPCs, just use ActorREF.SetAV BloodyMess 1

Link to comment
Share on other sites

Bloodymess is an actor value. You just set to non zero on the actor. Works in FO3 at least for NPCs. Have not tried it for FNV.

 

The perk, which only works on the player, additionally adds a multiplier for weapon damage in addition to setting the actor value. But for NPCs, just use ActorREF.SetAV BloodyMess 1

 

Whether it actually works for NPCs isn't of any particular relevance to my scenario - the script only checks if it is available at all and adds an additional parameter to KillActor (dismember head) if it is. I didn't know, however, that it's an actor value - that explains why HasPerk doesn't function as intended. Thanks for the heads-up! :happy:

Link to comment
Share on other sites

Bloodymess is an actor value. You just set to non zero on the actor. Works in FO3 at least for NPCs. Have not tried it for FNV.

 

The perk, which only works on the player, additionally adds a multiplier for weapon damage in addition to setting the actor value. But for NPCs, just use ActorREF.SetAV BloodyMess 1

 

That makes sense, given that it shows up under Value Modifier in the base effect window. Thanks for the clarification.

Link to comment
Share on other sites

The form list is what GetWeaponAmmo returns. Form lists don't have names. You can use the following to get the default ammo of the currently equipped weapon:

set rList to rActor.GetWeaponAmmo
set rAmmo to ListGetNthForm rList 0

 

I'm curious to see the details of how you worked around this.

You're forgetting that not ALL weapons use a form list. This will fail in those cases, possibly in very bad ways (CTD). In cases where you don't know what will be returned, you should always ALWAYS check the form type before doing anything with it. Use GetType to check for the form type. In the case of ammo you'll need to include a result for if the weapon has just an ammo form, or has a list of ammo forms. Usually it's the same thing, except with the list you have to get the first object before you can do something.

 

As for what you're doing, it's a kind of neat idea, but somewhat limiting to have to have a script applied to every ammo type in the game. I would suggest taking a look at the PN Rebalance module Headshot script. It fixes the incorrectly applied DT to heads when an actor is not wearing a helmet. It could be reworked to do what you're doing pretty easily, and would be compatible with everything.

Link to comment
Share on other sites

You're forgetting that not ALL weapons use a form list. This will fail in those cases, possibly in very bad ways (CTD). In cases where you don't know what will be returned, you should always ALWAYS check the form type before doing anything with it. Use GetType to check for the form type. In the case of ammo you'll need to include a result for if the weapon has just an ammo form, or has a list of ammo forms. Usually it's the same thing, except with the list you have to get the first object before you can do something.

 

As for what you're doing, it's a kind of neat idea, but somewhat limiting to have to have a script applied to every ammo type in the game. I would suggest taking a look at the PN Rebalance module Headshot script. It fixes the incorrectly applied DT to heads when an actor is not wearing a helmet. It could be reworked to do what you're doing pretty easily, and would be compatible with everything.

 

Yes, it's fairly limiting - but in my defense, object effect scripts applied to ammo are rare; not only in the base game, but in plugins as well. It also degrades nicely depending on load order. That said, mine is a hacky way of doing things; but I suppose that's what happens when you experiment.

 

I just took a look at that Rebalance script, and it's certainly much more elegant than what I've been doing. The only problem I can see so far is detecting by which type of ammo the head was stuck, which I haven't yet been able to do without an object effect.

Link to comment
Share on other sites

Yeah, that would be a limiting factor. This applies to all actors, correct, not just the player? If it was just the player, GetPlayerCurrentAmmo would let you know the current ammo, and you could do that.

 

Hmm, since NPCs don't really use other ammo types (by default, see my mod NPCs Consume Ammo), you could just always assume that they're using the default ammo type. Then you just need to detect the head hit, and could do whatever then. And the special cases for the player could use GetPlayerCurrentAmmo to refine it for the player.

 

NPCs almost never get headshots, and the ones they do (if I understand this correctly) would be fatal, so if they get a fatal shot against the player, who cares what it looks like, you're dead, and against other actors, I rarely if ever see an NPC get a gibbed kill or crit attack.

Link to comment
Share on other sites

Yeah, that would be a limiting factor. This applies to all actors, correct, not just the player? If it was just the player, GetPlayerCurrentAmmo would let you know the current ammo, and you could do that.

 

Hmm, since NPCs don't really use other ammo types (by default, see my mod NPCs Consume Ammo), you could just always assume that they're using the default ammo type. Then you just need to detect the head hit, and could do whatever then. And the special cases for the player could use GetPlayerCurrentAmmo to refine it for the player.

 

NPCs almost never get headshots, and the ones they do (if I understand this correctly) would be fatal, so if they get a fatal shot against the player, who cares what it looks like, you're dead, and against other actors, I rarely if ever see an NPC get a gibbed kill or crit attack.

 

Yeah, it's designed to apply to all actors. So combine "assume default" with GetPlayerCurrentAmmo? That could work... Maybe. One of the problems is that I still cannot get GetWeaponAmmo to work for NPCs; even with the code sample luthienanarion provided, no matter how I code it, all I ever get in return is "<no name>". Guessing ammo types through weapon types is not specific enough, and it'll be a cold day in hell before I resort to CompareNames (which would also break compatibility with non-vanilla weapons). Sigh... All of this would be so much easier if NVSE included a GetCurrentAmmo function that applies to all actors.

 

As an aside, I've noticed NPCs are actually somewhat efficient at scoring lethal headshots with my current setup. I'm not sure if they actually intend to score a headshot, but spray 'n pray seems to work out quite well for them. This plugin also includes ammo recipes for frenzy and tranquilizer rounds; sneaking up to a mob of fiends, frenzying a couple of them and watching them blow eachothers heads off has become one of my guilty pleasures. Ridiculously overpowered, of course - but those new ammo recipes were originally another experiment intended to facilitate pacifist playthroughs.

Link to comment
Share on other sites

  • 1 year later...

 

Hmm, since NPC's don't really use other ammo types (by default, see my mod NPC's Consume Ammo), you could just always assume that they're using the default ammo type.

 

 

Is this true? Aren't there leveled lists that allow for NPC's to carry a variety of ammo types (e.g. armor piercing .308)? Does this just mean the NPC'S carry this ammunition, but do not fire it?

Edited by irswat
Link to comment
Share on other sites

  • Recently Browsing   0 members

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