Jump to content

pan

Community Contributors
  • Content Count

    355
  • Joined

  • Last visited

  • Days Won

    13

Posts posted by pan


  1. Long time no see!

    I've been dabbling with adding multi-thread support to Hercules for quite some time and even started quite a few server projects from scratch, and having failed in most of my attempts - last year I tried again with a new core design and it seems to be working so far. A lot of the systems that the server core is reliant were reworked, I believe some of these changes can even be used upstream but they would need to be revised first. This is mostly a proof of concept.

    I'm still planning on finishing the map-server but as of now only login and char servers have multi-thread enabled - I didn't test with multiple users yet. There's no linux / FreeBSD support because I want to have everything in working condition before trying to add another I/O paradigm, the architecture is very reliant on the way that this module works so I thought it'd better to implement the whole server before trying to add other paradigms.

    Lately I haven't got much free time to finish the map-server, but sometime later this year I think I can finish it.

    The code is at https://github.com/panikon/HerculesMT , I forked from stable v2021.08.04

     

    Server architecture


    Hercules employs a multi-server approach in order to better load balance player requests, so for each game world there'll be at least three separate program instances running at all times. These instrances are: login-server, char-server and map-server. Each of which can only access a subset of the world's SQL tables and is responsible for a different step of the game experience.


    Authentication and account database changes are segregated to the login-server, while character selection and character specific information are to the char-server, and the actual gameplay to the map-server.

    The login-server is the player entry-point and can be responsible for multiple different world instances, so it's possible to use the same account table (login) for multiple worlds (char-server + map-server) and to dynamically change their IP without needing to push a new patch. After authentication the player is queried for which service they'll use and then the server relays the proper address so the client can connect.

    In the char-server the player usually is queried again for a four digit PIN (PACKETVER >= 20180124), after which they can select which playable character will be used to play. The server then relays the address of the proper map-server to the client.

    A single world instance can have multiple map-servers where each is responsible for a zone (set of maps), all inter map connectivity is managed by the char-server. When the player requests to change character the char-server IP is then relayed.
    A single map-server can be responsible for multiple different zones, and each will be a different thread.

     

    Relationship of each of the possible server instances

    server_design.png.40911a074225b440afb94804c59a89b6.png
     Brown - Game world | White - program instances

     

    Core design

    All servers are multi-threaded. Basic server functions are assigned to different threads:

    • Console (../src/common/console.c):
      This thread is responsible for all console input operations.
    • Timer (../src/common/timer.c):
      The timer thread manages the `timer_heap` and dequeues timer actions from the `timer_queue`. Each timer can be ran in a different thread depending on the `timer_target`, this is accomplished by either queuing an action in one of the available action queues (`target_id`) or by running the specified function in the main timer loop (`do_timer`).
      Other threads queue different timer actions (add, delete, set tick) to the `timer_queue`.
      The timer module is also responsible for tick acquiral via (`timer->gettick` and `timer->gettick_nocache`).
    • Message(../src/common/showmsg.c):
      The message thread is used to synchronize the output of multiple different threads, each call to `Show*` instead of being directly outputted to `STDOUT` is queued in the `showmsg_queue` and then dequeued by the main thread function `showmsg_worker`.
    • I/O Worker(../src/common/socket.c):
      All I/O operations are asynchronous and implemented via I/O completion ports and a thread pool. The main workers are defined in `socket_worker` and after a operation is dequeued it's converted into an action (`socket_operation_process`) that is then queued to the proper action worker (each session has a responsible worker, and it's obtained by the I/O worker via `action->queue_get`).
      These workers don't execute any "business logic" so we can minimize the time that they are blocked by any given operation, and also so we can better isolate different session groups without having to take into account in I/O operations (e.g. in map-server each zone has a different action worker and multiple actions can be queued simultaneously without having to block any of the threads for a longer period of time).
    • Action Worker(../src/common/action.c):
      Action workers perform all the "business logic" of each of the servers, and each is responsible for a different session group. After every action loop all send actions are queued to the completion port.

      • Login-server:
        Each char-server connection has a different worker. Player connections are randomly assigned.
      • Char-server:
        Each map-server connection has a different worker. Player connections are randomly assigned.
      • Map-server:
        Player connections are assigned depending on the current map according to the different configured zones. The char-server connection is randomly assigned.

    Thread relationships

    core_design.thumb.png.e5bec5734ac98eabe50453b1a18bda2c.png


  2. Wow how did I miss this??? Really nice tool but im running into issues. I used a 2013-12-23cRagexe client and upon selecting my character at the character select screen I get a error message saying "No match found in Length Table for Packet 0x68a" which is strange since no such packet exists....I think. When the error happens the program closes. No way to avoid the error or continue capturing. Even pausing before it happens doesn't help. Also when clicking the start analyzer it doesn't launch the client. Im using the restore login window patch if this affects anything.

     

    I tried using this to solve a issue with some packets with the client as the shuffled packets may not be right which are causing issues with whispering to other players and not being able to feed homunculus.

    I tried to use with 2013-12-23c and got this issue as well, I guess the problem is that the only release of this client is packed and if you try to extract its packet-list using the current hex pattern it won't work, try using this tool with a more current unpacked client from k3dt and it might work :)

  3. Parece que esse comando não está seguindo a caixa necessária:

    StrCharInfo(0)
    Deveria ser:
    strcharinfo(0)
    Idealmente você deveria utilizar strcharinfo utilizando algumas constantes que são definidas:
    PC_NAME		NomePC_PARTY	GrupoPC_GUILD	ClãPC_MAP		Mapa
    Ficando:
    strcharinfo(PC_NAME);
    Ou, se você tiver desativado a sensitividade à caixa, o que o evilpuncker disse estaria mais correto.

  4.  

     

     

    Amigo sem palavras, fico muito lindo o NPC, Muito obrigado pela paciência e dedicação.... OBRIGADO

     

    Só tirando uma dúvida se caso eu queira troca o delay para 10 segundos como eu faço? 10 , 15

     

     

    Sem problema nenhum :)

    Só achar a linha

    set bvip_delay, gettimetick(0) + 20 * 1000; // Delay de 20s
    Substitua o 20 pelo número de segundos desejado

  5. Não sei se é por causa do meu emulador ser compilção pré renovação mais aqui não pego

    cópiei e adicionei nos script e ele simplesmente sumiu

    coloquei em um bloco de nota e dei <TAB> para ver se ia e só apareceu o npc quando troquei 4_F_FAIRY por 436

    Mais ai quando eu clico nele acontece nada '-'

     

     

    Se precisar nen precisa ter as mensagem apenas o delay de 20 segundos mesmo... =/

    Melhor você atualizar sua revisão do emulador, parece que você não está usando Hercules, acabei de testar um dos SC's estava errado, aqui está a correção: http://pastebin.com/DcdMxebT só copiar e colar em um .txt

  6. Acabei de testar, você deve ter esquecido de por algum TAB no header do NPC, pega ele aqui: http://pastebin.com/jVcBgrG8 copia e cola em um .txt

    Ah, e o evento 'OnTouch' só é necessário quando você quer que o NPC funcione quando o jogador entre em alguma área, da uma olhada nesse post http://herc.ws/board/topic/3984-é-possível-utilizar-skills-via-servidor-para-efeitos-em-npcs/?p=25957 que ta explicado certinho


  7. Algo assim deve funcionar:

    <header>,{	OnTouch:		if( getgroupid() < 1 ) {			mes "["+strnpcinfo(0)+"]";			mes "Você não é VIP, apenas usuários VIP podem utilizar esse benefício.";			close;		}		// Verifica se o tempo atual é maior do que o definido na variável, se sim		// é porque ainda não passou o tempo necessário para o usuário poder receber os buffs		if( gettimetick(0) < bvip_delay )			end;		// Buffs		skilleffect 8,0; sc_start SC_ENDURE,360000,10;		skilleffect 33,0; sc_start SC_ANGELUS,360000,10;		skilleffect 74,0; sc_start SC_MAGNIFICAT,360000,5;		skilleffect 75,0; sc_start SC_GLORIA,360000,5;		skilleffect 66,0; sc_start SC_IMPOSITIO,360000,5;		skilleffect 34,0; sc_start SC_BLESSING,360000,10;		skilleffect 29,0; sc_start SC_INCREASEAGI,360000,10;		percentheal 100,100;		// Define uma variável com um tempo no futuro		// gettimetick(0) retorna o tempo em milisegundos		set bvip_delay, gettimetick(0) + 20 * 1000; // Delay de 20s		end;}
    Não se esqueça de trocar <header> pelo cabeçalho do seu NPC.

  8. Movi o tópico para a seção correta.

     

    O *showevent serve para avisar um jogador que há algo relacionado à uma quest em algum NPC portanto precisa que haja um jogador executando o script para que funcione. Basta executá-lo enquanto o jogador estiver falando com o NPC que ele continuará aparecendo enquanto o ele estiver no mesmo mapa, se você desejar que esse ícone apareça constantemente basta utilizar *questinfo, não se esqueça que esse comando só deve ser utilizado dentro de um OnInit.

     

    (Traduzido rapidinho)

    *questinfo <Quest ID>, <Icon> {, <Map Mark Color>{, <Job Class>}};
     
    Esse comando é essencialmente uma combinação de *checkquest e *showevent. Use somente
    em uma label OnInit. Para QuestID, especifique o ID que você quer que seja verificado quando
    o usuário entrar no mapa, o evento só será mostrado para usuários que não estiverem com
    a quest iniciada.
     
    Para Icon use:
     
    Nenhum : QTYPE_NONE
    ! Quest Icon : QTYPE_QUEST
    ? Quest Icon : QTYPE_QUEST2
    ! Job Icon : QTYPE_JOB
    ? Job Icon : QTYPE_JOB2
    ! Event Icon : QTYPE_EVENT
    ? Event Icon : QTYPE_EVENT2
    Warg : QTYPE_WARG
    Warg Face : QTYPE_WARG2 (Somente para packetver >= 20120410)
     
    Map Mark Color, quanto utilizado cria uma marca no mini mapa do usuário na
    posição do NPC, as cores disponíveis são:
     
    0 - Nenhum marcador
    1 - Marcador amarelo
    2 - Marcador  verde
    3 - Marcador roxo
     
    Quando um jogador entra em um mapa cada NPC verifica se alguma *questinfo foi definida.
    Se alguma estiver presente ele verificará se foi iniciada se não o ícone aparecerá.
     
    Opcionalmente você também pode definir uma classe para aparecer.

     

    <header>,{	OnInit:		questinfo <Quest ID>, <Icon> {, <Map Mark Color>{, <Job Class>}};		end;

    Os valores para 'Job Class' podem ser encontrados em npc/const.txt, são os primeiros valores.

     

    Mas se você quiser que um NPC tenha esse tipo de marcador para todo jogador que logue no servidor, independente de qualquer quest, basta utilizar um OnPCLoginEvent, algo como:

     

    <header>,{	OnPCLoadMapEvent:		if( strcharinfo(3) == strnpcinfo(4) )			showevent <icon>{,<mark color>};		end;}

    Não se esqueça de marcar o mapa com a mapflag loadevent.


  9. Without altering your source code it's not possible to know which item was got after using *getrandgroupitem, as you posted in source support I'll provide a snippet altering this command behaviour:

     

    Open your src/map/script.c and find:

    BUILDIN(getrandgroupitem) {[...]		for (i = 0; i < count; i += get_count) {			// if not pet egg			if (!pet->create_egg(sd, nameid)) {				if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) {					clif->additem(sd, 0, 0, flag);					if( pc->candrop(sd,&it) )						map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);				}			}		}		script_pushint(st, 0);[...]
    Alter it to:
    BUILDIN(getrandgroupitem) {[...]		for (i = 0; i < count; i += get_count) {			// if not pet egg			if (!pet->create_egg(sd, nameid)) {				if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) {					clif->additem(sd, 0, 0, flag);					if( pc->candrop(sd,&it) )						map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);				}			}		}		pc->setreg(sd, script->add_str("@nameid"), nameid);		pc->setreg(sd, script->add_str("@count"), get_count);		script_pushint(st, 0);[...]
    Save and build your map-server. Now every time that you use *getrandgroupitem and it's successful two temporary variables will be set:
    @nameid -> Item id@count  -> Item count
    To verify if the command was successful just check any variable.

     

    Now to use it in a item box. Put this function inside any script file:

    /** * Display an announce letting other players know which item strcharinfo(0) * got when using a box. * arg(0) - Id of the box * These args should be from *getrandgroupitem * arg(1) - @nameid * arg(2) - @count **/function	script	F_BOX_OPEN	{	@box_id = getarg(0);	@nameid = getarg(1);	@count = getarg(2);	announce strcharinfo(0)+" opened "+getitemname(@box_id)+" and got "+@count+" "+getitemname(@nameid)+""+((@count > 1)?"s":"")+"!", bc_map;	return;}
    Now go to your item_db.conf and find the entry for the item that you'd like to alter, for instance High Weapon Box:
    {	Id: 12623	AegisName: "High_Weapon_Box"	Name: "High Weapon Box"	Type: 2	Buy: 20	Weight: 10	Upper: 63	Script: <" getrandgroupitem 12623,1; ">},
    Now alter its script to something like:
    Script: <" getrandgroupitem 12623,1; if(@nameid) callfunc "F_BOX_OPEN",High_Weapon_Box, @nameid, @count;">
    If you'd like for this to be automatic you could add a broadcast function to BUILDIN(getrandgroupitem), but and any time this function is called it would automatically announce :)

  10. I am currently using Windows and I didn't found other .sql than main.sql and log.sql for Windows (Wiki never mention about other .sql for Windows)

     

    I will use Linux soon, I hope the problems won't occured like Windows does.

    SQL files are compatible with any OS that you're using.

  11. Update your revision, it should be there.

    #define MAX_NPC_PER_MAP 512#define AREA_SIZE (battle_config.area_size)#define DAMAGELOG_SIZE 30#define LOOTITEM_SIZE 10#define MAX_MOBSKILL 50#define MAX_MOB_LIST_PER_MAP 100#define MAX_EVENTQUEUE 2#define MAX_EVENTTIMER 32#define NATURAL_HEAL_INTERVAL 500#define MIN_FLOORITEM 2#define MAX_FLOORITEM START_ACCOUNT_NUM#define MAX_LEVEL 175#define MAX_IGNORE_LIST 20 // official is 14#define MAX_VENDING 12#define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo]#define BLOCK_SIZE 8#define block_free_max 1048576#define BL_LIST_MAX 1048576
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.