Jump to content

Disarm weapon script.


NameNotPresent

Recommended Posts

I am trying to make a script to disarm an opponents weapon, it is quite tricky. :psyduck: Also I am concerned about this causing save game bloat so I may also need a way to remove the weapon if it is not recovered, but how could I do that if the player is not in the same cell as the weapon? :confused:

Link to comment
Share on other sites

By "desarming an opponent's weapon" do yo mean unenchanting it?

No, I want the weapon to be knocked out of their hands, just like the special bonus from a side power attack.

 

if target.GetFatiguePercentage < .25 ;Chance to disarm target

set DisarmChance to GetRandomPercent +1

if DisarmChance <=100

set WeaponOfTarget to target.GetEquippedObject 16 ;get target's weapon

Let WeaponOfTargetArray := target.GetInvRefsForItem WeaponOfTarget

ForEach TempArray <- WeaponOfTargetArray

Let temp := TempArray["value"]

if temp.IsEquipped ==1

temp.unequipme

temp.DropMe

;temp.MoveToMarker target

break

endif

loop

endif

endif

 

Here is the disarm part of the script as it stands now. I don't think I am iterating over the array correctly. I know I can iterate over the whole inventory but this is more efficient. When I was iterating over the whole inventory the "MoveToMarker" part crashed the game. There was another method I tried that also crashed the game. Note conditions for the disarm have not been determined, I need to get the disarm working first.

 

What currently happens is the weapon is unequipped but not dropped.

Edited by NameNotPresent
Link to comment
Share on other sites


scn testDisarm
ref target
ref WeaponOfTarget
array_var TempArray
ref temp

ref temp
ref rf1
ref rf2
short sh1
float fl1

short removeOne

if removeOne
Let removeOne := 0
target.RemoveItemNS WeaponOfTarget 1
endif

if target.GetFatiguePercentage < .25 ;Chance to disarm target
if GetRandomPercent < 30 ;30% disarm chance
Let WeaponOfTarget := target.GetEquippedObject 16 ;get targets weapon
if WeaponOfTarget
ForEach TempArray <- target.GetInvRefsForItem WeaponOfTarget
Let temp := *TempArray
if temp.IsEquipped
Let rf1 := CreateTempRef WeaponOfTarget
Let fl1 := temp.GetCurrentHealth
rf1.SetCurrentHealth fl1
Let fl1 := temp.GetCurrentCharge
rf1.SetCurrentCharge fl1
Let rf2 := target.PlaceAtMe rf1 1 25 0
Let sh1 := target.GetPos z + 25
rf2.SetPos z sh1

Let removeOne := 1
break
endif
loop
endif
endif
endif
Link to comment
Share on other sites

How does the PlaceAtMe command in the post by lubronbrons compare to the Drop command? Maskar mentioned the Drop command could cause some savegame bloating, but how is PlaceAtMe different from it? Also, if the inventory item is removed, and a new one created, how would that affect persistent references, if a persistent weapon ref is picked up, equipped and disarmed? Or does persistent weapon ref exist as a concept?

 

Just a few questions that popped in mind, out of curiosity. :blush:

Link to comment
Share on other sites

for savegame bloat issue we can trust kuertee Clean Up mod, at least... :ermm:

 

but, to get a good clean script. preferably you should clean the mess by yourself using syntax Disable and DeleteReference

 

that is the best way to handle and prevent savegame bloat I think. since the PlaceAtMe command is pretty useful anyway,

 

I believe Maskar use some of PlaceAtMe too, but he clean the reference too with Disable and DeleteReference so no problem.....

 

ahh yeah !

 

I am still wondering why you change your name from Phillipetain to Contratethix ? :)

Link to comment
Share on other sites

I wouldn't use PlaceAtMe or Drop for disarming. Sure, you could build in some garbage collecting code, but I don't think it's worth the trouble/risk of bloating. It might be possible to trigger Oblivion's disarm function somehow, although I've never looked into that.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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