Armour Piercing Script help

Post » Sat Nov 27, 2010 5:39 am

As the title suggests, I've been working on an Armour (you say armor, I say armour) Piercing script for FOOK2, and although its working very well, I've hit a few snags.

scn FOOKAPDRSCPT; Credit for the base goes to Kanob: http://www.fallout3nexus.com/modules/members/index.php?id=1455440; FOSE is needed for this Script: http://fose.silverlock.org/ref PCWeapon                    ;# Ref of Playerweaponfloat PCWeaponDamage        ;# Damage of Playerweapon at 100% conditionshort PCWeaponType        ;# Type of equiped weaponfloat PCWeaponSkill            ;# Playerskill with weapontypefloat PCWeaponCondPenalty ;# Penalty of having less than 100% weapon conditionfloat PCSkillBonus		   ;# Damage adjustment depending on PC skillfloat MeleeArmConditionPenalty ;# Penalty for crippled arms in Meleefloat PCMeleeDamageAV 		;# Extra Melee Damage actor value (ie from Little Leaguer Cap, etc)float PCUnarmedDamageAV 	;# As above, but for Unarmed, ie Iron Fist Perk. float GameSettingGunCondBase ;# GMST for calculating minimum gun damage at 1 condition (0.6)float GameSettingGunCondMult ;# GMST for calculating range of gun damage between 1-100 condition (0.4)float GameSettingMeleeWeapCondBase ;# GMST for calculating minimum melee weapon damage at 1 condition (0.5)float GameSettingMeleeWeapCondMult ;# GMST for calculating range of melee weapon damage between 1-100 condfloat GameSettingSkillBase ;# GMST for calculating minimum weapon damage at 1 skill (0.5)float GameSettingSkillMult ;# GMST for calculating range of weapon damage between 1-100 skill (0.5)float ArmorPiercingDamage		;# Damage to be done by ArmorPiercingfloat GameSettingArmConditionBase ;# GMST for calculating melee weapon damage with both arms crippled (0.2)float GameSettingArmConditionMult ;# GMST for calculating melee weapon damage with 1 or no arms crippled (0.8)float RightArmStatus		;# 1 if arm is healthyfloat LeftArmStatus		;# As abovefloat APDRxDamageVar ;# Damage the player does with his weapon.ref rTargetshort vHealthBegin ScriptEffectStart Player	If FOSE	Else		Return	EndIf	set rTarget to GetSelf	set vHealth to rTarget.GetAV Health	set PCWeapon to player.GetEquippedObject 5	set PCWeaponDamage to GetAttackDamage PCWeapon	set PCWeaponType to GetWeaponSkill PCWeapon	set GameSettingGunCondBase to GetGS fDamageGunWeapCondBase	set GameSettingGunCondMult to GetGS fDamageGunWeapCondMult	set GameSettingSkillBase to GetGS fDamageSkillBase	set GameSettingSkillMult to GetGS fDamageSkillMult	set GameSettingMeleeWeapCondBase to GetGS fDamageMeleeWeapCondBase	set GameSettingMeleeWeapCondMult to GetGS fDamageMeleeWeapCondMult		set GameSettingArmConditionBase to GetGS fDamageArmConditionBase	set GameSettingArmConditionMult to GetGS fDamageArmConditionMult	set PCMeleeDamageAV to player.getav MeleeDamage	set PCUnarmedDamageAV to player.getav UnarmedDamage	if PCWeaponType == 33        ; Big Guns		set PCWeaponSkill to player.getav bigguns	elseif PCWeaponType == 34        ; Energy Weapons		set PCWeaponSkill to player.getav energyweapons	elseif PCWeaponType == 41        ; Small Guns		set PCWeaponSkill to player.getav smallguns	elseif PCWeaponType == 38	     ; Melee Weapons		set PCWeaponSkill to player.getav meleeweapons	elseif PCWeaponType == 45	     ; Unarmed		set PCWeaponSkill to player.getav unarmed	endif		if PCWeaponSkill > 100.0			set PCWeaponSkill to 100.0		endif	set PCSkillBonus to GameSettingSkillBase+(GameSettingSkillMult*(((PCWeaponSkill))/100))	if PCWeapontype == 41 || PCWeapontype == 34 || PCWeapontype == 33		set PCWeaponCondPenalty to GameSettingGunCondBase+(GameSettingGunCondMult*(player.GetWeaponHealthPerc/100))				set APDRxDamageVar to (PCWeaponDamage*PCSkillBonus*PCWeaponCondPenalty)		;# damagevar * targetDR / 100.0 = APdamage			elseif PCweaponType == 38 || PCWeapontype == 45			set PCWeaponCondPenalty to GameSettingMeleeWeapCondBase+(GameSettingMeleeWeapCondMult*(player.GetWeaponHealthPerc/100))		set RightArmStatus to (player.getav RightAttackCondition)			if RightArmStatus 				set RightArmStatus to 1			endif		set LeftArmStatus to (player.getav LeftAttackCondition)			if LeftArmStatus				set LeftArmStatus to 1			endif		; set MeleeArmConditionPenalty to (PCWeaponDamage*((GameSettingArmConditionBase)-1)+(GameSettingArmConditionMult*((RightArmStatus+LeftArmStatus)/2)))		if PCWeaponType == 38			set APDRxDamageVar to ((PCWeaponDamage*PCSkillBonus*PCWeaponCondPenalty)+(PCMeleeDamageAV)) ;+(MeleeArmConditionPenalty))		elseif PCWeaponType == 45			set APDRxDamageVar to ((PCWeaponDamage*PCSkillBonus*PCWeaponCondPenalty)+(PCUnarmedDamageAV)) ;+(MeleeArmConditionPenalty))		endif	endif	set ArmorPiercingDamage to (((APDRxDamageVar)/2)*(getav damageresist/100.0)) 	;I'm reliably informed by GECKWiki that Critical Hit damage ignores armour anyway, so there is no Critical/Sneak check.	;The reason its APDR/2 is because during my testing it appeared that body shots do half the listed damage and head shots the 	;listed damage (not what GECKwiki says, however). I decided not to give the player benefit of the doubt.		DamageActorValue Health ArmorPiercingDamage			;## Finally! Do the AP-Damage!End


Currently the biggest problem is generating a version that works for NPCs - as I don't know how to call the firer/user of the object script (if there even is currently a way), I had to make all the checks against a fixed ref, ie the player, which obviously means that no matter what AP weapon an NPC uses it'll be the same as the PC's weapon, which can turn out weird. The only thing I could thing of that is really rudimentary would be to use an equip script on the weapon to check if the user is the player, and if the user is the player, use the FOSE command to add the object effect in, and vice versa if the user is an NPC, but thats crude. Even just a simple way of making sure the script never runs when an NPC fires an AP weapon would do I guess, but if it could work for NPCs that would be beyond awesome.

Secondly, the reason the bit about MeleeArmConditionPenalty is commented out in the formula is because I can't devise a suitable check as to the number of crippled arms the player has; the bit about rightarmstatus/leftarmstatus doesn't seem to work (I had it as a global for testing initially, but it always displayed 0 no matter what I did), even though player.getav RightAttackCondition works in the console (but its out of 100). Basically what I want is if the condition of the limb is 0 or below, set the Right/LeftArmStatus to 0, and if it is above 0 (ie, the limb is not crippled) set it to 1... Or another, simpler, IsCrippled check would be great, but I couldn't find one on GECKWiki.

Thirdly, I can't remember if the UnarmedDamage/MeleeDamage bit works.. I remember having problems with it and I might have fixed them, but I've been sitting on this for far too long to remember, so I thought I'd throw it in if anyone sees anything obviously wrong with it.
User avatar
Emma-Jane Merrin
 
Posts: 3477
Joined: Fri Aug 08, 2008 1:52 am

Post » Sat Nov 27, 2010 6:41 pm

At the moment, you've specified that your http://geck.gamesas.com/index.php/ScriptEffectStart block should only run on the player, which I'm sure is not what you want.

There is no 100% accurate way to determine which actor has fired a weapon from its resultant object effect, but you can guess which actor it was by using FOSE's reference walking and looping functions, and checking various things on each actor found to determine which is most likely to be the attacker. The looping part of the script would look like this:
ref rCurrentRefref rBestRefBegin ScriptEffectStart	;...	set rCurrentRef to GetFirstRef 200 1 0 ; Actors	Label 10	if rCurrentRef		if rCurrentRef.IsAttacker ; Replace this with nested function calls to check if the current reference is probably the attacker			set rBestRef to rCurrentRef		endif		set rCurrentRef to Pencil01 ; Avoid "apple" bug		set rCurrentRef to GetNextRef		Goto 10	endif	;...End
You'll probably want to check things like the actor's weapon, their facing and distance relative to the target (http://geck.gamesas.com/index.php/GetHeadingAngle and http://geck.gamesas.com/index.php/GetDistance), whether or not their weapon is out etc. If multiple actors are aiming at the target with appropriate weapons then you'll probable get the odd false positive, but otherwise it should work quite well.

P.S. I say "armour" too, although I do notice that your variable names say "armor". I'm guessing that's left over from Kanob?

Cipscis
User avatar
Brentleah Jeffs
 
Posts: 3341
Joined: Tue Feb 13, 2007 12:21 am

Post » Sat Nov 27, 2010 5:01 pm

Off topic - I am a Canadian living in the USA, I say colour / color, armor / armour, zee and zed. Its all good. :rock:
User avatar
butterfly
 
Posts: 3467
Joined: Wed Aug 16, 2006 8:20 pm

Post » Sat Nov 27, 2010 6:18 am

At the moment, you've specified that your http://geck.gamesas.com/index.php/ScriptEffectStart block should only run on the player, which I'm sure is not what you want.


I completely missed that, it's left over from Kanob's original script. However, the script appears to function no matter who is hit or is doing the hitting, which is odd.
There is no 100% accurate way to determine which actor has fired a weapon from its resultant object effect, but you can guess which actor it was by using FOSE's reference walking and looping functions, and checking various things on each actor found to determine which is most likely to be the attacker. The looping part of the script would look like this: *snip*
You'll probably want to check things like the actor's weapon, their facing and distance relative to the target (http://geck.gamesas.com/index.php/GetHeadingAngle and http://geck.gamesas.com/index.php/GetDistance), whether or not their weapon is out etc. If multiple actors are aiming at the target with appropriate weapons then you'll probable get the odd false positive, but otherwise it should work quite well.

Brilliant, thanks a ton! A false positive doesn't bother me, as the likelihood is that the only scenario where lots of AP weapons will be being shot at the same target, at least in its intended function in FOOK2, is mobs using Energy Weapons (Enclave) against the player, in which case their stats will all be pretty much the same. I'll put some of these functions into the script and then post an edited version.

P.S. I say "armour" too, although I do notice that your variable names say "armor". I'm guessing that's left over from Kanob?


I figured its spelt that way in game, so I might as well keep it consistent.
User avatar
Emily abigail Villarreal
 
Posts: 3433
Joined: Mon Aug 27, 2007 9:38 am


Return to Fallout 3