[How to add monsters in Hellmouth]

03/09/2011 20:12 HackProvider#1
Hey guys,

I dont know what Im doing wrong

I added a MySqlReader for the MobSpawns
Quote:
public static void GetSpawns()
{

MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
cmd.Select("mobspawns");
uint Count = 0;
MySqlReader r = new MySqlReader(cmd);
while (r.Read())
{
MobSpawn S = new MobSpawn(r.ReadUInt16("Amount"), Dictionary.BaseMobs[r.ReadUInt16("SpawnMob")], r.ReadUInt16("X"), r.ReadUInt16("Y"), r.ReadUInt16("Spread"), r.ReadUInt16("Map"));
Count += (uint)S.Members.Count;

}
Console.WriteLine(Program.Title + " Spawning " + Count + " monsters into the world");


}
but there are no spawns at all..
so I looked in Spawn.cs

Quote:
public class MobSpawn
{
public Mob MobCoords(Mob M)
{
M.X = (ushort)Program.Rand.Next(X - Spread, Y + Spread);
M.Y = (ushort)Program.Rand.Next(Y - Spread, Y + Spread);
return M;
}
public MobSpawn(uint Amount, BaseMob Type, ushort BindX, ushort BindY,ushort Dist, ushort BindMap)

{
try
{
MobType = Type;
TotalSpawn = Amount;
X = BindX;
Y = BindY;
Spread = Dist;
if(!Dictionary.Maps.ContainsKey(BindMap))
{
Map = new Map(Enum.PkType.None);
Dictionary.Maps.ThreadSafeAdd(BindMap, Map);

}
for (uint I = 0; I < Amount; I++)
{
Mob M = new Mob();
M.Map = BindMap;
M = MobCoords(M);
int Tries = 10;
while (Tries > 0 && !Calculations.FreeCoord(M.X, M.Y, M.Map, M.Instance))
{ M = MobCoords(M); Tries--; }
M.UID = this.Map.MobCounter + I;
}
Map.MobCounter += Amount;
}

catch (Exception E) { Console.WriteLine(E.ToString()); }
}
public Dictionary<uint, Mob> Members = new Dictionary<uint, Mob>();
BaseMob MobType;
public uint TotalSpawn;
public uint TotalDead
{
get
{
uint Count = 0;
foreach (Mob M in Members.Values)
if (!M.Alive)
Count++;
return Count;
}
}
public ushort X, Y, Spread;
public Map Map;

}
}
I added a catch (Exception E) { Console.WriteLine(E.ToString()); } to gimme the errors,

and it said

Object reference is not set to an instance of an object,
I don't know how to solve this prob, Any advice?
Im still a learner , so a little help would be very appriciated :)

thanks in advance
03/09/2011 20:14 pro4never#2
What line is giving the null reference exception.

Chances are it's not reading in all the values.
03/09/2011 20:53 HackProvider#3
The errors are in line 36 and in line 40 as you can see on the attached file



thanks

Lines
36 M = MobCoords(M);
37 int Tries = 10;
38 while (Tries > 0 && !Calculations.FreeCoord(M.X, M.Y, M.Map, M.Instance))
39 { M = MobCoords(M); Tries--; }
40 M.UID = this.Map.MobCounter + I;
41 }
42 Map.MobCounter += Amount;
03/09/2011 22:40 12tails#4
probably M (guessing that is the monster) is nulled... or the Map is nulled... check then ^^
03/09/2011 23:03 _Emme_#5
What does the Count variable say, does it increase at all?
03/09/2011 23:08 HackProvider#6
Not sure but it says uint map.mobcounter ugh tried my best. What now? I guess i got no variable

Well i think my map is nulled,,, how can i fix it :s

* Still a C# Learner *
03/10/2011 16:37 RT-Gaming#7
Hmm , would be awesome if someone could explain it a bit better, I got the same prob :S

Thanks in advance
03/10/2011 17:28 Syst3m_W1z4rd#8
Quote:
Originally Posted by RT-Gaming View Post
Hmm , would be awesome if someone could explain it a bit better, I got the same prob :S

Thanks in advance
Looking at join date, then I would assume you're HackProvider.
03/10/2011 17:55 RT-Gaming#9
@Syst3m_W1z4rd

I am sorry, I'm not , are there any problems with that o.0 Im new here, or do I have to leave this thread?
03/10/2011 20:36 S/W#10
Quote:
Originally Posted by Syst3m_W1z4rd View Post
Looking at join date, then I would assume you're HackProvider.
Syst3m_W1z4rd

The Black Market: 0/0/0
Join Date: Nov 2010
And? WTF stop flame anothers!
03/10/2011 20:46 pro4never#11
So I just took a few seconds to open up the source...


Massive hint for you.

It's a total of 2 lines of code you need to add... and they are exactly related to what I said in the faq.

You need to add the monsters you are creating to the spawn and you need to add them to the map.

*gasp*

I'm sorry if my temper seems a tad short atm but this question has been brought up at LEAST 50 times in the past two days (seriously... every time I come back like 5 new ppl have added me on msn and that's the first thing they say) and it's getting a little old.

Adding the basic spawns is a very simple thing which I've essentially done for you. I suggest you read through the code and see what is missing... cause it's not missing much for that.

Movement/attacking/respawns/drops and anything advanced, you're on your own for that part (although I've also provided advice about that)
03/10/2011 21:59 S/W#12
Quote:
Originally Posted by pro4never View Post
So I just took a few seconds to open up the source...


Massive hint for you.

It's a total of 2 lines of code you need to add... and they are exactly related to what I said in the faq.

You need to add the monsters you are creating to the spawn and you need to add them to the map.

*gasp*

I'm sorry if my temper seems a tad short atm but this question has been brought up at LEAST 50 times in the past two days (seriously... every time I come back like 5 new ppl have added me on msn and that's the first thing they say) and it's getting a little old.

Adding the basic spawns is a very simple thing which I've essentially done for you. I suggest you read through the code and see what is missing... cause it's not missing much for that.

Movement/attacking/respawns/drops and anything advanced, you're on your own for that part (although I've also provided advice about that)
Cool you are one of members in epvpers who make most guides in coding glad to see you here so long....
03/11/2011 15:00 thomastur#13
I've been looking for more than 3 hours now, but I can't find the solution :S
any tips/help

thanks