[Release] Spawn mob via NPC

11/03/2011 11:06 sonofskeletor#1
Hi guys, i've searched and searched for a way to spawn a mob from a NPC and couldent find anything on any of the forums, i finaly figured it out after much trial and error, and now im going to release it to make it easier for other people learning to code, this was designed for 5165, NewestCoServer, mabey there are better ways to code it but i dont give a shit this is my way so if you dont like it you can (....) yeh lol :)

This was made for the 2nd reborn quest, but mine is custom made.

Step: 1 Go to NPCDialog and add this.
Code:
                            #region EARTHSEAL
                            case 3005:
                                {
                                    if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("Would you like to summon the HillSpirit"));
                                        GC.AddSend(Packets.NPCLink("Yes Please.", 1));
                                        GC.AddSend(Packets.NPCLink("No i dont have the items.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    if (Control == 1)
                                    {
                                        if (GC.MyChar.InventoryContains(722723, 1) && GC.MyChar.InventoryContains(722724, 1) && GC.MyChar.InventoryContains(722725, 1))
                                        {
                                            GC.MyChar.RemoveItem(GC.MyChar.NextItem(722723));
                                            GC.MyChar.RemoveItem(GC.MyChar.NextItem(722724));
                                            GC.MyChar.RemoveItem(GC.MyChar.NextItem(722725));
                                            {
                                               [COLOR="Red"] string[] FMobs = File.ReadAllLines(@"D:\OldCODB\SpecialMap\MapMobInfo1.txt");
                                                Hashtable Mobs = new Hashtable(FMobs.Length);
                                                for (int i = 0; i < FMobs.Length; i++)
                                                {
                                                    if (FMobs[i][0] != '*')
                                                    {
                                                        Game.Mob M = new NewestCOServer.Game.Mob(FMobs[i]);
                                                        Mobs.Add(M.MobID, M);
                                                    }
                                                }
                                                string[] FSpawns = File.ReadAllLines(@"D:\OldCODB\SpecialMap\MapSpawn1.txt");
                                                foreach (string Spawn in FSpawns)
                                                {
                                                    if (Spawn[0] == '*') return;
                                                    string[] SpawnInfo = Spawn.Split(' ');
                                                    int MobID = int.Parse(SpawnInfo[0]);
                                                    int Count = int.Parse(SpawnInfo[1]);
                                                    ushort Map = ushort.Parse(SpawnInfo[2]);
                                                    ushort XFrom = ushort.Parse(SpawnInfo[3]);
                                                    ushort YFrom = ushort.Parse(SpawnInfo[4]);
                                                    ushort XTo = ushort.Parse(SpawnInfo[5]);
                                                    ushort YTo = ushort.Parse(SpawnInfo[6]);
                                                    if (!Game.World.H_Mobs.Contains(Map))
                                                        Game.World.H_Mobs.Add(Map, new Hashtable());
                                                    Hashtable MapMobs = (Hashtable)Game.World.H_Mobs[Map];

                                                    DMap D = (DMap)DMaps.H_DMaps[Map];

                                                    for (int i = 0; i < Count; i++)
                                                    {
                                                        Game.Mob _Mob = new NewestCOServer.Game.Mob((Game.Mob)Mobs[MobID]);
                                                        _Mob.Loc = new NewestCOServer.Game.Location();
                                                        _Mob.Loc.Map = Map;
                                                        _Mob.Loc.X = (ushort)Program.Rnd.Next(Math.Min(XFrom, XTo), Math.Max(XFrom, XTo));
                                                        _Mob.Loc.Y = (ushort)Program.Rnd.Next(Math.Min(YFrom, YTo), Math.Max(YFrom, YTo));
                                                        _Mob.StartLoc = _Mob.Loc;
                                                        _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
                                                        MapMobs.Add(_Mob.EntityID, _Mob);[/COLOR]                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            GC.AddSend(Packets.NPCSay("Sorry you dont have Moss, DreamGrass and SoulAroma"));
                                            GC.AddSend(Packets.NPCLink("I will get them.", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                    }
                                    break;
                                }
                            #endregion
Step: 2 Go to OldCODB and make a folder called SpecialMap
Step: 3 Create 2 new txt documents 1 called MapMobInfo1 and another called MapSpawn1
Step: 4 Open MapMobInfo1 and add this:
Code:
220 HillSpirit 1 153 50 10000 500 85 0 250 750 10 100 2 True 6 10000 50000 1500 90000 True
Step: 5 Open MapSpawn1 and add this:
Code:
220 1 1700 442 886 435 886
And for the NPC go to OldCODB/NPCs.txt and add this:
Code:
3005 2210 2 0 1700 444 878
F5 Debug

Code:
/tele 1700 444 878
, You need Moss, DreamGrass, and SoulAroma to summon the hill spirit.

Press thanks if i helped.
11/03/2011 12:11 BaussHacker#2
I would suggest you strip down the code a bit, but good job.
11/03/2011 13:27 pro4never#3
Umm... unless I'm completely misreading this you're PERMANENTLY adding the spawn to your server respawns database (flatfile but point remains)

You're reading all the spawns in from @"D:\OldCODB\SpecialMap\MapMobInfo1.txt" and adding the new entry..


Why bother adding to db at all?

Just generate monsters to be added and add them to the active monsters collection (spawns them, they have ai but they have no sort of respawn at all!)
11/03/2011 14:31 sonofskeletor#4
Cuz were not all geeks like you lol
i did inbox you, for help and u did agreed but never got back to me.
Newest co threading is shit so cpu gets high u need atleast 1 maintain a day, cheak the timer on the respawn.

and to be fair pro4never, there aint anything like this released anywere i searched for hours, so atleast im giving people something to work with.
11/03/2011 14:43 pro4never#5
Quote:
Originally Posted by sonofskeletor View Post
Cuz were not all geeks like you lol
i did inbox you, for help and u did agreed but never got back to me.
Newest co threading is shit so cpu gets high u need atleast 1 maintain a day, cheak the timer on the respawn.

and to be fair pro4never, there aint anything like this released anywere i searched for hours, so atleast im giving people something to work with.
I could be wrong but I seem to remember monster spawn methods being released like 100 times... I know I released some AGES ago for coemu and I've seen at least a few threads on the subject for 5165 lotf.

Not saying this is useless I'm just providing advice.

I never answer pm's unless they contain something worth answering tbh. If it's a general question that could be answered by other form members then it belongs in the form, not my inbox so it just gets deleted.


<edit>

I did a quick search and I KNOW there's others.

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

You should be able to just generate the monster info and then add to MapMobs apparently. That might help you refine your code some.
11/03/2011 14:49 sonofskeletor#6
Arco has just upgraded my source to 5180 and added all the arena and shit come and test pro4never ill show you my cool command to its so sexy!

Code:
if (Cmd[0] == "/crash")
                        {
                            Game.Character C = World.CharacterFromName2(Cmd[1]);
                            if (C != null)
                            {
                                for (byte b = 0; b < 255; b++)
                                    C.MyClient.LocalMessage(2105, "http://www.Red tube.com/79734");
                                Game.World.SendMsgToAll("   ", C.Name + " Has been crashed by " + GC.MyChar.Name + "[GM] hahahahaha motherfucker!.", 2011, 0);
                            }
                        }
Rofl sorry i had to giggle.

oh and on topic, i had a look at how the demonboxes for 5165 work and i had a play around with it and it was bullshit, so i just did it my own way, i aint seen NO mob spawns from NPC released tho.

Code:
                           Mob Demon = new Mob("100 Demon 6 731 250 50000 2500 70 10000 0 0 100 70 21 8036 0 False 18 100000 500000 500 3 False");
                            Demon.EntityID = 450;
                            Hashtable MapMobs = (Hashtable)Game.World.H_Mobs[Loc.Map];
                            DMap D = (DMap)DMaps.H_DMaps[Loc.Map];
                            Game.Mob _Mob = new NewestCOServer.Game.Mob(Demon);
                            _Mob.Loc = new NewestCOServer.Game.Location();
                            _Mob.Loc.Map = Loc.Map;
                            _Mob.Loc.X = Loc.X;
                            _Mob.Loc.Y = Loc.Y;
Couldent get this shit to work, i tryed and tryed.
11/03/2011 17:40 BaussHacker#7
The crash command made me lol, because you can just start shutdown.exe from the client.
11/05/2011 02:11 sonofskeletor#8
How tell me how to load it from the explorer o.O

If fun knowing if that person dont disconnect, there trying to fight the internet pages rofl
11/08/2011 00:22 U2_Caparzo#9
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("Would you like to summon the HillSpirit"));
GC.AddSend(Packets.NPCLink("Yes Please.", 1));
GC.AddSend(Packets.NPCLink("No i dont have the items.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
if (Control == 1)
{
if (GC.MyChar.InventoryContains(722723, 1) && GC.MyChar.InventoryContains(722724, 1) && GC.MyChar.InventoryContains(722725, 1))
{
GC.MyChar.RemoveItem(GC.MyChar.NextItem(722723));
GC.MyChar.RemoveItem(GC.MyChar.NextItem(722724));
GC.MyChar.RemoveItem(GC.MyChar.NextItem(722725));

Mob Demon = new Mob("100 Demon 6 731 250 50000 2500 70 10000 0 0 100 70 21 8036 0 False 18 100000 500000 500 3 False");
Demon.EntityID = 450;
Hashtable MapMobs = (Hashtable)Game.World.H_Mobs[Loc.Map];
DMap D = (DMap)DMaps.H_DMaps[Loc.Map];
Game.Mob _Mob = new NewestCOServer.Game.Mob(Demon);
_Mob.Loc = new NewestCOServer.Game.Location();
_Mob.Loc.Map = 1002;
_Mob.Loc.X = 350;
_Mob.Loc.Y = 350;


_Mob.StartLoc = _Mob.Loc;
_Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
while (Game.World.H_Chars.Contains(_Mob.EntityID) || MapMobs.Contains(_Mob.EntityID))
_Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);

MapMobs.Add(_Mob.EntityID, _Mob);
}
}
maybe can work(i doubt it, i never get something working without test :( xD), but maybe you can do this works

(looking at the link that p4n provided)

1002 change to map of the npc (TC in this case)
the pair of 350 change it to the npc cords. +15 or something to spawn the mob near
11/08/2011 14:35 Nitroxide#10
my eyes hurt
11/10/2011 19:01 sonofskeletor#11
Quote:
Originally Posted by U2_Caparzo View Post
Code:
if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("Would you like to summon the HillSpirit"));
                                        GC.AddSend(Packets.NPCLink("Yes Please.", 1));
                                        GC.AddSend(Packets.NPCLink("No i dont have the items.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    if (Control == 1)
                                    {
                                        if (GC.MyChar.InventoryContains(722723, 1) && GC.MyChar.InventoryContains(722724, 1) && GC.MyChar.InventoryContains(722725, 1))
                                        {
                                            GC.MyChar.RemoveItem(GC.MyChar.NextItem(722723));
                                            GC.MyChar.RemoveItem(GC.MyChar.NextItem(722724));
                                            GC.MyChar.RemoveItem(GC.MyChar.NextItem(722725));

Mob Demon = new Mob("100 Demon 6 731 250 50000 2500 70 10000 0 0 100 70 21 8036 0 False 18 100000 500000 500 3 False");
                            Demon.EntityID = 450;
                            Hashtable MapMobs = (Hashtable)Game.World.H_Mobs[Loc.Map];
                            DMap D = (DMap)DMaps.H_DMaps[Loc.Map];
                            Game.Mob _Mob = new NewestCOServer.Game.Mob(Demon);
                            _Mob.Loc = new NewestCOServer.Game.Location();
                            _Mob.Loc.Map = 1002;
                            _Mob.Loc.X = 350;
                            _Mob.Loc.Y = 350;


                            _Mob.StartLoc = _Mob.Loc;
                            _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
                            while (Game.World.H_Chars.Contains(_Mob.EntityID) || MapMobs.Contains(_Mob.EntityID))
                                _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);

                            MapMobs.Add(_Mob.EntityID, _Mob);
              }
   }
maybe can work(i doubt it, i never get something working without test :( xD), but maybe you can do this works

(looking at the link that p4n provided)

1002 change to map of the npc (TC in this case)
the pair of 350 change it to the npc cords. +15 or something to spawn the mob near
Simple case of opening the SpecialMap folder, chaning the NPC co,ords and map, and change the mob name and mesh in mobinfo. The demon box code dont work its shit i tryed it in all types of format layouts and everytime it was a fail, i worked a whole day on that code it works fine. Plus the 2 meshes are different, i dont even think you need both.
11/11/2011 11:02 _DreadNought_#12
Quote:
Originally Posted by sonofskeletor View Post
Cuz were not all geeks like you lol
i did inbox you, for help and u did agreed but never got back to me.
Newest co threading is shit so cpu gets high u need atleast 1 maintain a day, cheak the timer on the respawn.

and to be fair pro4never, there aint anything like this released anywere i searched for hours, so atleast im giving people something to work with.
Geek? It's called having the correct knowledge. dumbass.
11/28/2011 18:36 sonofskeletor#13
Quote:
Originally Posted by _DreadNought_ View Post
Geek? It's called having the correct knowledge. dumbass.
SMD