Jump to content

Running script on activation of any NPC with a token


Recommended Posts

I seem to have run into a wall while making my mod and would appreciate some help.

An NPC with an OnActivate block in their script starts that block instead of a conversation when activated. Is there any way to replicate that effect without having to add the script to specific NPCs in the Construction Set? I'd like it to be tied to a token (item, spell, doesn't matter) that I could add to or remove from any NPCs during gameplay.

Link to comment
Share on other sites

There shouldn't be a need for such complex solution. By editing of OnActivate block and inserting Activate command(s) in it will also begin a dialog.

scn RomRSeedNeeusOnActSCR

short m

begin OnActivate
	if IsActionRef playerRef
		if m == 0
			set m to 1
			Activate
			Message "You activated this NPC for a first time."
		else
			Activate
			Message "You activated this NPC again."
		endif
	else
		Activate
	endif
end

For example this simple script will show a message whenever you activate NPC and begin a dialog as normal.

Edited by RomanR
Link to comment
Share on other sites

I'm not very good at explaining the issue so please do bear with me here.

Your example script there would be an object script that'd need to be attached directly to specific NPCs in the Construction Set. That's exactly what I want to avoid doing. Let's say the player has a spell that you can use on ANY NPC you want to, and whoever it hits is put in a state where activating displays the message box instead of dialogue. Is this possible? I tried using an event handler and it did play the script but unfortunately it didn't block the dialogue.

 

Link to comment
Share on other sites

For now the only way I found is to use event handler to put a NPC into unconscious state and adding a token which will show message box and after a choice is made, it will reset that state. Main problem is that after reseting a unconscious flag the face didn't return to its original state. Using Update3D command worked, but the way this command works makes NPC blink.

Link to comment
Share on other sites

What if you have the spell set the actor to destroyed (SetDestroyed), which will stop the player from being able to activate them?  Will your OnActivate event still fire?  If so, you would need to do the 'SetDestroyed 0' to return the actor to normal.

I am guessing you are using the OnActivate event to catch this.  For further help please post your scripts.

  • Thanks 1
Link to comment
Share on other sites

  On 6/11/2024 at 1:34 AM, GamerRick said:

What if you have the spell set the actor to destroyed (SetDestroyed), which will stop the player from being able to activate them?  Will your OnActivate event still fire?  If so, you would need to do the 'SetDestroyed 0' to return the actor to normal.

I am guessing you are using the OnActivate event to catch this.  For further help please post your scripts.

Expand  

Yes, use of this command did the trick and all seems working as it should. As I used OnActivate event in combination with a token, my result is this:

  Reveal hidden contents

As you run Oblivion, reaching the main menu will initialize OnActivate event, editor ID of this quest is RomRActivateQST in CS (I was lazy to change that).

  Reveal hidden contents

This handler applies some filtering and adds a token to NPC which will do the rest of work. Notice the use showMBox quest variable present in previous quest script, so you must set this variable to nonzero value first .

  Reveal hidden contents

And this is what you wanted. In this example a token will show a message box and your choice will be printed to console. After this token will reset NPC's "destroyed" flag and detaches from inventory.

As mentioned earlier, this approach is propably overkill. But all you need is to set one variable "on/off". 

  • Thanks 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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