Aller au contenu

Photo

Strange script behaviour


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
El Condoro

El Condoro
  • Members
  • 148 messages
Do some script functions not work or operate differently when called from a server-based module than a client-based one? The reason I ask is that I have two scripts that work perfectly when called on a standalone module but fail to function when called when playing off a server.

1. The OnPerception one I have included below. The oNPC OnPerception script checks if the oArea has a LocalInt "perception" set - if it does, it fires, if not, it ends. Works perfectly normally but when run from a server the oNPC still walks to oPC and starts its conversation.

2. An area Heartbeat script checks if it's raining so that the NPCs wandering around can do the intelligent thing and go inside. Works perfectly normally but the NPCs become a bit dumb on the server and keep wandering around.

Any ideas helpful. I can simply remove the OnPerception script and not have much effect on the module but I would prefer to understand why it is happening. Both scripts rely on the script being able to determine which area the caller is in - I suspect the problem is there, but not sure what it is.

Cheers.

OnPerception script. ( I put the Delay in because I think the OnPerception script was running before the Heartbeat could kick in, but to no avail)

// NPC will move to PC within perception range and start their default conversation
// Place in the OnPerception script event of the NPC
void main()
{
 object oPC = GetLastPerceived();
 object oNPC = OBJECT_SELF;
 
 // Determine if perception script runs in this area
 object oArea = GetArea(oNPC);
 int iAreaPerception = GetLocalInt(oArea,"perception");
 if (iAreaPerception != 1)
 {
 return;
 }
 
 // Make sure perceived is PC
 if (GetIsPC(oPC))
 {
 ClearAllActions();
 DelayCommand(6.0,ActionMoveToObject(oPC,FALSE,2.0));
 ActionStartConversation(oPC,"",FALSE,FALSE,FALSE,TRUE);
 }
}

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
The thing is, your script is designed to fail safe. So the script is indeed finding a variable on the area that's set to 1, when any kind of error (invalid area, or wrong npc) should cause it to find no variable, or rather a value of 0.

So, my best guess is that some other script is setting the variable, and that's the script that's bugged. To test, simply re-name the "perception" variable, and change the script to check for the new name.

#3
SkywingvL

SkywingvL
  • Members
  • 351 messages
Note that all modules are "server"-based modules. Even when you play single player, there's a server part running behind the scenes, the same as in multiplayer -- just that it happens to run inside of nwn2main instead of talking to it over the network.



I believe the DM client includes a facility to dump the locals of an object, so that might be useful for better debugging this issue if Lugaid's recommendation doesn't get you all of the way there.

#4
El Condoro

El Condoro
  • Members
  • 148 messages
Just did some testing:



- changing the variable name did not fix the problem - still did exactly the same thing

- using the DM Client alone (without the ADL) the problem did NOT occur - the NPCs didn't use their OnPerception script, which is what is supposed to happen.



So something in the ADL settings (ClientCacheStrategy=2?) may be affecting the stored values. I will continue to check this out.

#5
El Condoro

El Condoro
  • Members
  • 148 messages
I had the server running from a shortcut using the -home alt-home-path setting. It was using the server staging location that I am keeping separate from the main My Documents folders to avoid issues with inadvertently playing with the ADL on and losing files. It has been working fine up until now.



When I use nwn2server and the normal My Documents folders the issue with the area LocalInt does not occur - everything works as it should.