Jump to content

OnActivate question


Maegfaer

Recommended Posts

I have an OnActivate block in an object script attached to a chair. However, when the chair is activated by a NPC through an AI package, the OnActivate block does not run. When I activate it myself, it does work.

 

Is there any way for a script to detect when a chair has been activated by a NPC?

 

The NPC seems to bypass the OnActivate block and uses the default activation it seems.

Link to comment
Share on other sites

It depends on what happens in the script. If it's just focussed on the player. a la, player.additem...it won't work on the npc of course.

If possible, share the script and we can take a look at it.

Link to comment
Share on other sites

It depends on what happens in the script. If it's just focussed on the player. a la, player.additem...it won't work on the npc of course.

If possible, share the script and we can take a look at it.

 

Merely this doesn't work:

 

scn OnActivateChair

 

short Activated

 

begin OnActivate

if Activated == 0

set Activated to 1

endif

end

 

begin GameMode

if Activated == 1

MessageBox "Chair was activated by someone"

set Activated to 0

endif

end

 

 

 

I think it is because the NPC is in the middle of it's AI package when I enter the cell, i.e. the actor is supposedly already in that chair for a long time when I enter that cell. That's why the OnActivate block is skipped?

 

If that's so, is there any other way to get the ActionRef of the chair?

 

I was thinking of letting the chair cast a script effect spell with a small AOE on itself every 0.5 second to get the refID of the actor in the chair...

Link to comment
Share on other sites

Scripts on objects (save actors in high level processing) are only run if the player is in the same cell, so that could be it. I'm not sure if the OnActivate block can be triggered by the NPCs AI though.
Link to comment
Share on other sites

Scripts on objects (save actors in high level processing) are only run if the player is in the same cell, so that could be it. I'm not sure if the OnActivate block can be triggered by the NPCs AI though.

 

Thanks for your reply!

 

Do object scripts still run when the player just left the object's cell but that cell is still in the memory? I.e. if you walk back in there is no loading time.

 

And the variables in an Object script hold on to their values until the cell containing the object is reset, am I right?

Link to comment
Share on other sites

Scripts on objects (save actors in high level processing) are only run if the player is in the same cell, so that could be it. I'm not sure if the onactivate block can be triggered by the NPCs AI though.

 

NPC's go through the same onactivate scripts (when provided) that players do. I spent a quite entertaining time one night watching my companion try to steal stuff out of my COBL ingredients container in my house. She would try to open it and the onactivate would bring up the container menu - which of course she could not interact with. (Yes, I am easily amused. :teehee:)

 

The catch is the player pretty much has to be present for the NPC AI processing to take place in a timely fashion. When the player leaves the cell, NPC AIs might get processed every 15 minutes or so.

 

Also, quest scripts and actor (NPC) scripts are the ONLY scripts which will run when the player is not present.

Link to comment
Share on other sites

NPC's go through the same onactivate scripts (when provided) that players do. I spent a quite entertaining time one night watching my companion try to steal stuff out of my COBL ingredients container in my house. She would try to open it and the onactivate would bring up the container menu - which of course she could not interact with. (Yes, I am easily amused. :teehee:)

Well, I guess it's safe to assume the same thing applies to the chair then. :happy:

 

The catch is the player pretty much has to be present for the NPC AI processing to take place in a timely fashion. When the player leaves the cell, NPC AIs might get processed every 15 minutes or so.

 

Also, quest scripts and actor (NPC) scripts are the ONLY scripts which will run when the player is not present.

Yup, they will be run when the NPC's AI is evaluated. But keep in mind that this only applies to actors in high level processing/actors who don't have low level processing disabled.

Link to comment
Share on other sites

I found this to be untrue. When a NPC sits down on a chair by an AI package the OnActivate block is not run.

 

I tried this with merely:

 

Begin OnActivate

messagebox "Activated!"

end

 

The NPC walks to and sits down on the chair right before my eyes. No messagebox. I disabled the NPC and activate the chair myself, and the message pops up.

 

This is on a clean Oblivion install with SI and the latest update.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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