您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetUInt32Value函数代码示例

51自学网 2021-06-01 21:17:02
  C++
这篇教程C++ GetUInt32Value函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetUInt32Value函数的典型用法代码示例。如果您正苦于以下问题:C++ GetUInt32Value函数的具体用法?C++ GetUInt32Value怎么用?C++ GetUInt32Value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GetUInt32Value函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: event_Relocate

void GameObject::Update(uint32 p_time){	if(m_event_Instanceid != m_instanceId)	{		event_Relocate();		return;	}	if(!IsInWorld())		return;	if(m_deleted)		return;	if(spell && (GetUInt32Value(GAMEOBJECT_STATE) == 1))	{		if(checkrate > 1)		{			if(counter++%checkrate)				return;		}		ObjectSet::iterator itr = GetInRangeSetBegin();		ObjectSet::iterator it2 = itr;		ObjectSet::iterator iend = GetInRangeSetEnd();		Unit * pUnit;		float dist;		this->AquireInrangeLock(); //make sure to release lock before exit function !		for(; it2 != iend;)		{			itr = it2;			++it2;			dist = GetDistanceSq((*itr));			if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range)			{				pUnit = static_cast<Unit*>(*itr);				if(m_summonedGo)				{					if(!m_summoner)					{						ExpireAndDelete();						return;					}					if(!isAttackable(m_summoner,pUnit))continue;				}								Spell * sp=SpellPool.PooledNew();				sp->Init((Object*)this,spell,true,NULL);				SpellCastTargets tgt((*itr)->GetGUID());				tgt.m_destX = GetPositionX();				tgt.m_destY = GetPositionY();				tgt.m_destZ = GetPositionZ();				sp->prepare(&tgt);				// proc on trap trigger				if( pInfo->Type == GAMEOBJECT_TYPE_TRAP )				{					if( m_summoner != NULL )						m_summoner->HandleProc( PROC_ON_TRAP_TRIGGER, pUnit, spell );				} 				if(m_summonedGo)				{					ExpireAndDelete();					this->ReleaseInrangeLock();					return;				}				if(spell->EffectImplicitTargetA[0] == 16 ||					spell->EffectImplicitTargetB[0] == 16)				{					this->ReleaseInrangeLock();					return;	 // on area dont continue.				}			}		}		this->ReleaseInrangeLock();	}}
开发者ID:Chero,项目名称:abcwow,代码行数:79,


示例2: MAKE_NEW_GUID

bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result){    // create item before any checks for store correct guid    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB    Object::_Create(guid, 0, HIGHGUID_ITEM);    bool delete_result = false;    if(!result)    {        result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guid);        delete_result = true;    }    if (!result)    {        sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ",guid,GUID_LOPART(owner_guid));        return false;    }    Field *fields = result->Fetch();    if(!LoadValues(fields[0].GetString()))    {        sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.",guid);        if (delete_result) delete result;        return false;    }    bool need_save = false;                                 // need explicit save data at load fixes    // overwrite possible wrong/corrupted guid    uint64 new_item_guid = MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM);    if(GetUInt64Value(OBJECT_FIELD_GUID) != new_item_guid)    {        SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM));        need_save = true;    }    if (delete_result) delete result;    ItemPrototype const* proto = GetProto();    if(!proto)        return false;    // update max durability (and durability) if need    if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))    {        SetUInt32Value(ITEM_FIELD_MAXDURABILITY,proto->MaxDurability);        if(GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)            SetUInt32Value(ITEM_FIELD_DURABILITY,proto->MaxDurability);        need_save = true;    }    // recalculate suffix factor    if(GetItemRandomPropertyId() < 0)    {        if(UpdateItemSuffixFactor())            need_save = true;    }    // Remove bind flag for items vs NO_BIND set    if (IsSoulBound() && proto->Bonding == NO_BIND)    {        ApplyModFlag(ITEM_FIELD_FLAGS,ITEM_FLAGS_BINDED, false);        need_save = true;    }    // update duration if need, and remove if not need    if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))    {        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);        need_save = true;    }    // set correct owner    if (owner_guid != 0 && GetOwnerGUID() != owner_guid)    {        SetOwnerGUID(owner_guid);        need_save = true;    }    if (need_save)                                          // normal item changed state set not work at loading    {        std::ostringstream ss;        ss << "UPDATE item_instance SET data = '";        for(uint16 i = 0; i < m_valuesCount; ++i )            ss << GetUInt32Value(i) << " ";        ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guid << "'";        CharacterDatabase.Execute( ss.str().c_str() );    }    //Set extended cost for refundable item    if(HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE))    {        QueryResult *result_ext = CharacterDatabase.PQuery("SELECT ExtendedCost, price FROM item_instance WHERE guid = '%u'", guid);        if(result_ext)        {            m_ExtendedCostId = result_ext->Fetch()[0].GetUInt32();//.........这里部分代码省略.........
开发者ID:Nny,项目名称:Core,代码行数:101,


示例3: SetEntry

bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry){    //                                                    0                1      2         3        4      5             6                 7           8           9    10    //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);    // create item before any checks for store correct guid    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB    Object::_Create(guid, 0, HighGuid::Item);    // Set entry, MUST be before proto check    SetEntry(entry);    SetObjectScale(1.0f);    ItemTemplate const* proto = GetTemplate();    if (!proto)        return false;    // set owner (not if item is only loaded for gbank/auction/mail    if (owner_guid)        SetOwnerGUID(owner_guid);    bool need_save = false;                                 // need explicit save data at load fixes    SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid(HighGuid::Player, fields[0].GetUInt32()));    SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid(HighGuid::Player, fields[1].GetUInt32()));    SetCount(fields[2].GetUInt32());    uint32 duration = fields[3].GetUInt32();    SetUInt32Value(ITEM_FIELD_DURATION, duration);    // update duration if need, and remove if not need    if ((proto->Duration == 0) != (duration == 0))    {        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);        need_save = true;    }    Tokenizer tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);    if (tokens.size() == MAX_ITEM_PROTO_SPELLS)        for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)            SetSpellCharges(i, atoi(tokens[i]));    SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].GetUInt32());    // Remove bind flag for items vs NO_BIND set    if (IsSoulBound() && proto->Bonding == NO_BIND)    {        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, false);        need_save = true;    }    std::string enchants = fields[6].GetString();    _LoadIntoDataField(enchants.c_str(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);    SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());    // recalculate suffix factor    if (GetItemRandomPropertyId() < 0)        UpdateItemSuffixFactor();    uint32 durability = fields[8].GetUInt16();    SetUInt32Value(ITEM_FIELD_DURABILITY, durability);    // update max durability (and durability) if need    SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);    if (durability > proto->MaxDurability)    {        SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);        need_save = true;    }    SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());    SetText(fields[10].GetString());    if (need_save)                                           // normal item changed state set not work at loading    {        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_INSTANCE_ON_LOAD);        stmt->setUInt32(0, GetUInt32Value(ITEM_FIELD_DURATION));        stmt->setUInt32(1, GetUInt32Value(ITEM_FIELD_FLAGS));        stmt->setUInt32(2, GetUInt32Value(ITEM_FIELD_DURABILITY));        stmt->setUInt32(3, guid);        CharacterDatabase.Execute(stmt);    }    return true;}
开发者ID:StormDev2ofiical,项目名称:CoreStorm,代码行数:80,


示例4: GetGUIDLow

void Item::SaveToDB(){    uint32 guid = GetGUIDLow();    switch (uState)    {        case ITEM_NEW:        {            static SqlStatementID delItem ;            static SqlStatementID insItem ;            SqlStatement stmt = CharacterDatabase.CreateStatement(delItem, "DELETE FROM item_instance WHERE guid = ?");            stmt.PExecute(guid);            std::ostringstream ss;            for (uint16 i = 0; i < m_valuesCount; ++i)                ss << GetUInt32Value(i) << " ";            stmt = CharacterDatabase.CreateStatement(insItem, "INSERT INTO item_instance (guid,owner_guid,data) VALUES (?, ?, ?)");            stmt.PExecute(guid, GetOwnerGuid().GetCounter(), ss.str().c_str());        } break;        case ITEM_CHANGED:        {            static SqlStatementID updInstance ;            static SqlStatementID updGifts ;            SqlStatement stmt = CharacterDatabase.CreateStatement(updInstance, "UPDATE item_instance SET data = ?, owner_guid = ? WHERE guid = ?");            std::ostringstream ss;            for (uint16 i = 0; i < m_valuesCount; ++i)                ss << GetUInt32Value(i) << " ";            stmt.PExecute(ss.str().c_str(), GetOwnerGuid().GetCounter(), guid);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))            {                stmt = CharacterDatabase.CreateStatement(updGifts, "UPDATE character_gifts SET guid = ? WHERE item_guid = ?");                stmt.PExecute(GetOwnerGuid().GetCounter(), GetGUIDLow());            }        } break;        case ITEM_REMOVED:        {            static SqlStatementID delItemText;            static SqlStatementID delInst ;            static SqlStatementID delGifts ;            static SqlStatementID delLoot ;            if (uint32 item_text_id = GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID))            {                SqlStatement stmt = CharacterDatabase.CreateStatement(delItemText, "DELETE FROM item_text WHERE id = ?");                stmt.PExecute(item_text_id);            }            SqlStatement stmt = CharacterDatabase.CreateStatement(delInst, "DELETE FROM item_instance WHERE guid = ?");            stmt.PExecute(guid);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))            {                stmt = CharacterDatabase.CreateStatement(delGifts, "DELETE FROM character_gifts WHERE item_guid = ?");                stmt.PExecute(GetGUIDLow());            }            if (HasSavedLoot())            {                stmt = CharacterDatabase.CreateStatement(delLoot, "DELETE FROM item_loot WHERE guid = ?");                stmt.PExecute(GetGUIDLow());            }            delete this;            return;        }        case ITEM_UNCHANGED:            return;    }    if (m_lootState == ITEM_LOOT_CHANGED || m_lootState == ITEM_LOOT_REMOVED)    {        static SqlStatementID delLoot ;        SqlStatement stmt = CharacterDatabase.CreateStatement(delLoot, "DELETE FROM item_loot WHERE guid = ?");        stmt.PExecute(GetGUIDLow());    }    if (loot && (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED))    {        if (Player* owner = GetOwner())        {            static SqlStatementID saveGold ;            static SqlStatementID saveLoot ;            // save money as 0 itemid data            if (loot->GetGoldAmount())            {                SqlStatement stmt = CharacterDatabase.CreateStatement(saveGold, "INSERT INTO item_loot (guid,owner_guid,itemid,amount,property) VALUES (?, ?, 0, ?, 0)");                stmt.PExecute(GetGUIDLow(), owner->GetGUIDLow(), loot->GetGoldAmount());            }            SqlStatement stmt = CharacterDatabase.CreateStatement(saveLoot, "INSERT INTO item_loot (guid,owner_guid,itemid,amount,property) VALUES (?, ?, ?, ?, ?)");            // save items and quest items (at load its all will added as normal, but this not important for item loot case)            LootItemList lootList;//.........这里部分代码省略.........
开发者ID:Ghaster,项目名称:mangos-classic,代码行数:101,


示例5: GetGUIDLow

void Item::SaveToDB(SQLTransaction& trans){    uint32 guid = GetGUIDLow();    switch (uState)    {        case ITEM_NEW:        case ITEM_CHANGED:        {            uint8 index = 0;            PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_ADD_ITEM_INSTANCE : CHAR_UPDATE_ITEM_INSTANCE);            stmt->setUInt32(  index, GetEntry());            stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));            stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));            stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));            stmt->setUInt32(++index, GetCount());            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));            std::ostringstream ssSpells;            for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)                ssSpells << GetSpellCharges(i) << " ";            stmt->setString(++index, ssSpells.str());            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));            std::ostringstream ssEnchants;            for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)            {                ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << " ";                ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << " ";                ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << " ";            }            stmt->setString(++index, ssEnchants.str());            stmt->setInt32 (++index, GetItemRandomPropertyId());            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));            stmt->setString(++index, m_text);            stmt->setUInt32(++index, guid);            trans->Append(stmt);            if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))            {                stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_GIFT_OWNER);                stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));                stmt->setUInt32(1, guid);                trans->Append(stmt);            }            break;        }        case ITEM_REMOVED:        {            PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);            stmt->setUInt32(0, guid);            trans->Append(stmt);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))            {                stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);                stmt->setUInt32(0, guid);                trans->Append(stmt);            }            delete this;            return;        }        case ITEM_UNCHANGED:            break;    }    SetState(ITEM_UNCHANGED);}
开发者ID:H4D3S,项目名称:DarkmoonCore-Cataclysm,代码行数:70,


示例6: memset

void Creature::generateLoot(){    memset(item_list, 0, 8*128);    itemcount = 0;     int LootValue = 0, MaxLootValue = 0;            int itemsToGet = 0;    int creature_level = getLevel();    if(creature_level < 10)    {        itemsToGet = rand()%2;     }    else if(creature_level < 25)    {        itemsToGet = rand()%3;     }    else if(creature_level < 40)    {        itemsToGet = rand()%4;     }    else if(creature_level < 60)    {        itemsToGet = rand()%5;     }    else if(creature_level < 80)    {        itemsToGet = rand()%6;     }    else     {        itemsToGet = rand()%7;     }        m_lootMoney = (uint32)(creature_level * (rand()%5 + 1)*sWorld.getRate(RATE_DROP));         if( itemsToGet == 0 )    return;         MaxLootValue = (int)(((creature_level * (rand()%40+50))/5)*sWorld.getRate(RATE_DROP)+rand()%5+5);        const LootMgr::LootList &loot_list(LootManager.getCreaturesLootList(GetUInt32Value(OBJECT_FIELD_ENTRY)));    bool not_done = (loot_list.size()  && itemsToGet);    std::vector<short> indexes(loot_list.size());    std::generate(indexes.begin(), indexes.end(), SequenceGen());    sLog.outDebug("Number of items to get %d", itemsToGet);        while (not_done)    {        int idx = rand()%indexes.size();    const LootItem &item(loot_list[indexes[idx]]);    indexes.erase(indexes.begin()+idx);    ItemPrototype *pCurItem = objmgr.GetItemPrototype(item.itemid);        if( pCurItem != NULL && item.chance >= (rand()%100) )    {        if( !(LootValue > MaxLootValue) )        {        LootValue += pCurItem->BuyPrice;        addItem(item.itemid, 1);                --itemsToGet;        }    }        not_done = (itemsToGet && indexes.size() && !(LootValue > MaxLootValue));    }}
开发者ID:Artea,项目名称:mangos-svn,代码行数:71,


示例7: GetGUIDLow

void Item::SaveToDB(){    uint32 guid = GetGUIDLow();    switch (uState)    {        case ITEM_NEW:        {            static SqlStatementID delItem ;            static SqlStatementID insItem ;            SqlStatement stmt = CharacterDatabase.CreateStatement(delItem, "DELETE FROM item_instance WHERE guid = ?");            stmt.PExecute(guid);            std::ostringstream ss;            for (uint16 i = 0; i < m_valuesCount; ++i)                ss << GetUInt32Value(i) << " ";            stmt = CharacterDatabase.CreateStatement(insItem, "INSERT INTO item_instance (guid,owner_guid,data) VALUES (?, ?, ?)");            stmt.PExecute(guid, GetOwnerGuid().GetCounter(), ss.str().c_str());        } break;        case ITEM_CHANGED:        {            static SqlStatementID updInstance ;            static SqlStatementID updGifts ;            SqlStatement stmt = CharacterDatabase.CreateStatement(updInstance, "UPDATE item_instance SET data = ?, owner_guid = ? WHERE guid = ?");            std::ostringstream ss;            for (uint16 i = 0; i < m_valuesCount; ++i)                ss << GetUInt32Value(i) << " ";            stmt.PExecute(ss.str().c_str(), GetOwnerGuid().GetCounter(), guid);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))            {                stmt = CharacterDatabase.CreateStatement(updGifts, "UPDATE character_gifts SET guid = ? WHERE item_guid = ?");                stmt.PExecute(GetOwnerGuid().GetCounter(), GetGUIDLow());            }        } break;        case ITEM_REMOVED:        {            static SqlStatementID delItemText;            static SqlStatementID delInst ;            static SqlStatementID delGifts ;            static SqlStatementID delLoot ;            if (uint32 item_text_id = GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID))            {                SqlStatement stmt = CharacterDatabase.CreateStatement(delItemText, "DELETE FROM item_text WHERE id = ?");                stmt.PExecute(item_text_id);            }            SqlStatement stmt = CharacterDatabase.CreateStatement(delInst, "DELETE FROM item_instance WHERE guid = ?");            stmt.PExecute(guid);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))            {                stmt = CharacterDatabase.CreateStatement(delGifts, "DELETE FROM character_gifts WHERE item_guid = ?");                stmt.PExecute(GetGUIDLow());            }            if (HasSavedLoot())            {                stmt = CharacterDatabase.CreateStatement(delLoot, "DELETE FROM item_loot WHERE guid = ?");                stmt.PExecute(GetGUIDLow());            }            delete this;            return;        }        case ITEM_UNCHANGED:            return;    }    if (m_lootState == ITEM_LOOT_CHANGED || m_lootState == ITEM_LOOT_REMOVED)    {        static SqlStatementID delLoot ;        SqlStatement stmt = CharacterDatabase.CreateStatement(delLoot, "DELETE FROM item_loot WHERE guid = ?");        stmt.PExecute(GetGUIDLow());    }    if (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED)    {        if (Player* owner = GetOwner())        {            static SqlStatementID saveGold ;            static SqlStatementID saveLoot ;            // save money as 0 itemid data            if (loot.gold)            {                SqlStatement stmt = CharacterDatabase.CreateStatement(saveGold, "INSERT INTO item_loot (guid,owner_guid,itemid,amount,property) VALUES (?, ?, 0, ?, 0)");                stmt.PExecute(GetGUIDLow(), owner->GetGUIDLow(), loot.gold);            }            SqlStatement stmt = CharacterDatabase.CreateStatement(saveLoot, "INSERT INTO item_loot (guid,owner_guid,itemid,amount,property) VALUES (?, ?, ?, ?, ?)");            // save items and quest items (at load its all will added as normal, but this not important for item loot case)            for (size_t i = 0; i < loot.GetMaxSlotInLootFor(owner); ++i)//.........这里部分代码省略.........
开发者ID:ArgentPrawn,项目名称:server,代码行数:101,


示例8: Remove

void AreaTrigger::Update(uint32 p_time){    if (GetDuration() > int32(p_time))        _duration -= p_time;    else        Remove(); // expired    WorldObject::Update(p_time);    SpellInfo const* m_spellInfo = sSpellMgr->GetSpellInfo(GetUInt32Value(AREATRIGGER_SPELLID));    if (!m_spellInfo)        return;    if (!GetCaster())    {        Remove();        return;    }    Unit* caster = GetCaster();    float radius = 0.0f;    // Custom MoP Script    switch (m_spellInfo->Id)    {        case 102793:// Ursol's Vortex        {            std::list<Unit*> targetList;            radius = 8.0f;            SurgeCore::NearestAttackableUnitInObjectRangeCheck u_check(this, caster, radius);            SurgeCore::UnitListSearcher<SurgeCore::NearestAttackableUnitInObjectRangeCheck> searcher(this, targetList, u_check);            VisitNearbyObject(radius, searcher);            if (!targetList.empty())                for (auto itr : targetList)                    if (!itr->HasAura(127797))                        caster->CastSpell(itr, 127797, true);            break;        }        case 115460:// Healing Sphere        {            std::list<Unit*> targetList;            radius = 1.0f;            SurgeCore::AnyFriendlyUnitInObjectRangeCheck u_check(this, caster, radius);            SurgeCore::UnitListSearcher<SurgeCore::AnyFriendlyUnitInObjectRangeCheck> searcher(this, targetList, u_check);            VisitNearbyObject(radius, searcher);            if (!targetList.empty())            {                for (auto itr : targetList)                {                    caster->CastSpell(itr, 115464, true); // Healing Sphere heal                    SetDuration(0);                    return;                }            }            break;        }        case 115817:// Cancel Barrier        {            std::list<Unit*> targetList;            radius = 6.0f;            SurgeCore::AnyFriendlyUnitInObjectRangeCheck u_check(this, caster, radius);            SurgeCore::UnitListSearcher<SurgeCore::AnyFriendlyUnitInObjectRangeCheck> searcher(this, targetList, u_check);            VisitNearbyObject(radius, searcher);            if (!targetList.empty())                for (auto itr : targetList)                    itr->CastSpell(itr, 115856, true);            break;        }        case 116011:// Rune of Power        {            std::list<Unit*> targetList;            bool affected = false;            radius = 2.25f;            SurgeCore::AnyFriendlyUnitInObjectRangeCheck u_check(this, caster, radius);            SurgeCore::UnitListSearcher<SurgeCore::AnyFriendlyUnitInObjectRangeCheck> searcher(this, targetList, u_check);            VisitNearbyObject(radius, searcher);            if (!targetList.empty())            {                for (auto itr : targetList)                {                    if (itr->GetGUID() == caster->GetGUID())                    {                        caster->CastSpell(itr, 116014, true); // Rune of Power                        affected = true;                        if (caster->ToPlayer())                            caster->ToPlayer()->UpdateManaRegen();                        return;//.........这里部分代码省略.........
开发者ID:AwkwardDev,项目名称:SurgeCore-505,代码行数:101,


示例9: GetGUIDLow

void Item::SaveToDB(){    uint32 guid = GetGUIDLow();    switch (uState)    {        case ITEM_NEW:        {            std::string text = m_text;            CharacterDatabase.escape_string(text);            CharacterDatabase.PExecute( "DELETE FROM item_instance WHERE guid = '%u'", guid );            std::ostringstream ss;            ss << "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (" << guid << "," << GetOwnerGuid().GetCounter() << ",'";            for(uint16 i = 0; i < m_valuesCount; ++i )                ss << GetUInt32Value(i) << " ";            ss << "', '" << text << "')";            CharacterDatabase.Execute( ss.str().c_str() );        } break;        case ITEM_CHANGED:        {            std::string text = m_text;            CharacterDatabase.escape_string(text);            std::ostringstream ss;            ss << "UPDATE item_instance SET data = '";            for(uint16 i = 0; i < m_valuesCount; ++i )                ss << GetUInt32Value(i) << " ";            ss << "', owner_guid = '" << GetOwnerGuid().GetCounter();            ss << "', text = '" << text << "' WHERE guid = '" << guid << "'";            CharacterDatabase.Execute( ss.str().c_str() );            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))                CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GetOwnerGuid().GetCounter(), GetGUIDLow());        } break;        case ITEM_REMOVED:        {            CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))                CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());            if (HasSavedLoot())                CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u'", GetGUIDLow());            delete this;            return;        }        case ITEM_UNCHANGED:            return;    }    if (m_lootState == ITEM_LOOT_CHANGED || m_lootState == ITEM_LOOT_REMOVED)        CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u'", GetGUIDLow());    if (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED)    {        if(Player* owner = GetOwner())        {            // save money as 0 itemid data            if (loot.gold)                CharacterDatabase.PExecute("INSERT INTO item_loot (guid,owner_guid,itemid,amount,suffix,property) "                    "VALUES (%u, %u, 0, %u, 0, 0)",                    GetGUIDLow(), owner->GetGUIDLow(), loot.gold);            // save items and quest items (at load its all will added as normal, but this not important for item loot case)            for (size_t i = 0; i < loot.GetMaxSlotInLootFor(owner); ++i)            {                QuestItem *qitem = NULL;                LootItem *item = loot.LootItemInSlot(i,owner,&qitem);                if(!item)                    continue;                // questitems use the blocked field for other purposes                if (!qitem && item->is_blocked)                    continue;                CharacterDatabase.PExecute("INSERT INTO item_loot (guid,owner_guid,itemid,amount,suffix,property) "                    "VALUES (%u, %u, %u, %u, %u, %i)",                    GetGUIDLow(), owner->GetGUIDLow(), item->itemid, item->count, item->randomSuffix, item->randomPropertyId);            }        }    }    if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY)        SetLootState(ITEM_LOOT_UNCHANGED);    SetState(ITEM_UNCHANGED);}
开发者ID:z3usleo,项目名称:easy-mangos,代码行数:88,


示例10: assert

void Vehicle::_AddToSlot(Unit* pPassenger, uint8 slot){	assert( slot < m_seatSlotMax );	if(pPassenger->IsPlayer() && TO_PLAYER(pPassenger)->m_CurrentCharm)		return;	if(pPassenger->IsPlayer() && TO_PLAYER(pPassenger)->m_isGmInvisible)	{		sChatHandler.GreenSystemMessage(TO_PLAYER(pPassenger)->GetSession(), "Please turn off invis before entering vehicle.");		return;	}	CreatureProtoVehicle* vehicleproto = CreatureProtoVehicleStorage.LookupEntry(GetEntry());	m_passengers[slot] = pPassenger;	LocationVector v;	v.x = m_vehicleSeats[slot]->m_attachmentOffsetX; /* pPassenger->m_TransporterX = */	v.y = m_vehicleSeats[slot]->m_attachmentOffsetY; /* pPassenger->m_TransporterY = */	v.z = m_vehicleSeats[slot]->m_attachmentOffsetZ; /* pPassenger->m_TransporterZ = */	v.o = 0; /* pPassenger->m_TransporterO = */	//pPassenger->m_transportPosition =& v; // This is handled elsewhere, do not initialize here.	pPassenger->movement_info.flags |= MOVEFLAG_TAXI;	pPassenger->movement_info.transX = v.x;	pPassenger->movement_info.transY = v.y;	pPassenger->movement_info.transZ = v.z;	pPassenger->movement_info.transO = GetOrientation();	pPassenger->movement_info.transSeat = slot;	pPassenger->movement_info.transGuid = WoWGuid(GetGUID());	pPassenger->SetSeatID(slot);	pPassenger->m_TransporterGUID = GetGUID();	if( m_CastSpellOnMount )		pPassenger->CastSpell( pPassenger, m_CastSpellOnMount, true );	RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SELF_RES);	// This is where the real magic happens	if( pPassenger->IsPlayer() )	{		Player* pPlayer = TO_PLAYER(pPassenger);		//pPlayer->Root();		//Dismount		if(pPlayer->m_MountSpellId && pPlayer->m_MountSpellId != m_mountSpell)			pPlayer->RemoveAura(pPlayer->m_MountSpellId);		//Remove morph spells		if(pPlayer->GetUInt32Value(UNIT_FIELD_DISPLAYID) != pPlayer->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID))		{			pPlayer->RemoveAllAurasOfType(SPELL_AURA_TRANSFORM);			pPlayer->RemoveAllAurasOfType(SPELL_AURA_MOD_SHAPESHIFT);		}		//Dismiss any pets		if(pPlayer->GetSummon())		{			if(pPlayer->GetSummon()->GetUInt32Value(UNIT_CREATED_BY_SPELL) > 0)				pPlayer->GetSummon()->Dismiss(false);				// warlock summon -> dismiss			else				pPlayer->GetSummon()->Remove(false, true, true);	// hunter pet -> just remove for later re-call		}		pPlayer->SetVehicle(this);		pPlayer->SetUInt64Value(PLAYER_FARSIGHT, GetGUID());		pPlayer->SetPlayerStatus(TRANSFER_PENDING);		sEventMgr.AddEvent(pPlayer, &Player::CheckPlayerStatus, (uint8)TRANSFER_PENDING, EVENT_PLAYER_CHECK_STATUS_Transfer, 5000, 0, 0);		pPlayer->m_sentTeleportPosition.ChangeCoords(GetPositionX(), GetPositionY(), GetPositionZ());		WorldPacket data(SMSG_MONSTER_MOVE_TRANSPORT, 100);		data << pPlayer->GetNewGUID();							// Passengerguid		data << GetNewGUID();									// Transporterguid (vehicleguid)		data << uint8(slot);									// Vehicle Seat ID		data << uint8(0);										// Unknown		data << GetPositionX() - pPlayer->GetPositionX();		// OffsetTransporterX		data << GetPositionY() - pPlayer->GetPositionY();		// OffsetTransporterY		data << GetPositionZ() - pPlayer->GetPositionZ();		// OffsetTransporterZ		data << getMSTime();									// Timestamp		data << uint8(0x04);									// Flags		data << float(0);										// Orientation Offset		data << uint32(MOVEFLAG_TB_MOVED);						// MovementFlags		data << uint32(0);										// MoveTime		data << uint32(1);										// Points		data << v.x;											// GetTransOffsetX();		data << v.y;											// GetTransOffsetY();		data << v.z;											// GetTransOffsetZ();		SendMessageToSet(&data, true);		if(vehicleproto)		{	// We have proto, no accessory in slot, and slot sets unselectable, unlike some seats			if(!vehicleproto->seats[slot].accessoryentry && vehicleproto->seats[slot].unselectableaccessory)				pPlayer->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE));		}		else			pPlayer->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE));		if(slot == 0)		{			if(m_vehicleSeats[slot]->IsControllable())			{				m_redirectSpellPackets = pPlayer;//.........这里部分代码省略.........
开发者ID:SkyFire,项目名称:sandshroud,代码行数:101,


示例11: WorldGetUnit

//.........这里部分代码省略.........	case SPELL_AURA_MOD_POSSESS_PET: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_POSSESS_PET");		break; }	case SPELL_AURA_MOD_INCREASE_SPEED_ALWAYS: {		unit = WorldGetUnit (GetGUID());		if (unit != NULL) {			if (apply)	unit->ModifySpeedMod (mod->GetAmount() / 100.0f);			else {				if (mod->GetAmount() != 0)					unit->ModifySpeedMod (100.0f / mod->GetAmount());				else					unit->SetSpeedMod (1.0f);			}		} else {			sLog.outDebug ("ApplyModifier SPELL_AURA_MOD_INCREASE_SPEED_ALWAYS: Unit %X not found", GetGUIDLow());		}		break; }	case SPELL_AURA_MOD_DAMAGE_DONE: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_DAMAGE_DONE");		break; }	case SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS");		break; }	case SPELL_AURA_MOD_CREATURE_RANGED_ATTACK_POWER: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_CREATURE_RANGED_ATTACK_POWER");		break; }	case SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT: {		uint32 percent = mod->GetAmount();		uint32 current = GetUInt32Value(UNIT_FIELD_POWER4);		apply ?			SetUInt32Value(UNIT_FIELD_POWER4,current+current/100*percent)		:	SetUInt32Value(UNIT_FIELD_POWER4,current-current/(100+percent)*100);		break; }	case SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT: {		uint32 percent = mod->GetAmount();		uint32 current = GetUInt32Value(UNIT_FIELD_MAXHEALTH);		apply ?			SetUInt32Value(UNIT_FIELD_MAXHEALTH,current+current/100*percent)		:	SetUInt32Value(UNIT_FIELD_MAXHEALTH,current-current/(100+percent)*100);		break; }	case SPELL_AURA_MOD_MANA_REGEN_INTERRUPT: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_MANA_REGEN_INTERRUPT");		break; }	case SPELL_AURA_MOD_HEALING_DONE: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_HEALING_DONE");		break; }	case SPELL_AURA_MOD_HEALING_DONE_PERCENT: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_HEALING_DONE_PERCENT");		break; }	case SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE");		break; }	case SPELL_AURA_MOD_HASTE: {		sLog.outDebug ("ApplyModifier: Unsupported SPELL_AURA_MOD_HASTE");		break; }
开发者ID:vata,项目名称:prebcwow,代码行数:67,


示例12: data

void Vehicle::RemovePassenger(Unit* pPassenger){	if(pPassenger == NULL) // We have enough problems that we need to do this :(		return;	uint8 slot = pPassenger->GetSeatID();	pPassenger->SetVehicle(NULL);	pPassenger->SetSeatID(NULL);	pPassenger->RemoveFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE));	if( pPassenger->IsPlayer() && TO_PLAYER(pPassenger)->m_MountSpellId != m_mountSpell )		pPassenger->RemoveAura(TO_PLAYER(pPassenger)->m_MountSpellId);	if( m_mountSpell )		pPassenger->RemoveAura( m_mountSpell );	if( m_CastSpellOnMount )		pPassenger->RemoveAura( m_CastSpellOnMount );	WorldPacket data(SMSG_MONSTER_MOVE, 85);	data << pPassenger->GetNewGUID();			// PlayerGUID	data << uint8(0x40);						// Unk - blizz uses 0x40	data << pPassenger->GetPosition();			// Player Position xyz	data << getMSTime();						// Timestamp	data << uint8(0x4);							// Flags	data << pPassenger->GetOrientation();		// Orientation	data << uint32(MOVEFLAG_AIR_SUSPENSION);	// MovementFlags	data << uint32(0);							// MovementTime	data << uint32(1);							// Pointcount	data << GetPosition();						// Vehicle Position xyz	SendMessageToSet(&data, false);	pPassenger->movement_info.flags &= ~MOVEFLAG_TAXI;	pPassenger->movement_info.transX = 0;	pPassenger->movement_info.transY = 0;	pPassenger->movement_info.transZ = 0;	pPassenger->movement_info.transO = 0;	pPassenger->movement_info.transTime = 0;	pPassenger->movement_info.transSeat = 0;	pPassenger->movement_info.transGuid = WoWGuid(uint64(NULL));	if(pPassenger->IsPlayer())	{		Player* plr = TO_PLAYER(pPassenger);		if(plr == GetControllingUnit())		{			plr->m_CurrentCharm = NULL;			data.Initialize(SMSG_CLIENT_CONTROL_UPDATE);			data << GetNewGUID() << (uint8)0;			plr->GetSession()->SendPacket(&data);		}		RemoveFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_PLAYER_CONTROLLED_CREATURE | UNIT_FLAG_PLAYER_CONTROLLED));		plr->SetPlayerStatus(TRANSFER_PENDING); // We get an ack later, if we don't set this now, we get disconnected.		sEventMgr.AddEvent(plr, &Player::CheckPlayerStatus, (uint8)TRANSFER_PENDING, EVENT_PLAYER_CHECK_STATUS_Transfer, 5000, 0, 0);		plr->m_sentTeleportPosition.ChangeCoords(GetPositionX(), GetPositionY(), GetPositionZ());		plr->SetPosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());		data.Initialize(MSG_MOVE_TELEPORT_ACK);		data << plr->GetNewGUID();		data << plr->m_teleportAckCounter;		plr->m_teleportAckCounter++;		data << uint32(MOVEFLAG_FLYING);		data << uint16(0x40);		data << getMSTime();		data << GetPositionX();		data << GetPositionY();		data << GetPositionZ();		data << GetOrientation();		data << uint32(0);		plr->GetSession()->SendPacket(&data);		plr->SetUInt64Value( PLAYER_FARSIGHT, 0 );		data.Initialize(SMSG_PET_DISMISS_SOUND);		data << uint32(m_vehicleSeats[slot]->m_exitUISoundID);		data << plr->GetPosition();		plr->GetSession()->SendPacket(&data);		data.Initialize(SMSG_PET_SPELLS);		data << uint64(0);		data << uint32(0);		plr->GetSession()->SendPacket(&data);		CreatureProtoVehicle* vehicleproto = CreatureProtoVehicleStorage.LookupEntry(GetEntry());		if(vehicleproto && vehicleproto->healthfromdriver)		{			if(slot == 0)			{				uint32 health = GetUInt32Value(UNIT_FIELD_HEALTH);				uint32 maxhealth = GetUInt32Value(UNIT_FIELD_MAXHEALTH);				uint32 protomaxhealth = GetProto()->MaxHealth;				uint32 healthdiff = maxhealth - health;				uint32 plritemlevel = plr->GetTotalItemLevel();				uint32 convrate = vehicleproto->healthunitfromitemlev;				if(plritemlevel != 0 && convrate != 0)				{					uint32 healthloss = healthdiff+plritemlevel*convrate;					SetUInt32Value(UNIT_FIELD_HEALTH, GetProto()->MaxHealth - healthloss);//.........这里部分代码省略.........
开发者ID:SkyFire,项目名称:sandshroud,代码行数:101,


示例13: GetUInt32Value

bool Item::IsRefundOrSoulboundTradeExpired(Player* owner) const{    return GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + (2 * HOUR) < owner->GetTotalPlayedTime();}
开发者ID:120239197a,项目名称:SingleCore,代码行数:4,


示例14: EndFishing

void GameObject::UseFishingNode(Player *player){	sEventMgr.RemoveEvents( this );	if( GetUInt32Value( GAMEOBJECT_FLAGS ) != 32 ) // Clicking on the bobber before something is hooked	{		player->GetSession()->OutPacket( SMSG_FISH_NOT_HOOKED );		EndFishing( player, true );		return;	}		/* Unused code: sAreaStore.LookupEntry(GetMapMgr()->GetAreaID(GetPositionX(),GetPositionY()))->ZoneId*/	uint32 zone = player->GetAreaID();	if( zone == 0 ) // If the player's area ID is 0, use the zone ID instead		zone = player->GetZoneId();	FishingZoneEntry *entry = FishingZoneStorage.LookupEntry( zone );	if( entry == NULL ) // No fishing information found for area or zone, log an error, and end fishing	{		sLog.outError( "ERROR: Fishing zone information for zone %d not found!", zone );		EndFishing( player, true );		return;	}	uint32 maxskill = entry->MaxSkill;	uint32 minskill = entry->MinSkill;	if( player->_GetSkillLineCurrent( SKILL_FISHING, false ) < maxskill )			player->_AdvanceSkillLine( SKILL_FISHING, float2int32( 1.0f * sWorld.getRate( RATE_SKILLRATE ) ) );	GameObject * school = NULL;	this->AquireInrangeLock(); //make sure to release lock before exit function !	for ( InRangeSet::iterator it = GetInRangeSetBegin(); it != GetInRangeSetEnd(); ++it )	{		if ( (*it) == NULL || (*it)->GetTypeId() != TYPEID_GAMEOBJECT || (*it)->GetUInt32Value(GAMEOBJECT_TYPE_ID) != GAMEOBJECT_TYPE_FISHINGHOLE)			continue;		school = static_cast<GameObject *>( *it );		if ( !isInRange( school, (float)school->GetInfo()->sound1 ) )		{			school = NULL;			continue;		}		else			break;	}	this->ReleaseInrangeLock();	if ( school != NULL ) // open school loot if school exists	{		lootmgr.FillGOLoot( &school->loot, school->GetEntry(), school->GetMapMgr() ? ( school->GetMapMgr()->iInstanceMode ? true : false ) : false );		player->SendLoot( school->GetGUID(), LOOT_FISHING );		EndFishing( player, false );		school->CatchFish();		if ( !school->CanFish() )			sEventMgr.AddEvent( school, &GameObject::Despawn, ( 1800000 + RandomUInt( 3600000 ) ), EVENT_GAMEOBJECT_EXPIRE, 10000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT ); // respawn in 30 - 90 minutes	}	else if( Rand( ( ( player->_GetSkillLineCurrent( SKILL_FISHING, true ) - minskill ) * 100 ) / maxskill ) ) // Open loot on success, otherwise FISH_ESCAPED.	{		lootmgr.FillFishingLoot( &loot, zone );		player->SendLoot( GetGUID(), LOOT_FISHING );		EndFishing( player, false );	}	else // Failed	{		player->GetSession()->OutPacket( SMSG_FISH_ESCAPED );		EndFishing( player, true );	}}
开发者ID:Chero,项目名称:abcwow,代码行数:67,


示例15: VALUES

void Item::SaveToDB( int16 containerslot, int16 slot, bool firstsave, QueryBuffer* buf ){    if( !m_isDirty && !firstsave )        return;    std::stringstream ss;    ss << "REPLACE INTO playeritems VALUES(";    ss << m_uint32Values[ITEM_FIELD_OWNER] << ",";    ss << m_uint32Values[OBJECT_FIELD_GUID] << ",";    ss << m_uint32Values[OBJECT_FIELD_ENTRY] << ",";    ss << wrapped_item_id << ",";    ss << m_uint32Values[ITEM_FIELD_GIFTCREATOR] << ",";    ss << m_uint32Values[ITEM_FIELD_CREATOR] << ",";    ss << GetUInt32Value(ITEM_FIELD_STACK_COUNT) << ",";    ss << (int32)GetChargesLeft() << ",";    ss << GetUInt32Value(ITEM_FIELD_FLAGS) << ",";    ss << random_prop << "," << random_suffix << ",";    ss << GetTextID() << ",";    ss << GetUInt32Value(ITEM_FIELD_DURABILITY) << ",";    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 && remaining_duration > 5 ) || ( itr->second.Duration == 0 ) )            {                ss << itr->second.Enchantment->Id << ",";                ss << remaining_duration << ",";                ss << itr->second.Slot << ",";                ss << uint32(itr->second.Dummy ? 1 : 0) << ";";            }        }    }    ss << "','";    if(Gems[0] || Gems[1] || Gems[2])    {   // We get socket.        for(uint32 g = 0; g < 3; g++)        {            // Socket screen turn on.            if(Gems[g])            {                ss << g; // All your gem are belong to us.                ss << ":" << Gems[g] << ";";            }        }    }    ss << "')";    if( firstsave )        CharacterDatabase.WaitExecute( ss.str().c_str() );    else    {        if( buf == NULL )            CharacterDatabase.Execute( ss.str().c_str() );        else            buf->AddQueryStr( ss.str() );    }    m_isDirty = false;}
开发者ID:WowDevs,项目名称:Sandshroud,代码行数:76,


示例16: SetIsPet

void Pet::CreateAsSummon(uint32 entry, CreatureInfo *ci, Creature* created_from_creature, Unit *owner, SpellEntry* created_by_spell, uint32 type, uint32 expiretime){    SetIsPet(true);    std::string myname = sWorld.GenerateName();    if(!ci) return;    m_Owner = static_cast<Player*>(owner);    m_OwnerGuid = m_Owner->GetGUID();    // Create ourself        Create(myname.c_str(), owner->GetMapId(), owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation());    creature_info = ci;    SetUInt32Value(OBJECT_FIELD_ENTRY, entry);    SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);   // better set this one    // Fields common to both lock summons and pets    if(type & 0x2 && created_from_creature != NULL)        SetUInt32Value(UNIT_FIELD_LEVEL, created_from_creature->getLevel());    else        SetUInt32Value(UNIT_FIELD_LEVEL,owner->GetUInt32Value(UNIT_FIELD_LEVEL));    SetUInt32Value(UNIT_FIELD_DISPLAYID,  ci->DisplayID);    SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, ci->DisplayID);    SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner->GetGUID());    SetUInt64Value(UNIT_FIELD_CREATEDBY, owner->GetGUID());        if(type & 0x1 && created_by_spell != NULL)        SetUInt64Value(UNIT_CREATED_BY_SPELL, created_by_spell->Id);    BaseStats[0] = uint32(20+getLevel()*1.55);    BaseStats[1] = uint32(20+getLevel()*0.64);    BaseStats[2] = uint32(20+getLevel()*1.27);    BaseStats[3] = uint32(20+getLevel()*0.18);    BaseStats[4] = uint32(20+getLevel()*0.36);    if(type & 0x1 || created_from_creature == NULL)    {        Summon = true;        float scale = 1.0f;        switch(GetEntry())        {        case 416: //Imp            {                scale = 0.4f;            }break;        case 417: //Felhunter            {                scale = 0.7f;            }break;        case 1860: //VoidWalker            {                scale = 0.75f;            }break;        case 1863: //Succubus            {                scale = 1.0f;            }break;        }        SetFloatValue(OBJECT_FIELD_SCALE_X, scale);        uint32 hp=uint32(28 + 10 * getLevel());        SetUInt32Value(UNIT_FIELD_MAXHEALTH, hp);        SetUInt32Value(UNIT_FIELD_BASE_HEALTH,hp);        uint32 mp=uint32(28 + 10 * getLevel());        SetUInt32Value(UNIT_FIELD_MAXPOWER1,mp );        SetUInt32Value(UNIT_FIELD_BASE_MANA,mp);                SetFloatValue(OBJECT_FIELD_SCALE_X, scale);        SetUInt32Value(UNIT_FIELD_BYTES_0, 2048 | (0 << 24));        SetUInt32Value(UNIT_FIELD_FLAGS, 8);        SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 2000);        SetUInt32Value(UNIT_FIELD_BASEATTACKTIME_01, 2000);        SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 0.5f);        SetFloatValue(UNIT_FIELD_COMBATREACH, 0.75f);        SetFloatValue(UNIT_FIELD_MINDAMAGE,float(getLevel() * 1.88));        SetFloatValue(UNIT_FIELD_MAXDAMAGE,float(getLevel() * 3));        SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, float(GetFloatValue(UNIT_FIELD_MINDAMAGE)*0.5));        SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, float(GetFloatValue(UNIT_FIELD_MAXDAMAGE)*0.5));        SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,float((getLevel() * 1.88)/2));        SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,float((getLevel() * 3)/2));                SetUInt32Value(UNIT_FIELD_ATTACK_POWER, uint32(getLevel() * 1.7));        SetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, uint32(getLevel() * 2.4));                for(int x=0;x<5;x++)            SetUInt32Value(UNIT_FIELD_STAT0 + x, BaseStats[x]);        SetUInt32Value(UNIT_FIELD_RESISTANCES, 180);        SetUInt32Value(UNIT_FIELD_BYTES_2, 0x01);        SetUInt32Value(UNIT_FIELD_MAXPOWER1, uint32(28 + 10 * getLevel()));        SetUInt32Value(UNIT_FIELD_PETNUMBER, GetGUIDLow());    } else {        uint32 hp=created_from_creature->GetUInt32Value(UNIT_FIELD_MAXHEALTH);        SetUInt32Value(UNIT_FIELD_MAXHEALTH, hp);        SetUInt32Value(UNIT_FIELD_BASE_HEALTH,hp);//.........这里部分代码省略.........
开发者ID:AwkwardDev,项目名称:WoWD,代码行数:101,


示例17: VALUES

void Item::SaveToDB( int8 containerslot, int8 slot, bool firstsave, QueryBuffer* buf ){	if( !m_isDirty && !firstsave )		return;	std::stringstream ss;	ss << "REPLACE INTO playeritems VALUES(";	ss << m_uint32Values[ITEM_FIELD_OWNER] << ",";    ss << m_uint32Values[OBJECT_FIELD_GUID] << ",";	ss << m_uint32Values[OBJECT_FIELD_ENTRY] << ",";	ss << wrapped_item_id << ",";	ss << m_uint32Values[ITEM_FIELD_GIFTCREATOR] << ",";	ss << m_uint32Values[ITEM_FIELD_CREATOR] << ",";	ss << GetUInt32Value(ITEM_FIELD_STACK_COUNT) << ",";	ss << GetChargesLeft() << ",";	ss << GetUInt32Value(ITEM_FIELD_FLAGS) << ",";	ss << random_prop << ", " << random_suffix << ", ";	ss << GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) << ",";	ss << GetUInt32Value(ITEM_FIELD_DURABILITY) << ",";	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.RemoveAtLogout && (remaining_duration > 5 && itr->second.Slot != 2) || itr->second.Slot == 2)  // no point saving stuff with < 5 seconds... unless is perm enchant			{				ss << itr->second.Enchantment->Id << ",";				ss << remaining_duration << ",";				ss << itr->second.Slot << ";";			}			*/		  			if( itr->second.Enchantment && ( remaining_duration && remaining_duration > 5 ) || ( itr->second.Duration == 0 ) )			{				ss << itr->second.Enchantment->Id << ",";				ss << remaining_duration << ",";				ss << itr->second.Slot << ";";			}		}	}	ss << "')";		if( firstsave )		CharacterDatabase.WaitExecute( ss.str().c_str() );	else	{		if( buf == NULL )			CharacterDatabase.Execute( ss.str().c_str() );		else			buf->AddQueryStr( ss.str() );	}	m_isDirty = false;}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:70,


示例18: event_Relocate

void GameObject::Update(uint32 p_time){	if(m_event_Instanceid != m_instanceId)	{		event_Relocate();		return;	}	if(!IsInWorld())		return;	if(m_deleted)		return;	if(spell && (GetUInt32Value(GAMEOBJECT_STATE) == 1))	{		if(checkrate > 1)		{			if(counter++%checkrate)				return;		}		ObjectSet::iterator itr = GetInRangeSetBegin();		ObjectSet::iterator it2 = itr;		ObjectSet::iterator iend = GetInRangeSetEnd();		Unit * pUnit;		float dist;		for(; it2 != iend;)		{			itr = it2;			++it2;			dist = GetDistanceSq((*itr));			if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range)			{				pUnit = static_cast<Unit*>(*itr);				if(m_summonedGo)				{					if(!m_summoner)					{						ExpireAndDelete();						return;					}					if(!isAttackable(m_summoner,pUnit))continue;				}								Spell * sp=new Spell((Object*)this,spell,true,NULL);				SpellCastTargets tgt((*itr)->GetGUID());				tgt.m_destX = GetPositionX();				tgt.m_destY = GetPositionY();				tgt.m_destZ = GetPositionZ();				sp->prepare(&tgt);				if(m_summonedGo)				{					ExpireAndDelete();					return;				}				if(spell->EffectImplicitTargetA[0] == 16 ||					spell->EffectImplicitTargetB[0] == 16)					return;	 // on area dont continue.			}		}	}}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:64,


示例19: GetGUIDLow

void Item::SaveToDB(SQLTransaction& trans){    bool isInTransaction = !(trans.null());    if (!isInTransaction)        trans = CharacterDatabase.BeginTransaction();    uint32 guid = GetGUIDLow();    switch (uState)    {        case ITEM_NEW:        case ITEM_CHANGED:        {            uint8 index = 0;            PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);            stmt->setUInt32(  index, GetEntry());            stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));            stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));            stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));            stmt->setUInt32(++index, GetCount());            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));            std::ostringstream ssSpells;            for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)                ssSpells << GetSpellCharges(i) << ' ';            stmt->setString(++index, ssSpells.str());            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));            std::ostringstream ssEnchants;            for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)            {                ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';                ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';                ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';            }            stmt->setString(++index, ssEnchants.str());            stmt->setInt16 (++index, GetItemRandomPropertyId());            stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));            stmt->setString(++index, m_text);            stmt->setUInt32(++index, guid);            trans->Append(stmt);            if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))                trans->PAppend("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GUID_LOPART(GetOwnerGUID()), guid);            break;        }        case ITEM_REMOVED:        {            trans->PAppend("DELETE FROM item_instance WHERE guid = '%u'", guid);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))                trans->PAppend("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());            if (!isInTransaction)                CharacterDatabase.CommitTransaction(trans);            CharacterDatabase.PExecute("UPDATE character_donate SET state = 1 WHERE itemguid = '%u'", guid);            delete this;            return;        }        case ITEM_UNCHANGED:            break;    }    SetState(ITEM_UNCHANGED);    if (!isInTransaction)        CharacterDatabase.CommitTransaction(trans);}
开发者ID:Lbniese,项目名称:WoWCircle434,代码行数:72,


示例20:

ItemPrototype const *Item::GetProto() const{    return objmgr.GetItemPrototype(GetUInt32Value(OBJECT_FIELD_ENTRY));}
开发者ID:AwkwardDev,项目名称:mangos-svn,代码行数:4,


示例21: VALUES

void Item::SaveToDB( int8 containerslot, int8 slot, bool firstsave, QueryBuffer* buf ){	if( !m_isDirty && !firstsave )		return;	std::stringstream ss;	ss << "REPLACE INTO playeritems VALUES(";	ss << m_uint32Values[ITEM_FIELD_OWNER] << ",";	ss << m_uint32Values[OBJECT_FIELD_GUID] << ",";	ss << m_uint32Values[OBJECT_FIELD_ENTRY] << ",";	ss << wrapped_item_id << ",";	ss << m_uint32Values[ITEM_FIELD_GIFTCREATOR] << ",";	ss << m_uint32Values[ITEM_FIELD_CREATOR] << ",";	ss << GetUInt32Value(ITEM_FIELD_STACK_COUNT) << ",";	ss << GetChargesLeft() << ",";	ss << GetUInt32Value(ITEM_FIELD_FLAGS) << ",";	ss << random_prop << ", " << random_suffix << ", ";	ss << GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) << ",";	ss << GetUInt32Value(ITEM_FIELD_DURABILITY) << ",";	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.RemoveAtLogout && (remaining_duration > 5 && itr->second.Slot != 2) || itr->second.Slot == 2)  // no point saving stuff with < 5 seconds... unless is perm enchant			{				ss << itr->second.Enchantment->Id << ",";				ss << remaining_duration << ",";				ss << itr->second.Slot << ";";			}			*/			if( itr->second.Enchantment && ( remaining_duration && 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 << "')";	if( firstsave )		CharacterDatabase.WaitExecute( ss.str().c_str() );	else	{		if( buf == NULL )			CharacterDatabase.Execute( ss.str().c_str() );		else			buf->AddQueryStr( ss.str() );	}	m_isDirty = false;}
开发者ID:xiaofeng,项目名称:Arcemu,代码行数:93,


示例22: ObjectGuid

bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid){    // create item before any checks for store correct guid    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB    Object::_Create(guidLow, 0, HIGHGUID_ITEM);    if (!LoadValues(fields[0].GetString()))    {        sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.", guidLow);        return false;    }    bool need_save = false;                                 // need explicit save data at load fixes    // overwrite possible wrong/corrupted guid    ObjectGuid new_item_guid = ObjectGuid(HIGHGUID_ITEM, guidLow);    if (GetGuidValue(OBJECT_FIELD_GUID) != new_item_guid)    {        SetGuidValue(OBJECT_FIELD_GUID, new_item_guid);        need_save = true;    }    ItemPrototype const* proto = GetProto();    if (!proto)        return false;    // update max durability (and durability) if need    if (proto->MaxDurability != GetUInt32Value(ITEM_FIELD_MAXDURABILITY))    {        SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);        if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)            SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);        need_save = true;    }    // Remove bind flag for items vs NO_BIND set    if (IsSoulBound() && proto->Bonding == NO_BIND)    {        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, false);        need_save = true;    }    // update duration if need, and remove if not need    if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))    {        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);        need_save = true;    }    // set correct owner    if (ownerGuid && GetOwnerGuid() != ownerGuid)    {        SetOwnerGuid(ownerGuid);        need_save = true;    }    // set correct wrapped state    if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))    {        // wrapped item must be wrapper (used version that not stackable)        if (!(proto->Flags & ITEM_FLAG_IS_WRAPPER) || GetMaxStackCount() > 1)        {            RemoveFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED);            need_save = true;            static SqlStatementID delGifts ;            // also cleanup for sure gift table            SqlStatement stmt = CharacterDatabase.CreateStatement(delGifts, "DELETE FROM character_gifts WHERE item_guid = ?");            stmt.PExecute(GetGUIDLow());        }    }    if (need_save)                                          // normal item changed state set not work at loading    {        static SqlStatementID updItem ;        SqlStatement stmt = CharacterDatabase.CreateStatement(updItem, "UPDATE item_instance SET data = ?, owner_guid = ? WHERE guid = ?");        std::ostringstream ss;        for (uint16 i = 0; i < m_valuesCount; ++i)            ss << GetUInt32Value(i) << " ";        stmt.addString(ss);        stmt.addUInt32(GetOwnerGuid().GetCounter());        stmt.addUInt32(guidLow);        stmt.Execute();    }    return true;}
开发者ID:Ghaster,项目名称:mangos-classic,代码行数:92,


示例23: switch

void GameObject::Update(uint32 /*p_time*/){    if (IS_MO_TRANSPORT(GetGUID()))    {        //((Transport*)this)->Update(p_time);        return;    }    switch (m_lootState)    {        case GO_NOT_READY:            if (GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE)            {                // fishing code (bobber ready)                if( time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME )                {                    // splash bobber (bobber ready now)                    Unit* caster = GetOwner();                    if(caster && caster->GetTypeId()==TYPEID_PLAYER)                    {                        SetUInt32Value(GAMEOBJECT_STATE, 0);                        SetUInt32Value(GAMEOBJECT_FLAGS, 32);                        UpdateData udata;                        WorldPacket packet;                        BuildValuesUpdateBlockForPlayer(&udata,((Player*)caster));                        udata.BuildPacket(&packet);                        ((Player*)caster)->GetSession()->SendPacket(&packet);                        WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,8+4);                        data << GetGUID();                        data << (uint32)(0);                        ((Player*)caster)->SendMessageToSet(&data,true);                    }                    m_lootState = GO_READY;                 // can be succesfully open with some chance                }                return;            }            m_lootState = GO_READY;                         // for other GOis same switched without delay to GO_READY            // NO BREAK        case GO_READY:        {            if (m_respawnTime > 0)                          // timer on            {                if (m_respawnTime <= time(NULL))            // timer expired                {                    m_respawnTime = 0;                    m_SkillupList.clear();                    m_usetimes = 0;                    switch (GetGoType())                    {                        case GAMEOBJECT_TYPE_FISHINGNODE:   //  can't fish now                        {                            Unit* caster = GetOwner();                            if(caster && caster->GetTypeId()==TYPEID_PLAYER)                            {                                if(caster->m_currentSpells[CURRENT_CHANNELED_SPELL])                                {                                    caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0);                                    caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(false);                                }                                WorldPacket data(SMSG_FISH_NOT_HOOKED,0);                                ((Player*)caster)->GetSession()->SendPacket(&data);                            }                            // can be delete                            m_lootState = GO_JUST_DEACTIVATED;                            return;                        }                        case GAMEOBJECT_TYPE_DOOR:                        case GAMEOBJECT_TYPE_BUTTON:                            //we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)                            if( !GetUInt32Value(GAMEOBJECT_STATE) )                                SwitchDoorOrButton(false);                            //flags in AB are type_button and we need to add them here so no break!                        default:                            if(!m_spawnedByDefault)         // despawn timer                            {                                                            // can be despawned or destroyed                                SetLootState(GO_JUST_DEACTIVATED);                                return;                            }                                                            // respawn timer                            MapManager::Instance().GetMap(GetMapId(), this)->Add(this);                            break;                    }                }            }            // traps can have time and can not have            GameObjectInfo const* goInfo = GetGOInfo();            if(goInfo->type == GAMEOBJECT_TYPE_TRAP)            {                // traps                Unit* owner = GetOwner();                Unit* ok = NULL;                            // pointer to appropriate target if found any//.........这里部分代码省略.........
开发者ID:Artea,项目名称:mangos-svn,代码行数:101,


示例24: SetEntry

bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry){    //                                                    0                1      2         3        4      5             6                 7           8           9    10    //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);    // create item before any checks for store correct guid    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB    Object::_Create(guid, 0, HIGHGUID_ITEM);    // Set entry, MUST be before proto check    SetEntry(entry);    SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);    ItemPrototype const* proto = GetProto();    if (!proto)        return false;    // set owner (not if item is only loaded for gbank/auction/mail    if (owner_guid != 0)        SetOwnerGUID(owner_guid);    bool need_save = false;                                 // need explicit save data at load fixes    SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));    SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));    SetCount(fields[2].GetUInt32());    uint32 duration = fields[3].GetUInt32();    SetUInt32Value(ITEM_FIELD_DURATION, duration);    // update duration if need, and remove if not need    if ((proto->Duration == 0) != (duration == 0))    {        SetUInt32Value(ITEM_FIELD_DURATION, abs(proto->Duration));        need_save = true;    }    Tokens tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);    if (tokens.size() == MAX_ITEM_PROTO_SPELLS)        for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)            SetSpellCharges(i, atoi(tokens[i]));    SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].GetUInt32());    // Remove bind flag for items vs NO_BIND set    if (IsSoulBound() && proto->Bonding == NO_BIND)    {        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, false);        need_save = true;    }    std::string enchants = fields[6].GetString();    //_LoadIntoDataField(enchants.c_str(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);    {        // NOTE:        // in the recent update of reforge system, definition of EnchantmentSlot has been changed,        // and MAX_ENCHANTMENT_SLOT has been changed from 13 to 14,        // which makes enchantments column of item_instance table incompatible with previous version.        // in this case we will load only first 9 enchantment slots (0-8, for permanent, temporary, sockets, bonus, prismatic and reforge)        // and ignore the remaining ones (9-13, for random properties).        // which means item random properties will be lost after this update.        // after player logging in and saving the inventory, enchantments column will be properly updated.        uint32 count = MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET;        Tokens tokens(enchants, ' ', count);        if (tokens.size() < MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET)            count = REFORGE_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET;        for (uint32 index = 0; index < count; ++index)            m_uint32Values[ITEM_FIELD_ENCHANTMENT_1_1 + index] = index < tokens.size() ? atol(tokens[index]) : 0;    }    SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());    // recalculate suffix factor    if (GetItemRandomPropertyId() < 0)        UpdateItemSuffixFactor();    uint32 durability = fields[8].GetUInt16();    SetUInt32Value(ITEM_FIELD_DURABILITY, durability);    // update max durability (and durability) if need    SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);    if (durability > proto->MaxDurability)    {        SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);        need_save = true;    }    SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());    SetText(fields[10].GetString());    if (need_save)                                           // normal item changed state set not work at loading    {        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_ITEM_INSTANCE_ON_LOAD);        stmt->setUInt32(0, GetUInt32Value(ITEM_FIELD_DURATION));        stmt->setUInt32(1, GetUInt32Value(ITEM_FIELD_FLAGS));        stmt->setUInt32(2, GetUInt32Value(ITEM_FIELD_DURABILITY));        stmt->setUInt32(3, guid);        CharacterDatabase.Execute(stmt);    }    return true;}
开发者ID:H4D3S,项目名称:DarkmoonCore-Cataclysm,代码行数:99,


示例25:

GameObjectInfo const *GameObject::GetGOInfo() const{    return objmgr.GetGameObjectInfo(GetUInt32Value (OBJECT_FIELD_ENTRY));}
开发者ID:Artea,项目名称:mangos-svn,代码行数:4,


示例26: bool

void Item::SaveToDB(SQLTransaction& trans){    bool isInTransaction = bool(trans);    if (!isInTransaction)        trans = CharacterDatabase.BeginTransaction();    ObjectGuid::LowType guid = GetGUID().GetCounter();    switch (uState)    {        case ITEM_NEW:        case ITEM_CHANGED:        {            uint8 index = 0;            PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);            stmt->setUInt32(  index, GetEntry());            stmt->setUInt32(++index, GetOwnerGUID().GetCounter());            stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());            stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());            stmt->setUInt32(++index, GetCount());            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));            std::ostringstream ssSpells;            for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)                ssSpells << GetSpellCharges(i) << ' ';            stmt->setString(++index, ssSpells.str());            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));            std::ostringstream ssEnchants;            for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)            {                ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';                ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';                ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';            }            stmt->setString(++index, ssEnchants.str());            stmt->setInt16 (++index, GetItemRandomPropertyId());            stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));            stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));            stmt->setString(++index, m_text);            stmt->setUInt32(++index, guid);            trans->Append(stmt);            if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))            {                stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);                stmt->setUInt32(0, GetOwnerGUID().GetCounter());                stmt->setUInt32(1, guid);                trans->Append(stmt);            }            break;        }        case ITEM_REMOVED:        {            PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);            stmt->setUInt32(0, guid);            trans->Append(stmt);            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))            {                stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);                stmt->setUInt32(0, guid);                trans->Append(stmt);            }            if (!isInTransaction)                CharacterDatabase.CommitTransaction(trans);            // Delete the items if this is a container            if (!loot.isLooted())                ItemContainerDeleteLootMoneyAndLootItemsFromDB();            delete this;            return;        }        case ITEM_UNCHANGED:            break;    }    SetState(ITEM_UNCHANGED);    if (!isInTransaction)        CharacterDatabase.CommitTransaction(trans);}
开发者ID:StormDev2ofiical,项目名称:CoreStorm,代码行数:86,


示例27: SetUInt32Value

//.........这里部分代码省略.........	{		m_factionDBC = dbcFaction.LookupEntry(m_faction->Faction);		// not a neutral creature		if(!(m_factionDBC->RepListId == -1 && m_faction->HostileMask == 0 && m_faction->FriendlyMask == 0))		{			GetAIInterface()->m_canCallForHelp = true;		}	}//SETUP NPC FLAGS	SetUInt32Value(UNIT_NPC_FLAGS,proto->NPCFLags);	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ) )		m_SellItems = objmgr.GetVendorList(GetEntry());	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ) )		_LoadQuests();	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TAXIVENDOR) )		m_TaxiNode = sTaxiMgr.GetNearestTaxiNode( m_position.x, m_position.y, m_position.z, GetMapId() );	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) || HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_TRAINER_PROF))		mTrainer = objmgr.GetTrainer(GetEntry());	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER ) )		auctionHouse = sAuctionMgr.GetAuctionHouse(GetEntry());//NPC FLAGS	 m_aiInterface->m_waypoints=objmgr.GetWayPointMap(spawn->id);	//load resistances	for(uint32 x=0;x<7;x++)		BaseResistance[x]=GetUInt32Value(UNIT_FIELD_RESISTANCES+x);	for(uint32 x=0;x<5;x++)		BaseStats[x]=GetUInt32Value(UNIT_FIELD_STAT0+x);	BaseDamage[0]=GetFloatValue(UNIT_FIELD_MINDAMAGE);	BaseDamage[1]=GetFloatValue(UNIT_FIELD_MAXDAMAGE);	BaseOffhandDamage[0]=GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE);	BaseOffhandDamage[1]=GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE);	BaseRangedDamage[0]=GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE);	BaseRangedDamage[1]=GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE);	BaseAttackType=proto->AttackType;	SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);   // better set this one	SetUInt32Value(UNIT_FIELD_BYTES_0, spawn->bytes);	SetUInt32Value(UNIT_FIELD_BYTES_2, spawn->bytes2);////////////AI		// kek	for(list<AI_Spell*>::iterator itr = proto->spells.begin(); itr != proto->spells.end(); ++itr)	{		m_aiInterface->addSpellToList(*itr);	}	//m_aiInterface->m_canCallForHelp = proto->m_canCallForHelp;	//m_aiInterface->m_CallForHelpHealth = proto->m_callForHelpHealth;	m_aiInterface->m_canFlee = proto->m_canFlee;	m_aiInterface->m_FleeHealth = proto->m_fleeHealth;	m_aiInterface->m_FleeDuration = proto->m_fleeDuration;	//these fields are always 0 in db	GetAIInterface()->setMoveType(0);	GetAIInterface()->setMoveRunFlag(0);	
开发者ID:AwkwardDev,项目名称:ascent_classic,代码行数:66,


示例28: time

uint32 Item::GetPlayedTime(){    time_t curtime = time(NULL);    uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);    return GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + elapsed;}
开发者ID:winetaster,项目名称:InfinityCore,代码行数:6,


示例29: OCTRegenMPPerSpirit

void Player::UpdateManaRegen(){    // Mana regen from spirit    float spirit_regen = OCTRegenMPPerSpirit();    spirit_regen *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_POWER_REGEN_PERCENT, POWER_MANA);    float HastePct = 1.0f + GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_HASTE_MELEE) * GetRatingMultiplier(CR_HASTE_MELEE) / 100.0f;    float combat_regen = 0.004f * GetMaxPower(POWER_MANA) + spirit_regen + (GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) / 5.0f);    float base_regen = 0.004f * GetMaxPower(POWER_MANA) + (GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) / 5.0f);    if (getClass() == CLASS_WARLOCK)    {        combat_regen = 0.01f * GetMaxPower(POWER_MANA) + spirit_regen + GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA);        base_regen = 0.01f * GetMaxPower(POWER_MANA) + GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA);    }    // Mana Meditation && Meditation    if (HasAuraType(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT))        base_regen += 0.5 * spirit_regen; // Allows 50% of your mana regeneration from Spirit to continue while in combat.    // Rune of Power : Increase Mana regeneration by 100%    if (HasAura(116014))    {        combat_regen *= 2;        base_regen *= 2;    }    // Incanter's Ward : Increase Mana regen by 65%    if (HasAura(118858))    {        combat_regen *= 1.65f;        base_regen *= 1.65f;    }    // Chaotic Energy : Increase Mana regen by 625%    if (HasAura(111546))    {        // haste also increase your mana regeneration        HastePct = 1.0f + GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_HASTE_MELEE) * GetRatingMultiplier(CR_HASTE_MELEE) / 100.0f;        combat_regen = combat_regen + (combat_regen * 6.25f);        combat_regen *= HastePct;        base_regen = base_regen + (base_regen * 6.25f);        base_regen *= HastePct;    }    // Nether Attunement - 117957 : Haste also increase your mana regeneration    if (HasAura(117957))    {        HastePct = 1.0f + GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_HASTE_MELEE) * GetRatingMultiplier(CR_HASTE_MELEE) / 100.0f;        combat_regen *= HastePct;        base_regen *= HastePct;    }    // Mana Attunement : Increase Mana regen by 50%    if (HasAura(121039))    {        combat_regen = combat_regen + (combat_regen * 0.5f);        combat_regen *= HastePct;        base_regen = base_regen + (base_regen * 0.5f);        base_regen *= HastePct;    }    // Invocation : Decrease your mana regen by 50%    if (HasAura(114003))    {        combat_regen *= 0.5f;        base_regen *= 0.5f;    }        // Not In Combat : 2% of base mana + spirit_regen    SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, base_regen);    // In Combat : 2% of base mana    SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, combat_regen);}
开发者ID:AlucardVoss,项目名称:Patchs,代码行数:70,



注:本文中的GetUInt32Value函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GetURI函数代码示例
C++ GetUID函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。