Hello, I will share with you a few NPCs I made for -impulse-'s source.
First is the SurgeonMiracle NPC to change size/gender for one dragonball.
In Dialogs.cs
Code:
#region SurgeonMiracle
case 111812:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Do you want to have your size changed so that you can become much more");
dialog.Text(" adorable? Now here is a precious chance for you.");
dialog.Option("I want to change my size.", 1);
dialog.Option("I want to change my gender.", 2);
dialog.Option("I don't want to change.", 255);
dialog.Send();
break;
}
case 1:
{
dialog.Text("If you pay me one dragonball, I can have your size changed. You will become");
dialog.Text("more attractive and start a fresh life. By the way, to avoid some unexpected");
dialog.Text("things, make sure you are not in any disguise form.");
dialog.Option("Here is a dragonball.", 3);
dialog.Option("I have no dragonball.", 255);
dialog.Send();
break;
}
case 2:
{
dialog.Text("If you pay me one dragonball, I can have your gender changed. You will become");
dialog.Text("more attractive and start a fresh life. By the way, to avoid some unexpected");
dialog.Text("things, make sure you are not in any disguise form.");
dialog.Option("Here is a dragonball.", 4);
dialog.Option("I have no dragonball.", 255);
dialog.Send();
break;
}
case 3:
{
if (client.Inventory.Contains(1088000, 1))
{
client.Inventory.Remove(1088000, 1);
client.Equipment.Remove(9);
int Model = (int)client.Entity.Body % 10;
switch (Model)
{
case 2:
case 4:
client.Entity.Body--;
break;
case 1:
case 3:
client.Entity.Body++;
break;
}
client.Send(new Message("Your size has been changed.", System.Drawing.Color.BurlyWood, Message.TopLeft));
EntityTable.SaveEntity(client);
client.Inventory.Remove(1088000, 1);
client.Equipment.Remove(9);
break;
}
else
{
dialog.Text("Sorry, there is no dragonball in your inventory. I can't have your size changed.");
dialog.Option("Ok, Sorry.", 255);
dialog.Send();
}
break;
}
case 4:
{
if (client.Inventory.Contains(1088000, 1))
{
client.Inventory.Remove(1088000, 1);
client.Equipment.Remove(9);
int Model = (int)client.Entity.Body % 10;
switch (Model)
{
case 3:
case 4:
client.Entity.Body -= 2;
break;
case 1:
case 2:
client.Entity.Body += 2;
break;
}
client.Send(new Message("Your gender has been changed.", System.Drawing.Color.BurlyWood, Message.TopLeft));
EntityTable.SaveEntity(client);
break;
}
else
{
dialog.Text("Sorry, there is no dragonball in your inventory. I can't have your size changed.");
dialog.Option("Ok, Sorry.", 255);
dialog.Send();
}
}
break;
}
break;
}
#endregion
Next up is the CPAdmin NPC
In Dialogs.cs
Code:
#region CPAdmin
case 111816:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Greetings, here you can exchange either a Dragonball or a DragonScroll for cps. ");
dialog.Text("One Dragonball will get you 215 cps and a DragonScroll will get you 2150. ");
dialog.Text("What would you like to trade? Or would you rather not?");
dialog.Option("Dragonball", 1);
dialog.Option("DragonScroll", 2);
dialog.Option("I'll just leave", 255);
dialog.Send();
break;
}
case 1:
{
lock (client.Inventory)
{
if (client.Inventory.Contains(1088000, 1))
{
client.Inventory.Remove(1088000, 1);
client.Entity.ConquerPoints += 215;
}
else
{
dialog.Text("You do not have a Dragonball");
dialog.Send();
}
break;
}
}
case 2:
{
lock (client.Inventory)
{
if (client.Inventory.Contains(721511, 1))
{
client.Inventory.Remove(721511, 1);
client.Entity.ConquerPoints += 2150;
}
else
{
dialog.Text("You do not have a DragonPack");
dialog.Send();
}
break;
}
}
}
break;
}
#endregion
Here is the armor/headgear tinter.
In Dialogs.cs
Code:
#region Tinter
case 11191:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("I can dye your armor or your headgear. Care to get started?");
dialog.Option("Armor", 1);
dialog.Option("Headgear", 2);
dialog.Option("I'll just leave", 255);
dialog.Send();
break;
}
case 1:
{
dialog.Text("What color armor would like sir?");
dialog.Option("White", 4);
dialog.Option("Purple", 5);
dialog.Option("Orange", 6);
dialog.Option("Light Blue", 7);
dialog.Option("Blue", 8);
dialog.Option("Red", 9);
dialog.Option("Yellow", 10);
dialog.Send();
break;
}
case 4:
{
IConquerItem armor = client.Equipment.TryGetItem(3);
if (armor != null && armor.ID != 0)
{
armor.Color = Conquer_Online_Server.Game.Enums.Color.White;
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
armor.Send(client);
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 5:
{
IConquerItem armor = client.Equipment.TryGetItem(3);
if (armor != null && armor.ID != 0)
{
armor.Color = Conquer_Online_Server.Game.Enums.Color.Purple;
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
armor.Send(client);
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 6:
{
IConquerItem armor = client.Equipment.TryGetItem(3);
if (armor != null && armor.ID != 0)
{
armor.Color = Conquer_Online_Server.Game.Enums.Color.Orange;
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
armor.Send(client);
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 7:
{
IConquerItem armor = client.Equipment.TryGetItem(3);
if (armor != null && armor.ID != 0)
{
armor.Color = Conquer_Online_Server.Game.Enums.Color.LightBlue;
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
armor.Send(client);
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 8:
{
IConquerItem armor = client.Equipment.TryGetItem(3);
if (armor != null && armor.ID != 0)
{
armor.Color = Conquer_Online_Server.Game.Enums.Color.Blue;
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
armor.Send(client);
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 9:
{
IConquerItem armor = client.Equipment.TryGetItem(3);
if (armor != null && armor.ID != 0)
{
armor.Color = Conquer_Online_Server.Game.Enums.Color.Red;
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
armor.Send(client);
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 10:
{
IConquerItem armor = client.Equipment.TryGetItem(3);
if (armor != null && armor.ID != 0)
{
armor.Color = Conquer_Online_Server.Game.Enums.Color.Yellow;
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
armor.Send(client);
armor.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 2:
{
dialog.Text("What color armor would like sir?");
dialog.Option("White", 11);
dialog.Option("Purple", 12);
dialog.Option("Orange", 13);
dialog.Option("Light Blue", 14);
dialog.Option("Blue", 15);
dialog.Option("Red", 16);
dialog.Option("Yellow", 17);
dialog.Send();
break;
}
case 11:
{
IConquerItem headgear = client.Equipment.TryGetItem(1);
if (headgear != null && headgear.ID != 0)
{
headgear.Color = Conquer_Online_Server.Game.Enums.Color.White;
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
headgear.Send(client);
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 12:
{
IConquerItem headgear = client.Equipment.TryGetItem(1);
if (headgear != null && headgear.ID != 0)
{
headgear.Color = Conquer_Online_Server.Game.Enums.Color.Purple;
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
headgear.Send(client);
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 13:
{
IConquerItem headgear = client.Equipment.TryGetItem(1);
if (headgear != null && headgear.ID != 0)
{
headgear.Color = Conquer_Online_Server.Game.Enums.Color.Orange;
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
headgear.Send(client);
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 14:
{
IConquerItem headgear = client.Equipment.TryGetItem(1);
if (headgear != null && headgear.ID != 0)
{
headgear.Color = Conquer_Online_Server.Game.Enums.Color.LightBlue;
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
headgear.Send(client);
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 15:
{
IConquerItem headgear = client.Equipment.TryGetItem(1);
if (headgear != null && headgear.ID != 0)
{
headgear.Color = Conquer_Online_Server.Game.Enums.Color.Blue;
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
headgear.Send(client);
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 16:
{
IConquerItem headgear = client.Equipment.TryGetItem(1);
if (headgear != null && headgear.ID != 0)
{
headgear.Color = Conquer_Online_Server.Game.Enums.Color.Red;
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
headgear.Send(client);
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
case 17:
{
IConquerItem headgear = client.Equipment.TryGetItem(1);
if (headgear != null && headgear.ID != 0)
{
headgear.Color = Conquer_Online_Server.Game.Enums.Color.Yellow;
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
headgear.Send(client);
headgear.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
}
else
{
dialog.Text("Your not wearing any armor right now. Therefore, I can't do anything.");
dialog.Option("Ah alright.", 255);
dialog.Send();
}
break;
}
}
break;
}
#endregion
Now, here is an npc to give super +12 double sdg -7 255 enchant items
it uses the helpdesk npc in tc
In Dialogs.cs above
Code:
public static ISkill LearnableSpell(ushort spellid)
#region HelpDesk
case 12111:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("What free item would you like?");
dialog.Option("BuriedBlade", 1);
dialog.Option("Blizzard", 2);
dialog.Option("Thunder", 3);
dialog.Option("MagicCoronet", 4);
dialog.Option("CrystalEarrings", 5);
dialog.Option("Tornado", 6);
dialog.Option("KingsClub", 7);
dialog.Option("KingofSword", 8);
dialog.Send();
break;
}
case 1:
{
if (client.Inventory.Count < 40)
{
AwardItem(410339, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
case 2:
{
if (client.Inventory.Count < 40)
{
AwardItem(160249, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
case 3:
{
if (client.Inventory.Count < 40)
{
AwardItem(150249, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
case 4:
{
if (client.Inventory.Count < 40)
{
AwardItem(118109, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
case 5:
{
if (client.Inventory.Count < 40)
{
AwardItem(117099, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
case 6:
{
if (client.Inventory.Count < 40)
{
AwardItem(120249, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
case 7:
{
if (client.Inventory.Count < 40)
{
AwardItem(480339, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
case 8:
{
if (client.Inventory.Count < 40)
{
AwardItem(420339, client);
break;
}
else
{
client.Send(Constants.FullInventory);
break;
}
}
}
break;
}
#endregion
MillionaireLee
Code:
#region MillionaireLee
case 111811:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hello, I can take your meteors and dragonballs and pack them for you. ");
dialog.Text("Did I mention my services are free?");
dialog.Option("Pack my meteors.", 1);
dialog.Option("Pack my dragonballs.", 2);
dialog.Option("I'd rather leave", 255);
dialog.Send();
break;
}
case 1:
{
lock (client.Inventory)
{
if (client.Inventory.Contains(1088001, 10))
{
client.Inventory.Remove(1088001, 10);
client.Inventory.Add(720027, Enums.ItemEffect.None);
client.Send(new Message("Your meteors have successfully been packed.", System.Drawing.Color.Blue, Message.TopLeft));
}
else
{
dialog.Text("You do not have enough meteors for this.");
dialog.Option("Okay, sorry sir", 255);
dialog.Send();
}
}
break;
}
case 2:
{
lock (client.Inventory)
{
if (client.Inventory.Contains(1088000, 10))
{
client.Inventory.Remove(1088000, 10);
client.Inventory.Add(720028, Enums.ItemEffect.None);
client.Send(new Message("Your dragonballs have successfully been packed.", System.Drawing.Color.Blue, Message.TopLeft));
}
else
{
dialog.Text("You do not have enough dragonballs for this.");
dialog.Option("Okay, sorry sir", 255);
dialog.Send();
}
}
break;
}
}
break;
}
#endregion
I hope you like them. Good day.
EDIT: Added garment unequip for SurgeonMiracle and added MillionaireLee.
blehh I suppose I should have read this first seeing as I just coded some very similar stuff... and didn't notice alot of the functions I coded were already added into the source apparently.
Great reference material for people looking to learn to code. I assume doing the client.entity.conquerpoints +=/-= will update database? I'm so used to CoEmu that I was writing up functions for saving everything and updating stuff as i went through :P
Here's my version.... not that anyone needs it with yours being alot cleaner looking and presumably working perfectly.
All my functions are placed directly above
Code:
public static void GetDialog(NpcRequest npcRequest, GameState client)
but I suppose they could be anywhere.
PHP Code:
public static bool ChangeCPs(int amount, GameState client)
{
if (client.Entity.ConquerPoints + amount > 0)//DO NOT ALLOW NEGATIVE CP
{
client.Entity.ConquerPoints += (uint)amount;
EntityTable.SaveEntity(client);
return true;
}
else
{
ErrorMsg("You do not have enough CPs", client);
return false;
}
}
public static bool ChangeGold(int amount, GameState client)
{
if (client.Entity.Money + amount > 0)//remove money, DO NOT ALLOW NEGATIVE SILVER
{
client.Entity.Money += (uint)amount;
EntityTable.SaveEntity(client);
return true;
}
else
{
ErrorMsg("You do not have enough gold", client);
return false;
}
}
public static void ErrorMsg(string error, GameState client)
{
Dialogs dialog = new Dialogs();
dialog.Client = client;
dialog.Replies = new List<NpcReply>();
if (error.Length < 100)
{
dialog.Text(error);
dialog.Option("Sorry...", 255);
dialog.Send();
}
else
{
Console.WriteLine("You have entered an ErrorMsg greater than 100 characters in your NPC Dialogs!");
Console.WriteLine("Problem string: " + error);
}
}
Then changed the save entity to cover money and CP's (as by default it doesn't). I was gonna add a separate database function to update just money/cp but I never got around to it.
annddd my lil script for Cp Admin
PHP Code:
case 111816: //CP admin
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("I'm looking to buy DragonBalls. Do you have any?");
dialog.Option("DragonBall (215Cp)", 1);
dialog.Option("DBScroll (2150Cp)", 2);
dialog.Option("I'm saving them.", 255);
dialog.Send();
break;
}
case 1:
{
if (client.Inventory.Contains(1088000, 1))//db id
{
client.Inventory.Remove(1088000,1);
dialog.Text("Please check your inventory, I have added 215 CPs");
dialog.Option("I have more", 0);
dialog.Option("Thanks", 255);
dialog.Send();
ChangeCPs(215, client);
}
else
ErrorMsg("You don't have a DragonBall in your inventory!", client);
break;
}
case 2:
{
if (client.Inventory.Contains(720028, 1))//dbscroll id
{
dialog.Text("Please check your inventory, I have added 2150 CPs");
dialog.Option("I have more", 0);
dialog.Option("Thanks", 255);
dialog.Send();
ChangeCPs(2150, client);
}
else
ErrorMsg("You don't have a DBScroll in your inventory!", client);
break;
}
}
break;
}
Anyways, yours is probably quite a bit better but figured that I may as well throw mine out there as well. Kinda pissed at myself for not having noticed that alot of what I wanted was already in the source but ah well... next time I'll know :P
hmm tbh im not sure if it will save. I'll have to update entitysave as well. thanks for the heads up. And I like the functions it makes it a little more user friendly. instead of typing out client.Inventory.ConquerPoints and such.
Ofcource I know that, if I add it @ the bottom it doesn't work? o.0
Can you explain me where I have to add it? (Impulses source)
as far as i remember it called dialogs.cs or most likely npcs.cs
you should add it "@" where ever it's possible to add it
if it's looping for all npcs no matter the map then add it anywhere if it's looping throw maps (to save cpu cycles) then add it on the right map section which would actually be a case for a switch on map id
but trust me , you don't need to add npcs as much as you need to learn some programming
for whoever care about those codes i would like to point out some stuff
at first npc
at trinity the "client.Inventory.Remove" is a bool method which you can use instead of "client.Inventory.Contains" , so you loop once trying to remove the item and if it doesn't exist it will return false , saving cpu cycles
you may also switch on the body mesh without having one more variable
you may also notice that it takes the db twice
at the second npc
you should not lock the inventory everytime you are on an npc doin something , you should lock it while removing/adding something , aka on the event not on every npc
To be honest you shouldn't use the remove method as a contains method, because there is times where you don't want to remove it, but still want to know if the item is there.
To be honest you shouldn't use the remove method as a contains method, because there is times where you don't want to remove it, but still want to know if the item is there.
i didn't say you always should use the removing method unless you are actually removing and just don't check as the removing method is bool which will do the check
at nextco i've had overloaded the removing method too much ex. removeIRONORES , removeGoldOres, RemoveMeteorsAndTears, removeOnlyBounded , RemoveOnlyunBounded, RemoveAny , removeStack , pla pla pla
and all those bool overloaded methods was having a bool parameter to actually just check or check and remove (duno if it's smart or i was lazy to redo them all to be contains methods)
[HELP] Impulse Source 07/29/2010 - CO2 Private Server - 0 Replies Hey guys I have been at this for the last two days, Someone told me to take the way the Portals are loaded and use that to Spawn Mobs.
First please don't flame I am trying and probably got it very very wrong.
Ok my problem is I have made the Sql Files and added all the mobs to it. I do not know how to make the source read the Sql files and make them appear on the client screen.
Like I said I have been at this for days and can't figure it out. Many guides have been read and alot of googling...
[Release]NPCs for Coemu V2 source 06/26/2009 - CO2 PServer Guides & Releases - 2 Replies Post here the Npcs for Coemu Source, thanks for you contribution...
case 104839: // BoxerLi PC- TG teleporter
{
if (LinkBack == 0)
{
Text("If you are level 20 or above, you may train ub the training ground. Would you like me to teleport you there for 1000 silver.", CSocket);
Link("Yes, please.", 1, CSocket);
Link("No Thanks.", 255, CSocket);