How do you make a monster spawn with a command?

01/08/2010 07:16 dragon89928#16
haha its all good thanks for the help :) Ill try adding it to the hashtable now.
01/08/2010 17:16 ~Yuki~#17
U dont need to restart the server after changes to flatfiles (never)
01/09/2010 00:20 dragon89928#18
Quote:
Originally Posted by ~Yuki~ View Post
U dont need to restart the server after changes to flatfiles (never)
You dont? Idk.. I tried it and it didnt work until i restarted the server. And what do you mean by never, how did you do it?
01/09/2010 18:47 pro4never#19
So I was bored and decided to give it a whirl.

Monsters are now able to be spawned by command. The version I coded is VERY poorly done and most of the values are hard coded to avoid messing things up myself.

I did it in CoEmu but it should be fairly similar.


Go to where your source controls monster spawning (in coEmu it's MonsterSpawn.cs. It should be a very obvious section regardless of source)

Then just copy the required section over to where your source handles player commands in a way that will allow you to change what you want (map, x, y, mobid, number of mobs)

In CoEmu the main line that actually controls the final spawning was a little something like...

ConquerPacket.ToLocal(ConquerPacket.SpawnMonster(M on.UID, MobInfo.Mesh, Mon.X, Mon.Y, MobInfo.Name, Mon.CurrentHP, Mon.Level, Mon.Direction), Mon.X, Mon.Y, Mon.Map, 0, 0);
ConquerPacket.ToLocal(ConquerPacket.MobSpawnEffect (Mon.UID, Mon.X, Mon.Y, Mon.Direction, 131), Mon.X, Mon.Y, Mon.Map, 0, 0);
Interlocked.Add(ref SpawnNumber, 1);

Note that the Interlocked.Add(ref SpawnNumber, 1); is just a section that was in the monsterspawn.cs file that controls if it should start spawning new ones (for ever monster it spawns it says "hey, I finished spawning this one. Do I need to spawn another?" basically controlling how many should be spawned. I just copied basically the entire section out of there for testing purposes so I haven't tried removing it. In mine I just set it to 1 and let it be.

For any sort of quest monster I'd strongly suggest adding a timer of some form to control respawn. if not you would have to summon it manually via command every time you want. You could always use a combination of adding to the database and reloading it if you wanted a recurring spawn though I suppose.

ooh and just cause I am extra bored. Screenshot

[Only registered and activated users can see links. Click Here To Register...]

They move, attack, die, drop items etc all like normal mobs should via cmd.
01/10/2010 04:23 dragon89928#20
Ahh thanks :). I took spare2's advice also and got it to work adding it to hashtables.