Larian Banner
Previous Thread
Next Thread
Print Thread
Determining NPC vs Human #555954
27/09/14 03:45 PM
27/09/14 03:45 PM
Joined: Aug 2014
Posts: 54
M
Mag Offline OP
journeyman
Mag  Offline OP
journeyman
M

Joined: Aug 2014
Posts: 54
I'm working on a multiplayer mod. Each character not controlled by a human will be controlled by the computer. The system I'm using to determine NPC or human is crashing the editor. Would you guys mind taking a look? The general idea is to do the following:

1. Teleport the party
2. Ungroup the party so they don't follow the leader
3. Record the position of all characters in a character DB
4. Wait 2 seconds to give humans a chance to move their character
5. Set a DB flag to enable the determination system
6. Get the position for all of the characters in Character DB again.
7. If the original position matches the new position record the character as a NPC. Once the NPCs have been recorded record the others as humans.

The code I've copy pasted assumes the character DB was built in the INIT section, the party has already been teleported and the flag to enable the system has been set. I left these out because they are all working.

Here's the code:
Click to reveal..


//Once the DB_NPCSet is turned on this process kicks off

IF
DB_SetNPCs(1)
AND
DB_Character(_NPC,_TeleportedtoRoom,_type,_chosen) //gets a list of characters
AND
DB_CharacterPosition(_NPC,_OldX,_OldY,_OldZ) //Gets each characters original position
AND
CharacterGetPosition(_NPC,_NewX,_NewY,_NewZ) //Gets each character's new location.
AND
_OldX == _NewX //Compares their old location to their new locaion
AND
_OldY == _NewY //If they all match,
AND
_OldZ == _NewZ // It's determined the player is a NPC
THEN
NOT DB_Character(_NPC,_TeleportedtoRoom,_type,_chosen);
DB_Character(_NPC,_TeleportedtoRoom,"NPC",_chosen);
NOT DB_SetNPCs(1);


IF
DB_Character(_Character,_TeleportedtoRoom,"unknown",_chosen) //looks to see if there are any characters in the DB which we don't have a type for
THEN
PROC_Record_Humans();

//************************PROC*****************************************

PROC // Records humans in the character DB.
PROC_Record_Humans()
AND
DB_Character(_character,_TeleportedtoRoom,"unknown",_chosen) //gets a list of characters who we don't have a type for yet.
THEN
NOT DB_Character(_character,_TeleportedtoRoom,"unknown",_chosen);
DB_Character(_character,_TeleportedtoRoom,"human",_chosen);



Last edited by Mag; 27/09/14 03:49 PM.
Re: Determining NPC vs Human [Re: Mag] #555959
27/09/14 05:05 PM
27/09/14 05:05 PM
Joined: Aug 2014
Posts: 54
M
Mag Offline OP
journeyman
Mag  Offline OP
journeyman
M

Joined: Aug 2014
Posts: 54
I figured it out. I needed to do the whole system as a procedure. It stopped crashing.

Re: Determining NPC vs Human [Re: Mag] #556165
01/10/14 09:32 AM
01/10/14 09:32 AM
Joined: Oct 2008
Posts: 62
A
ALF Offline
journeyman
ALF  Offline
journeyman
A

Joined: Oct 2008
Posts: 62
Do you not get the CharacterIsPlayer events for your player characters? You could catch those, add them to a database and every character that's not in that database must be an NPC.

Re: Determining NPC vs Human [Re: Mag] #556934
13/10/14 12:09 PM
13/10/14 12:09 PM
Joined: Feb 2011
Posts: 136
Blablabla Offline

member
Blablabla  Offline

member

Joined: Feb 2011
Posts: 136
Originally Posted By: Mag
I figured it out. I needed to do the whole system as a procedure. It stopped crashing.
It would be great if you posted the working code here.

Re: Determining NPC vs Human [Re: Mag] #558268
10/11/14 01:46 AM
10/11/14 01:46 AM
Joined: Aug 2014
Posts: 54
M
Mag Offline OP
journeyman
Mag  Offline OP
journeyman
M

Joined: Aug 2014
Posts: 54
At the beginning of the goal I unchained the party with CharacterDetachFromGroup. I put a trigger at the end of a path. Then If a character enters the trigger I know they are controlled by a human. Eventually I know the remaining characters are NPCs and so I set them as so and then move them where I need to.


Powered by UBB.threads™ PHP Forum Software 7.6.2