Ok so this is sorta a mini/partial release. I'm tired and I really don't feel like finishing this (did conquer 1.0 not have blue mouse or is everything just fucked up on my end?...)
Anyways I wanted to finish up a blue mouse system for people but due to my own lazyness and stupidity I can't finish it up right now. Figured I may as well release what I have done for people to use.
THIS IS FOR COFUTURE CONQUER 1.0 SOURCE!
Co Emu will be virtually IDENTICAL, lotf will require a bit of conversion (you are welcome to do it if you want)
This is a simple way for people to add/remove npcs to their server while it's running via a command or have it used for npcs you want to move. Examples of uses would be...
-Blue mouse quest (as it exists on real co with randomly moving mice)
-Find the npc quest (random locations loaded from database. When used the npc jumps to a new location, etc)
-Having npcs only show up at certain times of days for events.
Or anything else you want really. Use some imagination!
Problem with current version: maybe I'm missing something but for the life of me I can't seem to de-spawn an npc client side unless I move my character. I'm sure it's simple enough but it's 3 am and I don't care to keep working on it (I've tried a few things... but w/e, no big deal)
Under Handlers>Functions.cs
So that's the spawn code for you as I currently have it. I was going to try to add custom npc names to it but again, lazy, late at night and I honestly forget how to do it.
Same area, simple despawn void for you
note I have 2 types. That's because for the uid of npcs I used a random value and to find them again I wanted to be able to use their npc script Id #. I included the other one for if you want to do it that way. Either one should work just fine (just go offscreen and back on and it will be gone)
Annndd simple command to use ingame to test it.
Implementation of the void is just that simple for any events, just use the Handler.NpcSpawn/DespawnNpc to control what is spawned where.
Anyways, hope some ppl enjoy it seeing as I'm never going to really use it.
Note: I just noticed when I was testing the early version of it... apparently I finished random events on my 1.0 server? wtf... I was playing and then it told me I missed my pk tournament. I didn't realize I ever finished that script :S
Anyways I wanted to finish up a blue mouse system for people but due to my own lazyness and stupidity I can't finish it up right now. Figured I may as well release what I have done for people to use.
THIS IS FOR COFUTURE CONQUER 1.0 SOURCE!
Co Emu will be virtually IDENTICAL, lotf will require a bit of conversion (you are welcome to do it if you want)
This is a simple way for people to add/remove npcs to their server while it's running via a command or have it used for npcs you want to move. Examples of uses would be...
-Blue mouse quest (as it exists on real co with randomly moving mice)
-Find the npc quest (random locations loaded from database. When used the npc jumps to a new location, etc)
-Having npcs only show up at certain times of days for events.
Or anything else you want really. Use some imagination!
Problem with current version: maybe I'm missing something but for the life of me I can't seem to de-spawn an npc client side unless I move my character. I'm sure it's simple enough but it's 3 am and I don't care to keep working on it (I've tried a few things... but w/e, no big deal)
Under Handlers>Functions.cs
Code:
public static void SpawnNpc(int id, int type, int subtype, int map, int x, int y, int direction, int flag)
{//blabla
{
{
Struct.NPC NPC = new Struct.NPC();
NPC.Direction = direction;
NPC.Flag = flag;
NPC.ID = id;
NPC.Map = map;
NPC.SubType = subtype;
NPC.Type = type;
NPC.X = Convert.ToUInt16(x);
NPC.Y = Convert.ToUInt16(y);
if (Start.Npcs.ContainsKey(NPC.ID))
{
while (Start.Npcs.ContainsKey(NPC.ID))
NPC.ID = Start.Rand.Next(100, 10000);
Console.WriteLine("Npc Id in use, selected random id: " + NPC.ID);
}
Start.Npcs.Add(NPC.ID, NPC);
foreach (KeyValuePair<uint, COClient> Clients in Start.Clients)
{
if (Clients.Value.Char.Map == NPC.Map && Calculation.CanSee(NPC.X, NPC.Y, Clients.Value.Char.X, Clients.Value.Char.Y))
{
Spawn.All(Clients.Value, true);
}
}
Console.WriteLine("Successfuly added npc to server");
}
}
}
Same area, simple despawn void for you
Code:
public static void DespawnNpc(int RemovalType, int ID)
{//blabla
switch (RemovalType)
{
case 1://Npc Type
{
foreach (KeyValuePair<int, Struct.NPC> LoopId in Start.Npcs)
{
if (LoopId.Value.Type == ID)
{
Start.Npcs.Remove(LoopId.Value.ID);
Console.WriteLine("Found type in for each loop! " + Convert.ToInt32(LoopId.Value.Type));
break;
}
}
break;
}
case 2://Npc Id
{
Start.Npcs.Remove(ID);
Console.WriteLine("Removed Npc ID: " + Convert.ToString(ID));
break;
}
}
}
Annndd simple command to use ingame to test it.
Code:
if (Splitter[0] == "/addnpc")
{
int NpcUid = Start.Rand.Next(100, 10000);
Handler.SpawnNpc(NpcUid, Convert.ToInt32(Splitter[1]), Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]), Convert.ToInt32(Splitter[4]), Convert.ToInt32(Splitter[5]), 2, Convert.ToInt32(Splitter[6]));
return 2;
}
Code:
if (Splitter[0] == "/removenpc")
{
Handler.DespawnNpc(1, Convert.ToInt32(Splitter[1]));
return 2;
}
Anyways, hope some ppl enjoy it seeing as I'm never going to really use it.
Note: I just noticed when I was testing the early version of it... apparently I finished random events on my 1.0 server? wtf... I was playing and then it told me I missed my pk tournament. I didn't realize I ever finished that script :S