Jump to content
Araştır
  • Diğer seçenekler ...
Sonuçları bul ...
Sonuçları bul ...
KOGamer

Pet Skillbar & P menü Sorunu Hakkında

Önerilen Mesajlar

Merhaba sevgili KoDevelopers Ailesi;

Sayenize Source Files mantığını kavrayabildim. Güncel Sorunuma gelicek olursak.

1 - Pet Görevini yapınca üzerine 2 adet kaul geliyor, Invertoryim full ise gameserver patlıyor.
2 - Pet çıkardığımda Skillbar ekrana gelmiyor ve P menüsü açılmıyor. (Ektra not : klavyeden alt + 1 kombinasyonu yaptığımda sağ altta logda çalışıyor gözüküyor bu çalışıyor)
3 - Pet npc sinde magic bag , oto looting kırdırabiliyorum sorunsuz bir şekilde, fakat Aynı npc üzerinden familiar , yaprak vs satın alamıyorum ve herhangi birşey satamıyorum.

Kullandığım ve düzenlediğim sourcede Kod bu şekildedir.

#include "stdafx.h"

#include "Map.h"
#include "KnightsManager.h"
#include "KingSystem.h"
#include "MagicInstance.h"
#include "DBAgent.h"
#include
#include "../shared/DateTime.h"

CPet::CPet(uint16 sSid ,uint64 SerialNum): Unit(UnitPet)
{
Initialize();

pUser = g_pMain->GetUserPtr(sSid);
m_Serial = SerialNum;
}

void CPet::Initialize()
{
Unit::Initialize();

m_sSid = 0;
m_sPid = 0; // MONSTER(NPC) Picture ID
m_sSize = 100; // MONSTER(NPC) Size
m_strName.clear(); // MONSTER(NPC) Name
m_iMaxHP = 0; // �ִ� HP
m_iHP = 0; // ���� HP
m_byState = 0; // ������ (NPC) �����̻�
m_tNpcType = 0; // NPC Type
// 0 : Normal Monster
// 1 : NPC
// 2 : �� �Ա�,�ⱸ NPC
// 3 : ������
m_iSellingGroup = 0;
//m_dwStepDelay = 0;

m_byDirection = 0; // npc�� ����,,
m_iWeapon_1 = 0;
m_iWeapon_2 = 0;
m_NpcState = PET_ATTACK;
m_byGateOpen = true;
m_byObjectType = NORMAL_OBJECT;
m_byTrapNumber = 0;
}

void CPet::HandlePacket(Packet & pkt, CUser* pUser)
{
uint8 type, opcode;

pkt >> type >> opcode;

printf("WIZ_PET PACKET Type :%u OpCode :%u
", type, opcode);

if(type == 1)
{
switch (opcode)
{
case PET_STATE_CHANGE:
{
uint8 state = pkt.read();
printf("state %u
",state);
PetStateChange(state, pUser);
}
break;
}
}
else
{
switch (opcode)
{
case 4:
{
uint16 test1,test2;
uint16 ssıd , echo , echo1 ,echo2, echo3;
pkt >> test1 >> test2 >> echo >> ssıd >> echo1 >> echo2 >> echo3;

printf("Move %u %u %u %u %u %u %u
",test1, test2, echo, echo1, echo2, echo3, ssıd);//, speed, echo);

if (pUser == nullptr) return;

CPet * pPet = g_pMain->GetPetPtr(pUser->GetSocketID() + INVALID_BAND);

if (pPet == nullptr
|| pPet->isDead())
return;

CNpc * pNpc = g_pMain->GetNpcPtr(ssıd);

pPet->MoveResult(echo1, echo2, echo3, 28.0f);
}
case PET_MAGIC_PROCESS:
MagicProcess(pkt, pUser);
break;
}
}
}

void CPet::PetStateChange(uint8 state, CUser *pUser)
{
Packet result(WIZ_PET, uint8(1));
CPet* pPet = g_pMain->GetPetPtr(pUser->GetSocketID() + INVALID_BAND);

if (pPet == nullptr)
return;

pPet->m_NpcState = state;
pPet->m_byState = state;

result m_NpcState pUser->Send(&result);
}

void CPet::MagicProcess(Packet & pkt, CUser *pUser)
{
if (g_pMain->m_IsMagicTableInUpdateProcess)
return;

MagicInstance instance;
instance.bOpcode = MAGIC_EFFECTING;
pkt >> instance.nSkillID;

printf("Pet Attığı Skill ID %u
", instance.nSkillID);

instance.pSkill = g_pMain->m_MagictableArray.GetData(instance.nSkillID);
if (instance.pSkill == nullptr)
{
if (pUser != nullptr)
printf("[%s] Used skill %d but it does not exist.
", pUser->GetName().c_str(), instance.nSkillID);

if (pUser != nullptr && pUser->isPlayer() && instance.nSkillID {
DateTime time;
g_pMain->SendFormattedNotice("%s is currently disconnect for skill hack.",Nation::ALL, pUser->GetName().c_str());
g_pMain->WriteCheatLogFile(string_format("[ SkillHack - %d:%d:%d ] %s Disconnected for SkillHack.
", time.GetHour(),time.GetMinute(),time.GetSecond(), pUser->GetName().c_str()));
TO_USER(pUser)->Disconnect();
}

return;
}

pkt >> instance.sCasterID >> instance.sTargetID
>> instance.sData[0] >> instance.sData[1] >> instance.sData[2] >> instance.sData[3]
>> instance.sData[4] >> instance.sData[5] >> instance.sData[6];

// Prevent users from faking other players or NPCs.
if (pUser != nullptr // if it's nullptr, it's from AI.
&& (instance.sCasterID >= NPC_BAND && instance.sCasterID return;

if(instance.sCasterID == instance.sTargetID)
instance.sCasterID = instance.sTargetID += INVALID_BAND;
else if (instance.sCasterID >= USER_BAND && instance.sCasterID instance.sCasterID += INVALID_BAND;

instance.bIsRecastingSavedMagic = false;
instance.Run();
}

bool CPet::LoadPetData()
{
if(pUser == nullptr )
return false;

return g_DBAgent.LoadPetData(m_Serial, this);
}

void CPet::SendPetMyInfo()
{
if(!LoadPetData())
return;

Packet result(WIZ_PET, uint8(1));

m_NpcState = m_NpcState;
m_sNid = pUser->GetSocketID() + INVALID_BAND;
m_sSize = 80;
m_iWeapon_1 = m_iWeapon_2 = 0;
m_bZone = pUser->GetZoneID();
m_bNation = pUser->GetNation();
m_strUserName = pUser->GetName();
m_bLevel = m_bLevel;
m_curx = pUser->m_curx;
m_curz = pUser->m_curz;
m_cury = pUser->m_cury;
m_tNpcType = 15;
m_iSellingGroup = 0 ;
m_byGateOpen = 0;
m_fTotalHitrate = 0;
m_fTotalEvasionrate = 0;
m_sTotalAc = 0;
m_sTotalHit = 0;
m_byObjectType = 0;
m_byTrapNumber = 0;
m_bMonster = true;
m_byDirection = 45;
m_oSocketID = pUser->GetSocketID() + INVALID_BAND;
m_bEventRoom = pUser->m_bEventRoom;
m_sFireR = m_sColdR = m_sLightningR = 0;
m_sMagicR = m_sDiseaseR = m_sPoisonR = 0;

m_iHP = m_iMaxHP = int(25 * m_bLevel * 1.5);
m_iMP = m_iMaxMP = int(25 * m_bLevel * 1.5);

m_pMap = g_pMain->GetZoneByID(pUser->GetZoneID());

if (GetMap() == nullptr)
return;

if(!g_pMain->m_UserPetArray.PutData(GetID(),this))
{
printf("Put Failed");
return;
}

SendInOut(INOUT_IN, GetX(), GetZ(), GetY());

result.DByte();
result
for (int i = 0; i {
_ITEM_DATA *pItem = GetItem(i);

if (pItem == nullptr)
continue;

result nNum sDuration sCount nSerialNum nExpirationTime;
}

pUser->Send(&result);

result.clear();
result.Initialize(WIZ_OBJECT_EVENT);
result
SendToRegion(&result);
printf("%u
",GetID());
}

/**
* @brief Constructs and sends an in/out packet for the NPC.
*
* @param bType The type (in or out).
* @param fX The x coordinate.
* @param fZ The z coordinate.
* @param fY The y coordinate.
*/
void CPet::SendInOut(uint8 bType, float fX, float fZ, float fY)
{
if (GetRegion() == nullptr)
{
SetRegion(GetNewRegionX(), GetNewRegionZ());
if (GetRegion() == nullptr)
return;
}

if (bType == INOUT_OUT)
{
GetRegion()->Remove(this);
}
else
{
GetRegion()->Add(this);
SetPosition(fX, fY, fZ);
}

Packet result;
GetInOut(result, bType);
SendToRegion(&result);
}

void CPet::GetNpcInfo(Packet & pkt)
{
pkt.SByte();
pkt }

void CPet::GetInOut(Packet & result, uint8 bType)
{
result.Initialize(WIZ_NPC_INOUT);
result if (bType != INOUT_OUT)
GetNpcInfo(result);

}

void CPet::OnDeath(Unit *pKiller)
{
if (m_NpcState == NPC_DEAD)
return;

ASSERT(GetMap() != nullptr);
ASSERT(GetRegion() != nullptr);

m_NpcState = NPC_DEAD;
m_sACPercent = 100;

Unit::OnDeath(pKiller);

InitType3();
InitType4();

if (GetRegion() != nullptr)
GetRegion()->Remove(TO_PET(this));

SetRegion();

if(g_pMain->GetPetPtr(pUser->GetSocketID() + INVALID_BAND))
g_pMain->m_UserPetArray.DeleteData(pUser->GetSocketID() + INVALID_BAND);
}

/**
* @brief Adds the Pet to the region.
*
* @param new_region_x The new region x coordinate.
* @param new_region_z The new region z coordinate.
*/
void CPet::AddToRegion(int16 new_region_x, int16 new_region_z)
{
GetRegion()->Remove(this);
SetRegion(new_region_x, new_region_z);
GetRegion()->Add(this);
}

void CPet::MoveResult(float fPosX, float fPosY, float fPosZ, float fSpeed)
{
Packet result(WIZ_NPC_MOVE, uint8(1));

SetPosition(fPosX, fPosY, fPosZ);
RegisterRegion();

result SendToRegion(&result);
}

/**
* @brief Changes an NPC's hitpoints.
*
* @param amount The amount to adjust the HP by.
* @param pAttacker The attacker.
* @param bSendToAI true to update the AI server.
*/
void CPet::HpChange(int amount, Unit *pAttacker /*= nullptr*/, bool bSendToAI /*= true*/)
{
uint16 tid = (pAttacker != nullptr ? pAttacker->GetID() : -1);

// Implement damage/HP cap.
if (amount amount = -MAX_DAMAGE;
else if (amount > MAX_DAMAGE)
amount = MAX_DAMAGE;

// Glorious copypasta.
if (amount m_iHP)
m_iHP = 0;
else if (amount >= 0 && m_iHP + amount > m_iMaxHP)
m_iHP = m_iMaxHP;
else
m_iHP += amount;

// NOTE: This will handle the death notification/looting.
if (bSendToAI)
//SendHpChangeToAI(tid, amount);

if (pAttacker != nullptr
&& pAttacker->isPlayer())
TO_USER(pAttacker)->SendTargetHP(0, GetID(), amount);

if (m_iHP == 0)
OnDeath(pAttacker);
}

void CPet::MSpChange(int amount)
{

}

void CPet::SendTargetHP( uint8 echo, int tid, int damage )
{
int hp = 0, maxhp = 0;

Unit *pTarget = nullptr;

if (tid >= USER_BAND && tid {
CUser *pUser = g_pMain->GetUserPtr(tid);
if (pUser == nullptr)
return;

hp = pUser->m_sHp;
maxhp = pUser->m_iMaxHp;
pTarget = pUser;
}
else if (tid >= NPC_BAND && tid {
if (g_pMain->m_bPointCheckFlag == false)
return;

CNpc *pNpc = g_pMain->GetNpcPtr(tid);
if (pNpc == nullptr)
return;

hp = pNpc->m_iHP;
maxhp = pNpc->m_iMaxHP;
pTarget = pNpc;
}
else
{
CPet * nPet = g_pMain->GetPetPtr(tid);

if (nPet == nullptr)
return;

hp = nPet->m_iHP;
maxhp = nPet->m_iMaxHP;
pTarget = nPet;
}

printf("Target ID %u %u %u %s
", pTarget->GetID(), TO_USER(pTarget)->GetID(), TO_NPC(pTarget)->GetProtoID(), pTarget->GetName().c_str());
CUser * pUser = g_pMain->GetUserPtr(GetID() - INVALID_BAND);
Packet result(WIZ_TARGET_HP);
result pUser->Send(&result);
}


Bu kodda bir hatamı var? var ise düzeltilmiş halini bana verirmisiniz? Umarım anlatmak istediğimi detaylıca anlatabilmişimdir. Eğer tam olarak kendimi ifade edemediğimi düşünüyorsanız lütfen skype: @Saitalierisek üzerinden iletişime geçebiliriz. (konuya çözümü yazmam şartıyla :)

@ OzkanOzdemir

İletiyi paylaş


Link to post
Sitelerde Paylaş
Alıntı
Npc'den item satın alamıyorsan eğer ItemTrade voidini incelemelisin orada bazı kısıtlamalar vardır o npc den item çekilmesine izin vermelisin.


Bunu inceleyeceğim. Düzeltebildiğim takdirde buradan bilgi vereceğim. Teşekkür ederim.

İletiyi paylaş


Link to post
Sitelerde Paylaş

×
×
  • Yeni Oluştur...