GithubHelp home page GithubHelp logo

pvemu's Introduction

PvEmu

Emulateur dofus en java créé par v4vx

Objetifs

Cet émulateur a été créé principalement pour m'entrainer, et utiliser différents design pattern, et pas vraiment pour faire un serveur, ou qu'il soit vraiment exploitable et débug 100%. Je l'ai dev dans l'optique qu'il soit le plus propre possible, le plus modulable et performant. Pour ce faire j'ai ajouté une API de scripting javascript, en utilisant l'excellentissime moteur rhino de Mozilla.

Fonctionnalités

  • Apache mina comme fw réseau
  • API scripting js (mozilla rhino)
  • système de packets très extensible
  • (future) possibiliter de faire tourner plusieurs versions de dofus 1.x.x
  • Lazy-loading
  • Système de commande beaucoup plus flexible
  • Mono serveur
  • la plupart des actions, fonctionnalités peuvent être étendues et modifiés via l'API de scripting

API de scripting

Ajout de packet :

network.game.GameInputHandler.instance().registerPacket({
    id: function(){
        return 'AP'; //id du packet (pa exemple generation du nom)
    },
    perform: function(extra, session){
        //action à faire
        Shell.println('Using API !');
        
        var name = '';
        var voy = 'aeiouy';
        var cons = 'bcdfghjklmnpqrstvwxz';
        var useVoy = true;
        for(var i = 0; i < 12; ++i){
            if(useVoy)
                name += voy.charAt(Utils.rand(0, voy.length));
            else
                name += cons.charAt(Utils.rand(0, cons.length));
            useVoy = !useVoy;
        }

        GamePacketEnum.CHARACTER_GENERATOR_NAME.send(session, name);
    }
});

Ajout d'une commande :

CommandsHandler.instance().registerCommand(JavaAdapter(Command, {
    name : function(){
        return "useless"; //nom de la commande
    },
    perform: function(args, asker){
        asker.write("I am useless !");
    }
}));

Modification d'un générateur de packets :

var generators = network.generators;
var Element = game.objects.dep.Stats.Element;

var PlayerGenerator = JavaAdapter(generators.PlayerGenerator, {
    generateGM: function(player){
        return player.getCell().getID() + ';' + player.orientation + ';'
                + player.getID() + ';'
                + player.getName() + ';'
                + player.getClassID() + ';'
                + player.getGfxID() + ';'
                + player.getSexe() + ';'
                + '0,'
                + '0,'
                + '0,'
                + player.getID() + ';'
                + jelly.Utils.implode(';', player.getColors()) + ';'
                + player.getGMStuff() + ';'
                + (player.getLevel() > 99 ? '1' : '0') + ';' //aura
                + ';' //emote
                + ';' //emote timer
                + ';;' // ?
                + player.restriction + ';'
                + ';;';
    },
    generateAs: function(player){
            var packet = '';

            packet += '0' + '|' + '0' + '|' + '150' + '|'; //cur xp | min xp | max xp
            packet += player.getPDVMax() + '|' + player.getPDVMax() + '|'; //cur pvd | max pdv
            packet += player.getTotalStats().get(Element.PA) + '|' + player.getTotalStats().get(Element.PM) + '|';
            packet += 18765 + '|'; //kamas
            packet += player.getBaseStats().get(Element.FORCE) + '|' + player.getBaseStats().get(Element.FORCE) + '|';
            packet += player.getBaseStats().get(Element.VITA) + '|' + player.getBaseStats().get(Element.VITA) + '|';
            packet += player.getBaseStats().get(Element.DOMMAGE) + '|' + player.getBaseStats().get(Element.DOMMAGE) + '|';
            packet += player.getBaseStats().get(Element.CHANCE) + '|' + player.getBaseStats().get(Element.CHANCE) + '|';
            packet += player.getBaseStats().get(Element.AGILITE) + '|' + player.getBaseStats().get(Element.AGILITE) + '|';
            packet += player.getBaseStats().get(Element.INTEL) + '|' + player.getBaseStats().get(Element.INTEL) + '|';
            packet += 0 + '|' + 0 + '|'; //capital | spell pts
            packet += player.getTotalStats().get(Element.PO) + '|';
            packet += "10000|10000|"; //energie
            packet += "0|"; //align ?
            packet += player.getTotalStats().get(Element.INVOC) + '|';
            packet += player.getInitiative() + '|';
            packet += player.getProspection();

            return packet;
    }
});

generators.GeneratorsRegistry.setPlayer(PlayerGenerator);

Ajout d'un canal de discution

game.chat.ChatHandler.instance().registerChannel({
    id: function(){
        return '&'; //[id] du canal (BM[id]|[message])
    },
    post: function(msg, player){
        GamePacketEnum.CHAT_MESSAGE_OK.sendToAll('|' + player.getID() + '|' + player.getName() + '|' + msg);
        Shell.println("Message envoyé à tous !");
    },
    condition: function(){
        return new jelly.filters.YesFilter();
    }
});

Execution de scripts :

API.execute("monScript"); // exécute un fichier js (ne pas mettre l'extension !)
API.execDir("monDir/monSousDir"); //exécute tout les scripts du dossier indiqué

Remerciements

  • Blackrush pour ses conseils java
  • Sébastien NEDJAR prof (de java) à l'IUT d'Aix-en-Provence
  • Mohammed pour son soutien
  • Ankama-games pour leur super jeu

pvemu's People

Contributors

vincent4vx avatar runriel avatar

Stargazers

 avatar  avatar Nikolay Debroh avatar Sergi Canaleta Fondó avatar Antoine Chauvin avatar

Watchers

 avatar Sergi Canaleta Fondó avatar baskwo avatar  avatar  avatar  avatar

pvemu's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.