Пример #1
0
bool Transmogrification::CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* proto2, ItemTemplate const* proto1)
{
    //if (!transmogrifier || !transmogrified)
    //    return false;

    //ItemTemplate const* proto1 = transmogrifier->GetTemplate(); // source
    //ItemTemplate const* proto2 = transmogrified->GetTemplate(); // dest

    if (proto1->ItemId == proto2->ItemId)
        return false;

    if (!SuitableForTransmogrification(player, proto2) || !SuitableForTransmogrification(player, proto1)) // if (!transmogrified->CanTransmogrify() || !transmogrifier->CanBeTransmogrified())
        return false;

    if (proto1->InventoryType == INVTYPE_BAG ||
        proto1->InventoryType == INVTYPE_RELIC ||
        proto1->InventoryType == INVTYPE_BODY ||
        proto1->InventoryType == INVTYPE_FINGER ||
        proto1->InventoryType == INVTYPE_TRINKET ||
        proto1->InventoryType == INVTYPE_AMMO ||
        proto1->InventoryType == INVTYPE_QUIVER)
        return false;

    //custom, TC doesnt check this? Checked by Inventory type check.
    if (proto1->Class != proto2->Class)
        return false;

    if (proto1->SubClass != proto2->SubClass && ((proto1->Class != ITEM_CLASS_WEAPON && !GetAllowMixedArmorTypes()) ||
        (!GetAllowMixedWeaponTypes() || (!IsRangedWeapon(proto2->SubClass, proto2->Class) || !IsRangedWeapon(proto1->SubClass, proto1->Class)))))
        return false;

    if (proto1->InventoryType != proto2->InventoryType &&
        (proto1->Class != ITEM_CLASS_WEAPON || (proto2->InventoryType != INVTYPE_WEAPONMAINHAND && proto2->InventoryType != INVTYPE_WEAPONOFFHAND)) &&
        (proto1->Class != ITEM_CLASS_ARMOR || (proto1->InventoryType != INVTYPE_CHEST && proto2->InventoryType != INVTYPE_ROBE && proto1->InventoryType != INVTYPE_ROBE && proto2->InventoryType != INVTYPE_CHEST) || true))
        return false;

    return true;
}
Пример #2
0
bool Transmogrification::CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* proto2, ItemTemplate const* proto1)
{
    //if (!transmogrifier || !transmogrified)
    //    return false;

    //ItemTemplate const* proto1 = transmogrifier->GetTemplate(); // source
    //ItemTemplate const* proto2 = transmogrified->GetTemplate(); // dest

    if (proto1->ItemId == proto2->ItemId)
        return false;

    if (!SuitableForTransmogrification(player, proto2) || !SuitableForTransmogrification(player, proto1)) // if (!transmogrified->CanTransmogrify() || !transmogrifier->CanBeTransmogrified())
        return false;

    if (proto1->InventoryType == INVTYPE_BAG ||
        proto1->InventoryType == INVTYPE_RELIC ||
        proto1->InventoryType == INVTYPE_BODY ||
        proto1->InventoryType == INVTYPE_FINGER ||
        proto1->InventoryType == INVTYPE_TRINKET ||
        proto1->InventoryType == INVTYPE_AMMO ||
        proto1->InventoryType == INVTYPE_QUIVER)
        return false;

    //custom, TC doesnt check this? Checked by Inventory type check.
    if (proto1->Class != proto2->Class)
        return false;

    uint32 Class = proto1->Class; // they're assured to be the same by this point
    bool res = true;

    // if subclasses mismatch we can't proceed unless ranged or unless told to do so in the config
    if (proto1->SubClass != proto2->SubClass)
    {
        res = false;
        if (Class == ITEM_CLASS_WEAPON)
        {
            if (IsRangedWeapon(Class, proto2->SubClass) && IsRangedWeapon(Class, proto1->SubClass))
                res = true;
            else if (GetAllowMixedWeaponTypes() && !IsRangedWeapon(Class, proto2->SubClass) && !IsRangedWeapon(Class, proto1->SubClass))
                res = true;

        }
        else if(GetAllowMixedArmorTypes())
            res = true;
    }

    // if inv type mismatches we cant proceed unless it's a wep (then exceptions apply) or robe/chest pair
    if (proto1->InventoryType != proto2->InventoryType && res)
    {
        res = false;
        if (Class == ITEM_CLASS_WEAPON)
        {
            if (GetAllowMixedWeaponInvTypes()) // 2h into 1h etc
                res = true;
            else if (proto2->InventoryType == INVTYPE_WEAPONMAINHAND || proto2->InventoryType == INVTYPE_WEAPONOFFHAND)
                res = true;
        }
        else if (Class == ITEM_CLASS_ARMOR && ((proto1->InventoryType == INVTYPE_CHEST && proto2->InventoryType == INVTYPE_ROBE) || ((proto1->InventoryType == INVTYPE_ROBE && proto2->InventoryType == INVTYPE_CHEST))))
            res = true;
    }

    return res;
}