Jump to content
  • 0

Make Script command NPC to do arbitrary code


Satoh

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/24/12
  • Last Seen:  

I'm hoping I won't need a source mod for this.

 

I'm looking for a way to send commands to another NPC from a utility script.

I know I could add event labels to the NPC and use cmdothernpc, but I'm trying to create something of a generic function to command any NPC to do this one function.

 

The function I want to use is npcwalkto, which has no deferred form like movenpc does, but I may think of others as well.

 

Is there a way to send full functions to another script in that way? (As opposed to telling another script to execute its own events)

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/24/12
  • Last Seen:  

"the event code of all NPCs with given label will be invoked"

 

The problem with that is that the NPC I'd like to command would not have a special event label.

I want to have my script run itself, through another NPC, rather than having my script call an event another NPC was already coded to do.

 

The reason for that is that I plan to have the event run on any NPC, regardless of what it does.

I guess you could call it a global controller script?

 

What I want to do is sort of like the inverse of a callfunc...

The more I think about it the more it seems like I'd need to modify the NPC source to route functions from one to another that way...

 

Example: Script A wants NPC B to walk 4 steps south. Script A has code to do this, NPC B does not. Script A would execute its own code, but have it act on NPC B instead of itself.

 

EDIT: Ok, I've scoured the documents and command lists as hard as I possibly can, I've tried a number of things, none of them work. I'm calling this impossible, pending source mods.

Edited by Satoh
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

What about

 

*donpcevent "<NPC object name>::<event label>";

This command invokes the event label code within an another NPC or NPCs. It
starts a separate instance of execution, and the invoking NPC will resume
execution its immediately.

If the supplied event label has the form "NpcName::OnLabel", then only given
NPC's event label will be invoked (much like 'goto' into another NPC). If the
form is "::OnLabel" (NPC name omitted), the event code of all NPCs with given
label will be invoked, one after another.
In both cases the invoked script
will run without an attached RID, whether or not the invoking script was
attached to a player. The event label name is required to start with "On".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...