Jump to content

Disarm weapon script.


NameNotPresent

Recommended Posts

The script is good, but I have a little suggestion:

begin GameMode
	if GetGameRestarted
		RemoveEventHandler	"OnHealthDamage"	disarmWpnOnDmg
		SetEventHandler		"OnHealthDamage"	disarmWpnOnDmg
	endif
end 

There's no need to use RemoveEventHandler inside a GetGameRestarted block.

Event handlers only last for the session, so no handler could exists on game start and GetGameRestarted is true once, right when the game start.

So, when that code runs, there's still no event handler, and RemoveEventHandler has nothing to remove.

Link to comment
Share on other sites

If the disarm script is being triggered by being hit, then how exactly is this going to be different from what's already in the game? You might be able to do this by (temporarily) changing a few game settings when being hit (using event handlers).

It's very different: this script doesn't need a left/right power attack, can disarm even if the actor is blocking with a shield and it runs for whatever damage the actor takes (including fall damage, trap damage, lava damage and drown damage).

Yes, this may be the bad aspect: whatever the actor is damaged, he drop his weapon!

Edited by forli
Link to comment
Share on other sites

 

... Yes, this may be the bad aspect: whatever the actor is damaged, he drop his weapon!

 

 

yeah :) the script will support lava, drown, trap, falling

 

if we remove this line

elseif atker.IsActor == 0 ;only works if there is valid actor as attacker
	return
Link to comment
Share on other sites

I see two weak points and a little bug:

 

1) it works with magic damage too. This can be solved by adding an OnMagicApply event handler to catch spell hits and "mark" the actor somehow (with a token or an ability) to prevent the very next OnHealthDamage event (which should fire in the same frame or the next one) form dropping the weapon.

 

2) with continuous damage (magic effects with duration), it makes the actor unable to hold any weapon for the duration of the damage. Any weapon equipped in this time would be dropped immediately. This can't be easily countered with the above solution, as OnMagicApply event handler fire once for a magic effect, while OnHealthDamage event fires every frame the actor receive damage from it (for the whole duration).

You can't detect what's causing a continuous damage inside the OnHealthDamage, as you can't detect if the the current OnHealthDamage event has been caused by the magic effect with duration or if it has been caused from a new hit (even physical hit).

 

I guess we may consider the OnHit handler instead, which run once for hit (with OnMagicApply to filter magic attacks).

 

 

 

Bug: the script drops all stackable items of the same base object:

      Let sh1 := rf1.GetRefCount
      rf2.SetRefCount sh1
    break
  endif
loop
RemoveItemNS weapon sh

If you have 5 "Iron longsword" in your inventory, one of them equipped, and someone hit you, this code drops all 5 of them on the ground.

Edited by forli
Link to comment
Share on other sites

The 'drop all' current stack is intended :) I am too lazy to create the serious actual one ...

since it is more hassle ---> transfer the stack to another container then add it back

I just use simple method instead, just drop it all at once

 

yeah I know,

the real problem is the projectile : player's arrow or flying magic ball

I am aware of this script is not validated deep enough that's why I put this

;elseif atker.IsPowerAttacking == 0		;make the disarm only happen when power attacking only
;	return

the real detection of attack type is more advanced than this.

actually, I've created mod that detect correct attack type ( Hand, 1H 2H weapon, Magic, Bow + Arrow )

in here >>> Instant Kill Advanced http://www.nexusmods.com/oblivion/mods/47002

validate the projectile with the help of event handler on release and on spell cast

Link to comment
Share on other sites

Ok so I am using the PlaceAtMe method now which works fine though I will need to add removal of the weapon if it is not picked up.

 

set DroppedWeapon to target.PlaceAtMe WeaponOfTarget 1 64 0
set WeaponPosition to DroppedWeapon.getpos z +80

 

I am currently tweaking the bolded values as the weapon seems to collide with the actor causing the weapon to rocket away. :laugh:

 

Edit: fix the shooting off of the weapon by change the placeatme spawn to the right side of the actor.

Edited by NameNotPresent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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