Jump to content

ModWeaponSpeed


cfh85

Recommended Posts

The updated version.

I have 3 UD Functions. 1 is a standard function that will determine the NPCs level based off of it's faction rank, and the PCs fame and infamy. The other two are used only for this ability. The one determines the initial weapon to be cloned and the other is for when the NPC is added to the special ability faction

 

Ability script

 

Scriptname CFHCompanionsClass13AbilityScript

;Knife Dancer - Lightning Speed

Array_var Weapons

Ref Self
Ref Weapon1	;The base weapon.
Ref Weapon1Base
Ref WeaponBase
Ref TempWeapon	;The new weapon to be copied

Float IISpeed
Float IIReach
Float IIDamage
Float IIRating
Float Level
Float SpeedMod
Float Equip

Short Key

Begin ScriptEffectUpdate
If Equip == 1
	Self.EquipItemNS Weapon1
	Set Equip to 0
EndIf
If (Self.GetInFaction CFHCompanionSpecialFaction) == 0
	Return
Else
	Let TempWeapon := Call UDCFHClass13Update Self Weapon1
	Let Level := Call UDCFHCompanionLevelNeutral Self

	Set SpeedMod to (1 + (Level / 50))
	Weapon1.CopyModelPath TempWeapon
	Set IISpeed to ((GetWeaponSpeed TempWeapon) * SpeedMod)
	Set IIReach to (GetWeaponReach TempWeapon)
	Set IIDamage to (GetAttackDamage TempWeapon)
	SetWeaponSpeed IISpeed Weapon1
	SetWeaponReach IIReach Weapon1
	SetAttackDamage IIDamage Weapon1
	Self.UnequipItemNS Weapon1
	Set Equip to 1
	Self.SetFactionRank CFHCompanionSpecialFaction -1
	Return
EndIf
End

Begin ScriptEffectStart
Set Self to GetSelf

Let TempWeapon := Call UDCFHClass13Start Self

Set WeaponBase to TempWeapon.GetBaseObject
Set Weapon1Base to CloneForm WeaponBase
Set Weapon1 to (Self.PlaceAtMe Weapon1Base 1, 0, 0,)
Weapon1.Activate Self
Self.EquipItem Weapon1
End

 

 

UD Function for cloned weapon

 

Scriptname UDCFHClass13Start

Ref Target

Array_var Weapons


Ref TempWeapon
Ref InventoryItem

Float IISpeed
Float IIReach
Float IIDamage
Float IIRating
Float TempWeaponRating

Short Key

Begin Function {Target}
Let Weapons := (Target.GetItems 33)
Let Key := ar_Size Weapons

While Key > 0
Let Key -= 1
Let InventoryItem := Weapons[Key]

If (InventoryItem.IsWeapon == 0)
Continue
ElseIf (InventoryItem.GetWeaponType != 0)
Continue
ElseIf ((GetWeaponReach InventoryItem) > 0.7)
Continue
Else
Set IISpeed to (GetWeaponSpeed InventoryItem)
Set IIReach to (GetWeaponReach InventoryItem)
Set IIDamage to (GetAttackDamage InventoryItem)
Set IIRating to (IIDamage * IISpeed * IIReach * IIReach)
If IIRating > TempWeaponRating
Set TempWeapon to InventoryItem
Set TempWeaponRating to IIRating
EndIf
EndIf
Loop

SetFunctionValue TempWeapon
End[/Code]

 

 

UD Function for updating the weapon. With this one the function is told which weapon is the cloneform so it doesn't consider it as an option

 

[Code]Scriptname UDCFHClass13Update

Ref Target
Ref Clone

Array_var Weapons


Ref TempWeapon
Ref InventoryItem

Float IISpeed
Float IIReach
Float IIDamage
Float IIRating
Float TempWeaponRating

Short Key

Begin Function {Target, Clone}
Let Weapons := (Target.GetItems 33)
Let Key := ar_Size Weapons

While Key > 0
Let Key -= 1
Let InventoryItem := Weapons[Key]

If (InventoryItem.IsWeapon == 0)
Continue
ElseIf (InventoryItem.GetWeaponType != 0)
Continue
ElseIf (InventoryItem == Clone)
Continue
ElseIf ((GetWeaponReach InventoryItem) > 0.7)
Continue
Else
Set IISpeed to (GetWeaponSpeed InventoryItem)
Set IIReach to (GetWeaponReach InventoryItem)
Set IIDamage to (GetAttackDamage InventoryItem)
Set IIRating to (IIDamage * IISpeed * IIReach * IIReach)
If IIRating > TempWeaponRating
Set TempWeapon to InventoryItem
Set TempWeaponRating to IIRating
EndIf
EndIf
Loop

SetFunctionValue TempWeapon
End[/Code]

 

 

This just determines the effective level for neutral characters (the NPCs will 'level' up in a faction as they're used, but depending on being Good Evil or Neutral they have requirements on fame/infamy/renown which changes the effective level)

 

[Code]Scriptname UDCFHCompanionLevelNeutral

Ref Target

Float Level
Float Fame
Float Infamy
Float Renown

Begin Function {Target}
Set Level to (Target.GetFactionRank CFHCompanionLevelFaction)
Set Fame to GetPCFame
set Infamy to GetPCInfamy
Set Renown to (Fame + Infamy)
If (Level > (Renown / 3))
Set Level to (Renown / 3)
EndIf

SetFunctionValue Level
End[/Code]

 

 

As long as it works I'm pretty happy with this for now :biggrin:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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