Weapon Health Damage

Post » Tue May 17, 2011 5:43 am

Hey guys, I need a bit of help with part of my script.

I'm trying to damage the health of the NPCs' armor and weapon on death.

I've been able to script their armor damage so that it it works perfectly in my script, but I cannot seem to get the equipped weapon's health to be damage. I think that the problem may be mostly because the weapon is often dropped, but even when the weapon is not dropped, it is still not damaged. I've even tried using the right hand slot, without any success. This is the part of my script that I'm having problems with (the armor part works great).


set rTarget to GetCrosshairRefif rTarget.getDead 	set ArmorHealth to rTarget.GetEquippedCurrentHealth 2	if ArmorHealth > 25		set ArmorHealth to 25		rTarget.SetEquippedCurrentHealth ArmorHealth 2	endif	set WeaponHealth to rTarget.GetEquippedCurrentHealth 5	if WeaponHealth > 25 		set WeaponHealth to 25		rTarget.SetEquippedCurrentHealth WeaponHealth 5	endifendif


Any suggestions would be greatly appreciated.

Edited: I forgot to add that this is part of a quest script.
User avatar
herrade
 
Posts: 3469
Joined: Thu Apr 05, 2007 1:09 pm

Post » Tue May 17, 2011 9:05 am

Did you remember to make a custom script processing delay time? That is, something like 0.01 s to get it to run in each frame?
User avatar
Loane
 
Posts: 3411
Joined: Wed Apr 04, 2007 6:35 am

Post » Tue May 17, 2011 8:14 am

Did you remember to make a custom script processing delay time? That is, something like 0.01 s to get it to run in each frame?

Yes, I have the delay set at 0.01.
User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Post » Tue May 17, 2011 11:00 am

I did some tests in the console where I clicked dead NPCs and used GetEquippedCurrentHealth. For GetEquippedCurrentHealth 2, I got the health of the armor, but for GetEquippedCurrentHealth 5 (and GetEquippedCurrentHealth 6) I got no result. So it would seem that weapons are automatically unequipped when an NPC dies. An alternative to the script above would be to walk through the inventory of the NPC and handle all their weapons, but it could cause some lag ...
User avatar
Eddie Howe
 
Posts: 3448
Joined: Sat Jun 30, 2007 6:06 am

Post » Tue May 17, 2011 12:11 am

Thanks for doing the tests!

Yes, the unequipping of their weapon on death seems to be the biggest problem. There are times when their weapon is not unequipped . . . perhaps 1 in 10 cases (or even less) . . . and then the second half of my code does work, and their equipped weapon is damaged.

So, now I'm wondering if there is any way to cause them not to unequip their weapon on death.
User avatar
Claudia Cook
 
Posts: 3450
Joined: Mon Oct 30, 2006 10:22 am

Post » Tue May 17, 2011 12:17 am

Zumbs: Er, that's not going to work as inventory walks return base items.
Refwalking all the weapons in the cell and picking the one closest to the dead NPC is probably the closest you're going to get.

They don't drop weapons that are equipped but not drawn, or are flagged as "Can't drop" or "Unplayable".
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Tue May 17, 2011 10:46 am

In most cases, even the dropped weapons are still in their inventory.

So perhaps I'm going about this in the wrong way.

Is there a way to do this using "if menumode 1008" ; ( Container), with a if GetDead condition?

(I wound not mind if all of a dead NPC's inventory was damaged.)
User avatar
Jessica White
 
Posts: 3419
Joined: Sun Aug 20, 2006 5:03 am

Post » Tue May 17, 2011 6:06 am

In most cases, even the dropped weapons are still in their inventory.

So perhaps I'm going about this in the wrong way.

Is there a way to do this using "if menumode 1008" ; ( Container), with a if GetDead condition?

(I wound not mind if all of a dead NPC's inventory was damaged.)


You can use a perk with an Activate entry point with the conditions GetIsObjectType == NPC and GetDead == 1. In the result script of the perk entry point, you can set your quest rTarget variable to GetCrosshairRef, then start your quest script to do the processing on the NPC.

Since there's no way to know what the health of the weapons in the container are, you could set it randomly to various values, with perhaps a cap depending on level, modified by luck, perks, or other factors.
You might approach it this way:
Walk the inventory and add all the weapon-type base objects to a form list, say TargetFormList (Depending on how complicated you want to get, you can set this up to either ignore, or add multiples of the same item)
Remove all the weapons from the NPC - rTarget.RemoveItem TargetFormList 999 <---- learned this trick from TheTalkieToaster ;)
Go back through the TargetFormList and read the first item,
Figure out the random health % you are going to give it - fHealth
Add it to the NPC - rTarget.AddItemHealthPercent 1 fHealth
Repeat for the other items.
Finally, activate the rTarget container for the Player
Stop the quest script until you need it again
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Tue May 17, 2011 2:27 am

Remove all the weapons from the NPC - rTarget.RemoveItem TargetFormList 999 <---- learned this trick from TheTalkieToaster ;)


That's very interesting, what exactly does that do?
User avatar
Ashley Campos
 
Posts: 3415
Joined: Fri Sep 22, 2006 9:03 pm

Post » Tue May 17, 2011 7:38 am

That's very interesting, what exactly does that do?


It removes up to 999 of every item in the formlist.
User avatar
Jaki Birch
 
Posts: 3379
Joined: Fri Jan 26, 2007 3:16 am

Post » Tue May 17, 2011 4:26 am

You can use a perk with an Activate entry point with the conditions GetIsObjectType == NPC and GetDead == 1. In the result script of the perk entry point, you can set your quest rTarget variable to GetCrosshairRef, then start your quest script to do the processing on the NPC.

Since there's no way to know what the health of the weapons in the container are, you could set it randomly to various values, with perhaps a cap depending on level, modified by luck, perks, or other factors.
You might approach it this way:
Walk the inventory and add all the weapon-type base objects to a form list, say TargetFormList (Depending on how complicated you want to get, you can set this up to either ignore, or add multiples of the same item)
Remove all the weapons from the NPC - rTarget.RemoveItem TargetFormList 999 <---- learned this trick from TheTalkieToaster ;)
Go back through the TargetFormList and read the first item,
Figure out the random health % you are going to give it - fHealth
Add it to the NPC - rTarget.AddItemHealthPercent 1 fHealth
Repeat for the other items.
Finally, activate the rTarget container for the Player
Stop the quest script until you need it again


Thanks RickerHK,

but that is way more involved than what I want (and I'm not very confident that I could get that to work).
I still think the best approach for me would be if I could prevent the NPCs from dropping their equipped weapon when they die.
User avatar
Assumptah George
 
Posts: 3373
Joined: Wed Sep 13, 2006 9:43 am

Post » Tue May 17, 2011 12:41 am

After not having any luck damaging the health of dropped weapons, I'm wondering if there is any possible way to toggle on an off the "playable" tag that is attached to weapons?

I've searched the GECK wiki and the FOSE commands, but cannot see any direct way to do this. So I'm wondering if there might be an indirect way. Any ideas?
User avatar
Hayley Bristow
 
Posts: 3467
Joined: Tue Oct 31, 2006 12:24 am


Return to Fallout 3