avatar_Ghost

[0.97.11 kayito] Custom Bow/Crossbow

Автор Ghost, Март 06, 2024, 07:41

« назад - далее »

0 Пользователи и 1 гость просматривают эту тему.

Ghost

ItemASM.h
#pragma once

class CItemASM
{
public:
    void Init();

private:
    static void StatsBow();
    static void BowSafeZone();
    static void SetPlayerStopBows();
    static void SetPlayerWalkBows();
    static void SetPlayerWalkRunBows();
    static void ArrowReloadBow1();
    static void ArrowReloadBow2();
    static void FixNoMoreBowArrows();
    static void RangeBowShoot1();
    static void BowRangeEffectShoot();
    static void RangeBowShoot2();
    static void SetPlayerAttackBowMount();
    static void FixShootBowArrows();
    static void SoundBowsShoot();
    static void RenderObjectScreenBows();
    static void BowSkillEffect();
    static void PenetrationArrow();
    static void IceArrow();
};
extern CItemASM gItemASM;

ItemASM.cpp
#include "stdafx.h"
#include "ItemASM.h"

CItemASM gItemASM;

void CItemASM::Init()
{
    SetCompleteHook(0xE9, 0x0047D4A7, &StatsBow);                   // Muestra las estadisticas de stats en el panel character "C"
    SetCompleteHook(0xE9, 0x00458344, &BowSafeZone);                // Muestra el arco en la espalda dentro de las zonas seguras 100%
    SetCompleteHook(0xE9, 0x004432B5, &SetPlayerStopBows);          // Sostiene el arco estando el personaje sin moverse 100%
    SetCompleteHook(0xE9, 0x00443C41, &SetPlayerWalkBows);          // Sostiene el arco cuando el personaje camina 100%
    SetCompleteHook(0xE9, 0x00443D3A, &SetPlayerWalkRunBows);       // Sostiene el arco cuando el personaje corre 100%
    SetCompleteHook(0xE9, 0x004826E1, &ArrowReloadBow1);            // Recarga las flechas si tenes en el inventario 100%
    SetCompleteHook(0xE9, 0x0048B96E, &ArrowReloadBow2);            // Recarga las flechas si tenes en el inventario 100%
    SetCompleteHook(0xE9, 0x0048BCAA, &FixNoMoreBowArrows);         // Detecta si no tienes flechas y muestra un mensaje 100%
    // ------------------------------------------------------------ Trabajan en conjunto para que dispare a distancia y se acerque al objetivo
    SetCompleteHook(0xE9, 0x004AEFDA, &RangeBowShoot1);             // Rango de disparo 1
    SetCompleteHook(0xE9, 0x004AE74E, &BowRangeEffectShoot);        // Efecto de acercamiento al objetivo, se podria eliminar de todos los arcos o agregar a los nuevos.
    SetCompleteHook(0xE9, 0x0048D7B3, &RangeBowShoot2);             // Rango de disparo 2
    // -------------------------------------------------------------
    SetCompleteHook(0xE9, 0x004E143D, &RenderObjectScreenBows);     // Posicion de las bows (Dentro de la funcion: RenderObjectScreen)

    // En la funcion SetPlayerAttack -> 0x00444410
    MemorySet(0x004444A5, 0x90, 7);
    SetCompleteHook(0xE9, 0x004444A5, &SetPlayerAttackBowMount);    // Movimiento de Disparar flechas montado en unuria y dinorat 100%
    SetCompleteHook(0xE9, 0x0044473D, &FixShootBowArrows);          // Movimiento de Disparar flechas 100%
    SetCompleteHook(0xE9, 0x00444934, &SoundBowsShoot);             // Sonido de las flechas al disparar 100%

    // En la funcion CreateArrows -> 0x00474BD0

    // Disparar Penetration Arrow
    MemorySet(0x0049D9FC, 0x90, 61);
    SetCompleteHook(0xE9, 0x0049D9FC, &PenetrationArrow);

    // Disparar Ice Arrow
    MemorySet(0x0049F156,0x90,53);
    SetCompleteHook(0xE9, 0x0049F156, &IceArrow);

    // En la funcion CreateArrow -> 0x00474370
    MemorySet(0x00474A9A, 0x90, 9);
    SetCompleteHook(0xE9, 0x00474A9A, &BowSkillEffect);             // Agregamos los efectos existentes de bows a los arcos nuevos, pueden cambiarse.
}

_declspec(naked) void CItemASM::StatsBow()
{
    static DWORD StatsBowNext = 0x0047D4AC;

    _asm
    {
        cmp dx, GET_ITEM(4, 17)
        je short next_instruction
        cmp dx, GET_ITEM(4, 20)
        je short next_instruction
        cmp dx, GET_ITEM(4, 21)
        je short next_instruction
        cmp dx, GET_ITEM(4, 22)
        je short next_instruction
        cmp dx, GET_ITEM(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[StatsBowNext]
    }
}

_declspec(naked) void CItemASM::BowSafeZone()
{
    static DWORD BowSafeZoneNext = 0x00458349;

    _asm
    {
        cmp bx, GET_ITEM_MODEL(4, 17)
        je short next_instruction
        cmp bx, GET_ITEM_MODEL(4, 20)
        je short next_instruction
        cmp bx, GET_ITEM_MODEL(4, 21)
        je short next_instruction
        cmp bx, GET_ITEM_MODEL(4, 22)
        je short next_instruction
        cmp bx, GET_ITEM_MODEL(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[BowSafeZoneNext]
    }
}

_declspec(naked) void CItemASM::SetPlayerStopBows()
{
    static DWORD StaticBowNext = 0x004432BA;

    _asm
    {
        cmp cx, GET_ITEM_MODEL(4, 17)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 20)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 21)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 22)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[StaticBowNext]
    }
}

_declspec(naked) void CItemASM::SetPlayerWalkBows()
{
    static DWORD MovementBowNext = 0x00443C46;

    _asm
    {
        cmp cx, GET_ITEM_MODEL(4, 17)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 20)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 21)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 22)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[MovementBowNext]
    }
}

_declspec(naked) void CItemASM::SetPlayerWalkRunBows()
{
    static DWORD Movement2BowNext = 0x00443D3F;

    _asm
    {
        cmp cx, GET_ITEM_MODEL(4, 17)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 20)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 21)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 22)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[Movement2BowNext]
    }
}

_declspec(naked) void CItemASM::ArrowReloadBow1()
{
    static DWORD TestBowNext = 0x004826E6;

    _asm
    {
        cmp eax, GET_ITEM(4, 17)
        je short next_instruction
        cmp eax, GET_ITEM(4, 20)
        je short next_instruction
        cmp eax, GET_ITEM(4, 21)
        je short next_instruction
        cmp eax, GET_ITEM(4, 22)
        je short next_instruction
        cmp eax, GET_ITEM(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[TestBowNext]
    }
}

_declspec(naked) void CItemASM::ArrowReloadBow2()
{
    static DWORD TTestBowNext = 0x0048B973;

    _asm
    {
        cmp cx, GET_ITEM(4, 17)
        je short next_instruction
        cmp cx, GET_ITEM(4, 20)
        je short next_instruction
        cmp cx, GET_ITEM(4, 21)
        je short next_instruction
        cmp cx, GET_ITEM(4, 22)
        je short next_instruction
        cmp cx, GET_ITEM(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[TTestBowNext]
    }
}

_declspec(naked) void CItemASM::FixNoMoreBowArrows()
{
    static DWORD TTestBowNext = 0x0048BCB0;

    _asm
    {
        cmp ebp, GET_ITEM(4, 17)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 20)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 21)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 22)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[TTestBowNext]
    }
}

_declspec(naked) void CItemASM::RangeBowShoot1()
{
    static DWORD DescubrirBow9Next = 0x004AEFDF;

    _asm
    {
        cmp eax, GET_ITEM(4, 17)
        je short next_instruction
        cmp eax, GET_ITEM(4, 20)
        je short next_instruction
        cmp eax, GET_ITEM(4, 21)
        je short next_instruction
        cmp eax, GET_ITEM(4, 22)
        je short next_instruction
        cmp eax, GET_ITEM(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[DescubrirBow9Next]
    }
}

_declspec(naked) void CItemASM::BowRangeEffectShoot()
{
    static DWORD DescubrirBow10Next = 0x004AE754;

    _asm
    {
        cmp ebp, GET_ITEM(4, 17)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 20)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 21)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 22)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[DescubrirBow10Next]
    }
}

_declspec(naked) void CItemASM::RangeBowShoot2()
{
    static DWORD DescubrirBow11Next = 0x0048D7B9;

    _asm
    {
        cmp ebp, GET_ITEM(4, 17)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 20)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 21)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 22)
        je short next_instruction
        cmp ebp, GET_ITEM(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[DescubrirBow11Next]
    }
}

_declspec(naked) void CItemASM::RenderObjectScreenBows()
{
    static DWORD DescubrirBow16Next = 0x004E1443;

    _asm
    {
        cmp esi, GET_ITEM_MODEL(4, 17)
        je short next_instruction
        cmp esi, GET_ITEM_MODEL(4, 20)
        je short next_instruction
        cmp esi, GET_ITEM_MODEL(4, 21)
        je short next_instruction
        cmp esi, GET_ITEM_MODEL(4, 22)
        je short next_instruction
        cmp esi, GET_ITEM_MODEL(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[DescubrirBow16Next]
    }
}

_declspec(naked) void CItemASM::SetPlayerAttackBowMount()
{
    static DWORD SetPlayerAttackBowMountNext1 = 0x004444AC;
    static DWORD SetPlayerAttackBowMountNext2 = 0x004444BC;

    _asm
    {
        cmp cx, GET_ITEM_MODEL(4, 17)
        je short next_instruction_1
        cmp cx, GET_ITEM_MODEL(4, 20)
        je short next_instruction_1
        cmp cx, GET_ITEM_MODEL(4, 21)
        je short next_instruction_1
        cmp cx, GET_ITEM_MODEL(4, 22)
        je short next_instruction_1
        cmp cx, GET_ITEM_MODEL(4, 23)
        jnz short next_instruction_2

    next_instruction_1 :
        jmp dword ptr[SetPlayerAttackBowMountNext1]

    next_instruction_2 :
        jmp dword ptr[SetPlayerAttackBowMountNext2]
    }
}

_declspec(naked) void CItemASM::FixShootBowArrows()
{
    static DWORD ShootBowArrowsNext = 0x00444742;

    _asm
    {
        cmp cx, GET_ITEM_MODEL(4, 17)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 20)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 21)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 22)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[ShootBowArrowsNext]
    }
}

_declspec(naked) void CItemASM::SoundBowsShoot()
{
    static DWORD StaticBowNext = 0x00444939;

    _asm
    {
        cmp cx, GET_ITEM_MODEL(4, 17)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 20)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 21)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 22)
        je short next_instruction
        cmp cx, GET_ITEM_MODEL(4, 23)
        je short next_instruction

        next_instruction :
        jmp dword ptr[StaticBowNext]
    }
}

_declspec(naked) void CItemASM::BowSkillEffect()
{
    static DWORD CaseDefault = 0x00474B6A;
    static DWORD Continua = 0x00474AA3;

    _asm
    {
        CMP EAX, 0x11
        JE short instruccion_continua

        CMP EAX, 0x13
        JL short instruccion_continua

        CMP EAX, 0x14
        JZ short instruccion_diamond

        CMP EAX, 0x15
        JZ short instruccion_aphrodite

        CMP EAX, 0x16
        JZ short instruccion_royal

        CMP EAX, 0x17
        JZ short instruccion_ashbringer

        CMP EAX, 0x1A
        JG short primera_instruccion

    primera_instruccion :
        MOV EAX, 0x01
        JMP instruccion_salto_case_default

    instruccion_diamond :
        MOV EAX, 0x06
        JZ short instruccion_continua

    instruccion_aphrodite :
        MOV EAX, 0x05
        JZ short instruccion_continua

    instruccion_royal :
        MOV EAX, 0x06
        JZ short instruccion_continua

    instruccion_ashbringer :
        MOV EAX, 0x02
        JZ short instruccion_continua

    instruccion_salto_case_default :
        jmp dword ptr[CaseDefault]

    instruccion_continua :
        jmp dword ptr[Continua]
    }
}

_declspec(naked) void CItemASM::PenetrationArrow()
{
    static DWORD SaltoInstruccion = 0x0049DA39;
    static DWORD SegundoSalto = 0x0049E6FE;

    _asm
    {
        cmp cx, 0x218
        jl short primera_instruccion        // Saltar a primera_instruccion solo si el registro cx es menor a 218 (4,8). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp cx, 0x21F
        jl short instruccion_de_salto       // Saltar a 0049DA39 solo si el registro cx es menor a 21F (4,15). En caso contrario, continuará ejecutando las instrucciones en secuencia.

    primera_instruccion:
        mov ax, word ptr ds : [eax + 0x288]
        cmp ax, 0x210
        jl short segunda_instruccion // Saltar a segunda_instruccion solo si el registro ax es menor a 210 (4,0). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x217
        jl short instruccion_de_salto        // Saltar a instruccion_de_salto solo si el registro ax es menor a 217 (4,7). En caso contrario, continuará ejecutando las instrucciones en secuencia.

    segunda_instruccion:
        cmp ax, 0x221
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 221 (4,17). En caso contrario, continuará ejecutando las instrucciones en secuencia.
       
        cmp ax, 0x224
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 224 (4,20). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x225
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 225 (4,21). En caso contrario, continuará ejecutando las instrucciones en secuencia.
       
        cmp ax, 0x226
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 226 (4,22). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x227
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 227 (4,23). En caso contrario, continuará ejecutando las instrucciones en secuencia.
       
        cmp cx, 0x220
        jl segundo_salto                    // Saltar a segundo_salto solo si el registro cx es menor a 220 (4,16). En caso contrario, continuará ejecutando las instrucciones en secuencia.
       
        cmp cx, 0x222
        jg segundo_salto                    // Saltar a segundo_salto solo si el registro cx es mayor a 222 (4,18). En caso contrario, continuará ejecutando las instrucciones en secuencia.

    instruccion_de_salto:
        jmp dword ptr[SaltoInstruccion]

    segundo_salto:
        jmp dword ptr[SegundoSalto]
    }
}

_declspec(naked) void CItemASM::IceArrow()
{
    static DWORD SaltoInstruccion = 0x0049F18B;
    static DWORD SegundoSalto = 0x0049F195;

    _asm
    {
        cmp cx, 0x218
        jl short primera_instruccion        // Saltar a primera_instruccion solo si el registro cx es menor a 218 (4,8). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp cx, 0x21F
        jl short instruccion_de_salto       // Saltar a 0049DA39 solo si el registro cx es menor a 21F (4,15). En caso contrario, continuará ejecutando las instrucciones en secuencia.

    primera_instruccion :
        mov ax, word ptr ds : [eax + 0x288]
        cmp ax, 0x210
        jl short segunda_instruccion // Saltar a segunda_instruccion solo si el registro ax es menor a 210 (4,0). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x217
        jl short instruccion_de_salto        // Saltar a instruccion_de_salto solo si el registro ax es menor a 217 (4,7). En caso contrario, continuará ejecutando las instrucciones en secuencia.

    segunda_instruccion :
        cmp ax, 0x221
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 221 (4,17). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x224
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 224 (4,20). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x225
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 225 (4,21). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x226
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 226 (4,22). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp ax, 0x227
        je short instruccion_de_salto       // Saltar a instruccion_de_salto solo si el registro ax es igual a 227 (4,23). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp cx, 0x220
        jl segundo_salto                    // Saltar a segundo_salto solo si el registro cx es menor a 220 (4,16). En caso contrario, continuará ejecutando las instrucciones en secuencia.

        cmp cx, 0x222
        jg segundo_salto                    // Saltar a segundo_salto solo si el registro cx es mayor a 222 (4,18). En caso contrario, continuará ejecutando las instrucciones en secuencia.

    instruccion_de_salto :
        jmp dword ptr[SaltoInstruccion]

    segundo_salto :
        jmp dword ptr[SegundoSalto]
    }
}

We place the ItemConvert function in the Item.cpp and we make a change to the nex
else if ((ip->Type >= GET_ITEM(4, 0) && ip->Type < GET_ITEM(4, 8)) || ip->Type == GET_ITEM(4, 17)) // Bows, Bolts
{
ip->Part = EQUIPMENT_WEAPON_LEFT;
}

We modify that else if for the next one where we are adding the new bow
else if ((ip->Type >= GET_ITEM(4, 0) && ip->Type < GET_ITEM(4, 8)) || ip->Type == GET_ITEM(4, 17)
|| ip->Type == GET_ITEM(4, 20)
|| ip->Type == GET_ITEM(4, 21)
|| ip->Type == GET_ITEM(4, 22)
|| ip->Type == GET_ITEM(4, 23)
) // Bows, Bolts
{
ip->Part = EQUIPMENT_WEAPON_LEFT;
}

Main.cpp
#include "ItemASM.h"
gItemASM.Init();