We need to supply more live info about the NPCs, so we can do more cool stuff.
Need Input
Seeing NPCs suddenly be dead isn’t very interesting; we want to see them take damage, know who they’re fighting, etc. So I made a quick laundry list of NPC details we should be able to track:
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
CREATE TABLE [dbo].[LiveNPC](
[uniqueId] [int] NOT NULL,
[name] [nvarchar](255) NOT NULL,
[facet] [smallint] NOT NULL,
[land] [smallint] NOT NULL,
[map] [smallint] NOT NULL,
[xCord] [smallint] NOT NULL,
[yCord] [smallint] NOT NULL,
[zCord] [int] NOT NULL,
[level] [int] NOT NULL,
[hits] [int] NOT NULL,
[fullHits] [int] NOT NULL,
[mana] [int] NOT NULL,
[fullMana] [int] NOT NULL,
[lastCommand] [nvarchar](255) NOT NULL,
[lastActiveRound] [int] NOT NULL,
[firstActiveRound] [int] NOT NULL,
[isDead] [bit] NOT NULL DEFAULT (0),
[mostHatedId] [int] NULL,
[hateCenterX] [smallint] NULL,
[hateCenterY] [smallint] NULL,
[loveCenterX] [smallint] NULL,
[loveCenterY] [smallint] NULL,
[fearLove] [int] NULL,
[NpcTypeCode] [int] NULL ,
[BaseTypeCode] [int] NULL ,
[CharacterClassCode] [int] NULL ,
[AlignCode] [int] NULL ,
[numAttackers] [int] NULL,
[lairLocationX] [smallint] NULL,
[lairLocationY] [smallint] NULL,
[lairLocationZ] [int] NULL,
[priorityCode] [int] NULL,
[effects] [nvarchar](255) NULL
So out with the NPCLocation
table, in with the LiveNPC
table. I replaced the necessary logic, pulling what I needed from the NPC and Character classes. Lots of cut-paste-edit, with a couple of interesting bits:
|
|
|
|
143
144
145
146
@lastCommand,
@lastActiveRound,
@lastActiveRound,
@isDead,
|
|
I wanted to track dead NPCs, as long as they were still in the world, to see if there are any cases where they stick around while dead. So rather than checking IsDead, I have to see if they’ve been removed from the global NPC list yet.
Very Interesting

Matching Client
Of course, now that we’ve changed where the live NPC data is going, the client side will have to read from there. An easy change:
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
public static List<NPC> GetAllNpcs()
{
List<NPC> npclist = new List<NPC>();
using (SqlConnection tempConnection = DataAccess.GetSQLConnection())
using (SqlStoredProcedure sp = new SqlStoredProcedure("prApp_LiveNPC_by_MapID", tempConnection)) {
sp.AddParameter("@facet", SqlDbType.Int, 4, ParameterDirection.Input, 0);
sp.AddParameter("@land", SqlDbType.Int, 4, ParameterDirection.Input, 0);
sp.AddParameter("@map", SqlDbType.Int, 4, ParameterDirection.Input, 0);
DataTable dtNPCs = sp.ExecuteDataTable();
foreach (DataRow dr in dtNPCs.Rows)
{
NPC npc = new NPC();
npc.worldNpcID = Convert.ToInt32(dr["uniqueId"]);
npc.lastActiveRound = Convert.ToInt32(dr["lastActiveRound"]);
npc.Name = dr["name"].ToString();
npc.X = Convert.ToInt16(dr["xCord"]);
npc.Y = Convert.ToInt16(dr["yCord"]);
npc.Z = Convert.ToInt16(dr["zCord"]);
npclist.Add(npc);
}
}
return npclist;
}
