主要是玩家PVP死亡后,然后胜利的一方可以捡尸体,获得玩家的掉落。。 至于具体的详细功能,请自行测试一下
此代码是最新的。。可以适用于最新的Mangos-zero 魔兽世界私服单机版的代码
1、玩家死亡后,创建尸体的函数
Corpse* Player::CreateCorpse() { // prevent existence 2 corpse for player SpawnCorpseBones(); Corpse *corpse = new Corpse((m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE); SetPvPDeath(false); if (!corpse->Create(sObjectMgr.GenerateCorpseLowGuid(), this)) { delete corpse; return NULL; } uint8 skin = GetByteValue(PLAYER_BYTES, 0); uint8 face = GetByteValue(PLAYER_BYTES, 1); uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2); uint8 haircolor = GetByteValue(PLAYER_BYTES, 3); uint8 facialhair = GetByteValue(PLAYER_BYTES_2, 0); corpse->SetByteValue(CORPSE_FIELD_BYTES_1, 1, getRace()); corpse->SetByteValue(CORPSE_FIELD_BYTES_1, 2, getGender()); corpse->SetByteValue(CORPSE_FIELD_BYTES_1, 3, skin); corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 0, face); corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 1, hairstyle); corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 2, haircolor); corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 3, facialhair); uint32 flags = CORPSE_FLAG_UNK2; flags |= CORPSE_FLAG_LOOTABLE; if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) flags |= CORPSE_FLAG_HIDE_HELM; if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) flags |= CORPSE_FLAG_HIDE_CLOAK; //if (InBattleGround()) // flags |= CORPSE_FLAG_LOOTABLE; // to be able to remove insignia corpse->SetUInt32Value(CORPSE_FIELD_FLAGS, flags); corpse->SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, GetNativeDisplayId()); corpse->SetUInt32Value(CORPSE_FIELD_GUILD, GetGuildId()); uint32 iDisplayID; uint32 iIventoryType; uint32 _cfi; for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) { if (m_items[i]) { iDisplayID = m_items[i]->GetProto()->DisplayInfoID; iIventoryType = m_items[i]->GetProto()->InventoryType; _cfi = iDisplayID | (iIventoryType << 24); corpse->SetUInt32Value(CORPSE_FIELD_ITEM + i, _cfi); } } // we not need saved corpses for BG/arenas if (!GetMap()->IsBattleGround()) corpse->SaveToDB(); // register for player, but not show sObjectAccessor.AddCorpse(corpse); return corpse; } 2、掉落徽章的函数 /* If in a battleground a player dies, and an enemy removes the insignia, the player's bones is lootable Called by remove insignia spell effect */ void Player::RemovedInsignia(Player* looterPlr) { //if (!GetBattleGroundId()) // return; // If not released spirit, do it ! if (m_deathTimer > 0) { m_deathTimer = 0; if (GetBattleGroundId()) BuildPlayerRepop(); RepopAtGraveyard(); } Corpse* corpse = GetCorpse(); if (!corpse) return; // We have to convert player corpse to bones, not to be able to resurrect there // SpawnCorpseBones isn't handy, 'cos it saves player while he in BG Corpse* bones = GetCorpse(); if (GetBattleGroundId()) { Corpse* bones = sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid(), true); } if (!bones) return; // Now we must make bones lootable, and send player loot bones->SetFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE); // We store the level of our player in the gold field // We retrieve this information at Player::SendLoot() bones->loot.gold = getLevel(); bones->lootRecipient = looterPlr; looterPlr->SendLoot(bones->GetObjectGuid(), LOOT_INSIGNIA); } 3、对比参考修改一下Sendloot函数,这里实现掉落 case HIGHGUID_CORPSE: // remove insignia { Corpse *bones = GetMap()->GetCorpse(guid); if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA))) //|| (bones->GetType() != CORPSE_BONES)) { SendLootRelease(guid); return; } loot = &bones->loot; if (!bones->lootForBody) { bones->lootForBody = true; uint32 pLevel = bones->loot.gold; bones->loot.clear(); if (GetBattleGround()) { if (GetBattleGround()->GetTypeID() == BATTLEGROUND_AV) loot->FillLoot(0, LootTemplates_Creature, this, false); } // It may need a better formula // Now it works like this: lvl10: ~6copper, lvl70: ~9silver bones->loot.gold = (uint32)(urand(50, 150) * 0.016f * pow(((float)pLevel) / 5.76f, 2.5f) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); // ADDED TO REMOVE LOOTABLE AFTER LOOT. uint32 flags = CORPSE_FLAG_UNK2; flags &= ~CORPSE_FLAG_LOOTABLE; bones->SetUInt32Value(CORPSE_FIELD_FLAGS, flags); } if (bones->lootRecipient != this) permission = NONE_PERMISSION; else permission = OWNER_PERMISSION; break; }
|