Premium DarkFire 12 Posted April 22, 2015 Premium Share Posted April 22, 2015 Hi , I want to do so that if somebody kill you in map with index <<x>> and you have on you or in your inventory the items "a,b,c,d" those items will fall from your invetory. In chart_battle after: void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller) ai put this: if(GetMapIndex()==1) if (pkItem) { switch(pkItem->GetVnum()) { case 19: //id la item case 11209: //id la item case 3: //id la item case 4: //id la item case 5: //id la item SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255); //arunca din inventar vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY)); //arunca din inventar default: continue; } } and it dosent work....somebody help me? 1 Link to comment Share on other sites More sharing options...
Premium DarkFire 12 Posted April 25, 2015 Author Premium Share Posted April 25, 2015 Up this is all function : if (bDropInventory) // Drop Inventory { std::vector<BYTE> vec_bSlots; for (i = 0; i < INVENTORY_MAX_NUM; ++i) if (GetInventoryItem(i)) vec_bSlots.push_back(i); if (!vec_bSlots.empty()) { random_shuffle(vec_bSlots.begin(), vec_bSlots.end()); int iQty = MIN(vec_bSlots.size(), r.iInventoryQty); if (iQty) iQty = number(1, iQty); for (i = 0; i < iQty; ++i) { pkItem = GetInventoryItem(vec_bSlots[i]); //cruel if(GetMapIndex()==1) if (pkItem) { switch(pkItem->GetVnum()) { case 19: //id la item case 11209: //id la item case 3: //id la item case 4: //id la item case 5: //id la item SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255); //arunca din inventar vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY)); //arunca din inventar default: continue; } } //endcruel if (IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_PKDROP)) continue; SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255); vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY)); } } else if (iAlignIndex == 8) isDropAllEquipments = true; } Link to comment Share on other sites More sharing options...
Premium DarkFire 12 Posted April 25, 2015 Author Premium Share Posted April 25, 2015 UP ! This is all function : if (bDropInventory) // Drop Inventory { std::vector<BYTE> vec_bSlots; for (i = 0; i < INVENTORY_MAX_NUM; ++i) if (GetInventoryItem(i)) vec_bSlots.push_back(i); if (!vec_bSlots.empty()) { random_shuffle(vec_bSlots.begin(), vec_bSlots.end()); int iQty = MIN(vec_bSlots.size(), r.iInventoryQty); if (iQty) iQty = number(1, iQty); for (i = 0; i < iQty; ++i) { pkItem = GetInventoryItem(vec_bSlots[i]); //cruel if(GetMapIndex()==1) if (pkItem) { switch(pkItem->GetVnum()) { case 19: //id la item case 11209: //id la item case 3: //id la item case 4: //id la item case 5: //id la item SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255); //arunca din inventar vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY)); //arunca din inventar default: continue; } } //endcruel if (IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_PKDROP)) continue; SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255); vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY)); } } else if (iAlignIndex == 8) isDropAllEquipments = true; } Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted April 25, 2015 Premium Share Posted April 25, 2015 In char_battle.cpp find this: void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead) and after ClearAffect(true); add this code: if (IsPC() && GetMapIndex() == YOUR_MAPINDEX && pkKiller->IsPC()) { PIXEL_POSITION pos; pos.x = GetX(); pos.y = GetY(); for (WORD i = 0; i < INVENTORY_MAX_NUM; ++i) { LPITEM item = GetInventoryItem(i); if (item) { switch (item->GetVnum()) { case 1: case 2: case 3: case 4: case 5: { SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255); item->RemoveFromCharacter(); item->AddToGround(GetMapIndex(), pos, true); item->StartDestroyEvent(); } break; } } } } Replace YOUR_MAPINDEX with the mapindex where you want items to drop. In switch replace the numbers with your items code. Also, the items will be dropped only if the killer is another player. 2 Link to comment Share on other sites More sharing options...
Premium DarkFire 12 Posted April 25, 2015 Author Premium Share Posted April 25, 2015 i will try , thx EDIT: At compilation i have this... char_battle.cpp: In member function 'void CHARACTER::Dead(CHARACTER*, bool)': char_battle.cpp:1302: error: expected primary-expression before ')' token compile cmd_emotion.cpp compile cmd_general.cpp gmake: *** [OBJDIR/char_battle.o] Error 1 gmake: *** Waiting for unfinished jobs.... Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted April 25, 2015 Premium Share Posted April 25, 2015 i will try , thx EDIT: At compilation i have this... char_battle.cpp: In member function 'void CHARACTER::Dead(CHARACTER*, bool)': char_battle.cpp:1302: error: expected primary-expression before ')' token compile cmd_emotion.cpp compile cmd_general.cpp gmake: *** [OBJDIR/char_battle.o] Error 1 gmake: *** Waiting for unfinished jobs.... Ooops. I writed the code wrong. I edited my previous post so you can copy again the code. 1 Link to comment Share on other sites More sharing options...
Premium DarkFire 12 Posted April 26, 2015 Author Premium Share Posted April 26, 2015 Ok , now it's work only if i have this items in inventory but if they are equipped they don't drop.... And also i have problem, after compilation the game with this function , when i write /kill <player name> and this player is online i have crash core(ch1_core1) Link to comment Share on other sites More sharing options...
Premium Solution Cataclismo 86 Posted April 26, 2015 Premium Solution Share Posted April 26, 2015 Ok , now it's work only if i have this items in inventory but if they are equipped they don't drop.... And also i have problem, after compilation the game with this function , when i write /kill <player name> and this player is online i have crash core(ch1_core1) Oh, you want equipment too. I didn't know. About the command, yeah, probably because the pkKiller parameter is not set. I fixed that too. Here's the code: if (pkKiller && IsPC()) { if (GetMapIndex() == YOUR_MAPINDEX && pkKiller->IsPC()) { PIXEL_POSITION pos; pos.x = GetX(); pos.y = GetY(); for (WORD i = 0; i < INVENTORY_MAX_NUM + WEAR_MAX_NUM; ++i) { LPITEM item = GetInventoryItem(i); if (item) { switch (item->GetVnum()) { case 1: case 2: case 3: case 4: case 5: { SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255); item->RemoveFromCharacter(); item->AddToGround(GetMapIndex(), pos, true); item->StartDestroyEvent(); } break; } } } } } 1 Link to comment Share on other sites More sharing options...
Premium DarkFire 12 Posted April 26, 2015 Author Premium Share Posted April 26, 2015 (edited) Thx.Now all work fine Edit : After a reboot for all characters i have this... : and after 10minutes from -31871 points all character have 20000points... Edited August 24, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted April 26, 2015 Premium Share Posted April 26, 2015 My code does not affect alignment. I think that's your own problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now