Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 06:22

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



editing source form inside the client :O

Discussion on editing source form inside the client :O within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
editing source form inside the client :O

i want to edit something form the source from outside the source like npc dialogs , should i move them to database or it's possible to do that ?
go for it is offline  
Old 09/28/2012, 15:07   #2
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Use a script engine, I was writing one some time ago for a C# script engine specific for NPC's and commands, but my laptop broke some days ago, so I haven't taken backup. I might make a new later today or something that you could take a look at :P

If you want to try yourself then my script engine basically loaded all the npc scripts at startup and compiled them in memory so they could interact with the actual source.

Then once in a while (running in a new thread) it would check if there was any npc scripts that was changed. This could be done 2 ways, check if the md5 hash is not the same or if the last edited date is different. Then it would update the npc scripts that have been changed.

It wn't make a difference in speed at all since the methods for each npc is compiled, it may be a VERY LITTLE slower than actually coding the npcs is the source, but it's far faster than having scripts and parsing it.

This could be done with the same way binaries are doing their npc scripts (through database) as well, but you'd just load the actions and convert it to actual code that can be compiled.

You could also just parse the npc scripts from the database, but I'd rather not because the speed will be far slower.

If you want to know how to compile in memory here is an example from my very old game engine for Sdl in c#.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.CSharp;
using System.Reflection;
using System.CodeDom.Compiler;

namespace Sdl_Game_Project.ScriptEngine
{
    /// <summary>
    /// A C# script engine.
    /// Notice: This will be optimized to support a new thread for better performance.
    /// </summary>
    public class CSharpEngine
    {
        /// <summary>
        /// Handling a script file.
        /// </summary>
        /// <param name="scriptFile">The file to handle.</param>
        /// <param name="methodName">The method to invoke.</param>
        /// <param name="nameSpace">The namespace.</param>
        /// <param name="className">The class.</param>
        /// <param name="Params">The parameters of the methods. Null if none parameters.</param>
        public static void Handle(string scriptFile, string methodName, string nameSpace, string className, object[] Params = null)
        {
            if (!scriptFile.EndsWith(".cs"))
            {
                throw new Exception("Make sure the script file is a CSharp (C#) file.");
            }

            string code = File.ReadAllText(scriptFile);

            Dictionary<string, string> providerOptions = new Dictionary<string, string>()
                {
                    {"CompilerVersion", Sdl.GameCore.ScriptFramework}
                };

            CompilerParameters compilerParams = new CompilerParameters()
            {
                GenerateInMemory = true,
                GenerateExecutable = false
            };

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                compilerParams.ReferencedAssemblies.Add(assembly.Location);
            }

            CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);
            CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, code);

            if (results == null)
                throw new Exception("Unknown compiler error.");

            if (results.Errors.Count != 0)
                throw new Exception("Failed to compile the game script.");

            MethodInfo method = FindMethod(results.CompiledAssembly, methodName, nameSpace, className);
            if (method != null)
                method.Invoke(null, (Params == null ? null : Params));
        }

        /// <summary>
        /// Finds a method within an assembly.
        /// </summary>
        /// <param name="assembly">The assembly</param>
        /// <param name="methodName">The method to find.</param>
        /// <param name="nameSpace">The namespace.</param>
        /// <param name="className">The class.</param>
        /// <returns>Returns null if no methods were found.</returns>
        internal static MethodInfo FindMethod(Assembly assembly, string methodName, string nameSpace, string className)
        {
            foreach (Type type in assembly.GetTypes())
            {
                if (type.Namespace == nameSpace && type.IsClass && type.Name == className)
                {
                    foreach (MethodInfo method in type.GetMethods())
                    {
                        if (method.IsStatic && method.Name == methodName)
                        {
                            return method;
                        }
                    }
                }
            }

            return null;
        }
    }
}
I don't have a username is offline  
Thanks
2 Users
Old 09/28/2012, 17:19   #3
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
well i prefer binary way but it will take load of time to import a param everytime someone request npc dialog (kinda will cause lag) , the other method is interesting , ill try it , thanks mate ^^
go for it is offline  
Reply


Similar Threads Similar Threads
Register Form For 12tails Source (Note 5369)
09/03/2011 - CO2 PServer Guides & Releases - 21 Replies
This is register form for 12tails Source with check account & E-mail if in user or not http://i56.tinypic.com/30jpw2b.jpg Download Link Multiupload.com - upload your files to multiple file hosting sites! To Use In Your Site
[Release] Editing music Files Inside the Data.Saf
03/16/2011 - Shaiya PServer Guides & Releases - 7 Replies
Ok so heres what you need to do First off you need the chinese Data.Saf editor it can be found here Data.saf editor.zip Credit for This goes to ZeroSignal You will also need a Audio Convertor the one i used can be found here. 4U WMA MP3 Converter v6.2.8 WinAll-CAMPAiGNER (download torrent) - TPB
Wallhack / LoS File Editing? <Inside>
02/19/2010 - General Gaming Discussion - 0 Replies
Okay I know this can be done, but I don't exactly know which files (I mass-remove references because I'm clueless). Does anyone know EXACTLY how you get rid of LoS and Wallhack through buildings by removing them? Someone managed to do it here Goth Harbor hax - DaocHax.Net This hack (youtube video at bottom) lets you go through buildings and cast through them. Also, if you stand still for a few sec, you can go invisible. So... anyone care to share any info on this topic?
[REQUEST]LOFT Class editing! IN CLIENT/SOURCE
03/09/2009 - CO2 Private Server - 1 Replies
Can anyone tell me or give me a guide on how to: Add/Edit classes in source/client?
[help] editing source rates ect.
02/02/2009 - CO2 Private Server - 3 Replies
im using source TCWNN LOTF and whenever i try to edit drop rates or anything else for that matter in any of the .cs files i build it, save it, and go in game and there has been no changes made, code is dif but not the game. my ultimate goal is 2 things.... 1. change drop rates of dbs, mets, +1 stones, and quality items, they're uber high. 2. change the ext shown when first logging into the game "Welcome to ****" any help would be appreciated EDIT: ive also even tried deleting the...



All times are GMT +2. The time now is 06:22.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.