Noticias:

SMF - Just Installed!

Menú principal

Source DailyReward Paso a Paso

Publicado por Dakosmu, Feb 09, 2025, 08:59 PM

Tema anterior - Siguiente tema

Dakosmu

Source DailyReward Paso a Paso



LADO MAIN

stdafx.h


#define DAILY                            1 // ON

DailyReward.cpp

#include "stdafx.h"
#if (DAILY)
#include "DailyReward.h"
#include "Import.h"
#include "CustomFont.h"
#include <ctime>
#include "Interface.h"
#include "Defines.h"


cDailyReward DailyReward;

cDailyReward::cDailyReward()
{
    this->Init();
}

cDailyReward::~cDailyReward()
{
}

void cDailyReward::Init()
{
    this->SetWindow(false);
    this->SetRect(120, 70, 400, 255);
    //this->SetTitle("Daily Reward", 0xc1c1c1ff, 0x0, 1);
    this->SetTitle("Daily Reward", 0xFFBD19FF, 0x0, 1); // usando eGold
    this->SelectedDay = 1;
}

unsigned char last_day_of_month(int year, unsigned char month) {
    return month != 2 ? ((month ^ (month >> 3))) | 30 :
        year % 4 ? 29 : 28;
}

void cDailyReward::ClearDayGift()
{
    this->DayInfo = false;
    this->Type = -1;
    this->Level = 0;
    this->Ex = 0;
    this->Zen = 0;
    this->Wcoin = 0;
}

int ImgTag100 = 0;

void cDailyReward::DrawIcon() //focus move box daily
{

    if (gInterface.CheckWindow(CashShop)
        || gInterface.CheckWindow(SkillTree)
        || gInterface.CheckWindow(FullMap)
        || gInterface.CheckWindow(MoveList)
        || gInterface.CheckWindow(Inventory)
        || gInterface.CheckWindow(ExpandInventory)
        || gInterface.CheckWindow(Store)
        || gInterface.CheckWindow(Inventory)
        || gInterface.CheckWindow(Party)
        || gInterface.CheckWindow(Trade)
        || gInterface.CheckWindow(Warehouse)
        || gInterface.CheckWindow(ExpandWarehouse))
    {
        return;
    }
    int j;

    if (!Blink)
    {
        return;
    }

    CustomFont.Draw(CustomFont.FontNormal, 73, 60, 0xffffffff, 0x00000050, 0, 0, 3, "Daily Reward"); //Move Daily Reward - 70 lados - 60 arriba

    int speed = 2, r = 0;
    if (ImgTag100 >= 25 * speed) ImgTag100 = 0;

    r = floor((float)ImgTag100 / (float)speed);

    RenderBitmap(531026, 80, 30, 102.4 / 2, 93.4 / 2, (r % 5) * 102.4 / 512.0, (r - (r % 5)) / 5 * 93.4 / 512.0, 102.4 / 512.0, 93.4 / 512.0, 0, 1, 0.0);
    ImgTag100++; //Move Box Daily -- 80 lados -- 30 Ariba+Abajo


    if (IsWorkZone(80, 30, 40, 40, false))
    {
        if (pIsKeyRelease(VK_LBUTTON) && IsOnWindow())
            DailyReward.ToggleWindow(true);
    }

    if (IsWorkZone(80, 30, 40, 40, false))
    {
        pSetCursorFocus = true;
    }
    else pSetCursorFocus = false;
}

void cDailyReward::Draw()
{
    if (pPlayerState < GameProcess)
    {
        return;
    }
    if (gInterface.CheckWindow(ObjWindow::CashShop)
        || gInterface.CheckWindow(ObjWindow::FriendList)
        || gInterface.CheckWindow(ObjWindow::MoveList)
        || gInterface.CheckWindow(ObjWindow::Party)
        || gInterface.CheckWindow(ObjWindow::Quest)
        || gInterface.CheckWindow(ObjWindow::NPC_Devin)
        || gInterface.CheckWindow(ObjWindow::Guild)
        || gInterface.CheckWindow(ObjWindow::Trade)
        || gInterface.CheckWindow(ObjWindow::Warehouse)
        || gInterface.CheckWindow(ObjWindow::ChaosBox)
        || gInterface.CheckWindow(ObjWindow::CommandWindow)
        || gInterface.CheckWindow(ObjWindow::PetInfo)
        || gInterface.CheckWindow(ObjWindow::Shop)
        || gInterface.CheckWindow(ObjWindow::Inventory)
        || gInterface.CheckWindow(ObjWindow::Store)
        || gInterface.CheckWindow(ObjWindow::OtherStore)
        || gInterface.CheckWindow(ObjWindow::Character)
        || gInterface.CheckWindow(ObjWindow::DevilSquare)
        || gInterface.CheckWindow(ObjWindow::BloodCastle)
        || gInterface.CheckWindow(ObjWindow::CreateGuild)
        || gInterface.CheckWindow(ObjWindow::GuardNPC)
        || gInterface.CheckWindow(ObjWindow::SeniorNPC)
        || gInterface.CheckWindow(ObjWindow::GuardNPC2)
        || gInterface.CheckWindow(ObjWindow::CastleGateSwitch)
        || gInterface.CheckWindow(ObjWindow::CatapultNPC)
        || gInterface.CheckWindow(ObjWindow::CrywolfGate)
        || gInterface.CheckWindow(ObjWindow::IllusionTemple)
        || gInterface.CheckWindow(ObjWindow::HeroList)
        || gInterface.CheckWindow(ObjWindow::ChatWindow)
        || gInterface.CheckWindow(ObjWindow::FastMenu)
        || gInterface.CheckWindow(ObjWindow::Options)
        || gInterface.CheckWindow(ObjWindow::Help)
        || gInterface.CheckWindow(ObjWindow::FastDial)
        || gInterface.CheckWindow(ObjWindow::SkillTree)
        || gInterface.CheckWindow(ObjWindow::GoldenArcher1)
        || gInterface.CheckWindow(ObjWindow::GoldenArcher2)
        || gInterface.CheckWindow(ObjWindow::LuckyCoin1)
        || gInterface.CheckWindow(ObjWindow::LuckyCoin2)
        || gInterface.CheckWindow(ObjWindow::NPC_Duel)
        || gInterface.CheckWindow(ObjWindow::NPC_Titus)
        || gInterface.CheckWindow(ObjWindow::CashShop)
        || gInterface.CheckWindow(ObjWindow::Lugard)
        || gInterface.CheckWindow(ObjWindow::QuestList1)
        || gInterface.CheckWindow(ObjWindow::QuestList2)
        || gInterface.CheckWindow(ObjWindow::Jerint)
        || gInterface.CheckWindow(ObjWindow::FullMap)
        || gInterface.CheckWindow(ObjWindow::NPC_Dialog)
        || gInterface.CheckWindow(ObjWindow::GensInfo)
        || gInterface.CheckWindow(ObjWindow::NPC_Julia)
        || gInterface.CheckWindow(ObjWindow::NPC_ChaosMix)
        || gInterface.CheckWindow(ObjWindow::ExpandInventory)
        || gInterface.CheckWindow(ObjWindow::ExpandWarehouse)
        || gInterface.CheckWindow(ObjWindow::MuHelper)
        )
    {

        this->CloseWindow(true);
    }

    if (!CheckWindow())
    {
        DrawIcon();
        return;
    }
    this->DrawBase();

    tm today;
    time_t ltime;
    time(&ltime);
    localtime_s(&today, &ltime);

    char* DoW[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

    float sW = 35, sH = 38;
    int i, v1, v2, v3, v4, v5;
    v3 = this->FWday;
    v4 = this->MaxDay;
    for (i = 0; i < 7; i++)
    {
        CustomFont.Draw(CustomFont.FontNormal, x + 15 + sW * i, y + 35, 0xffffffff, 0xc1c1c150, sW - 2, 0, 3, DoW[i]);
    }
    if (Loaded)
    {
        for (i = v3; i < (v3 + v4); i++)
        {
            v1 = i % cDR_SPLIT_DAY;
            v2 = (i - v1) / cDR_SPLIT_DAY;
            v5 = i - v3 + 1;
            //
            if (SelectedDay == v5)
            {
                CustomFont.Draw(CustomFont.FontNormal, x + 15 + sW * v1, y + 52 + v2 * sH, 0xffffffff, 0x00000050, sW - 2, sH - 2, 3, " ");
            }
            if (SelectedDay == v5 && State[v5 - 1] == 0) //selecting
            {
                RenderBitmap(531020, x + 8 + sW * v1 + (sW - 16) / 2, y + 50 + v2 * sH, 45, 53, 0.0, 0.0, 1.0, 1.0, 1, 1, 0.0);
            }
            else if (IsWorkZone(x + 15 + sW * v1, y + 52 + v2 * sH, sW - 2, sH - 2, true))
            {
                RenderBitmap(531020, x + 8 + sW * v1 + (sW - 16) / 2, y + 50 + v2 * sH, 45, 53, 0.0, 0.0, 1.0, 1.0, 1, 1, 0.0);
                if (pIsKeyRelease(VK_LBUTTON))
                {
                    SelectedDay = v5;
                    if (State[v5 - 1] == 0)
                    {
                        this->SendRequest(0x01, SelectedDay);
                        this->ClearDayGift();
                    }
                }
            }
            else if (State[v5 - 1] == 0) //
            {
                RenderBitmap(531020, x + 8 + sW * v1 + (sW - 16) / 2, y + 50 + v2 * sH, 45, 53, 0.0, 0.0, 1.0, 1.0, 1, 1, 0.0);
            }
            else
            {
                RenderBitmap(531021, x + 8 + sW * v1 + (sW - 16) / 2, y + 50 + v2 * sH, 45, 53, 0.0, 0.0, 1.0, 1.0, 1, 1, 0.0);
            }
            CustomFont.Draw(CustomFont.FontNormal, x + 15 + sW * v1, y + 52 + v2 * sH + sH - 13, 0xffffffff, (v5) != today.tm_mday ? 0x00000050 : 0x00ff007f, sW - 2, 12, 3, "%d", v5);
        }

        if (SelectedDay != 0)
        {
            if (State[SelectedDay - 1] != 0)
            {
                CustomFont.Draw(CustomFont.FontNormal, x + 265, y + 100, 0xffffffff, 0x00FF0050, 125, 0, 3, "CONCLUIDO");
                CustomFont.Draw(CustomFont.FontNormal, x + 265, y + 110, 0xffffffff, 0x00000050, 125, 0, 3, "Esta recompensa foi resgatada,");
                CustomFont.Draw(CustomFont.FontNormal, x + 265, y + 120, 0xffffffff, 0x00000050, 125, 0, 3, "continue jogando todos os dias");
                CustomFont.Draw(CustomFont.FontNormal, x + 265, y + 130, 0xffffffff, 0x00000050, 125, 0, 3, "para resgatar mais recompensas!");

            }
            else if (DayInfo)
            {
                CustomFont.Draw(CustomFont.FontNormal, x + 259, y + 49, 0xffffffff, 0x00000050, 131, 191, 3, " ");

                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 50, 0xFFFFFFFF, 0x00FF0050, 129, 0, 3, Text);
                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 62, 0xffffffff, 0xffffff30, 129, 0, 3, "WCoin (C): %d", Wcoin);
                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 74, 0xffffffff, 0xffffff30, 129, 0, 3, "WCoin (P): %d", GPoint);
                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 86, 0xffffffff, 0xffffff30, 129, 0, 3, "Globin Point: %d", GPoint1);
                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 98, 0xffffffff, 0xffffff30, 129, 0, 3, "Zen: %d", Zen);

                if (SelectedDay <= today.tm_mday)
                {
                    this->DrawButton(32331, x - 5 + 75 * 4, y + h - 50, 73, 27, 128.0, 128.0, DailyReward.RecvGiftAction);
                    CustomFont.Draw(CustomFont.FontNormal, x - 5 + 75 * 4, y + h - 42.5, 0xffffffff, 0x0, 73, 0, 3, "Rewarded");
                }

                CustomFont.Draw(CustomFont.FontNormal, x + 280, y + 100, 0xffffffff, 0x00000050, 90, 90, 3, " ");

                gInterface.DrawItem2(x + 280, y + 100, 90, 90, this->Type, this->Level, this->Ex, 0, 0);


                if (IsWorkZone(x + 280, y + 100, 90, 90, true))
                {
                    gInterface.DrawItemToolTipTextDaily((void*)&Item, *(int*)0x879340C, *(int*)0x8793410 + 25);
                    glColor3f(1, 1, 1);
                    pSetBlend(false);
                }
            }
            else
            {
                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 50, 0xffffffff, 0x00000050, 130, 0, 3, "Sem informações...", Wcoin);
                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 70, 0xffffffff, 0x00000050, 130, 0, 3, "Sem informações...", GPoint);
                CustomFont.Draw(CustomFont.FontNormal, x + 260, y + 90, 0xffffffff, 0x00000050, 130, 0, 3, "Sem informações...", GPoint1);

            }
        }
    }
    else
    {
        CustomFont.Draw(CustomFont.FontNormal, x + 60, y + 50, 0xffffffff, 0x00000050, 200, 0, 3, "No Data...");
    }
    if (!pSetCursorFocus)
    {
        pSetCursorFocus = true;
    }
}


bool cDailyReward::AllowedGift()
{
    return Loaded && State[SelectedDay - 1] == 0 && SelectedDay <= CurDay;
}
void cDailyReward::SendRequest(BYTE type, int value)
{
    PMSG_DAILY_REWARD_SEND pRequest;
    pRequest.h.set((LPBYTE)&pRequest, 0xF5, 0x02, sizeof(pRequest));
    pRequest.Type = type;
    pRequest.Value = value;
    DataSend((LPBYTE)&pRequest, pRequest.h.size);
}

void cDailyReward::RecvGiftAction(LPVOID pClass)
{
    cDailyReward* This = (cDailyReward*)pClass;

    if (This->AllowedGift())
    {
        This->SendRequest(0x02, This->SelectedDay);
    }
}

void cDailyReward::OnOpen()
{
    this->Loaded = false;
    this->DayInfo = false;
    this->SendRequest(0x0, 0x0);
}
void cDailyReward::OnClose()
{
}

void cDailyReward::ToggleWindow(bool mode)
{
    if (gInterface.CheckWindow(SkillTree) || gInterface.CheckWindow(Shop) || gInterface.CheckWindow(CreateGuild) || gInterface.CheckWindow(ChatWindow) || gInterface.CheckWindow(FriendList) || gInterface.CheckWindow(MuHelper) || gInterface.CheckWindow(Store) || gInterface.CheckWindow(Warehouse) || gInterface.CheckWindow(Trade) || gInterface.CheckWindow(CashShop) || gInterface.CheckWindow(GuardNPC) || gInterface.CheckWindow(ObjWindow::FastMenu))
    {
        return;
    }

    gInterface.CloseWindow(Character);
    gInterface.CloseWindow(Inventory);
#if JewelBankMain
    gInterface.CloseJewelBankWindow();
#endif
    gInterface.CloseCustomWindow();
    SetWindow(!CheckWindow(), mode);
}

void cDailyReward::OpenWindow(bool mode)
{
    SetWindow(true, mode);
}
void cDailyReward::CloseWindow(bool mode)
{
    SetWindow(false, mode);
}
void cDailyReward::SetWindow(bool state, bool mode)
{
    this->Drawing = state;
    if (mode)
        CheckWindow() ? OnOpen() : OnClose();
}

void cDailyReward::GCRecvUserInfo(BYTE* a)
{
    PMSG_DAILY_REWARD_USER_INFO_RECV* Data = (PMSG_DAILY_REWARD_USER_INFO_RECV*)a;
    this->CurDay = Data->CurDay;
    this->MaxDay = Data->MaxDay;
    this->FWday = Data->FWday;
    this->Timer = Data->Timer;

    for (int i = 0; i < 31; i++)
    {
        this->State[i] = Data->State[i];
    }

    if (State[CurDay - 1] == 0)
    {
        Blink = true;
    }
    else
    {
        Blink = false;
    }

    Loaded = true;
}

int cDailyReward::CheckItemInfo(signed int a1)
{
    if (a1 > 3092)
    {
        if (a1 > 4661)
        {
            if (a1 > 5685 || a1 < 5676 && (a1 < 5164 || a1 > 5173))
                return 0;
        }
        else if (a1 < 4652 && (a1 > 4149 || a1 < 4140 && (a1 < 3628 || a1 > 3637)))
        {
            return 0;
        }

        return 1;
    }

    if (a1 >= 3089)
        return 1;

    if (a1 > 2071)
    {
        if (a1 != 2580 && (a1 <= 2589 || a1 > 2592))
            return 0;
        return 1;
    }

    if (a1 == 2071 || a1 <= 1041 && (a1 >= 1040 || a1 >= 26 && a1 <= 28))
        return 1;

    return 0;
}

void cDailyReward::GCRecvDayInfo(BYTE* a)
{
    PMSG_DAILY_REWARD_DAY_INFO_RECV* Data = (PMSG_DAILY_REWARD_DAY_INFO_RECV*)a;

    DayInfo = true;
    if (Data->Type != -1)
    {
        this->Type = Data->Type;

        DWORD dwAddress;
        int a5;
        int a6;
        int a7;
        int a8;
        int a9;
        DWORD a10;

        dwAddress = (DWORD)&this->Item;

        *(WORD*)dwAddress = Data->Type;
        a5 = Data->Dur;
        *(BYTE*)(dwAddress + 22) = a5;
        a6 = Data->Item[3];
        *(BYTE*)(dwAddress + 23) = a6;
        a7 = Data->Item[4];
        *(BYTE*)(dwAddress + 24) = a7;
        a8 = Data->Item[5];
        *(BYTE*)(dwAddress + 97) = (a8 & 2) >> 1 > 0;
        *(BYTE*)(dwAddress + 98) = (a8 & 4) >> 2 > 0;
        *(BYTE*)(dwAddress + 73) = 16 * (a8 & 8) >> 7 > 0;
        a9 = Data->Item[6];
        *(WORD*)(dwAddress + 69) = (a9 & 0xF0) >> 4;
        *(WORD*)(dwAddress + 71) = a9 & 0xF;

        a10 = (DWORD)&Data->Item[7];

        if (a10)
        {
            *(BYTE*)(dwAddress + 79) = 5;

            for (int i = 0; i < 5; ++i)
                *(BYTE*)(i + dwAddress + 74) = *(BYTE*)(i + a10);

            for (int j = 0; j < 5; ++j)
            {
                if (*(BYTE*)(j + a10) == 255)
                {
                    *(BYTE*)(dwAddress + 79) = j;
                    break;
                }

                if (*(BYTE*)(j + a10) == 254)
                {
                    *(BYTE*)(j + dwAddress + 80) = -1;
                }
                else
                {
                    *(BYTE*)(j + dwAddress + 80) = *(BYTE*)(j + a10) % 50;
                    *(BYTE*)(j + dwAddress + 85) = *(BYTE*)(j + a10) / 50 + 1;
                }
            }

            if (this->CheckItemInfo(*(WORD*)dwAddress))
            {
                *(BYTE*)(dwAddress + 90) = a9;
                *(WORD*)(dwAddress + 69) = 0;
                *(WORD*)(dwAddress + 71) = 0;
            }
            else
            {
                *(BYTE*)(dwAddress + 90) = -1;
            }
        }
        else
        {
            *(BYTE*)(dwAddress + 79) = 0;
        }

        *(BYTE*)(dwAddress + 96) = 0;
        *(DWORD*)(dwAddress + 103) = 1;

        if (Data->PeriodTime)
        {
            this->Item.PeriodItem = 1;
            this->Item.ExpireDateConvert = Data->PeriodTime;
        }

        ((void(__cdecl*)(ObjectItem * lpItem, BYTE Option, BYTE Special, BYTE Value)) 0x58B910)(&this->Item, Data->Item[1], Data->Item[3], Data->Item[4]);
    }
    this->Zen = Data->Zen;
    this->Wcoin = Data->Wcoin;
    this->GPoint = Data->GPoint;
    this->GPoint1 = Data->GPoint1;
    memcpy_s(Text, 100, Data->Text, 100);
}
//Evento para bloquear el pes cursor del ico
void cDailyReward::Bind()
{
    gInterface.BindObject(eMAIN_DailySystem, 0x7A5A, 445, 364, 205, -1);
    gInterface.BindObject(OBJECT_DAILY_SYSTEM_CLOSE, 0x7EC5, 36, 29, -1, -1);
}
int cDailyReward::Button(DWORD Event)
{

    if (gInterface.ButtonEx(Event, OBJECT_DAILY_SYSTEM_CLOSE, false))
    {
        pSetCursorFocus = false;
        IsOnWindow();
        this->SetWindow(false, true);
        gInterface.Data[eMAIN_DailySystem].OnShow = false;

        return true;
    }


    return false;
}
#endif


DailyReward.h

#pragma once
#if (DAILY)
#include "InterfaceBase.h"
#include "Protocol.h"
#include "Object.h"

#define IsRelease                ((bool  (__cdecl*)(int iVirtKey))0x00791050)
#define pCheckInMouse                                ((bool(__cdecl*)(int x, int y, int w, int h)) 0x00790B10)


#define cDR_SPLIT_DAY    7

struct PMSG_DAILY_REWARD_SEND
{
    PBMSG_HEAD2 h;
    BYTE Type;
    int  Value;
};

struct PMSG_DAILY_REWARD_USER_INFO_RECV
{
    PBMSG_HEAD2 h;
    BYTE MaxDay;
    BYTE CurDay;
    BYTE FWday;
    BYTE State[31];
    DWORD Timer;
};


struct PMSG_DAILY_REWARD_DAY_INFO_RECV
{
    PBMSG_HEAD2 h;
    short Type;
    BYTE Dur;
    BYTE Item[12];
    int  PeriodTime;
    int Wcoin;
    int GPoint;
    int GPoint1;
    int Zen;
    char Text[100];
};

class cDailyReward : public cInterfaceBase
{
public:
    cDailyReward();
    ~cDailyReward();
    void ToggleWindow(bool mode = false);
    void OpenWindow(bool mode = false);
    void CloseWindow(bool mode = false);
    void SetWindow(bool state, bool mode = false);
    void Init();
    void Draw();
    void Bind();
    void OnOpen();
    void OnClose();
    bool AllowedGift();
    void OnRequestGift();
    void ClearDayGift();
    void SendRequest(BYTE type, int value);
    void GCRecvUserInfo(BYTE* a);
    void GCRecvDayInfo(BYTE* a);
    int  CheckItemInfo(signed int a1);
    void DrawIcon();
    static void RecvGiftAction(LPVOID pClass);
    int Button(DWORD Event);
    BYTE SelectedDay;
    BOOL Blink;
    BOOL Loaded;
    BOOL Checked;
    BOOL DayInfo;
    BYTE MaxDay;
    BYTE CurDay;
    BYTE FWday;
    BYTE State[31];
    DWORD Timer;
    ObjectItem Item;
    short Type;
    BYTE Level;
    BYTE Ex;
    int Wcoin;
    int GPoint;
    int GPoint1;
    int Zen;
    char Text[100];
    DWORD TickCount;
};

extern cDailyReward DailyReward;
#endif


Controller.cpp


#include "DailyReward.h"

Buscar case WM_LBUTTONDOWN


Agregar


#if (DAILY)
            DailyReward.Button(wParam);
#endif

buscar case VK_ESCAPE

Agregar


#if(DAILY)
                DailyReward.CloseWindow(true);

#endif


Interface.cpp

Buscar void Interface::RenderObjectSystem() o void Interface::Load()

Agregar


#if (DAILY)
    DailyReward.Bind();
#endif


Buscar void Interface::LoadImages()


Agregar


#if (DAILY)
    pLoadImage("Custom\\Daily\\dong.tga", 531020, GL_LINEAR, GL_REPEAT, 1, 0);
    pLoadImage("Custom\\Daily\\mo.tga", 531021, GL_LINEAR, GL_REPEAT, 1, 0);
    pLoadImage("Custom\\Daily\\giftboxnotice.tga", 531026, GL_LINEAR, GL_REPEAT, 1, 0);
    pLoadImage("Custom\\Daily\\DailyReward2024.tga", 73104, GL_LINEAR, GL_REPEAT, 1, 0);

#endif

Buscar void Interface::Work()

Agregar


#if (DAILY)
    DailyReward.Draw();
#endif


Buscar if (GetKeyState


Agregar


#if (DAILY)
        if (GetKeyState('Y') & 0x4000 && GetTickCount() >= gCustomRankUser.OpenTestDelay + 250)
        {
            if (GetForegroundWindow() == pGameWindow && !gInterface.CheckWindow(ObjWindow::ChatWindow))
            {
                DailyReward.ToggleWindow(true);
                gCustomRankUser.OpenTestDelay = GetTickCount();
            }
        }
#endif


Buscar GetKeyState(VK_ESCAPE) < 0


Agregar


#if (DAILY)
            DailyReward.CloseWindow(true);
#endif



Protocol.cpp


#include "DailyReward.h"

#if (DAILY)
        case 0xF5:
            switch (((lpMsg[0] == 0xC1) ? lpMsg[3] : lpMsg[4]))
            {
            case 0x03:
                DailyReward.GCRecvUserInfo(lpMsg);
                break;
            case 0x04:
                DailyReward.GCRecvDayInfo(lpMsg);
                break;
            }
            break;
#endif


Bon Dia

Dakosmu

LADO DATASERVER



stdafx.h


#define DAILY                1

DataServerProtocol.cpp

Buscar como indica la imagen void GDSaveTheGiftRecv(THEGIFT_GD_SAVE_DATA* lpMsg) // OK


Agregar como Indica la imagen


#if (DAILY)
        case 0x68:
            GDDailyRewardInfoRecv(lpMsg, index);
            break;
#endif

Agregar debajo de void GDRankingBosSaveRecv(SDHP_RANKING_BOS_SAVE_RECV* lpMsg)


#if (DAILY)
void GDDailyRewardInfoRecv(BYTE* lpMsg, int index)
{
    SDHP_DAILY_REWARD_INFO_SEND* dailyreward = (SDHP_DAILY_REWARD_INFO_SEND*)lpMsg;

    for (int i = 0; i < 31; i++)
    {
        if (dailyreward->Status[i])
        {
            if (gQueryManager.ExecQuery("SELECT * FROM DailyReward WHERE Acc='%s' AND date = %d AND month = MONTH(GETDATE())", dailyreward->acc, i + 1) == 0 || gQueryManager.Fetch() == SQL_NO_DATA)
            {
                gQueryManager.Close();
                gQueryManager.ExecQuery("INSERT INTO DailyReward (acc, name, date) VALUES ('%s','%s', %d)", dailyreward->acc, dailyreward->name, i + 1);
                gQueryManager.Close();
            }
            else
            {
                gQueryManager.Close();
            }
        }
    }
}

#endif

DataServerProtocol.h


#if (DAILY)
struct SDHP_DAILY_REWARD_INFO_SEND
{
    PWMSG_HEAD header; // C2:04
    WORD index;
    int  result;
    char acc[11];
    char name[11];
    BYTE Status[31];
};
#endif



Agregar


#if (DAILY)
void GDDailyRewardInfoRecv(BYTE* lpMsg, int index);
#endif







Bon Dia

Dakosmu

GAMESERVER


stdafx.h


#define DAILY 1
DailyReward.cpp

#include "stdafx.h"
#if (DAILY)
#include "DailyReward.h"
#include "Util.h"
#include "GameMain.h"
#include "MemScript.h"
#include "Util.h"
#include "DSProtocol.h"
#include "Notice.h"
#include "ItemManager.h"

cDailyReward DailyReward;

cDailyReward::cDailyReward()
{
}

cDailyReward::~cDailyReward()
{
}

void cDailyReward::OnSecondProc(int aIndex)
{
tm today;
time_t ltime;
time(&ltime);
localtime_s(&today, &ltime);

int rIndex = aIndex - OBJECT_START_USER;

if (!OBJECT_USER_RANGE(aIndex))
{
return;
}

if (this->Users[rIndex].mDay != today.tm_mday)
{
this->OnRequestInfo(aIndex);
this->Users[rIndex].mDay = today.tm_mday;
}
}

void cDailyReward::Read(char* path)
{
CMemScript* lpMemScript = new CMemScript;

if (lpMemScript == 0)
{
ErrorMessageBox(MEM_SCRIPT_ALLOC_ERROR, path);
return;
}

if (lpMemScript->SetBuffer(path) == 0)
{
ErrorMessageBox(lpMemScript->GetLastError());
delete lpMemScript;
return;
}

this->m_Configs.clear();

int type = -1;

int sNum = 1;
int lNum = 1;

try
{
while (true)
{
if (lpMemScript->GetToken() == TOKEN_END)
{
break;
}

int section = lpMemScript->GetNumber();

while (true)
{
if (section == 0)
{
if (strcmp("end", lpMemScript->GetAsString()) == 0)
{
break;
}

cDR_Config info;

info.Day = lpMemScript->GetNumber();

info.Item = lpMemScript->GetAsNumber() * 512 + lpMemScript->GetAsNumber();

info.Level = lpMemScript->GetAsNumber();

info.Op1 = lpMemScript->GetAsNumber();

info.Op2 = lpMemScript->GetAsNumber();

info.Op3 = lpMemScript->GetAsNumber();

info.Dur = lpMemScript->GetAsNumber();

info.Ex = lpMemScript->GetAsNumber();

info.Anc = lpMemScript->GetAsNumber();

info.Sk[0] = lpMemScript->GetAsNumber();

info.Sk[1] = lpMemScript->GetAsNumber();

info.Sk[2] = lpMemScript->GetAsNumber();

info.Sk[3] = lpMemScript->GetAsNumber();

info.Sk[4] = lpMemScript->GetAsNumber();

info.Skbonus = lpMemScript->GetAsNumber();

info.Expire = lpMemScript->GetAsNumber();

info.Wcoin = lpMemScript->GetAsNumber();

info.Zen = lpMemScript->GetAsNumber();

info.Cost = lpMemScript->GetAsNumber();

strcpy_s(info.Text, lpMemScript->GetAsString());

this->m_Configs.insert(std::pair<int, cDR_Config>(info.Day, info));
}
else
{
break;
}
}
}
}
catch (...)
{
ErrorMessageBox(lpMemScript->GetLastError());
}

delete lpMemScript;
}

void cDailyReward::CharZero(int aIndex)
{
int rIndex = aIndex - OBJECT_START_USER;

if (!OBJECT_USER_RANGE(aIndex))
{
return;
}
this->Users[rIndex].aIndex = -1;
this->Users[rIndex].mDay = 0;

for (int i = 0; i < 31; i++)
{
this->Users[rIndex].State[i] = 0;
}

}

void cDailyReward::DGDailyInfo(LPBYTE buf)
{
SDHP_DAILY_REWARD_INFO_RECV* Data = (SDHP_DAILY_REWARD_INFO_RECV*)buf;

int rIndex = Data->index - OBJECT_START_USER;

if (!OBJECT_USER_RANGE(Data->index))
{
return;
}

tm today;
time_t ltime;
time(&ltime);
localtime_s(&today, &ltime);

this->Users[rIndex].mDay = today.tm_mday;

this->Users[rIndex].aIndex = Data->index;

for (int i = 0; i < 31; i++)
{
this->Users[rIndex].State[i] = Data->Status[i];
}


this->OnRequestInfo(Data->index);
}

void cDailyReward::GDDailySave(int aIndex)
{
LPOBJ lpObj = &gObj[aIndex];

if (!OBJECT_USER_RANGE(aIndex))
{
return;
}

SDHP_DAILY_REWARD_INFO_RECV pMsg;

pMsg.header.set(0x68, sizeof(pMsg));

pMsg.index = lpObj->Index;

memcpy(pMsg.acc, lpObj->Account, sizeof(pMsg.acc));

memcpy(pMsg.name, lpObj->Name, sizeof(pMsg.name));

pMsg.result = 1;

int rIndex = aIndex - OBJECT_START_USER;

for (int i = 0; i < 31; i++)
{
pMsg.Status[i] = this->Users[rIndex].State[i];
}

gDataServerConnection.DataSend((BYTE*)&pMsg, sizeof(pMsg));
}

void cDailyReward::CGRequest(BYTE* a, int aIndex)
{
LPOBJ lpObj = &gObj[aIndex];

if (!OBJECT_USER_RANGE(aIndex))
{
return;
}

PMSG_DAILY_REWARD_RECV* Data = (PMSG_DAILY_REWARD_RECV*)a;

switch (Data->Type)
{
case 0x0:
this->OnRequestInfo(aIndex);
break;
case 0x1:
this->GCDailyInfo(Data->Value, aIndex);
break;
case 0x2:
this->OnRequestRecvGift(Data->Value, aIndex);
break;
default:
break;
}
}

unsigned char last_day_of_month(int year, unsigned char month) {
return month != 2 ? ((month ^ (month >> 3))) | 30 :
year % 4 ? 29 : 28;
}

void cDailyReward::GCDailyUserInfo(int aIndex)
{
LPOBJ lpObj = &gObj[aIndex];

if (!OBJECT_USER_RANGE(aIndex))
{
return;
}

tm today;
time_t ltime;
time(&ltime);
localtime_s(&today, &ltime);

tm fmday = { 0, 0, 0, 1, today.tm_mon, today.tm_year };
time_t time_temp = mktime(&fmday);
tm* tmonth = localtime(&time_temp);

PMSG_DAILY_REWARD_USER_INFO_SEND rSend;

rSend.h.set((LPBYTE)&rSend, 0xF5, 0x03, sizeof(rSend));

rSend.CurDay = today.tm_mday;
rSend.MaxDay = last_day_of_month(today.tm_year + 190, today.tm_mon + 1);
rSend.FWday = tmonth->tm_wday;

int rIndex = aIndex - OBJECT_START_USER;

for (int i = 0; i < 31; i++)
{
rSend.State[i] = this->Users[rIndex].State[i];
}

rSend.Timer = (DWORD)ltime;
DataSend(aIndex, (LPBYTE)&rSend, sizeof(rSend));
}

cDR_Config* cDailyReward::GetInfo(int day) // OK
{
std::map<int, cDR_Config>::iterator it = this->m_Configs.find(day);

if (it != this->m_Configs.end())
{
return &it->second;
}
return 0;
}

void cDailyReward::GCDailyInfo(int day, int aIndex)
{
LPOBJ lpObj = &gObj[aIndex];

if (!OBJECT_USER_RANGE(aIndex))
{
return;
}
PMSG_DAILY_REWARD_DAY_INFO_SEND rSend;
rSend.h.set((LPBYTE)&rSend, 0xF5, 0x04, sizeof(rSend));

cDR_Config* Day = this->GetInfo(day);
if (Day == 0)
{
return;
}

rSend.Type = Day->Item;
rSend.Dur = Day->Dur;
this->ItemByteConvert(rSend.Item, day);
rSend.PeriodTime = Day->Expire;

rSend.Wcoin = Day->Wcoin;
rSend.Zen = Day->Zen;

memcpy_s(rSend.Text, sizeof(rSend.Text), Day->Text, sizeof(rSend.Text));

DataSend(aIndex, (LPBYTE)&rSend, sizeof(rSend));
}

void cDailyReward::OnRequestInfo(int aIndex)
{

tm today;
time_t ltime;
time(&ltime);
localtime_s(&today, &ltime);

this->GCDailyUserInfo(aIndex);
this->GCDailyInfo(today.tm_mday, aIndex);
}

void cDailyReward::ItemByteConvert(BYTE* lpMsg, int day) // OK
{
cDR_Config* Day = this->GetInfo(day);
if (Day == 0)
{
return;
}
lpMsg[0] = Day->Item & 0xFF;

lpMsg[1] = 0;
lpMsg[1] |= Day->Level * 8;
lpMsg[1] |= Day->Op1 * 128;
lpMsg[1] |= Day->Op2 * 4;
lpMsg[1] |= Day->Op3 & 3;

lpMsg[2] = Day->Dur;

lpMsg[3] = 0;
lpMsg[3] |= (Day->Item & 0x100) >> 1;
lpMsg[3] |= ((Day->Op3 > 3) ? 0x40 : 0);
lpMsg[3] |= Day->Ex;

lpMsg[4] = Day->Anc;

lpMsg[5] = 0;
lpMsg[5] |= (Day->Item & 0x1E00) >> 5;
lpMsg[5] |= ((Day->Ex & 0x80) >> 4);
lpMsg[5] |= ((Day->Expire & 1) << 2);

lpMsg[6] = Day->Skbonus;

lpMsg[7] = Day->Sk[0];
lpMsg[8] = Day->Sk[1];
lpMsg[9] = Day->Sk[2];
lpMsg[10] = Day->Sk[3];
lpMsg[11] = Day->Sk[4];
}

void cDailyReward::OnRequestRecvGift(int day, int aIndex)
{
if (!OBJECT_USER_RANGE(aIndex))
{
return;
}

LPOBJ lpObj = &gObj[aIndex];

cDR_Config* Day = this->GetInfo(day);
if (Day == 0)
{
gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "No Reward!");
return;
}

int rIndex = aIndex - OBJECT_START_USER;


if (day > 0 && day <= 31)
{
if (Users[rIndex].State[day - 1] != 0)
{
gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "You Complete!");
return;
}

if (gItemManager.CheckItemInventorySpace(lpObj, 4, 4) == 0)
{
gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "Inventory full!");
return;
}

if (day != Users[rIndex].mDay)
{
gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "You Can't Receive Gifts!");
return;
//cost
if (Day->Cost == -1 || day > Users[rIndex].mDay)
{
gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "You Can't Receive Gifts!");
return;
}
else if (Day->Cost)
{
if (lpObj->Coin1 < Day->Cost)
{
gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "You Don't Have Enough Money!");
return;
}

GDSetCoinSend(lpObj->Index, -Day->Cost, 0, 0, "Nhan lai qua");
}
}

//trao qua
if (Day->Item != -1)
{

//check range ...
BYTE ItemSocketOption[MAX_SOCKET_OPTION] = { Day->Sk[0], Day->Sk[1], Day->Sk[2], Day->Sk[3], Day->Sk[4] };
GDCreateItemSend(lpObj->Index, 0xEB, (BYTE)lpObj->X, (BYTE)lpObj->Y, Day->Item, Day->Level, Day->Dur, Day->Op1, Day->Op2, Day->Op3, -1, Day->Ex, Day->Anc, 0, 0, ItemSocketOption, Day->Skbonus, Day->Expire);
}
if (Day->Zen)
{
if (gObjCheckMaxMoney(lpObj->Index, Day->Zen) == 0)
{
lpObj->Money = MAX_MONEY;
}
else
{
lpObj->Money += Day->Zen;
}

GCMoneySend(lpObj->Index, lpObj->Money);
}
if (Day->Wcoin)
{
GDSetCoinSend(lpObj->Index, Day->Wcoin, 0, 0, "DailyReward");
}

gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "You Received Success Gifts!");
Users[rIndex].State[day - 1] = 1;
OnRequestInfo(aIndex);
GDCharacterInfoSaveSend(lpObj->Index);
}
}
#endif

DailyReward.h

#pragma once

#include "Protocol.h"
#include <WinDef.h>
#include <WinBase.h>
#if (DAILY)
struct cDR_User
{
int aIndex;
int mDay;
BYTE State[31];
};

struct SDHP_DAILY_REWARD_INFO_RECV
{
PWMSG_HEAD header; // C2:04
WORD index;
int  result;
char acc[11];
char name[11];
BYTE Status[31];
};

struct PMSG_DAILY_REWARD_RECV
{
PBMSG_HEAD2_Origin h;
BYTE Type;
int  Value;
};

struct PMSG_DAILY_REWARD_USER_INFO_SEND
{
PBMSG_HEAD2_Origin h;
BYTE MaxDay;
BYTE CurDay;
BYTE FWday;
BYTE State[31];
DWORD Timer;
};

struct PMSG_DAILY_REWARD_DAY_INFO_SEND
{
PBMSG_HEAD2_Origin h;
short Type;
BYTE Dur;
BYTE Item[12];
int  PeriodTime;
int Wcoin;
int Zen;
char Text[100];
};

struct cDR_Config
{
short Day;
short Item;
BYTE Level;
BYTE Op1;
BYTE Op2;
BYTE Op3;
BYTE Dur;
BYTE Ex;
BYTE Anc;
BYTE Sk[5];
BYTE Skbonus;
DWORD Expire;
int Wcoin;
int  Zen;
int  Cost;
char Text[100];
};

class cDailyReward
{
public:
cDailyReward();
~cDailyReward();
void Read(char* path);
void OnSecondProc(int aIndex);
void CharZero(int aIndex);
void DGDailyInfo(LPBYTE buf);
void GDDailySave(int aIndex);
void CGRequest(BYTE* a, int aIndex);
void GCDailyUserInfo(int aIndex);
void GCDailyInfo(int day, int aIndex);
void OnRequestInfo(int aIndex);
void OnRequestRecvGift(int day, int aIndex);
void ItemByteConvert(BYTE* lpMsg, int day);
cDR_Config* GetInfo(int day);
private:
cDR_User Users[MAX_OBJECT_USER];
std::map<int, cDR_Config> m_Configs;
};

extern cDailyReward DailyReward;

#endif


DSProtocol.cpp

Buscar case 0xD3:

#if (DAILY)
    DailyReward.GDDailySave(aIndex);
#endif

Agregar

#if (DAILY)
        case 0x68:
            DailyReward.DGDailyInfo(lpMsg);
            break;
#endif


Buscar void GDInventoryItemSaveSend(int aIndex) // OK


Agregar
#if (DAILY)
    DailyReward.GDDailySave(aIndex);
#endif

Colocar este codigo al final de todos los codigos


#if (DAILY)
void GDSetCoinSend(int aIndex, int value1, int value2, int value3, char* LogName) // OK
{
    LPOBJ lpObj = &gObj[aIndex];

    SDHP_SETCOIN_SEND pMsg;

    pMsg.header.set(0xF3, sizeof(pMsg));

    pMsg.index = aIndex;

    memcpy(pMsg.account, lpObj->Account, sizeof(pMsg.account));

    memcpy(pMsg.name, lpObj->Name, sizeof(pMsg.name));

    //pMsg.value1 = (value1 > 0) ? value1 : 0;
    //pMsg.value2 = (value2 > 0) ? value2 : 0;
    //pMsg.value3 = (value3 > 0) ? value3 : 0;

    pMsg.value1 = (!value1) ? 0 : value1;
    pMsg.value2 = (!value2) ? 0 : value2;
    pMsg.value3 = (!value3) ? 0 : value3;

    gDataServerConnection.DataSend((BYTE*)&pMsg, pMsg.header.size);

    if (value1 > 0)
    {
        lpObj->Coin1 += value1;
        gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, gMessage.GetMessage(730), value1);
    }
    if (value2 > 0)
    {
        lpObj->Coin2 += value2;
        gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, gMessage.GetMessage(731), value2);
    }
    if (value3 > 0)
    {
        lpObj->Coin3 += value3;
        gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, gMessage.GetMessage(732), value3);
    }

    if (value1 < 0)
    {
        lpObj->Coin1 += value1;
        gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, gMessage.GetMessage(760), value1);
    }
    if (value2 < 0)
    {
        lpObj->Coin2 += value2;
        gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, gMessage.GetMessage(761), value2);
    }
    if (value3 < 0)
    {
        lpObj->Coin3 += value3;
        gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, gMessage.GetMessage(762), value3);
    }

#if(GAMESERVER_UPDATE<=402)
    gPcPoint.GDPcPointPointSend(lpObj->Index);
#endif
    gCashShop.CGCashShopPointRecv(lpObj->Index);


    LogAdd(LOG_ALERT, "[%s][%s] WZ_SetCoin(%s) Val1: %d, Val2: %d, Val3: %d", lpObj->Account, lpObj->Name, LogName, value1, value2, value3);
}

#endif

DSProtocol.h

Buscar void DGOptionDataRecv(SDHP_OPTION_DATA_RECV* lpMsg);

Agregar



#if (DAILY)
void GDSetCoinSend(int aIndex, int value1, int value2, int value3, char* LogName);
#endif


Protocol.cpp


Agregar

#if (DAILY)
case 0xF5:
switch (lpMsg[3])
{
case 0x02:
DailyReward.CGRequest(lpMsg, aIndex);
break;

}
break;
#endif


ServerInfo.cpp

Dentro de void CServerInfo::ReadCustomInfo() // OK


#if (DAILY)
DailyReward.Read(gPath.GetFullPath("Custom\\CustomDailyReward.txt"));
#endif


User.cpp


Dentro de void gObjCharZeroSet(int aIndex) // OK


Agregar
#if (DAILY)
DailyReward.CharZero(aIndex);
#endif


Buscar GCNewHealthBarSend(lpObj);

Agregar

#if (DAILY)
DailyReward.OnSecondProc(lpObj->Index);
#endif
Bon Dia

🡱 🡳