I've noticed some weird behavior from the Control-NPC script. I was playing around, testing out what is and isnt saved to the npc database ,by setting up some objects in Control-NPC's onCreated event. heres the code:
in the Control-NPC script...
PHP Code:
function onCreated() {
sendtorc("Control-NPC has been reset");
this.testobj = new TGraalVar();
this.testobj.join("test");
}
in the 'test' class' script...
PHP Code:
function onCreated() {
sendtorc("new test object created...");
}
Whats happening, is on the first reset, the message in Control-NPC's onCreated event is printed, then when test class is joined, the message in its onCreated event is printed aswell.. which makes sense.
Now...
On subsequent resets, the message in Control-NPC's onCreated event is still printed, but the one in the test class is not. If i add a new variable to Control-NPC, with a different name than before, joining the test class to it triggers the test classes onCreated event again, but like in the first case, it isnt triggered on subsequent resets.
Why? How does this make any sense? I was thinking it would be a good place to put recovery code, for when the npc server is restarted (in Control-NPC's onInitialized() event), or for setting things into motion that dont logically make any sense being tied to when a level is loaded, a player connects, or a player enters a level. But i dont see how this is possible.
I understand that Control-NPC is usually used to detect when a projectile lands, or when a player connects to the server. But what is its purpose in general? and how does it benifit from this behavior?
Someone told me NEVER EVER to reset Control-NPC, but i don't understand how i could do that, when its reset everytime its edited, and there are legitimate reasons for editing it.