Jump to content

How to detect weapon being readied/unsheathed


MaxYari

Recommended Posts

Hello beautiful people, subject says it all, to be specific I want to detect fists bein readied, so some way to put event onto ready animation maybe?
Any Ideas?

Or maybe there's some general way to detect that actor is in combat stance and then I can use this in a script to detect when player enters combat stance and check what is being used as a weapon?

Thanks in advance!

Edited by SinnerSmile
Link to comment
Share on other sites

Could IsWeaponOut help?

 

Ok, it's working, but now I need to know readied as soon as it occurs, so I'm checking for it each frame, the problem is that when i move from a cell that object (activator) is unloaded and my script doesn't run, is there a general elegant way of having script that runs each frame that will not stop when you move from cell to cell? Maybe a way to "attach" object to player so it'll move to different cells together with a player?

I guess i can move it to player pos inside my quest script but since that runs only each 5 sec or so - I will still potentially 5 sec of downtime upon entering the cell.

Link to comment
Share on other sites

What about adding this object straight to player's inventory ? The script attached to it can use GetContainer command to get the actor's reference and after its work is done, you can remove it by RemoveMe. It will also run each frame.

By an object do you mean weapon? It's not a weapon, I'm tryin to detect fists readied, but I actually fiddled around and figured that i can do

`set fQuestDelayTime to 1/60`

In order to make quest script run 60 times/sec, seems to be working fine, so I would hope it's solved for now, but thanks for the input :)

Link to comment
Share on other sites

No, I mean some sort of a "token"- instead of using an activator, you will use some (temporary) item which can be added to actor's inventory ( weapon, torch, etc.) with script attached. This will have the advantage that you don't need to worry about checking a positon, you will need only get actor's reference - the token will "move" with the player and also the script will always run each frame until the token is removed.

 

The token's script could be something like this:

 

ref actor

(some other variables)

 

begin OnAdd

set actor to GetContainer

end

 

begin GameMode

if actor == 0

set actor to GetContainer

endif

if actor && actor.IsWeaponOut

(do your stuff here)

RemoveMe ; all done

endif

end

 

In this case you need only add this "token'' by your quest script. I suggested it because you wanted to attach activator to a player and I thought this would be more elegant solution. However it will not be propably needed, as you found your own in the meantime.

Link to comment
Share on other sites

No, I mean some sort of a "token"- instead of using an activator, you will use some (temporary) item which can be added to actor's inventory ( weapon, torch, etc.) with script attached. This will have the advantage that you don't need to worry about checking a positon, you will need only get actor's reference - the token will "move" with the player and also the script will always run each frame until the token is removed.

 

The token's script could be something like this:

 

ref actor

(some other variables)

 

begin OnAdd

set actor to GetContainer

end

 

begin GameMode

if actor == 0

set actor to GetContainer

endif

if actor && actor.IsWeaponOut

(do your stuff here)

RemoveMe ; all done

endif

end

 

In this case you need only add this "token'' by your quest script. I suggested it because you wanted to attach activator to a player and I thought this would be more elegant solution. However it will not be propably needed, as you found your own in the meantime.

Hm, are you sure that this will work? Looks really interesting but i think I tried adding script onto object and it was only running when it was on the ground and not in the inventory!

Link to comment
Share on other sites

Scripts on objects in inventories (often called tokens) will always run while the actor the inventory of which it is in is near. In case of a token inside the player's inventory the script will run constantly, or I think, as I haven't checked for split-second interruptions when e.g. switching cells.

But I'm using tokens a lot myself to get certain scripts to run on certain actors, or the player, because assigning a script directly to an actor is limited to only 1 at a time and doing it this way will cause lots of conflicts with other mods, doing it with a quest script needs a huge database of tracked actors with long running loops. And so far they've always been working very reliably.

 

However, if this is only about the player, or any single actor, alone, doing it with a quest script is also fine. Their frequency can be fine-tuned just as much as any object script's. And the player's always easy to reference anyways.

Link to comment
Share on other sites

Yes, and if you need your script running also in inventory, you must add "begin MenuMode XXXX" part, where "XXXX" is number corensponding to particular menu you want to use. For example inventory number is 1002. If number is ommited, the script will run on every menu, but it is often undesired. The commands will be same as in "GameMode" part.

 

Some examples:

 

begin MenuMode ; run on every menu

(your stuff)

end

 

begin MenuMode 1002 ; run only in player's inventory menu

(commands here)

end

 

begin MenuMode

If (MenuMode 1002 != 0) || (MenuMode 1036 != 0) || (MenuMode 1008 != 0) ; run only on inventory, race and container/barter menu

...................

endif

end

 

You can get these numbers on wiki or, if you using OBSE, also in obse_command_doc file (Menu Codes part).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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