[Hybrid]Shortcut npc

11/24/2010 09:41 InfamousNoone#16
Realize, mine is runtime-editable (in sense of editing the script file, in this case, all are *.vb, will be taken in to consideration at run-time, and changes will be visible in game without a server restart) where I doubt the first one is.

The second one is, but it seems like it'd be a lot of pain to implement things that require more logic such as, how would one script the marriage NPC in this format (due to the packet logic, and the need for variables). In scenarios such as where keep-alive scope variables are required (i.e. the tinter/armor dye) how does one store variables with this system (or even perform arithmetic).

I think the second system has a good idea to it, but isn't thoroughly thought out, and would require the end-programmer to do a more work than required to implement for support for these sorts of things (i.e. variables) while accommodating for speed.

Also,
Code:
Engine = new ScriptEngine("VB/C#");
Code:
// By: Wolf
// Npc: 10021
// Name: ArenaGuard

using System;
using ConquerScriptLinker;

public partial class NpcEngine
{
    public static void ArenaGuard()
    {
        string[] dlg = null;
        switch (OptionID)
        {
            case 0:
                dlg = new string[3];
                dlg[0] = "TEXT Hello would you like to enter the PK Arena for 50 silvers?";
                dlg[1] = "OPTION1 Yes, here you go.";
                dlg[2] = "OPTION-1 No thanks.";
                break;
            case 1:
                if (Player.Money >= 50)
                {
                    Player.Money -= 50;
                    Command("@mm 1005 50 50");
                }
                else
                {
                    dlg = new string[2];
                    dlg[0] = "TEXT I'm sorry you dont have 50 silvers.";
                    dlg[1] = "OPTION-1 Oh, I will go work my corner more.";
                }
                break;
        }
        if (dlg != null)
            Dialog(dlg);
    }
}
Good to go.

Edit -- Scripted Marriage:
Code:
'#include ...\define_data.vb
'#include ...\define_string.vb
' By: Hybrid
' Npc: 390
' Name: Love Stone

Imports System
Imports ConquerScriptLinker

Partial Public Class NpcEngine
    Public Shared Sub LoveStone()
        Dim dlg As String() = Nothing

        Select Case OptionID
            Case 0
                ReDim dlg(3)
                dlg(0) = "TEXT I am the all mighty digital-pimp, what is it you wish?"
                dlg(1) = "OPTION1 Get married."
                dlg(2) = "OPTION2 Get divorced."
                dlg(3) = "OPTION-1 Nothing."
            Case 1
                Player.SendData(DataID.Switch, DataSwitchArg.MarriageMouse, 0, 0)
            Case 2
                Dim spouse As INpcPlayer = FindPlayerByName(Player.Spouse)
                If Not spouse Is Nothing Then
                    Player.SpouseAccount = ""
                    Player.Spouse = "None"
                    spouse.SpouseAccount = ""
                    spouse.Spouse = "None"

                    Player.SendString(StringID.Spouse, "None")
                    spouse.SendString(StringID.Spouse, "None")
                Else
                    Dim SpouseFile As String = DatabasePath & "\Accounts\" & Player.SpouseAccount & ".ini"
                    If String.Compare(QueryDatabase("Character", "Spouse", "", SpouseFile), Player.Account, True) Then
                        Player.SpouseAccount = ""
                        Player.Spouse = "None"
                        Player.SendString(StringID.Spouse, "None")

                        WriteDatabase("Character", "Spouse", "", SpouseFile)
                    End If
                End If
        End Select

        If Not dlg Is Nothing Then
            Dialog(dlg)
        End If
    End Sub
End Class
11/24/2010 10:08 ChingChong23#17
the first one can be modified during runtime and changes do update. the second one is good but it can't perform arithmetic and is very limited, also a lot of work to create.
11/24/2010 10:37 InfamousNoone#18
Oh, at first I assumed that was C#, but I suppose that's probably LUA you're using there in the first one, eh? I don't particularly like LUA, but it would certainly get the job done for this task (when I coded my engine I intended it to be used for other stuff other than Conquer, but I'm not going to bother going into detail...)
11/24/2010 11:24 ChingChong23#19
nah it's Beanshell and its for Java. it also supports full Java syntax and the scripts have full access to the server scope, i have a wrapper class full of helpful methods that each script may use.

Lua & IronPython for C# would be good ones to look into though. WoW private servers like to use Lua.
11/24/2010 20:44 _DreadNought_#20
Just made my scripting format.

Ill be using something kinda like ini(except its not).
Format:
Code:
By: Me ;END
ID: 2209; ;END
Cases: 12; ;END

Case1: ;END
Text: Howdy there partner! ;END
Link: Hi ;GOTO 4 ;END
;CASE1END;

;NPCEND;
Looks ugly? Doesnt really matter. I'll be making an user friendly application to generate this file with what they want. Fully flexible. Will create backups and send to the server, Might even upload all the npcs to a secure link and have the server read them(Wondering on delay of the npc loading if needed to establish a connection to the site, but create a connection then if connection loses just make all NPCS say "NPCs are offline will be back shortly, if after 3 failed attempts to establish a connection all gms/pms will be informed of this error and all players will be alerted "Error with NPCs. Will be back online asap.") and have not designed the engine at all yet.