Esempio n. 1
0
uint32 Item::RepairItemCost()
{
    uint32 ilevel = m_itemProto->ItemLevel;
    if(ilevel <= 0)
        ilevel = 1;
    DurabilityCostsEntry* dcosts = dbcDurabilityCosts.LookupEntryForced(ilevel);
    if(dcosts == NULL)
    {
        //dcosts->itemlevel = 1;
        LOG_ERROR("Repair: Unknown item level (%u)", dcosts);
        return 0;
    }

    DurabilityQualityEntry* dquality = dbcDurabilityQuality.LookupEntryForced((m_itemProto->Quality + 1) * 2);
    if(dquality == NULL)
    {
        //dquality->quality_modifier = 4;
        LOG_ERROR("Repair: Unknown item quality (%u)", dquality);
        return 0;
    }

    uint32 dmodifier = dcosts->modifier[ m_itemProto->Class == ITEM_CLASS_WEAPON ? m_itemProto->SubClass : m_itemProto->SubClass + 21 ];
    uint32 cost = long2int32((GetDurabilityMax() - GetDurability()) * dmodifier * double(dquality->quality_modifier));
    return cost * 4;
}
Esempio n. 2
0
 void Animal::DoRareAction() {
     if ( GROUP_MEAT != GetSubGroup(Sub()) ) return;
     if ( not IsSubAround(AIR) ) {
         if ( breath <= 0 ) {
             Damage(10, DAMAGE_BREATH);
         } else {
             --breath;
         }
     } else if ( breath < MAX_BREATH ) {
         ++breath;
     }
     if ( GetDurability() <= 0 ) {
         GetWorld()->DestroyAndReplace(X(), Y(), Z());
     } else {
         emit Updated();
     }
 }
Esempio n. 3
0
 void Box::DoRareAction() {
     if ( GROUP_MEAT == GetSubGroup(Sub()) ) {
         Damage(MAX_DURABILITY/World::SECONDS_IN_DAY, DAMAGE_TIME);
         if ( GetDurability() <= 0 ) {
             World::GetWorld()->DestroyAndReplace(X(), Y(), Z());
         }
     } else if ( Sub() == DIFFERENT ) {
         World* const world = World::GetWorld();
         Inventory* const inv =
             world->GetBlock(X(), Y(), Z()-1)->HasInventory();
         if ( inv ) {
             inv->GetAll(this);
         }
         if ( IsEmpty() ) {
             world->DestroyAndReplace(X(), Y(), Z());
         }
     }
 }
Esempio n. 4
0
void Falling::FallDamage() {
    const int SAFE_FALL_HEIGHT = 5;
    if ( fallHeight > SAFE_FALL_HEIGHT ) {
        const int dmg = (fallHeight - SAFE_FALL_HEIGHT)*10;
        World* const world = World::GetWorld();
        Block* const block_under = world->GetBlock(X(), Y(), Z()-1);
        world->Damage(X(), Y(), Z()-1, dmg, DamageKind());
        if ( block_under->GetDurability() <= 0 ) {
            world->DestroyAndReplace(X(), Y(), Z()-1);
        }
        Damage(dmg, block_under->DamageKind());
        if ( GetDurability() <= 0 ) {
            world->DestroyAndReplace(X(), Y(), Z());
            return;
        }
    }
    falling = false;
    fallHeight = 0;
}
Esempio n. 5
0
uint32 Item::RepairItemCost()
{
	DurabilityCostsEntry * dcosts = dbcDurabilityCosts.LookupEntry( m_itemProto->ItemLevel );
	if( dcosts == NULL )
	{
		sLog.outError("Repair: Unknown item level (%u)", dcosts);
		return 0;
	}

	DurabilityQualityEntry * dquality = dbcDurabilityQuality.LookupEntry( ( m_itemProto->Quality + 1 ) * 2);
	if( dquality == NULL )
	{
		sLog.outError("Repair: Unknown item quality (%u)", dquality);
		return 0;
	}

	uint32 dmodifier = dcosts->modifier[ m_itemProto->Class == ITEM_CLASS_WEAPON ? m_itemProto->SubClass : m_itemProto->SubClass + 21 ];
	uint32 cost = long2int32( ( GetDurabilityMax() - GetDurability() ) * dmodifier * double( dquality->quality_modifier ) );
	return cost;
}
Esempio n. 6
0
void Item::SaveToDB(int8 containerslot, int8 slot, bool firstsave, QueryBuffer* buf)
{
    if (!m_isDirty && !firstsave)
        return;

    uint64 GiftCreatorGUID = GetGiftCreatorGUID();
    uint64 CreatorGUID = GetCreatorGUID();

    std::stringstream ss;

    ss << "DELETE FROM playeritems WHERE guid = " << GetLowGUID() << ";";

    if (firstsave)
        CharacterDatabase.WaitExecute(ss.str().c_str());
    else
    {
        if (buf == NULL)
            CharacterDatabase.Execute(ss.str().c_str());
        else
            buf->AddQueryNA(ss.str().c_str());
    }

    ss.rdbuf()->str("");

    uint64 ownerGUID = GetOwnerGUID();

    ss << "INSERT INTO playeritems VALUES(";

    ss << (Arcemu::Util::GUID_LOPART(ownerGUID)) << ",";
    ss << GetLowGUID() << ",";
    ss << GetEntry() << ",";
    ss << wrapped_item_id << ",";
    ss << (Arcemu::Util::GUID_LOPART(GiftCreatorGUID)) << ",";
    ss << (Arcemu::Util::GUID_LOPART(CreatorGUID)) << ",";

    ss << GetStackCount() << ",";
    ss << int32(GetChargesLeft()) << ",";
    ss << uint32(m_uint32Values[ITEM_FIELD_FLAGS]) << ",";
    ss << random_prop << ", " << random_suffix << ", ";
    ss << 0 << ",";
    ss << GetDurability() << ",";
    ss << static_cast<int>(containerslot) << ",";
    ss << static_cast<int>(slot) << ",'";

    // Pack together enchantment fields
    if (Enchantments.size() > 0)
    {
        EnchantmentMap::iterator itr = Enchantments.begin();
        for (; itr != Enchantments.end(); ++itr)
        {
            if (itr->second.RemoveAtLogout)
                continue;

            uint32 elapsed_duration = uint32(UNIXTIME - itr->second.ApplyTime);
            int32 remaining_duration = itr->second.Duration - elapsed_duration;
            if (remaining_duration < 0)
                remaining_duration = 0;

            if (itr->second.Enchantment && (remaining_duration > 5 || itr->second.Duration == 0))
            {
                ss << itr->second.Enchantment->Id << ",";
                ss << remaining_duration << ",";
                ss << itr->second.Slot << ";";
            }
        }
    }
    ss << "','";
    ss << ItemExpiresOn << "','";

    ////////////////////////////////////////////////// Refund stuff /////////////////////////////////

    // Check if the owner is instantiated. When sending mail he/she obviously will not be :P
    if (this->GetOwner() != NULL)
    {
        std::pair< time_t, uint32 > refundentry;

        refundentry.first = 0;
        refundentry.second = 0;

        refundentry = this->GetOwner()->GetItemInterface()->LookupRefundable(this->GetGUID());

        ss << uint32(refundentry.first) << "','";
        ss << uint32(refundentry.second);
    }
    else
    {
        ss << uint32(0) << "','";
        ss << uint32(0);
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////
    ss << "','";
    ss << text;
    ss << "')";

    if (firstsave)
        CharacterDatabase.WaitExecute(ss.str().c_str());
    else
    {
        if (buf == NULL)
            CharacterDatabase.Execute(ss.str().c_str());
        else
            buf->AddQueryNA(ss.str().c_str());
    }

    m_isDirty = false;
}