about the multi-npc

May 21, 2012 at 7:54 AM

Hi Colinvella,

I have a question for you, the game "DungeonOrb" has Pig, Troll, Lizard, Wizard and Boss 5 kind of NPC. I want to create a game, each NPC has different actions from any other NPCs. Eg. 4 Trolls named Mike, Jack, Peter and Alice. How can I make them diferent responses.
I tried created a script for each of them, compiled successfully, but the running result was terrible. Mike sometimes will use Jack or Alice's script. everything goes to mess. I don't know how to fix it. Can you please give me some advice. 
Do you think is it possible to make it like a text MUD. each NPC/Object has a script file?
Thank you for your time to read my post.
Regards,
Leo
Coordinator
May 21, 2012 at 9:24 AM

Hi Leo,

Making distinct scripts for your different troll NPSs should not in principle be any different from assigning scripts to different enemy types as in the DoD example game. Are you sure you're not accidentally assigning multiple scripts to the same NPC? I'm not entirely sure, but it crossed my mind that you might have more than one script competing to control the same NPC.

Hope that helps,

Colin

May 23, 2012 at 1:16 AM
Hi Colin,
Thank you so much. You helped a lot. What I gonna do is creating a RPGS game. Player can chat with NPCs. And each NPC has variety responses. Add more TYPEs is a good way. If my game has 50 NPC, I need to get 50 TYPEs.if I want to add more. I have to change code. It seems not a final solution. I am trying put some new functions, like 'NpcName_functionName' in related script. Put a loop in enemy.cs to get more functions. Eg. Transfer the say() into mike_say(), Joy_say() etc.

What do you think?


Regards,
Leo


Sent from my iPhone

On 21/05/2012, at 17:24, "colinvella" <notifications@codeplex.com> wrote:

From: colinvella

Hi Leo,

Making distinct scripts for your different troll NPSs should not in principle be any different from assigning scripts to different enemy types as in the DoD example game. Are you sure you're not accidentally assigning multiple scripts to the same NPC? I'm not entirely sure, but it crossed my mind that you might have more than one script competing to control the same NPC.

Hope that helps,

Colin

Coordinator
May 23, 2012 at 8:45 AM

When it comes to a host function like say(), I don't think it is a good idea to clone it for each NPC. It could instead accept a parameter indicating the NPC id and the text to say. You would on the other hand need distinct scripts for each NPC to drive quests etc. Within such scripts, you could then make calls to say(...) amongst other things.

Keep also in mind that it is still possible to assign multiple scripts to the same NPC. For instance, you might assign a generic one to make NPCs wander around in a small area, like for example NPCs in RPG maker games. Such a script could be assigned to most NPCs, but each NPC would have his/her/its own additional unique quest script where applicable.

May 23, 2012 at 9:32 AM
I tried to use a parameter. While it was activated in one script. The function of other NPC got activated too. It was random. Every NPC's script a loop. For the wander that's fine. But how is others. You are right, I am looking for multi-script support. But I don't know how. Your code in conscript is too difficult to me to understand. I understand the scripts, but how it connected with the NPC. I am so frustrated. ;(



Sent from my iPhone

On 23/05/2012, at 16:45, "colinvella" <notifications@codeplex.com> wrote:

From: colinvella

When it comes to a host function like say(), I don't think it is a good idea to clone it for each NPC. It could instead accept a parameter indicating the NPC id and the text to say. You would on the other hand need distinct scripts for each NPC to drive quests etc. Within such scripts, you could then make calls to say(...) amongst other things.

Keep also in mind that it is still possible to assign multiple scripts to the same NPC. For instance, you might assign a generic one to make NPCs wander around in a small area, like for example NPCs in RPG maker games. Such a script could be assigned to most NPCs, but each NPC would have his/her/its own additional unique quest script where applicable.

Coordinator
May 23, 2012 at 11:00 AM
One way of handling it is to associate a collection of script execution objects with each NPC and run them for a short while at every iteration of your main loop. I suggest you have a look around to see how game engines handle scripting.
May 23, 2012 at 5:07 PM

Sounds I can put some code in update() of enemy.cs, to check if any NPC has a collision with the Player. If it does, change its wander script into chatting script. Otherwise just keep it going. Am I right? I did the judgement (NPC collision with the Player) in NPC script and I found it was very hard to control. Maybe I should do it in the code instead of script.

From: colinvella [email removed]
Sent: Wednesday, 23 May 2012 7:00 PM
To: yeeler@gmail.com
Subject: Re: about the multi-npc [conscript:356506]

From: colinvella

One way of handling it is to associate a collection of script execution objects with each NPC and run them for a short while at every iteration of your main loop. I suggest you have a look around to see how game engines handle scripting.