|
You last visited: Today at 23:50
Advertisement
[Hybrid]Shortcut npc
Discussion on [Hybrid]Shortcut npc within the CO2 Private Server forum part of the Conquer Online 2 category.
11/21/2010, 19:22
|
#1
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
[Hybrid]Shortcut npc
Would this work by creating npcs in hybrids source?
Code:
public static void Avatar(GameClient Hero, byte face)
{
NpcProcessor.Dialog(Hero, new string[] {
"AVATAR " + face});
}
public static void Say(GameClient Hero, string MSG)
{
NpcProcessor.Dialog(Hero, new string[] {
"TEXT " + MSG});
}
public static void Exit(GameClient Hero, string MSG)
{
NpcProcessor.Dialog(Hero, new string[] {
"OPTION-1 " + MSG});
}
public static void Link(GameClient Hero, string MSG, byte Option)
{
NpcProcessor.Dialog(Hero, new string[] {
"OPTION" + Option + " " + MSG});
}
Code:
case 0001:
{
switch (OptionID)
{
case 0:
{
Avatar(Hero, 100);
Say(Hero, "Hello There!");
Link(Hero, "What sup?", 1);
Exit(Hero, "Bye");
break;
}
case 1:
{
Avatar(Hero, 100);
Say(Hero, "Not much");
Exit(Hero, "Okay");
break;
}
}
break;
}
|
|
|
11/21/2010, 19:56
|
#2
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
|
Looks like it would work conceptually anyways, why not test it?
|
|
|
11/21/2010, 20:00
|
#3
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
I am gonna do, just need to download a client etc. dats why >.< I might do later today or tomorrow ;P
Thanks anyway
|
|
|
11/21/2010, 20:42
|
#4
|
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
|
You shouldn't have to pass the 'GameClient' parameter all the time.
|
|
|
11/21/2010, 20:56
|
#5
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
Bas, how would u else define the GameClient?
Code:
public static int Dialog(GameClient Hero, string[] dlg)
{
|
|
|
11/21/2010, 20:59
|
#6
|
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
|
Quote:
Originally Posted by 1337 H4X0R
Bas, how would u else define the GameClient?
Code:
public static int Dialog(GameClient Hero, string[] dlg)
{
|
There are thousands of ways to accomplish the same thing, but since you are trying to make things shorter, why keep passing that parameter all the time? Instead of passing it once?
|
|
|
11/21/2010, 21:00
|
#7
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
Ahh I get it now.
Nevermind, just my stupidity ;P
Thanks
|
|
|
11/21/2010, 23:25
|
#8
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
|
I don`t get how is this a shortcut though, I thought that those strings replaced lines of code where you send the dialog packets. If it is like this then you`re theoretically doubling the execution time of the parsing of an NPC.
|
|
|
11/21/2010, 23:49
|
#9
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
Ya I found out to <.<
|
|
|
11/22/2010, 06:11
|
#10
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
|
Quote:
Originally Posted by KraHen
I don`t get how is this a shortcut though, I thought that those strings replaced lines of code where you send the dialog packets. If it is like this then you`re theoretically doubling the execution time of the parsing of an NPC.
|
That's 'cuz I was originally going to integrate my entire scripting system into this souce but never got around to it albeit, I wanted to make things as user-friendly as possible.
Strings = user friendly,
Brackets, semi-colons, parameters are not sadly.
|
|
|
11/22/2010, 10:11
|
#11
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
Well im sticking to the old methode
|
|
|
11/22/2010, 15:07
|
#12
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
|
Quote:
Originally Posted by InfamousNoone
That's 'cuz I was originally going to integrate my entire scripting system into this souce but never got around to it albeit, I wanted to make things as user-friendly as possible.
Strings = user friendly,
Brackets, semi-colons, parameters are not sadly.
|
I certainly see your point there, but scripting in games IMO should be done by someone who has at least a bit of experience in programming, thus making it similar to a language which many are familiar with has more advantages.
Just my two cents though
|
|
|
11/23/2010, 21:33
|
#13
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
|
Quote:
Originally Posted by KraHen
I certainly see your point there, but scripting in games IMO should be done by someone who has at least a bit of experience in programming, thus making it similar to a language which many are familiar with has more advantages.
Just my two cents though
|
Since all my NPCs were home coded, my community pitched in with coding a lot of them, and they were done in a language everyone's familiar with.
Code:
' By: Wolf
' Npc: 10021
' Name: ArenaGuard
Imports System
Imports ConquerScriptLinker
Partial Public Class NpcEngine
Public Shared Sub ArenaGuard()
Dim dlg As String() = Nothing
Select Case OptionID
Case 0
ReDim dlg(2)
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."
Case 1
If Player.Money >= 50 Then
Player.Money -= 50
Command("@mm 1005 50 50")
Else
ReDim dlg(1)
dlg(0) = "TEXT I'm sorry you dont have 50 silvers."
dlg(1) = "OPTION-1 Oh, I will go work my corner more."
End If
End Select
If Not dlg Is Nothing Then
Dialog(dlg)
End If
End Sub
End Class
Notice how the dialog functions are handled for you, also, no packet-knowledge is required and is internally done as required by the engine to synchronize the client as such. I'd explain the Engine setup, but it's overly complicated to explain how everything works at this time, for instance; this is jut setting it up;
Code:
private static ScriptExtension GenerateExtension()
{
ScriptExtension extend = new ScriptExtension("Engine", "VB");
extend.AddPreprocess("'#new_assembly System.Core.dll");
extend.AddPreprocess("'#assembly " + ServerDatabase.Startup + "\\ConquerScriptLinker.dll");
extend.AddNamespace("Imports ConquerScriptLinker");
extend.AddVariable("Public Shared DatabasePath As String = \"" + ServerDatabase.Path + "\"");
extend.AddVariable("Public Shared Player As INpcPlayer");
extend.AddVariable("Public Shared NativeDialog As Func(Of INpcPlayer, String(), Int32)");
extend.AddVariable("Public Shared NativeCommand As Func(Of INpcPlayer, String, Int32)");
extend.AddVariable("Public Shared FindPlayerByName As Func(Of String, INpcPlayer)");
extend.AddVariable("Public Shared FindPlayerByUID As Func(Of UInt32, INpcPlayer)");
extend.AddVariable("Public Shared QueryDatabase As Func(Of String, String, String, String, String)");
extend.AddVariable("Public Shared WriteDatabase As Func(Of String, String, String, String, Int32)");
extend.AddVariable("Public Shared timeGetTime As Func(Of UInt32)");
extend.AddVariable("Public Shared GuildPoleID As Func(Of UInt16)");
extend.AddVariable("Public Shared FlipGate As Func(Of UInt32, Int32)");
extend.AddVariable("Public Shared GenerateLotteryItem As Func(Of Int32, INpcItem)");
extend.AddFunction(
"Public Shared Sub Dialog(ByVal Dlg As String())\r\n" +
"\tNativeDialog(Player, Dlg)\r\n" +
"End Sub"
);
extend.AddFunction(
"Public Shared Sub Command(ByVal Cmd As String)\r\n" +
"\tNativeCommand(Player, Cmd)\r\n" +
"End Sub"
);
extend.AddExternalClass(
"\r\nPartial Public Class NpcEngine\r\n" +
"Inherits Engine\r\n" +
"\tPublic Shared NpcID As UInt32\r\n" +
"\tPublic Shared OptionID As Byte\r\n" +
"\tPublic Shared Input As String\r\n" +
"End Class\r\n"
);
extend.AddExternalClass(
"\r\nPartial Public Class ItemEngine\r\n" +
"Inherits Engine\r\n" +
"\tPublic Shared Item as INpcItem\r\n" +
"End Class\r\n"
);
return extend;
}
private static void LinkScriptMethods()
{
Engine.RegisterGlobalVariable("Engine", "NativeDialog", new Func<INpcPlayer, string[], int>(Dialog));
Engine.RegisterGlobalVariable("Engine", "NativeCommand", new Func<INpcPlayer, string, int>(Command));
Engine.RegisterGlobalVariable("Engine", "FindPlayerByName", new Func<string, INpcPlayer>(FindPlayerByName));
Engine.RegisterGlobalVariable("Engine", "FindPlayerByUID", new Func<uint, INpcPlayer>(FindPlayerByUID));
Engine.RegisterGlobalVariable("Engine", "QueryDatabase", new Func<string, string, string, string, string>(QueryDatabase));
Engine.RegisterGlobalVariable("Engine", "WriteDatabase", new Func<string, string, string, string, int>(WriteDatabase));
Engine.RegisterGlobalVariable("Engine", "timeGetTime", new Func<uint>(timeGetTime));
Engine.RegisterGlobalVariable("Engine", "GuildPoleID", new Func<ushort>(GuildPoleID));
Engine.RegisterGlobalVariable("Engine", "FlipGate", new Func<uint, int>(FlipGate));
Engine.RegisterGlobalVariable("Engine", "GenerateLotteryItem", new Func<int, INpcItem>(GenerateLotteryItem));
}
public static void Init()
{
Engine = new ScriptEngine("VB");
Engine.Extension = GenerateExtension();
Engine.BuildPath = ServerDatabase.Path + "\\Scripts\\";
LinkScriptMethods();
CreateDefinedFiles();
}
|
|
|
11/23/2010, 21:44
|
#14
|
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
|
Can I add the scripting engine you made, still amazes me?
|
|
|
11/24/2010, 07:58
|
#15
|
elite*gold: 0
Join Date: Feb 2006
Posts: 550
Received Thanks: 81
|
i don't like it, i feel it could be a lot easier. in my opinion that isn't user friendly, i actually find VB harder to look at than C# (obviously because im used to it).
An example of something i have set up:
Code:
SetText("Hello would you like to enter the PK Arena for 50 silvers?");
option = AddOptions("Yes, here you go.", "No thanks");
if(option == 1) {
if(HasMoney(50)) {
RemoveMoney(50);
Teleport(1005, 50, 50);
} else {
SetText("I'm sorry you dont have 50 silvers.");
AddOptions("Oh, I will go work my corner more.");
}
}
maybe someone should create a thread on here about script engines and see what people can come up with, it can be judged by ease of use, speed and control.
From my old community i remember someone had the easiest setup i have ever seen, it went something like this
Code:
:start
text "Hello would you like to enter the PK Arena for 50 silvers?"
option1 "Yes, here you go."
option2 "No thanks."
:answer1
if hasmoney 50 goto tp else goto fail
:tp
money -50
teleport 1005 50 50
:fail
text "You dont have enough money"
option1 "Oh, I will go work my corner more"
i think above is pretty cool for end users.
|
|
|
|
|
Similar Threads
|
Hilfe bei Shortcut und Gui
10/06/2010 - AutoIt - 8 Replies
Hallo :)
Ich bin relativ neu in Auto it und wollte fragen wie ich bei meinem Script ein Exit Shortcut machen kann?
Ausserdem wollte ich frage wie ich ein Gui erstelle bei dem man nur euf einen Knopf drücken muss und dann reconnectet wird...?
HotKeySet ("^!{s}","start")
Func start()
Run ("C:\Program Files\Mozilla Firefox\firefox.exe")
WinWaitActive ("Google - Mozilla Firefox")
|
SRO DB-BOT Shortcut Key
06/09/2010 - SRO Private Server - 10 Replies
Hi,
can someone tell me if there is a shortcut key to pop-up the botmenu? Like in isrobot. Pos1 or something.
Since I am using Windows 7 it does cause trouble alt+tab with the bot.
It wont appear anymore! Windows xp didn´t hat this problem.
Thanks alot
|
Vista EO Shortcut
04/20/2009 - EO Exploits, Hacks, Tools & Macros - 6 Replies
As most of us know there are some errors with Vista and EO's play.exe and autopatch.exe
Ive edited my own shortcut (recently got Vista) so it works a lot better.
Jusrt replace this shortcut with your old one IF you have Vista.
give thx if you like xD
or
give thx for the effort
xDxD
|
COOL SHORTCUT
09/22/2008 - Zero - 8 Replies
hey im new to zero, only playing for a couple of weeks and im not sure if everyone already knows this... but here it goes
to make all robots dissapear press CTRL + tab !
this is great for market and robots re-appear when u move
less lag
;)
|
All times are GMT +2. The time now is 23:50.
|
|