本文整理汇总了C++中SetUInt32Value函数的典型用法代码示例。如果您正苦于以下问题:C++ SetUInt32Value函数的具体用法?C++ SetUInt32Value怎么用?C++ SetUInt32Value使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetUInt32Value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ARCEMU_ASSERT
void Item::LoadFromDB(Field* fields, Player* plr, bool light)
{
uint32 itemid = fields[2].GetUInt32();
uint32 random_prop, random_suffix;
uint32 count;
m_itemProto = ItemPrototypeStorage.LookupEntry(itemid);
ARCEMU_ASSERT(m_itemProto != NULL);
locked = m_itemProto->LockId ? true : false;
SetEntry(itemid);
m_owner = plr;
wrapped_item_id = fields[3].GetUInt32();
SetGiftCreatorGUID(fields[4].GetUInt32());
SetCreatorGUID(fields[5].GetUInt32());
count = fields[6].GetUInt32();
if (count > m_itemProto->MaxCount && (m_owner && !m_owner->ItemStackCheat))
count = m_itemProto->MaxCount;
SetStackCount(count);
SetChargesLeft(fields[7].GetUInt32());
SetUInt32Value(ITEM_FIELD_FLAGS, fields[8].GetUInt32());
random_prop = fields[9].GetUInt32();
random_suffix = fields[10].GetUInt32();
SetItemRandomPropertyId(random_prop);
int32 rprop = int32(random_prop);
// If random properties point is negative that means the item uses random suffix as random enchantment
if (rprop < 0)
SetItemRandomSuffixFactor(random_suffix);
else
SetItemRandomSuffixFactor(0);
//SetTextId( fields[11].GetUInt32() );
SetDurabilityMax(m_itemProto->MaxDurability);
SetDurability(fields[12].GetUInt32());
if (light)
return;
string enchant_field = fields[15].GetString();
vector< string > enchants = StrSplit(enchant_field, ";");
uint32 enchant_id;
EnchantEntry* entry;
uint32 time_left;
uint32 enchslot;
for (vector<string>::iterator itr = enchants.begin(); itr != enchants.end(); ++itr)
{
if (sscanf((*itr).c_str(), "%u,%u,%u", (unsigned int*)&enchant_id, (unsigned int*)&time_left, (unsigned int*)&enchslot) == 3)
{
entry = dbcEnchant.LookupEntryForced(enchant_id);
if (entry && entry->Id == enchant_id && m_itemProto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN)
{
AddEnchantment(entry, time_left, (time_left == 0), false, false, enchslot);
//(enchslot != 2) ? false : true, false);
}
else
{
/*
EnchantEntry *pEnchant = new EnchantEntry;
memset(pEnchant,0,sizeof(EnchantEntry));
pEnchant->Id = enchant_id;
if(enchslot != 2)
AddEnchantment(pEnchant,0,true, false);
else
AddEnchantment(pEnchant,0,false,false);
*/
}
}
}
ItemExpiresOn = fields[16].GetUInt32();
///////////////////////////////////////////////////// Refund stuff ////////////////////////
std::pair< time_t, uint32 > refundentry;
refundentry.first = fields[17].GetUInt32();
refundentry.second = fields[18].GetUInt32();
if (refundentry.first != 0 && refundentry.second != 0 && GetOwner() != NULL)
{
uint32* played = GetOwner()->GetPlayedtime();
if (played[1] < uint32(refundentry.first + 60 * 60 * 2))
m_owner->GetItemInterface()->AddRefundable(this, refundentry.second, refundentry.first);
}
///////////////////////////////////////////////////////////////////////////////////////////
text = fields[19].GetString();
ApplyRandomProperties(false);
//.........这里部分代码省略.........
示例2: ASSERT
void Item::LoadFromDB(Field* fields, Player* plr, bool light )
{
uint32 itemid = fields[2].GetUInt32();
uint32 random_prop, random_suffix;
uint32 count;
m_itemProto = ItemPrototypeStorage.LookupEntry( itemid );
ASSERT( m_itemProto );
if(m_itemProto->LockId > 1)
locked = true;
else
locked = false;
SetUInt32Value( OBJECT_FIELD_ENTRY, itemid );
m_owner = plr;
wrapped_item_id=fields[3].GetUInt32();
m_uint32Values[ITEM_FIELD_GIFTCREATOR] = fields[4].GetUInt32();
m_uint32Values[ITEM_FIELD_CREATOR] = fields[5].GetUInt32();
count = fields[6].GetUInt32();
if (count > m_itemProto->MaxCount)
count = m_itemProto->MaxCount;
SetUInt32Value( ITEM_FIELD_STACK_COUNT, count);
// Again another for that did not indent to make it do anything for more than
// one iteration x == 0 was the only one executed
for( uint32 x = 0; x < 5; x++ )
{
if( m_itemProto->Spells[x].Id )
{
SetUInt32Value( ITEM_FIELD_SPELL_CHARGES + x , fields[7].GetUInt32() );
break;
}
}
SetUInt32Value( ITEM_FIELD_FLAGS, fields[8].GetUInt32() );
random_prop = fields[9].GetUInt32();
random_suffix = fields[10].GetUInt32();
if( random_prop )
SetRandomProperty( random_prop );
else if( random_suffix )
SetRandomSuffix( random_suffix );
SetUInt32Value( ITEM_FIELD_ITEM_TEXT_ID, fields[11].GetUInt32() );
SetUInt32Value( ITEM_FIELD_MAXDURABILITY, m_itemProto->MaxDurability );
SetUInt32Value( ITEM_FIELD_DURABILITY, fields[12].GetUInt32() );
if( light )
return;
string enchant_field = fields[15].GetString();
vector< string > enchants = StrSplit( enchant_field, ";" );
uint32 enchant_id;
EnchantEntry* entry;
uint32 time_left;
uint32 enchslot;
for( vector<string>::iterator itr = enchants.begin(); itr != enchants.end(); ++itr )
{
if( sscanf( (*itr).c_str(), "%u,%u,%u", (unsigned int*)&enchant_id, (unsigned int*)&time_left, (unsigned int*)&enchslot) == 3 )
{
entry = dbcEnchant.LookupEntry( enchant_id );
if( entry && entry->Id == enchant_id && m_itemProto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN)
{
AddEnchantment( entry, time_left, ( time_left == 0 ), false, false, enchslot );
//(enchslot != 2) ? false : true, false);
}
else
{
/*
EnchantEntry *pEnchant = new EnchantEntry;
memset(pEnchant,0,sizeof(EnchantEntry));
pEnchant->Id = enchant_id;
if(enchslot != 2)
AddEnchantment(pEnchant,0,true, false);
else
AddEnchantment(pEnchant,0,false,false);
*/
}
}
}
ApplyRandomProperties( false );
// Charter stuff
if(m_uint32Values[OBJECT_FIELD_ENTRY] == ITEM_ENTRY_GUILD_CHARTER)
{
SetUInt32Value( ITEM_FIELD_FLAGS, 1 );
SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 );
SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 );
if( plr->m_charters[CHARTER_TYPE_GUILD] )
SetUInt32Value( ITEM_FIELD_ENCHANTMENT, plr->m_charters[CHARTER_TYPE_GUILD]->GetID() );
}
//.........这里部分代码省略.........
示例3: FindFreeEnchantSlot
int32 Item::AddEnchantment( EnchantEntry* Enchantment, uint32 Duration, bool Perm /* = false */, bool apply /* = true */, bool RemoveAtLogout /* = false */, uint32 Slot_, uint32 RandomSuffix )
{
int32 Slot = Slot_;
m_isDirty = true;
/*
if(Perm)
{
if(Slot_)
{
Slot=Slot_;
}
else
{
Slot = FindFreeEnchantSlot(Enchantment);
}
}
else
{
if(Enchantment->EnchantGroups > 1) // replaceable temp enchants
{
Slot = 1;
RemoveEnchantment(1);
}
else
{
Slot = FindFreeEnchantSlot(Enchantment);*/
/*
Slot = Enchantment->type ? 3 : 0;
//that's 's code
for(uint32 Index = ITEM_FIELD_ENCHANTMENT_09; Index < ITEM_FIELD_ENCHANTMENT_32; Index += 3)
{
if(m_uint32Values[Index] == 0) break;;
++Slot;
}
//Slot = FindFreeEnchantSlot(Enchantment);
// reach max of temp enchants
if(Slot >= 11) return -1;
*/
/*}
}
*/
// Create the enchantment struct.
EnchantmentInstance Instance;
Instance.ApplyTime = UNIXTIME;
Instance.BonusApplied = false;
Instance.Slot = Slot;
Instance.Enchantment = Enchantment;
Instance.Duration = Duration;
Instance.RemoveAtLogout = RemoveAtLogout;
Instance.RandomSuffix = RandomSuffix;
// Set the enchantment in the item fields.
uint32 EnchantBase = Slot * 3 + ITEM_FIELD_ENCHANTMENT;
SetUInt32Value( EnchantBase, Enchantment->Id );
SetUInt32Value( EnchantBase + 1, (uint32)Instance.ApplyTime );
SetUInt32Value( EnchantBase + 2, 0 ); // charges
// Add it to our map.
Enchantments.insert(make_pair((uint32)Slot, Instance));
if( m_owner == NULL )
return Slot;
// Add the removal event.
if( Duration )
{
sEventMgr.AddEvent( this, &Item::RemoveEnchantment, uint32(Slot), EVENT_REMOVE_ENCHANTMENT1 + Slot, Duration * 1000, 1, 0 );
}
// No need to send the log packet, if the owner isn't in world (we're still loading)
if( !m_owner->IsInWorld() )
return Slot;
if( apply )
{
WorldPacket EnchantLog( SMSG_ENCHANTMENTLOG, 25 );
EnchantLog << m_owner->GetGUID();
EnchantLog << m_owner->GetGUID();
EnchantLog << m_uint32Values[OBJECT_FIELD_ENTRY];
EnchantLog << Enchantment->Id;
EnchantLog << uint8(0);
m_owner->GetSession()->SendPacket( &EnchantLog );
if( m_owner->GetTradeTarget() )
{
m_owner->SendTradeUpdate();
}
/* Only apply the enchantment bonus if we're equipped */
uint8 slot = m_owner->GetItemInterface()->GetInventorySlotByGuid( GetGUID() );
if( slot >= EQUIPMENT_SLOT_START && slot < EQUIPMENT_SLOT_END )
ApplyEnchantmentBonus( Slot, APPLY );
}
return Slot;
}
示例4: time_t
bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
{
//// 0 1 2 3 4 5 6
//QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map,"
//// 7 8 9 10 11 12 13 14 15 16 17 18
// "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse"
uint32 playerLowGuid= fields[1].GetUInt32();
float positionX = fields[2].GetFloat();
float positionY = fields[3].GetFloat();
float positionZ = fields[4].GetFloat();
float orientation = fields[5].GetFloat();
uint32 mapid = fields[6].GetUInt32();
Object::_Create(ObjectGuid(HIGHGUID_CORPSE, lowguid));
m_time = time_t(fields[7].GetUInt64());
m_type = CorpseType(fields[8].GetUInt32());
if(m_type >= MAX_CORPSE_TYPE)
{
sLog.outError("%s Owner %s have wrong corpse type (%i), not load.", GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), m_type);
return false;
}
uint32 instanceid = fields[9].GetUInt32();
uint32 phaseMask = fields[10].GetUInt32();
uint8 gender = fields[11].GetUInt8();
uint8 race = fields[12].GetUInt8();
uint8 _class = fields[13].GetUInt8();
uint32 playerBytes = fields[14].GetUInt32();
uint32 playerBytes2 = fields[15].GetUInt32();
uint32 guildId = fields[17].GetUInt32();
uint32 playerFlags = fields[18].GetUInt32();
ObjectGuid guid = ObjectGuid(HIGHGUID_CORPSE, lowguid);
ObjectGuid playerGuid = ObjectGuid(HIGHGUID_PLAYER, playerLowGuid);
// overwrite possible wrong/corrupted guid
SetGuidValue(OBJECT_FIELD_GUID, guid);
SetGuidValue(CORPSE_FIELD_OWNER, playerGuid);
SetObjectScale(DEFAULT_OBJECT_SCALE);
PlayerInfo const *info = sObjectMgr.GetPlayerInfo(race, _class);
if(!info)
{
sLog.outError("Player %u has incorrect race/class pair.", GetGUIDLow());
return false;
}
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, gender == GENDER_FEMALE ? info->displayId_f : info->displayId_m);
// Load equipment
Tokens data = StrSplit(fields[16].GetCppString(), " ");
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++)
{
uint32 visualbase = slot * 2;
uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id);
if(!proto)
{
SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0);
continue;
}
SetUInt32Value(CORPSE_FIELD_ITEM + slot, proto->DisplayInfoID | (proto->InventoryType << 24));
}
uint8 skin = (uint8)(playerBytes);
uint8 face = (uint8)(playerBytes >> 8);
uint8 hairstyle = (uint8)(playerBytes >> 16);
uint8 haircolor = (uint8)(playerBytes >> 24);
uint8 facialhair = (uint8)(playerBytes2);
SetUInt32Value( CORPSE_FIELD_BYTES_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24)) );
SetUInt32Value( CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)) );
SetUInt32Value(CORPSE_FIELD_GUILD, guildId);
uint32 flags = CORPSE_FLAG_UNK2;
if(playerFlags & PLAYER_FLAGS_HIDE_HELM)
flags |= CORPSE_FLAG_HIDE_HELM;
if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
flags |= CORPSE_FLAG_HIDE_CLOAK;
SetUInt32Value( CORPSE_FIELD_FLAGS, flags );
// no need to mark corpse as lootable, because corpses are not saved in battle grounds
// place
SetLocationInstanceId(instanceid);
SetLocationMapId(mapid);
SetPhaseMask(phaseMask, false);
Relocate(positionX, positionY, positionZ, orientation);
if(!IsPositionValid())
{
sLog.outError("%s Owner %s not created. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), GetPositionX(), GetPositionY());
return false;
}
m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY());
//.........这里部分代码省略.........
示例5: SetUInt32Value
void Player::UpdateArmorPenetration(int32 amount)
{
// Store Rating Value
SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_ARMOR_PENETRATION, amount);
}
示例6: SetIsPet
void Pet::CreateAsSummon(uint32 entry, CreatureInfo *ci, Creature* created_from_creature, Unit* owner, SpellEntry* created_by_spell, uint32 type, uint32 expiretime)
{
if(ci == NULL)
return;
SetIsPet(true);
m_OwnerGuid = owner->GetGUID();
m_Owner = TO_PLAYER(owner);
m_OwnerGuid = m_Owner->GetGUID();
creature_info = ci;
myFamily = dbcCreatureFamily.LookupEntry(creature_info->Family);
//m_name = objmgr.GetCreatureFamilyName(myFamily->ID);
if( myFamily->name == NULL )
m_name = "Pet";
else
m_name.assign( myFamily->name );
// Create ourself
Create(m_name.c_str(), owner->GetMapId(), owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation());
SetUInt32Value(OBJECT_FIELD_ENTRY, entry);
SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // better set this one
// Fields common to both lock summons and pets
uint32 level = (m_Owner->GetUInt32Value( UNIT_FIELD_LEVEL ) - 5);
if( type & 0x2 && created_from_creature != NULL && created_from_creature->getLevel() > level)
{
level = created_from_creature->getLevel();
}
SetUInt32Value(UNIT_FIELD_LEVEL, level);
SetUInt32Value(UNIT_FIELD_DISPLAYID, ci->Male_DisplayID);
SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, ci->Male_DisplayID);
SetSummonedByGUID(owner->GetGUID());
SetCreatedByGUID(owner->GetGUID());
if(type & 0x1 && created_by_spell != NULL)
SetUInt64Value(UNIT_CREATED_BY_SPELL, created_by_spell->Id);
if(type & 0x1 || created_from_creature == NULL)
{
Summon = true;
SetUInt32Value(UNIT_FIELD_BYTES_0, 2048 | (0 << 24));
SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 2000);
SetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME, 2000);
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 0.5f);
SetFloatValue(UNIT_FIELD_COMBATREACH, 0.75f);
SetUInt32Value(UNIT_FIELD_BYTES_2, (0x01 | (0x2 << 24)));
SetUInt32Value(UNIT_FIELD_PETNUMBER, GetUIdFromGUID());
SetPowerType(POWER_TYPE_MANA);
if(entry == WATER_ELEMENTAL)
m_name = "Water Elemental";
else if( entry == 19668)
m_name = "Shadowfiend";
else
m_name = sWorld.GenerateName();
}
else
{
SetUInt32Value(UNIT_FIELD_BYTES_0, 2048 | (0 << 24));
SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 2000);
SetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME, 2000); // Supalosa: 2.00 normalized attack speed
// hacks D: allow correct creation of hunter pets via gm command
if(created_from_creature == this)
{
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 0.5f);
SetFloatValue(UNIT_FIELD_COMBATREACH, 0.75f);
}
else
{
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, created_from_creature->GetFloatValue(UNIT_FIELD_BOUNDINGRADIUS));
SetFloatValue(UNIT_FIELD_COMBATREACH, created_from_creature->GetFloatValue(UNIT_FIELD_COMBATREACH));
}
// These need to be checked.
SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED | UNIT_FLAG_COMBAT); // why combat ??
SetHappiness(PET_HAPPINESS_UPDATE_VALUE >> 1); // happiness
SetUInt32Value(UNIT_FIELD_MAXPOWER5, 1000000);
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, GetNextLevelXP(getLevel()));
SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
// Focus
SetUInt32Value(UNIT_FIELD_POWER3, 100);
SetUInt32Value(UNIT_FIELD_MAXPOWER3, 100);
// 0x3 -> Enable pet rename.
SetUInt32Value(UNIT_FIELD_BYTES_2, 1 | (0x3 << 16));
// Change the power type to FOCUS
SetPowerType(POWER_TYPE_FOCUS);
// create our spells
SetDefaultSpells();
InitTalentsForLevel(true);
}
// Apply stats.
//.........这里部分代码省略.........
示例7: switch
//.........这里部分代码省略.........
if( !caster || caster->GetTypeId()!=TYPEID_PLAYER )
return;
// accept only use by player from same group for caster except caster itself
if(((Player*)caster)==player || !((Player*)caster)->IsInSameRaidWith(player))
return;
AddUniqueUse(player);
// full amount unique participants including original summoner
if(GetUniqueUseCount() < info->summoningRitual.reqParticipants)
return;
// in case summoning ritual caster is GO creator
spellCaster = caster;
if(!caster->m_currentSpells[CURRENT_CHANNELED_SPELL])
return;
spellId = info->summoningRitual.spellId;
// finish spell
caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0);
caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish();
// can be deleted now
SetLootState(GO_JUST_DEACTIVATED);
// go to end function to spell casting
break;
}
case GAMEOBJECT_TYPE_SPELLCASTER: //22
{
SetUInt32Value(GAMEOBJECT_FLAGS,2);
GameObjectInfo const* info = GetGOInfo();
if(!info)
return;
if(info->spellcaster.partyOnly)
{
Unit* caster = GetOwner();
if( !caster || caster->GetTypeId()!=TYPEID_PLAYER )
return;
if(user->GetTypeId()!=TYPEID_PLAYER || !((Player*)user)->IsInSameRaidWith((Player*)caster))
return;
}
spellId = info->spellcaster.spellId;
AddUse();
break;
}
case GAMEOBJECT_TYPE_MEETINGSTONE: //23
{
GameObjectInfo const* info = GetGOInfo();
if(user->GetTypeId()!=TYPEID_PLAYER)
return;
Player* player = (Player*)user;
Player* targetPlayer = ObjectAccessor::FindPlayer(player->GetSelection());
// accept only use by player from same group for caster except caster itself
示例8: SetUInt32Value
void GameObject::EventCloseDoor()
{
SetUInt32Value(GAMEOBJECT_STATE, 0);
}
示例9: float
//.........这里部分代码省略.........
case FORM_DIREBEAR:
val2 = 0.0f; break;
default:
val2 = GetStat(STAT_AGILITY) - 10.0f; break;
}
break;
default: val2 = GetStat(STAT_AGILITY) - 10.0f; break;
}
}
else
{
switch(getClass())
{
case CLASS_WARRIOR: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
case CLASS_PALADIN: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
case CLASS_ROGUE: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
case CLASS_HUNTER: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
case CLASS_SHAMAN: val2 = level*2.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
case CLASS_DRUID:
{
//Check if Predatory Strikes is skilled
float mLevelMult = 0.0;
switch(m_form)
{
case FORM_CAT:
case FORM_BEAR:
case FORM_DIREBEAR:
case FORM_MOONKIN:
{
Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY);
for (Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr)
{
// Predatory Strikes
if ((*itr)->GetSpellProto()->SpellIconID == 1563)
{
mLevelMult = (*itr)->GetModifier()->m_amount / 100.0f;
break;
}
}
break;
}
}
switch(m_form)
{
case FORM_CAT:
val2 = getLevel()*(mLevelMult+2.0f) + GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f; break;
case FORM_BEAR:
case FORM_DIREBEAR:
val2 = getLevel()*(mLevelMult+3.0f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
case FORM_MOONKIN:
val2 = getLevel()*(mLevelMult+1.5f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
default:
val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
}
break;
}
case CLASS_MAGE: val2 = GetStat(STAT_STRENGTH) - 10.0f; break;
case CLASS_PRIEST: val2 = GetStat(STAT_STRENGTH) - 10.0f; break;
case CLASS_WARLOCK: val2 = GetStat(STAT_STRENGTH) - 10.0f; break;
}
}
SetModifierValue(unitMod, BASE_VALUE, val2);
float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);
//add dynamic flat mods
if (ranged && (getClassMask() & CLASSMASK_WAND_USERS)==0)
{
AuraList const& mRAPbyIntellect = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
for (AuraList::const_iterator i = mRAPbyIntellect.begin();i != mRAPbyIntellect.end(); ++i)
attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifierValue() / 100.0f);
}
float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;
SetUInt32Value(index, (uint32)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field
SetUInt32Value(index_mod, (uint32)attPowerMod); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
//automatically update weapon damage after attack power modification
if (ranged)
{
UpdateDamagePhysical(RANGED_ATTACK);
Pet *pet = GetPet(); //update pet's AP
if (pet)
pet->UpdateAttackPowerAndDamage();
}
else
{
UpdateDamagePhysical(BASE_ATTACK);
if (CanDualWield() && haveOffhandWeapon()) //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
UpdateDamagePhysical(OFF_ATTACK);
if (getClass() == CLASS_SHAMAN) // mental quickness
UpdateSpellDamageAndHealingBonus();
}
}
示例10: 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);
//.........这里部分代码省略.........
示例11: WorldGetUnit
//.........这里部分代码省略.........
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; }
case SPELL_AURA_FORCE_REACTION: {
示例12: assert
//.........这里部分代码省略.........
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;
SetSpeed(RUN, m_runSpeed);
SetSpeed(FLY, m_flySpeed);
// send "switch mover" packet
data.Initialize(SMSG_CLIENT_CONTROL_UPDATE);
data << GetNewGUID() << uint8(1);
pPlayer->GetSession()->SendPacket(&data);
pPlayer->m_CurrentCharm = TO_UNIT(this);
pPlayer->SetUInt64Value(UNIT_FIELD_CHARM, GetGUID());
SetUInt64Value(UNIT_FIELD_CHARMEDBY, pPlayer->GetGUID());
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE);
if(!m_faction || m_faction->ID == 35 || m_faction->ID == 2105)
{
SetCharmTempVal(pPlayer->GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE));
SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, pPlayer->GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE));
}
if(vehicleproto && vehicleproto->healthfromdriver)
{
uint32 health = GetUInt32Value(UNIT_FIELD_HEALTH);
uint32 maxhealth = GetUInt32Value(UNIT_FIELD_MAXHEALTH);
uint32 healthdiff = maxhealth - health;
SetUInt32Value(UNIT_FIELD_MAXHEALTH, (maxhealth+((pPlayer->GetTotalItemLevel())*(vehicleproto->healthunitfromitemlev))));
SetUInt32Value(UNIT_FIELD_HEALTH, (health+((pPlayer->GetTotalItemLevel())*(vehicleproto->healthunitfromitemlev))) - healthdiff);
}
SendSpells(GetEntry(), pPlayer);
if(pPlayer->HasAura(62064))
{
uint32 stack = pPlayer->FindActiveAura(62064)->stackSize;
AddAura(new Aura(dbcSpell.LookupEntry(62064),-1,this,this));
FindActiveAura(62064)->ModStackSize(stack);
}
}
}
else
{
data.Initialize(SMSG_CLIENT_CONTROL_UPDATE);
data << GetNewGUID() << uint8(0);
pPlayer->GetSession()->SendPacket(&data);
}
data.Initialize(SMSG_PET_DISMISS_SOUND);
data << uint32(m_vehicleSeats[slot]->m_enterUISoundID);
data << pPlayer->GetPosition();
pPlayer->GetSession()->SendPacket(&data);
++m_ppassengerCount;
}
else
{
pPassenger->SetVehicle(this);
if(vehicleproto != NULL)
if(vehicleproto->seats[slot].accessoryentry == pPassenger->GetEntry())
if(vehicleproto->seats[slot].unselectableaccessory == true)
pPassenger->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE));
else
pPassenger->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION));
else
pPassenger->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE));
pPassenger->SetPosition(GetPositionX()+v.x, GetPositionY()+v.y, GetPositionZ()+v.z, GetOrientation());
}
SendHeartBeatMsg(false);
if(IsFull())
RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
if(canFly())
EnableFlight();
_setFaction();
}
示例13: 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);
//.........这里部分代码省略.........
示例14: 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();
//.........这里部分代码省略.........
示例15: Relocate
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, uint32 go_state)
{
Relocate(x,y,z,ang);
SetMapId(map->GetId());
SetInstanceId(map->GetInstanceId());
if(!IsPositionValid())
{
sLog.outError("ERROR: Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,name_id,x,y);
return false;
}
GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(name_id);
if (!goinfo)
{
sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f) ang: %f rotation0: %f rotation1: %f rotation2: %f rotation3: %f",guidlow, name_id, map->GetId(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3);
return false;
}
Object::_Create(guidlow, goinfo->id, HIGHGUID_GAMEOBJECT);
m_DBTableGuid = guidlow;
if (goinfo->type >= MAX_GAMEOBJECT_TYPE)
{
sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist GO type '%u' in `gameobject_template`. It's will crash client if created.",guidlow,name_id,goinfo->type);
return false;
}
// SetUInt32Value(GAMEOBJECT_TIMESTAMP, (uint32)time(NULL));
SetFloatValue(GAMEOBJECT_POS_X, x);
SetFloatValue(GAMEOBJECT_POS_Y, y);
SetFloatValue(GAMEOBJECT_POS_Z, z);
SetFloatValue(GAMEOBJECT_FACING, ang); //this is not facing angle
SetFloatValue (GAMEOBJECT_ROTATION, rotation0);
SetFloatValue (GAMEOBJECT_ROTATION+1, rotation1);
SetFloatValue (GAMEOBJECT_ROTATION+2, rotation2);
SetFloatValue (GAMEOBJECT_ROTATION+3, rotation3);
SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size);
SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction);
SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags);
m_flags = goinfo->flags;
SetUInt32Value (OBJECT_FIELD_ENTRY, goinfo->id);
SetUInt32Value (GAMEOBJECT_DISPLAYID, goinfo->displayId);
SetUInt32Value (GAMEOBJECT_STATE, go_state);
SetUInt32Value (GAMEOBJECT_TYPE_ID, goinfo->type);
SetUInt32Value (GAMEOBJECT_ANIMPROGRESS, animprogress);
// Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22)
if (goinfo->type == GAMEOBJECT_TYPE_SPELLCASTER)
m_charges = goinfo->spellcaster.charges;
//Notify the map's instance data.
//Only works if you create the object in it, not if it is moves to that map.
//Normally non-players do not teleport to other maps.
if(map && map->GetInstanceData())
{
map->GetInstanceData()->OnObjectCreate(this);
}
return true;
}