Forum C# How to make a NPC?

How to make a NPC?

Postby prsolucoes » March 26th, 2010, 7:33 pm

Hi,

I want make a NPC on server.

Basically is a player, but with a timer(3000 mls), that will make the player walk and interact with other players.

But how to add a new player on server manually?
prsolucoes
 
Posts: 47
Joined: March 18th, 2010, 3:20 pm

Re: How to make a NPC?

Postby Benjaminsen » March 28th, 2010, 11:25 am

The Players collection is limited to real players as they have connections and can send and receive messages. This would not be true for an NPC.

Thus if you want NPC's you would have to create your on data-model / system for this.
Should be fairly easy using server-side timers and events.

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: How to make a NPC?

Postby prsolucoes » March 28th, 2010, 12:39 pm

Hi,

Thansk for response. It was what i imagine that i have to do, but OK.

Another question based on this problem:

I can send the player object as parameter when send the message?

For example:

Code: Select all
Broadcast("USER_JOIN", player)


And i can send another class different from player as parameter?

For example:

Code: Select all
NPC npc = new NPC();
npc.setPosX(256);
npc.setPosY(128);

player.send("NPC", npc);


Another example:

Code: Select all
NPC npc1 = new NPC();
npc1.setPosX(256);
npc1.setPosY(128);
npc1.setPosZ(3);

NPC npc2 = new NPC();
npc2.setPosX(128);
npc2.setPosY(256);
npc2.setPosZ(3);

ArrayList npcs = new ArrayList();
npcs.Add(npc1);
npcs.Add(npc2);

player.send("NPC", npcs);
prsolucoes
 
Posts: 47
Joined: March 18th, 2010, 3:20 pm

Re: How to make a NPC?

Postby Benjaminsen » March 28th, 2010, 2:00 pm

The message format only support simple types.

Basically you will have to write out what data you want to send back and forward manually.

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to C#



cron