|
You last visited: Today at 15:07
Advertisement
[Rls] [C++] PetPickup
Discussion on [Rls] [C++] PetPickup within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.
05/09/2016, 17:06
|
#1
|
elite*gold: 20
Join Date: Jun 2011
Posts: 2,897
Received Thanks: 3,328
|
[Rls] [C++] PetPickup
PetPickUpSystem ( Pet läuft zu den von euch gedroppten Items und hebt sie auf)
Wer fehler findet darf sie behalten.
Code:
service.h:
add:
#define __PET_PICKUP
PetSystem.h:
search:
void SetSummonItem (LPITEM pItem);
add below:
#ifdef __PET_PICKUP
void PickUpItems(int range);
void BringItem();
void SetPickup(bool is_pickup) { m_is_pickup = is_pickup; }
bool IsPickup(){ return m_is_pickup; }
void SetPickupItem(LPITEM item) { m_pickup_item = item; }
LPITEM GetPickupItem(){ return m_pickup_item; }
#endif
search:
LPCHARACTER m_pkOwner;
add below:
#ifdef __PET_PICKUP
bool m_is_pickup;
LPITEM m_pickup_item;
#endif
char.h:
search:
bool PickupItem(DWORD vid);
add below:
#ifdef __PET_PICKUP
bool PickupItemByPet(DWORD vid);
#endif
char_item.cpp:
search:
bool CHARACTER::PickupItem(DWORD dwVID)
add above:
#ifdef __PET_PICKUP
bool CHARACTER::PickupItemByPet(DWORD dwVID)
{
LPITEM item = ITEM_MANAGER::instance().FindByVID(dwVID);
if (IsObserverMode())
return false;
if (!item || !item->GetSectree())
return false;
if (item->IsOwnership(this))
{
if (item->GetType() == ITEM_ELK)
{
GiveGold(item->GetCount());
item->RemoveFromGround();
M2_DESTROY_ITEM(item);
Save();
}
else
{
if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
{
BYTE bCount = item->GetCount();
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
{
LPITEM item2 = GetInventoryItem(i);
if (!item2)
continue;
if (item2->GetVnum() == item->GetVnum())
{
int j;
for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
if (item2->GetSocket(j) != item->GetSocket(j))
break;
if (j != ITEM_SOCKET_MAX_NUM)
continue;
BYTE bCount2 = MIN(200 - item2->GetCount(), bCount);
bCount -= bCount2;
item2->SetCount(item2->GetCount() + bCount2);
if (bCount == 0)
{
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¾ÆÀÌÅÛ È¹µæ: %s"), item2->GetName());
M2_DESTROY_ITEM(item);
if (item2->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem(GetPlayerID(), item2);
return true;
}
}
}
item->SetCount(bCount);
}
int iEmptyCell;
if (item->IsDragonSoul())
{
if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
{
sys_log(0, "No empty ds inventory pid %u size
itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼ÒÁöÇϰí ÀÖ´Â ¾ÆÀÌÅÛÀÌ ³Ê¹« ¸¹½À´Ï´Ù."));
return false;
}
}
else
{
if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty inventory pid %u size
itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼ÒÁöÇϰí ÀÖ´Â ¾ÆÀÌÅÛÀÌ ³Ê¹« ¸¹½À´Ï´Ù."));
return false;
}
}
item->RemoveFromGround();
if (item->IsDragonSoul())
item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
else
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
char szHint[32 + 1];
snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
LogManager::instance().ItemLog(this, item, "GET", szHint);
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¾ÆÀÌÅÛ È¹µæ: %s"), item->GetName());
if (item->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem(GetPlayerID(), item);
}
//Motion(MOTION_PICKUP);
return true;
}
return false;
}
#endif
PetSystem.cpp:
search:
bool CPetActor::Follow(float fMinDistance)
add above:
#ifdef __PET_PICKUP
struct PetPickUpItemStruct
{
CPetActor * pet;
int range;
PetPickUpItemStruct(CPetActor * p, int r){
pet = p;
range = r;
}
void operator()(LPENTITY pEnt)
{
if (!pet->GetOwner() || !pet->GetCharacter())
return;
if (pet->IsPickup())
return;
if (pEnt->IsType(ENTITY_ITEM) == true)
{
LPITEM item = (LPITEM)pEnt;
LPCHARACTER player = pet->GetOwner();
if (!item->GetSectree() || !item->IsOwnership(player))
return;
int iDist = DISTANCE_APPROX(item->GetX() - player->GetX(), player->GetY() - player->GetY());
if (iDist > range)
return;
pet->SetPickup(true);
pet->SetPickupItem(item);
}
}
};
void CPetActor::PickUpItems(int range){
if (IsPickup())
return;
long map = m_pkChar->GetMapIndex();
PIXEL_POSITION m = m_pkChar->GetXYZ();
LPSECTREE tree = SECTREE_MANAGER::instance().Get(map, m.x, m.y);
if (!tree)
{
sys_err("cannot find sectree by %dx%d", m.x, m.y);
return;
}
PetPickUpItemStruct f(this, range);
tree->ForEachAround(f);
}
void CPetActor::BringItem(){
if (!IsPickup())
return;
LPITEM item = GetPickupItem();
if (!m_pkOwner || !m_pkChar || !item || !item->GetSectree())
return;
float fMinDistance = 20.0;
float fPetX = m_pkChar->GetX();
float fPetY = m_pkChar->GetY();
float itemX = item->GetX();
float itemY = item->GetY();
float fDist = DISTANCE_SQRT(itemX - fPetX, itemY - fPetY);
if (fDist <= 250.0)
{
SetPickup(false);
m_pkOwner->PickupItemByPet(item->GetVID());
SetPickupItem(NULL);
m_pkChar->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0, 0);
return;
}
m_pkChar->SetRotationToXY(itemX, itemY);
float fx, fy;
float fDistToGo = fDist - fMinDistance;
GetDeltaByDegree(m_pkChar->GetRotation(), fDistToGo, &fx, &fy);
if (!m_pkChar->Goto((int)(fPetX + fx + 0.5f), (int)(fPetY + fy + 0.5f)))
return;
m_pkChar->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0, 0);
}
#endif
search:
if (this->IsSummoned() && HasOption(EPetOption_Followable))
add above:
#ifdef __PET_PICKUP
if (this->IsSummoned()){
this->BringItem();
this->PickUpItems(900); // 900 = RANGE
}
#endif
search:
this->SetSummonItem(NULL);
add below:
#ifdef __PET_PICKUP
this->SetPickupItem(NULL);
this->SetPickup(false);
#endif
search:
m_dwSummonItemVID = 0;
m_dwSummonItemVnum = 0;
add below:
#ifdef __PET_PICKUP
this->SetPickupItem(NULL);
this->SetPickup(false);
#endif
und nein, das ändern der normalen Pickup Function wollte nicht so recht (mit optionalem Parameter), da beim VS2013 sowie bei gcc der core beim pickup crashen wollte
|
|
|
05/09/2016, 19:58
|
#2
|
elite*gold: 105
Join Date: Jun 2015
Posts: 453
Received Thanks: 293
|
Cooles release! 
Danke <3
|
|
|
05/09/2016, 20:10
|
#3
|
elite*gold: 2
Join Date: Jun 2013
Posts: 1,143
Received Thanks: 1,719
|
Hammer.
|
|
|
05/09/2016, 21:50
|
#4
|
elite*gold: 0
Join Date: Apr 2013
Posts: 563
Received Thanks: 437
|
Du Released auch immer nur Bullshit oder? Witz komm herbei  , Danke.
|
|
|
05/10/2016, 20:13
|
#5
|
elite*gold: 84
Join Date: Dec 2010
Posts: 822
Received Thanks: 402
|
Ty.
|
|
|
05/10/2016, 22:35
|
#6
|
elite*gold: 0
Join Date: Dec 2014
Posts: 999
Received Thanks: 488
|
ty endlich mal wieder was nütztliches.
da du in letzter zeit so offen für vorschläge bist:
besser wäre es wenn nur bestimmte pets über dieses feature verfügen.
|
|
|
05/10/2016, 23:09
|
#7
|
elite*gold: 20
Join Date: Jun 2011
Posts: 2,897
Received Thanks: 3,328
|
einfach in:
void CPetActor::PickUpItems(int range){
if (IsPickup())
return;
long map = m_pkChar->GetMapIndex();
PIXEL_POSITION m = m_pkChar->GetXYZ();
LPSECTREE tree = SECTREE_MANAGER::instance().Get(map, m.x, m.y);
if (!tree)
{
sys_err("cannot find sectree by %dx%d", m.x, m.y);
return;
}
PetPickUpItemStruct f(this, range);
tree->ForEachAround(f);
}
einfügen
If(m_pkChar->GetVnum() != 101)
return;
damit geht es nur bei vnum 101.
|
|
|
05/11/2016, 15:31
|
#8
|
elite*gold: 0
Join Date: Aug 2014
Posts: 11
Received Thanks: 0
|
the problem is , this not really good for metin2
becous there too many items drops by mobs - stone ...
so every time when u want pick up the item it will take time , so this is very borring
Like this
if you make thia systen without pet goto item it will be very nice
Anyway thanks for you !
|
|
|
05/11/2016, 17:52
|
#9
|
elite*gold: 0
Join Date: Dec 2014
Posts: 999
Received Thanks: 488
|
weiterer vorschlag? pets heben nur bestimmte items mit nem subtype auf z.b 27102 USE_ABILITY_UP
|
|
|
05/11/2016, 18:07
|
#10
|
elite*gold: 88
Join Date: Jun 2013
Posts: 667
Received Thanks: 243
|
So:
Player Test1 Dropt item 180 bei mob ***
Player Test2 Hat ein Pet bei sich, dieses Läuft hin und kann dieses aufsammeln und es landet im inventar von Test2 Trotz bei dem item 180 Der name Test1 Trüber steht.
Habs nicht getestet , aber ist ja nirgendo definiert was es aufheben kann.
Trzdem THX
|
|
|
05/11/2016, 22:35
|
#11
|
elite*gold: 0
Join Date: May 2016
Posts: 3
Received Thanks: 11
|
vorab: ich beziehe mich nur auf den coding stil, da ich mich mit der game kein bisschen auskenne (nie mit befasst da der source nach meiner zeit kam)
also heult nicht rum dass ich es besser machen soll
ich weiß ich weiß, es ist persönliche vorliebe etc aber wollte es trotzdem mal ansprechen
1. warum benutzt du diese notation mit den underscores? (habe gerade den namen nicht mehr im kopf)
wird normaler weise für die c++ standard libs und in c für embedded systems verwendet
klar, kann man nutzen aber unter dem ganzen camel case sieht es blöd aus
2. ich würde auf nested conditionals verzichten weil es einfach nervig zu lesen ist
beispiel:
anstatt:
Code:
if(item) {
if(item2) {
....
}
}
lieber:
Code:
if(!item)
return;
if(!item2)
return;
hast es ja teilweise gemacht aber der größte teil ist nested und das ist nervig zu lesen vor allem weil man einfach oft nach rechts scrollen muss
3. ist mir das aufgefallen (machen mehrere):
Code:
char szHint[32 + 1];
wieso??
könnte nun sagen ist ne unnötige rechenoperation aber da trifft man hier eh auf taube ohren
4. dieses inline member function definition zeug ist auch schon 20 jahre alt
ist schöner wenn es außerhalb der eigentlichen klassen bzw struct deklaration wäre
ist auch für außenstehende besser zu lesen.. wenn die nur wissen wollen was alles drin ist müssen die sich erst mal durch scrollen
|
|
|
05/12/2016, 14:38
|
#12
|
elite*gold: 70
Join Date: Mar 2015
Posts: 87
Received Thanks: 89
|
Funktioniert nicht
char_item.cpp:6156: error: 'itemid' was not declared in this scope
char_item.cpp:6156: error: 'u' was not declared in this scope
char_item.cpp:6166: error: 'itemid' was not declared in this scope
char_item.cpp:6166: error: 'u' was not declared in this scope
|
|
|
05/12/2016, 17:19
|
#13
|
elite*gold: 0
Join Date: Apr 2010
Posts: 66
Received Thanks: 101
|
Quote:
Originally Posted by .Callous
Funktioniert nicht
char_item.cpp:6156: error: 'itemid' was not declared in this scope
char_item.cpp:6156: error: 'u' was not declared in this scope
char_item.cpp:6166: error: 'itemid' was not declared in this scope
char_item.cpp:6166: error: 'u' was not declared in this scope
|

Code:
sys_log(0, "No empty ds inventory pid %u size
itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
to
Code:
sys_log(0, "No empty ds inventory pid %u size itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
space space space...
|
|
|
05/13/2016, 00:15
|
#14
|
elite*gold: 0
Join Date: May 2016
Posts: 8,681
Received Thanks: 1,633
|
Sehr nützlich Danke dir
|
|
|
05/13/2016, 00:19
|
#15
|
elite*gold: 70
Join Date: Mar 2015
Posts: 87
Received Thanks: 89
|
Bug gefunden!
Wenn man ein Item auf den Boden wirft, hebt das Pet es wieder auf.
|
|
|
All times are GMT +1. The time now is 15:07.
|
|