irswat Posted April 15, 2014 Share Posted April 15, 2014 (edited) Working on the mech mod with devp and trying to make a custom damage script so bb's and small arms fire bounce off the meech, while more substantial weaponry actually does some damage.This is from that thread: I'm working on variable damage section of the script. It seems tricky. I was thinking of using Begin OnHitWith or if GetAttack next i need to get the refid of the NPC that is attacking, the refid of the weapon they are using and the formid of the projectile they are firing. Then I think I can use GetType and GetHitLocation to conditionally SetAttackDamage to the projectile formID. Weapon Type 0: HandToHandMelee 1: OneHandMelee 2: TwoHandMelee 3: OneHandPistol 4: OneHandPistolEnergy 5: TwoHandRifle 6: TwoHandAutomatic 7: TwoHandRifleEnergy 8: TwoHandHandle 9: TwoHandLauncher 10: OneHandGrenade 11: OneHandMine 12: OneHandLunchboxMine None -1 Torso 0 Head 1 1 Head 2 2 Left Arm 1 3 Left Arm 2 4 Right Arm 1 5 Right Arm 2 6 Left Leg 1 7 Left Leg 2 8 Left Leg 3 9 Right Leg 1 10 Right Leg 2 11 Right Leg 3 12 Brain 13 Hand or Weapon 14 I am not sure how to get the refid of the NPC (s) attacking, the refid of the weapon they are using, or the formid of the projectile being fired. Can you point me in the right direction? any ideas how to make armor resistant to certain types of weapons/projectiles, while being more prone to other types? Edited April 15, 2014 by irswat Link to comment Share on other sites More sharing options...
irswat Posted April 18, 2014 Author Share Posted April 18, 2014 MY SCRIPT: ScriptName MechDamageGradient int counter int numNPC int MechCheckFlag ref rCurrentNPC ref rCurrentNPCWpn ref rNPCTarget float NPCProximity short NormalAttackDmg short ModifiedAttackDmg short NormalDmgModifier Begin GameMode set numNPC to GetNumRefs 200 1 0 set counter to 0 if (numNPC == 0)||(player.IsInCombat == 0) return elseif (numNPC > 0)||(player.IsInCombat) set rCurrentNPC to GetFirstRef 200 1 if Player.GetEquipped ArmorUniqueEnclaveMech set MechCheckFlag to 1 else return endif endif while (counter <= numNPC) && (rCurrentNPC != 0) set counter to (counter + 1) if (rCurrentNPC.IsInCombat) set rNPCTarget to rCurrentNPC.GetCombatTarget if (rNPCTarget == player) set rCurrentNPCWpn to rCurrentNPC.GetEquippedObject 5 if (GetWeaponType rCurrentNPCWpn == 0) || (GetWeaponType rCurrentNPCWpn == 1) ||(GetWeaponType rCurrentNPCWpn == 2) || (GetWeaponType rCurrentNPCWpn == 3) set NormalAttackDmg to rCurrentNPC.GetAttackDamage rCurrentNPCWpn set NormalDmgModifier to (NormalAttackDmg *.65) set ModifiedAttackDmg to (NormalAttackDmg - NormalDmgModifier) ;I would like to buff up these formulas to incorporate actor values SetAttackDamage ModifiedAttackDmg rCurrentNPCWpn elseif (GetWeaponType rCurrentNPCWpn == 7) || (GetWeaponType rCurrentNPCWpn == 9) ||(GetWeaponType rCurrentNPCWpn == 10) || (GetWeaponType rCurrentNPCWpn == 11) set NormalAttackDmg to rCurrentNPC.GetAttackDamage rCurrentNPCWpn set ModifiedAttackDmg to (NormalAttackDmg*1.9) SetAttackDamage ModifiedAttackDmg rCurrentNPCWpn endif endif endif SetAttackDamage NormalAttackDmg rCurrentNPCWpn set rCurrentNPC to Apple set rCurrentNPC to GetNextRef ;this gets the next NPC ref loop return End Link to comment Share on other sites More sharing options...
luthienanarion Posted April 22, 2014 Share Posted April 22, 2014 I think it would be a lot simpler to add and remove a hidden perk with entry points that add DR/DT if the attacker is using certain weapons, etc. Link to comment Share on other sites More sharing options...
irswat Posted April 22, 2014 Author Share Posted April 22, 2014 Updated script now can return the kind of ammo a hostile NPC is using against player. E.g. Armour piercing, hollow point, EMP, Incidienary, Magnum, etc. NPC attack damage is altered depending not only on weapon type, but also ammo type and ammo effect. Since there was no function that returns NPC ammo type I wrote one. I need to do some play testing. ;swats' weapon effectiveness script set numNPC to GetNumRefs 200 1 set counter to 0 if (numNPC == 0)||(player.IsInCombat == 0) return elseif (numNPC > 0)||(player.IsInCombat) set rCurrentNPC to GetFirstRef 200 1 if Player.GetEquipped ArmorUniqueEnclaveMech set MechCheckFlag to 1 else return endif endif while (counter <= numNPC) && (rCurrentNPC != 0) set counter to (counter + 1) if (rCurrentNPC.IsInCombat) set rNPCTarget to rCurrentNPC.GetCombatTarget if (rNPCTarget == player) set rCurrentNPCWpn to rCurrentNPC.GetEquippedObject 5 if (rCurrentNPCWpn != 0) ;shout out to Gribbleshnibit8 for heads up about error checking form lists ;see http://forums.nexusmods.com/index.php?/topic/839682-problem-with-getweaponammo/page-2#entry6742499 for potential issues set rNPCAmmoList to rCurrentNPC.GetWeaponAmmo set NPCAmmoTypeCheck to GetObjectType rNPCAmmoList ;error checking ;what other exceptions are not covered here? set RndFlag to 0 if (NPCAmmoTypeCheck != 0) && (NPCAmmoTypeCheck == 85) ;did GetWeaponAmmo Return a form list? set AmmoTypeFormListFlag to rNPCAmmoList.IsFormValid if (AmmoTypeFormListFlag) ;OPTION #1 - if GetWeapAmmo returns a formlist ;this will return the default ammo, at index 0 in Ammo type form list ;how accurate is this method? do NPC's shoot 'special' variety bulsets like AP? set rNPCAmmoType to ListGetNthForm rNPCAmmoList 0 ;shout out to luthienanarion for this endif elseif (NPCAmmoTypeCheck != 85) ;if not a form list, what other object types could GetWeaponAmmo return? ;OPTION #2 set rNPCAmmoType to GetWeaponAmmo rCurrentNPCWpn ;what does this return? if (rNPCAmmoType == 0) MessageEx "Ammo not found" endif elseif (NPCAmmoTypeCheck == 0) set RndFlag to 1 MessageEx "Ammo not found" endif ;This experimental method will try to flag whether the ammo that is being fired ;is identifiable by its editor id. e.g. AP for Armour Piercing ;If a recognized substring is found in the ammo name the script ;will search the respective ammo type form list for this variety. ;If the ammo type form is not found in that form list, it will be added. ;Armor Piercing check set sv_EquippedAmmoName to rNPCAmmoType.GetName set AmmoFoundFlag to sv_Find "AP" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList APAmmoList == 0) AddFormToFormList rNPCAmmoType APAmmoList endif set AmmoDmgModifier to 1 endif set AmmoFoundFlag to sv_Find "Piercing" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList APAmmoList == 0) AddFormToFormList rNPCAmmoType APAmmoList endif set AmmoDmgModifier to 1 endif ;High explosive check set AmmoFoundFlag to sv_Find "HE" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList HEAmmoList == 0) AddFormToFormList rNPCAmmoType HEAmmoList endif set AmmoDmgModifier to 2 endif ;Hollow Point check set AmmoFoundFlag to sv_Find "HP" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList HPAmmoList == 0) AddFormToFormList rNPCAmmoType HPAmmoList endif set AmmoDmgModifier to 3 endif set AmmoFoundFlag to sv_Find "Hollow Point" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList HPAmmoList == 0) AddFormToFormList rNPCAmmoType HPAmmoList endif set AmmoDmgModifier to 3 endif set AmmoFoundFlag to sv_Find "HollowPoint" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList HPAmmoList == 0) AddFormToFormList rNPCAmmoType HPAmmoList endif set AmmoDmgModifier to 3 endif ;Magnum check set AmmoFoundFlag to sv_Find "Magnum" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList MagnumAmmoList == 0) AddFormToFormList rNPCAmmoType MagnumAmmoList endif set AmmoDmgModifier to 4 endif ;Dragons Breath check set AmmoFoundFlag to sv_Find "DragonsBreath" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList DragonsBreathAmmoList == 0) AddFormToFormList rNPCAmmoType DragonsBreathAmmoList endif set AmmoDmgModifier to 5 endif ;Pulse check set AmmoFoundFlag to sv_Find "Pulse" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList PulseAmmoList == 0) AddFormToFormList rNPCAmmoType PulseAmmoList endif set AmmoDmgModifier to 6 endif ;EMP check set AmmoFoundFlag to sv_Find "EMP" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList EMPAmmoList == 0) AddFormToFormList rNPCAmmoType EMPAmmoList endif set AmmoDmgModifier to 7 endif ;Plasma check set sv_EquippedAmmoName to rNPCAmmoType.GetName set AmmoFoundFlag to sv_Find "Plasma" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList PlasmaAmmoList == 0) AddFormToFormList rNPCAmmoType PlasmaAmmoList endif set AmmoDmgModifier to 8 endif ;Incendiary check set sv_EquippedAmmoName to rNPCAmmoType.GetName set AmmoFoundFlag to sv_Find "Incendiary" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList IncendiaryAmmoList == 0) AddFormToFormList rNPCAmmoType IncendiaryAmmoList endif set AmmoDmgModifier to 9 endif ;Explosive check set sv_EquippedAmmoName to rNPCAmmoType.GetName set AmmoFoundFlag to sv_Find "Explosive" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList ExplosivesAmmoList == 0) AddFormToFormList rNPCAmmoType ExplosivesAmmoList endif set AmmoDmgModifier to 10 endif ;Frag check set sv_EquippedAmmoName to rNPCAmmoType.GetName set AmmoFoundFlag to sv_Find "Frag" sv_EquippedAmmoName if (AmmoFoundFlag != -1) if (rNPCAmmoType.IsInList FragAmmoList == 0) AddFormToFormList rNPCAmmoType FragAmmoList endif set AmmoDmgModifier to 11 endif ;this block of code modifies damage to the mech based on the weapon type ;e.g. small arms fire will not do much damage. Energy weapons will. ;ammo types are also factored in if (GetWeaponType rCurrentNPCWpn <=3) set NormalAttackDmg to rCurrentNPCWpn.GetAttackDamage set NormalDmgModifier to (NormalAttackDmg *.65) set ModifiedAttackDmg to (NormalAttackDmg - NormalDmgModifier) MessageEx "NPC: %i| Weapon: %i |Original Damage: %g |DmgModifier: %g| ModifiedDmg: %g" rCurrentNPC NormalAttackDmg NormalDmgModifier ModifiedAttackDmg SetAttackDamage ModifiedAttackDmg rCurrentNPCWpn elseif (GetWeaponType rCurrentNPCWpn == 7) || (GetWeaponType rCurrentNPCWpn == 9) ||(GetWeaponType rCurrentNPCWpn == 10) || (GetWeaponType rCurrentNPCWpn == 11) set NormalAttackDmg to rCurrentNPCWpn.GetAttackDamage set ModifiedAttackDmg to (NormalAttackDmg*1.2) ;%25 increase in damage if munitions are effective verse mech armor if (AmmoDmgModifier > 1) set AmmoDmgModifier to (NormalAttackDmg*.25) set ModifiedAttackDmg to ModifiedAttackDmg + AmmoDmgModifier endif SetAttackDamage ModifiedAttackDmg rCurrentNPCWpn MessageEx "NPC: %i| Weapon: %i |Original Damage: %g |DmgModifier: %g| ModifiedDmg: %g" rCurrentNPC NormalAttackDmg NormalDmgModifier ModifiedAttackDmg endif endif endif endif ;this was to reset attack damage to its original value ;I am unsure if this will need to be manually reset ;SetAttackDamage NormalAttackDmg rCurrentNPCWpn set rCurrentNPC to Apple set rCurrentNPC to GetNextRef ;this gets the next NPC ref loop Link to comment Share on other sites More sharing options...
Recommended Posts