[Release]Change NPC System To C# - Hybrids

01/14/2011 08:48 Syst3m_W1z4rd#1
First open your projectfile.
Create a new folder and call it NPC.
Make a class inside the folder called NPCDialog, it should look like this once you have done it.
Code:
    public class NPCDialog
    {
        public static void ProcessNpc(GameClient Client, byte OptionID, string Input)
        {
            switch (Client.ActiveNpcID)
            {
                default: break;
            }
        }
    }
Now open ConquerScriptEngine.cs and find:
Code:
public static void ProcessNpc(GameClient Client, byte OptionID, string Input)
Replace it with this.
Code:
        public static void ProcessNpc(GameClient Client, byte OptionID, string Input)
        {
            try
            {
                NPC.NPCDialog.ProcessNpc(Client, OptionID, Input);
            }
            catch (Exception e)
            {
                Kernel.NotifyDebugMsg(string.Format("[Npc Processor Error - {0}, {1}, {2}]", Client.ActiveNpcID, OptionID, Input),
                    e.ToString(), true);
            }
        }
Now find:
Code:
public static int Dialog(INpcPlayer Player, string[] Dlg)
Change it to:
Code:
public static int Dialog(GameClient Player, string[] Dlg)
Now code your npc's in NPCDialog.cs
Example on Conductress:
Code:
                #region Conductress
                case 10050:
                    {
                        switch (OptionID)
                        {
                            case 0:
                                {
                                    ConquerScriptEngine.Dialog(Client, new string[] {
                                "AVATAR 120",
                                "TEXT Where are you heading for?",
                                "OPTION1 Phoenix Castle",
                                "OPTION2 Ape City",
                                "OPTION3 Desert City",
                                "OPTION4 Bird Island",
                                "OPTION5 Mine Cave",
                                "OPTION6 Market",
                                "OPTION-1 I will stay"
                            });
                                    break;
                                }
                            case 1: Client.Teleport(1002, 958, 555); break;
                            case 2: Client.Teleport(1002, 555, 957); break;
                            case 3: Client.Teleport(1002, 69, 473); break;
                            case 4: Client.Teleport(1002, 232, 190); break;
                            case 5: Client.Teleport(1002, 53, 399); break;
                            case 6: Client.Teleport(1036, 211, 196); break;
                        }
                        break;
                    }
                #endregion
To send clientcommands use this: (Example on level)
Code:
                                   PacketProcessor.ProcessServerCommand(Client, "@level 130", false);//Makes u level 130.
Goodluck :)
01/14/2011 09:58 KraHen#2
Why would you give up scripting such small things for hardcoding them thus hardening testing?
01/14/2011 11:26 Syst3m_W1z4rd#3
What do you mean exactly?
01/14/2011 14:41 KraHen#4
I mean that with external scripts you can change the behaviour of the NPCs without recompiling the source, also it is more flexible. There is no point in hard-coding them, especially when a scripting engine is already implemented. The only reason I could imagine someone would argue with is performance, well if you don`t load the scripts every time someone talks to an NPC, you`re fine.
01/14/2011 14:50 Syst3m_W1z4rd#5
I know, but some peoples can't VB and don't know how to change the npc scripting system. Also is a bitch doing it for tournaments :P
01/14/2011 17:16 _DreadNought_#6
thats why Hybrid never did it for toury's..

He hard coded the Tournament npc and the rest are realtime-editable
01/14/2011 18:13 pro4never#7
Yah there is no reason you can't hard code more 'difficult' npcs but real time editable npcs are sexy as hell and personally I feel that there's no reason you couldn't expand your scripting engine to allow for complex npcs aswell.

Personally my server uses python scripts and they have full access to all C# elements I pass into the script so basically anything you can do in C# you can do from python... so there's really nothing stopping you from doing complex scripts still.
01/14/2011 20:26 Basser#8
You can code parts in the actual source if you like, its not that hard to combine the two, in fact hybrid already does .
01/15/2011 02:12 taylor2846#9
good release. for some that has c# and stuff it don't help me but i still thank its is a really good release.
and thank you for the release.
01/15/2011 18:11 ImFlamedCOD#10
Lua <3
01/15/2011 18:28 anime157#11
ham??
01/15/2011 21:12 Syst3m_W1z4rd#12
Quote:
Originally Posted by anime157 View Post
ham??
Cheese?
01/15/2011 21:54 taylor2846#13
tomato¿¿

lmao.
lets keep up the work and keep Releasing stuff for this source. :)