Metin2 Hide weapon when acting emotions

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Vanilla

Elite
Elite
Joined
Jan 28, 2019
Messages
839
Credits
1,190

common/service.h
Code:
Expand Collapse Copy
/// 1.
// Add:
#define __EMOTION_HIDE_WEAPON__
game/char.cpp
C++:
Expand Collapse Copy
/// 1.
// Search @ CHARACTER::Initialize
    memset(&m_tvLastSyncTime, 0, sizeof(m_tvLastSyncTime));
    m_iSyncHackCount = 0;

// Add below
#ifdef __EMOTION_HIDE_WEAPON__
    m_pkEmotionEvent = NULL;
#endif

/// 2.
// Search @ CHARACTER::Destroy
    StopHackShieldCheckCycle();

// Add above
#ifdef __EMOTION_HIDE_WEAPON__
    event_cancel(&m_pkEmotionEvent);
#endif

/// 3.
// Search @ CHARACTER::OnMove
    // MINING
    mining_cancel();
    // END_OF_MINING

// Add below
#ifdef __EMOTION_HIDE_WEAPON__
    CancelEmotion();
#endif

/// 4.
// Add to the very bottom of the document
#ifdef __EMOTION_HIDE_WEAPON__
void CHARACTER::CancelEmotion()
{
    if (m_pkEmotionEvent)
    {
        event_cancel(&m_pkEmotionEvent);
        RefreshWeapon(this);
    }
}

void CHARACTER::RefreshWeapon(LPCHARACTER ch)
{
    if (!ch->IsPC())
        return;

    const CItem* pWeapon = ch->GetWear(WEAR_WEAPON);
    DWORD toSetValue = (NULL != pWeapon) ? pWeapon->GetVnum() : ch->GetOriginalPart(PART_WEAPON);
#ifdef __CHANGE_LOOK_SYSTEM__
    if (pWeapon)
        toSetValue = pWeapon->GetTransmutation() != 0 ? pWeapon->GetTransmutation() : pWeapon->GetVnum();
#endif

#ifdef __WEAPON_COSTUME_SYSTEM__
    const CItem* pWeaponCostume = ch->GetWear(WEAR_COSTUME_WEAPON);
    if (0 != ch->GetWear(WEAR_COSTUME_WEAPON))
        toSetValue = (NULL != pWeaponCostume) ? pWeaponCostume->GetVnum() : ch->GetOriginalPart(PART_WEAPON);
#endif
game/char.h
C++:
Expand Collapse Copy
/// 1.
// Search
        // MINING
        void            mining(LPCHARACTER chLoad);
        void            mining_cancel();
        void            mining_take();
        // END_OF_MINING

// Add below
#ifdef __EMOTION_HIDE_WEAPON__
        void            CancelEmotion();
        void            RefreshWeapon(LPCHARACTER ch);
#endif

/// 2.
// Search
        LPEVENT                m_pkPetSystemUpdateEvent;

// Add below
#ifdef __EMOTION_HIDE_WEAPON__
        LPEVENT                m_pkEmotionEvent;
#endif

game/cmd_emotion.cpp


C++:
Expand Collapse Copy
/*
emotion_types[] = {
    { "키스",    "french_kiss",    NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM,    4.000000f    },
    { "뽀뽀",    "kiss",    NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM,    1.5f    },
    { "따귀",    "slap",    NEED_PC | SELF_DISARM,    2.0f    },
    { "박수",    "clap",    0,    2.66667f    },
    { "와",    "cheer1",    0,    2.33333f    },
    { "만세",    "cheer2",    0,    2.33333f    },
    // DANCE
    { "댄스1",    "dance1",    0,    28.3333f    },
    { "댄스2",    "dance2",    0,    4.76667f    },
    { "댄스3",    "dance3",    0,    27.3333f    },
    { "댄스4",    "dance4",    0,    30.3333f    },
    { "댄스5",    "dance5",    0,    21.1f    },
    { "댄스6",    "dance6",    0,    30.433332f    },
    // END_OF_DANCE
    { "축하",    "congratulation",    0,    6.33333f    },
    { "용서",    "forgive",    0,    8.33333f    },
    { "화남",    "angry",    0,    4.33333f    },
    { "유혹",    "attractive",    0,    4.83333f    },
    { "슬픔",    "sad",    0,    7.33333f    },
    { "브끄",    "shy",    0,    4.66667f    },
    { "응원",    "cheerup",    0,    5.0f    },
    { "질투",    "banter",    0,    7.0f    },
    { "기쁨",    "joy",    0,    5.33333f    },
*/

/// 1.
// Search
#define NEED_TARGET    (1 << 0)

// Add above
#ifdef __EMOTION_HIDE_WEAPON__
    #include "item.h"
#endif

/// 2.
// Search
ACMD(do_emotion)

// Add above
#ifdef __EMOTION_HIDE_WEAPON__
EVENTINFO(EmotionEventInfo)
{
    LPCHARACTER me;
    LPCHARACTER target;

    EmotionEventInfo()
    : me(0)
    , target(0)
    {
    }
};

EVENTFUNC(EmotionEvent)
{
    EmotionEventInfo * info = dynamic_cast<EmotionEventInfo*>(event->info);

    if (info == NULL)
    {
        sys_err("EmotionEventInfo> <Factor> Null pointer");
        return 0;
    }

    LPCHARACTER me = info->me;
    LPCHARACTER target = info->target;

    if (me) me->RefreshWeapon(me);
    if (target) target->RefreshWeapon(target);

    return 0;
}
#endif

/// 3.
// Search
            s_emotion_set.insert(std::make_pair(ch->GetVID(), victim->GetVID()));
        }
    }

// Add above
#ifdef __EMOTION_HIDE_WEAPON__
            EmotionEventInfo * info = AllocEventInfo<EmotionEventInfo>();
            info->target = victim;

            victim->SetPart(PART_WEAPON, 0);
            victim->UpdatePacket();

            victim->m_pkEmotionEvent = event_create(EmotionEvent, info, PASSES_PER_SEC(emotion_types[i].extra_delay));
#endif

/// 4.
// Search
    TPacketGCChat pack_chat;
    pack_chat.header = HEADER_GC_CHAT;
    pack_chat.size = sizeof(TPacketGCChat) + len;
    pack_chat.type = CHAT_TYPE_COMMAND;
    pack_chat.id = 0;
    TEMP_BUFFER buf;
    buf.write(&pack_chat, sizeof(TPacketGCChat));
    buf.write(chatbuf, len);

// Add above
#ifdef __EMOTION_HIDE_WEAPON__
    EmotionEventInfo * info = AllocEventInfo<EmotionEventInfo>();
    info->me = ch;

    ch->SetPart(PART_WEAPON, 0);
    ch->UpdatePacket();

    ch->m_pkEmotionEvent = event_create(EmotionEvent, info, PASSES_PER_SEC(emotion_types[i].extra_delay));
#endif
 
Back
Top