示例#1
0
void Creature::setDeathState(DeathState s)
{
    if(s == JUST_DIED)
    {
        m_deathTimer = m_corpseDelay*1000;

        // always save boss respawn time at death to prevent crash cheating
        if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss())
            SaveRespawnTime();

        if(!IsStopped()) StopMoving();
    }
    Unit::setDeathState(s);

    if(s == JUST_DIED)
    {
        SetUInt32Value(UNIT_NPC_FLAGS, 0);
        if(!isPet() && GetCreatureInfo()->SkinLootId)
        {
            LootStore skinStore = LootTemplates_Skinning;
            LootStore::iterator tab = skinStore.find(GetCreatureInfo()->SkinLootId);
            if ( tab != skinStore.end() )
                SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
        }
        Unit::setDeathState(CORPSE);
    }
}
示例#2
0
void FillLoot(Loot *loot, uint32 loot_id, LootStore& store)
{
    loot->clear();

    LootStore::iterator tab = store.find(loot_id);

    if (tab == store.end())
    {
        sLog.outErrorDb("Loot id #%u used in `creature_template` or `gameobject` or fishing but it doesn't have records in appropriate *_loot_template table.",loot_id);
        return;
    }

    loot->items.reserve(min(tab->second.size(),MAX_NR_LOOT_ITEMS));
    loot->quest_items.reserve(min(tab->second.size(),MAX_NR_QUEST_ITEMS));

    // fill loot with all normal and quest items that have a chance
    HasChance      hasChance(&store);
    HasQuestChance hasQuestChance;

    for(LootStoreItemList::iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)
    {
        // There are stats of count variations for 100% drop - so urand used
        if ( loot->quest_items.size() < MAX_NR_QUEST_ITEMS && hasQuestChance(*item_iter) )
            loot->quest_items.push_back(LootItem(*item_iter, urand(item_iter->mincount, item_iter->maxcount),Item::GenerateItemRandomPropertyId(item_iter->itemid)));
        else if ( loot->items.size() < MAX_NR_LOOT_ITEMS )
        {
            LootStoreItem* LootedItem = hasChance(*item_iter);
            if ( LootedItem )
                loot->items.push_back(
                    LootItem(*LootedItem, urand(LootedItem->mincount, LootedItem->maxcount),
                    Item::GenerateItemRandomPropertyId(LootedItem->itemid)));
        }
    }
    loot->unlootedCount = loot->items.size();
}