Нашел скрипт перековки в старых исходниках одного серва,взял залил,вроде работает нормально,статы добавляет,НО только косметически,так как после перековки общая статистика не меняеться(сила,интелект,дух..... всё остаёться прежним,но показывает на шмотке что статы успешно добавились,в чем может быть причина того что не добавляет стат? После выхода из игры и удаления кеш,статы пропадают!
for (std::vector<playerItems_format>::iterator it = playerItems[pGUID].begin(); it != playerItems[pGUID].end(); it++) { // See how enchanthing is done // Update player cache (self only) pure visual. // HandleItemQuerySingleOpcode copy paste: const ItemTemplate* proto = sObjectMgr->GetItemTemplate(it->Entry); std::string Name = proto->Name1; std::string Description = proto->Description; int loc_idx = player->GetSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) { if (ItemLocale const* il = sObjectMgr->GetItemLocale(proto->ItemId)) { ObjectMgr::GetLocaleString(il->Name, loc_idx, Name); ObjectMgr::GetLocaleString(il->Description, loc_idx, Description); } } WorldPacket data(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 600); data << proto->ItemId; data << proto->Class; data << proto->SubClass; data << int32(proto->SoundOverrideSubclass); data << Name; data << uint8(0x00); data << uint8(0x00); data << uint8(0x00); data << proto->DisplayInfoID; data << proto->Quality; data << proto->Flags; data << proto->Flags2; data << proto->BuyPrice; data << proto->SellPrice; data << proto->InventoryType; data << proto->AllowableClass; data << proto->AllowableRace; data << proto->ItemLevel; data << proto->RequiredLevel; data << proto->RequiredSkill; data << proto->RequiredSkillRank; data << proto->RequiredSpell; data << proto->RequiredHonorRank; data << proto->RequiredCityRank; data << proto->RequiredReputationFaction; data << proto->RequiredReputationRank; data << int32(proto->MaxCount); data << int32(proto->Stackable); data << proto->ContainerSlots; data << proto->StatsCount; for (uint32 i = 0; i < proto->StatsCount; ++i) { data << proto->ItemStat[i].ItemStatType; if(sObjectMgr->_itemFakeStatStore[it->lowGUID].find(i) != sObjectMgr->_itemFakeStatStore[it->lowGUID].end()) data << proto->ItemStat[i].ItemStatValue + sObjectMgr->_itemFakeStatStore[it->lowGUID][i]; else data << proto->ItemStat[i].ItemStatValue; } data << proto->ScalingStatDistribution; data << proto->ScalingStatValue; for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) { data << proto->Damage[i].DamageMin; data << proto->Damage[i].DamageMax; data << proto->Damage[i].DamageType; } data << proto->Armor; data << proto->HolyRes; data << proto->FireRes; data << proto->NatureRes; data << proto->FrostRes; data << proto->ShadowRes; data << proto->ArcaneRes; data << proto->Delay; data << proto->AmmoType; data << proto->RangedModRange; for (int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s) { SpellInfo const* spell = sSpellMgr->GetSpellInfo(proto->Spells[s].SpellId); if (spell) { bool db_data = proto->Spells[s].SpellCooldown >= 0 || proto->Spells[s].SpellCategoryCooldown >= 0; data << proto->Spells[s].SpellId; data << proto->Spells[s].SpellTrigger; data << uint32(-abs(proto->Spells[s].SpellCharges)); if (db_data) { data << uint32(proto->Spells[s].SpellCooldown); data << uint32(proto->Spells[s].SpellCategory); data << uint32(proto->Spells[s].SpellCategoryCooldown); } else { data << uint32(spell->RecoveryTime); data << uint32(spell->CategoryEntry); data << uint32(spell->CategoryRecoveryTime); } } else { data << uint32(0); data << uint32(0); data << uint32(0); data << uint32(-1); data << uint32(0); data << uint32(-1); } } data << proto->Bonding; data << Description; data << proto->PageText; data << proto->LanguageID; data << proto->PageMaterial; data << proto->StartQuest; data << proto->LockID; data << int32(proto->Material); data << proto->Sheath; data << proto->RandomProperty; data << proto->RandomSuffix; data << proto->Block; data << proto->ItemSet; data << proto->MaxDurability; data << proto->Area; data << proto->Map; data << proto->BagFamily; data << proto->TotemCategory; for (int s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s) { data << proto->Socket[s].Color; data << proto->Socket[s].Content; } data << proto->socketBonus; data << proto->GemProperties; data << proto->RequiredDisenchantSkill; data << proto->ArmorDamageModifier; data << proto->Duration; data << proto->ItemLimitCategory; data << proto->HolidayId; player->GetSession()->SendPacket(&data); } }
class REFORGING_DATA_HANDLER : public PlayerScript { public: REFORGING_DATA_HANDLER() : PlayerScript("REFORGING_DATA_HANDLER") { // DB cleanup on startup CharacterDatabase.Execute("DELETE FROM custom_reforges WHERE NOT EXISTS (SELECT 1 FROM item_instance WHERE item_instance.guid = custom_reforges.iGUID)"); }
// Called when a player logs out. void OnLogout(Player* player) { DeleteSavedReforges(player->GetGUIDLow()); // delete stored reforges from the player (not DB) }
char * GetSlotName(uint8 slot, WorldSession* session) { switch (slot) { case EQUIPMENT_SLOT_HEAD : return "|TInterface/ICONS/Inv_helmet_96:30|tГолова"; case EQUIPMENT_SLOT_NECK : return "|TInterface/ICONS/Inv_jewelry_necklace_ahnqiraj_01:30|tШея"; case EQUIPMENT_SLOT_SHOULDERS : return "|TInterface/ICONS/Inv_shoulder_60:30|tПлечи"; case EQUIPMENT_SLOT_BODY : return "|TInterface/ICONS/Inv_shirt_purple_01:30|tРубашка"; case EQUIPMENT_SLOT_CHEST : return "|TInterface/ICONS/Inv_chest_plate_22:30|tТело"; case EQUIPMENT_SLOT_WAIST : return "|TInterface/ICONS/Inv_belt_28:30|tПояс"; case EQUIPMENT_SLOT_LEGS : return "|TInterface/ICONS/Inv_pants_plate_29:30|tШтаны"; case EQUIPMENT_SLOT_FEET : return "|TInterface/ICONS/Inv_boots_plate_03:30|tСапоги"; case EQUIPMENT_SLOT_WRISTS : return "|TInterface/ICONS/Inv_bracer_32b:30|tБраслеты"; case EQUIPMENT_SLOT_HANDS : return "|TInterface/ICONS/Inv_gauntlets_69:30|tПерчатки"; case EQUIPMENT_SLOT_FINGER1 : return "|TInterface/ICONS/Inv_jewelry_ring_24:30|tПравое кольцо"; case EQUIPMENT_SLOT_FINGER2 : return "|TInterface/ICONS/Inv_jewelry_ring_24:30|tЛевое кольцо"; case EQUIPMENT_SLOT_TRINKET1 : return "|TInterface/ICONS/Inv_trinket_naxxramas02:30|tПравая серьга"; case EQUIPMENT_SLOT_TRINKET2 : return "|TInterface/ICONS/Inv_trinket_naxxramas02:30|tЛевая серьга"; case EQUIPMENT_SLOT_BACK : return "|TInterface/ICONS/Inv_misc_cape_21:30|tПлащ"; case EQUIPMENT_SLOT_MAINHAND : return "|TInterface/ICONS/Inv_axe_103:30|tПравая рука"; case EQUIPMENT_SLOT_OFFHAND : return "|TInterface/ICONS/Inv_shield_31:30|tЛевая рука"; case EQUIPMENT_SLOT_RANGED : return "|TInterface/ICONS/Inv_relics_totemofrage:30|tОружие дальнего боя"; case EQUIPMENT_SLOT_TABARD : return "|TInterface/ICONS/Inv_misc_tabardpvp_01:30|tГербовая накидка"; default: return NULL; } }
std::string GetItemName(uint32 entry, WorldSession* session) { const ItemTemplate* itemTemplate = sObjectMgr->GetItemTemplate(entry); std::string name = itemTemplate->Name1; int loc_idx = session->GetSessionDbLocaleIndex(); if (loc_idx >= 0) if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplate->ItemId)) sObjectMgr->GetLocaleString(il->Name, loc_idx, name); return name; }
bool IsReforgable(Item* invItem, Player* player) { if(invItem->IsEquipped() && invItem->GetOwnerGUID() == player->GetGUID()) { if(sObjectMgr->_itemFakeStatStore.find(invItem->GetGUIDLow()) != sObjectMgr->_itemFakeStatStore.end()) if(sObjectMgr->_itemFakeStatStore[invItem->GetGUIDLow()].size() >= maxReforges) return false; const ItemTemplate* proto = invItem->GetTemplate(); // block heirlooms necessary? probably. (their stats are handled differently) if(proto->Quality != ITEM_QUALITY_HEIRLOOM && proto->StatsCount > 0) { for (uint32 i = 0; i < proto->StatsCount; ++i) { if(stat_types.find(proto->ItemStat[i].ItemStatType) == stat_types.end()) continue; if(proto->ItemStat[i].ItemStatValue == 0) continue; if(sObjectMgr->_itemFakeStatStore.find(invItem->GetGUIDLow()) != sObjectMgr->_itemFakeStatStore.end()) { if(sObjectMgr->_itemFakeStatStore[invItem->GetGUIDLow()].find(i) == sObjectMgr->_itemFakeStatStore[invItem->GetGUIDLow()].end()) return true; // found a stat that is not increased yet and is accepted by the script } else return true; // the item is not reforged yet and a good stat was found } } } return false; }
// non tradeable and refundable invItem->SetNotRefundable(player); invItem->SetBinding(true);
// Update player stats player->_ApplyItemMods(invItem, invItem->GetSlot(), false); sObjectMgr->_itemFakeStatStore[guidlow][stat_count_id] = stat_diff; // save to container for item stats applying (used a lot) playerItems_format temp = {invItem->GetEntry(), guidlow}; // temp var so we can insert our stuff to playerItems_format playerItems[player->GetGUIDLow()].push_back(temp); // save entry and guid of the item so we can delete the item data on logout player->_ApplyItemMods(invItem, invItem->GetSlot(), true);
// save to DB player->SaveToDB(); // save player to DB too, since if a crash comes by, he will get a free reforge and no token removing is saved. CharacterDatabase.PExecute("REPLACE INTO `custom_reforges` (`pGUID`, `Entry`, `iGUID`, `stat_count_id`, `stat_diff`) VALUES (%u, %u, %u, %u, %i)", player->GetGUIDLow(), invItem->GetEntry(), guidlow, stat_count_id, stat_diff);
SendReforgePackets(player); } };
void AddSC_REFORGER_NPC() { new REFORGER_NPC; new REFORGING_DATA_HANDLER; }