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

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

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

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

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

示例1: GetMap

Creature* Transport::AddNPCPassenger (uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim){    Map* map = GetMap();    Creature* pCreature = new Creature;    if (!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))    {        delete pCreature;        return 0;    }    pCreature->SetTransport(this);    pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);    pCreature->m_movementInfo.guid = GetGUID();    pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o);    o += GetOrientation();    MapManager::NormalizeOrientation(o);    pCreature->Relocate(GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ(), o);    pCreature->SetHomePosition(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ(), pCreature->GetOrientation());    if (!pCreature->IsPositionValid())    {        sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", pCreature->GetGUIDLow(), pCreature->GetEntry(), pCreature->GetPositionX(), pCreature->GetPositionY());        delete pCreature;        return 0;    }    map->Add(pCreature);    m_NPCPassengerSet.insert(pCreature);    pCreature->setActive(true);    sScriptMgr->OnAddCreaturePassenger(this, pCreature);    return pCreature;}
开发者ID:BoThay,项目名称:ArkCORE,代码行数:36,


示例2: DeleteFromDB

void Corpse::SaveToDB(){    // prevent DB data inconsistence problems and duplicates    SQLTransaction trans = CharacterDatabase.BeginTransaction();    DeleteFromDB(trans);    uint16 index = 0;    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE);    stmt->setUInt64(index++, GetOwnerGUID().GetCounter());                            // guid    stmt->setFloat (index++, GetPositionX());                                         // posX    stmt->setFloat (index++, GetPositionY());                                         // posY    stmt->setFloat (index++, GetPositionZ());                                         // posZ    stmt->setFloat (index++, GetOrientation());                                       // orientation    stmt->setUInt16(index++, GetMapId());                                             // mapId    stmt->setUInt32(index++, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID));                // displayId    stmt->setString(index++, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END));   // itemCache    stmt->setUInt32(index++, GetUInt32Value(CORPSE_FIELD_BYTES_1));                   // bytes1    stmt->setUInt32(index++, GetUInt32Value(CORPSE_FIELD_BYTES_2));                   // bytes2    stmt->setUInt8 (index++, GetUInt32Value(CORPSE_FIELD_FLAGS));                     // flags    stmt->setUInt8 (index++, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS));             // dynFlags    stmt->setUInt32(index++, uint32(m_time));                                         // time    stmt->setUInt8 (index++, GetType());                                              // corpseType    stmt->setUInt32(index++, GetInstanceId());                                        // instanceId    trans->Append(stmt);    for (uint32 phaseId : GetPhases())    {        index = 0;        stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE_PHASES);        stmt->setUInt64(index++, GetOwnerGUID().GetCounter());                        // OwnerGuid        stmt->setUInt32(index++, phaseId);                                            // PhaseId        trans->Append(stmt);    }    CharacterDatabase.CommitTransaction(trans);}
开发者ID:doriangray2,项目名称:TrinityCore-devil,代码行数:36,


示例3: VALUES

void Creature::SaveToDB(){    sDatabase.BeginTransaction();    sDatabase.PExecuteLog("DELETE FROM `creature` WHERE `guid` = '%u'", m_DBTableGuid);    std::ostringstream ss;    ss << "INSERT INTO `creature` VALUES ("        << m_DBTableGuid << ","        << GetEntry() << ","        << GetMapId() <<","        << GetPositionX() << ","        << GetPositionY() << ","        << GetPositionZ() << ","        << GetOrientation() << ","        << m_respawnDelay << ","                            //respawn time        << (float) 0  << ","                                //spawn distance (float)        << (uint32) (0) << ","                              //currentwaypoint        << respawn_cord[0] << ","                           //spawn_position_x        << respawn_cord[1] << ","                           //spawn_position_y        << respawn_cord[2] << ","                           //spawn_position_z        << (float)(0) << ","                                //spawn_orientation        << GetHealth() << ","                               //curhealth        << GetPower(POWER_MANA) << ","                      //curmana        << (uint32)(m_deathState) << ","                    // is it really death state or just state?    //or    //<< (uint32)(m_state) << ","                     // is it really death state or just state?        << GetDefaultMovementType() << ","                  // default movement generator type        << "'')";                                           // should save auras    sDatabase.PExecuteLog( ss.str( ).c_str( ) );    sDatabase.CommitTransaction();}
开发者ID:chrayn,项目名称:mangos-06,代码行数:36,


示例4: GetMainWindow

void PictureTextCBox::Draw(const Point2i &/*mousePosition*/){  Surface & video_window = GetMainWindow();  if (m_value) {    uint enabled_x = GetPositionX() + (GetSizeX() - m_enabled.GetWidth())/2 ;    uint enabled_y = GetPositionY();    uint outside_x = std::max(uint(0), GetPositionX() - enabled_x);    uint outside_y = std::max(uint(0), GetPositionY() - enabled_y);    enabled_x += outside_x;    enabled_y += outside_y;    Rectanglei srcRect(outside_x, outside_y, m_enabled.GetWidth() - outside_x,                       m_enabled.GetHeight() - outside_y);    video_window.Blit(m_enabled, srcRect, Point2i(enabled_x, enabled_y));  } else {    uint disabled_x = GetPositionX() + (GetSizeX() - m_disabled_back.GetWidth())/2 ;    uint disabled_y = GetPositionY();    uint outside_x = std::max(uint(0), GetPositionX() - disabled_x);    uint outside_y = std::max(uint(0), GetPositionY() - disabled_y);    disabled_x += outside_x;    disabled_y += outside_y;    Rectanglei srcRect(outside_x, outside_y, m_disabled_back.GetWidth() - outside_x,                       m_disabled_back.GetHeight() - outside_y);    video_window.Blit(m_disabled_back, srcRect, Point2i(disabled_x, disabled_y));  }  // center the image  uint tmp_x = GetPositionX() + (GetSizeX() - m_image.GetWidth())/2 ;  uint tmp_y = GetPositionY() + (m_enabled.GetHeight() - m_image.GetHeight())/2;  video_window.Blit(m_image, Point2i(tmp_x, tmp_y));  Text::DrawCenterTop(GetPosition() + Point2i(GetSizeX()/2,                      GetSizeY() - Text::GetHeight()));  if (!m_value) {    uint disabled_x = GetPositionX() + (GetSizeX() - m_disabled_front.GetWidth())/2 ;    uint disabled_y = GetPositionY() + (m_enabled.GetHeight() - m_disabled_front.GetHeight())/2;    video_window.Blit(m_disabled_front, Point2i(disabled_x, disabled_y));  }}
开发者ID:fluxer,项目名称:warmux,代码行数:43,


示例5: switch

void GameObject::Use(Unit* user){    // by default spell caster is user    Unit* spellCaster = user;    uint32 spellId = 0;    switch(GetGoType())    {        case GAMEOBJECT_TYPE_DOOR:                          //0        case GAMEOBJECT_TYPE_BUTTON:                        //1            //doors/buttons never really despawn, only reset to default state/flags            UseDoorOrButton();            // activate script            sWorld.ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);            return;        case GAMEOBJECT_TYPE_QUESTGIVER:                    //2        {            if(user->GetTypeId()!=TYPEID_PLAYER)                return;            Player* player = (Player*)user;            player->PrepareQuestMenu( GetGUID() );            player->SendPreparedQuest( GetGUID() );            return;        }        //Sitting: Wooden bench, chairs enzz        case GAMEOBJECT_TYPE_CHAIR:                         //7        {            GameObjectInfo const* info = GetGOInfo();            if(!info)                return;            if(user->GetTypeId()!=TYPEID_PLAYER)                return;            Player* player = (Player*)user;            // a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one            // check if the db is sane            if(info->chair.slots > 0)            {                float lowestDist = DEFAULT_VISIBILITY_DISTANCE;                float x_lowest = GetPositionX();                float y_lowest = GetPositionY();                // the object orientation + 1/2 pi                // every slot will be on that straight line                float orthogonalOrientation = GetOrientation()+M_PI*0.5f;                // find nearest slot                for(uint32 i=0; i<info->chair.slots; i++)                {                    // the distance between this slot and the center of the go - imagine a 1D space                    float relativeDistance = (info->size*i)-(info->size*(info->chair.slots-1)/2.0f);                    float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation);                    float y_i = GetPositionY() + relativeDistance * sin(orthogonalOrientation);                    // calculate the distance between the player and this slot                    float thisDistance = player->GetDistance2d(x_i, y_i);                    /* debug code. It will spawn a npc on each slot to visualize them.                    Creature* helper = player->SummonCreature(14496, x_i, y_i, GetPositionZ(), GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10000);                    std::ostringstream output;                    output << i << ": thisDist: " << thisDistance;                    helper->MonsterSay(output.str().c_str(), LANG_UNIVERSAL, 0);                    */                    if(thisDistance <= lowestDist)                    {                        lowestDist = thisDistance;                        x_lowest = x_i;                        y_lowest = y_i;                    }                }                player->TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);            }            else            {                // fallback, will always work                player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);            }            player->SetStandState(PLAYER_STATE_SIT_LOW_CHAIR+info->chair.height);            return;        }        //big gun, its a spell/aura        case GAMEOBJECT_TYPE_GOOBER:                        //10        {            GameObjectInfo const* info = GetGOInfo();            if(user->GetTypeId()==TYPEID_PLAYER)            {                Player* player = (Player*)user;                // show page                if(info->goober.pageId)//.........这里部分代码省略.........
开发者ID:Actionfox,项目名称:mangos,代码行数:101,


示例6: SetMap

bool AreaTrigger::CreateAreaTrigger(uint32 guidlow, uint32 triggerEntry, Unit* caster, SpellInfo const* spell, Position const& pos, float radius, uint32 duration){    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        sLog->outError("misc", "AreaTrigger (spell %u) not created. Invalid coordinates (X: %f Y: %f)", spell->Id, GetPositionX(), GetPositionY());        return false;    }    WorldObject::_Create(guidlow, HIGHGUID_AREATRIGGER, caster->GetPhaseMask());    SetEntry(triggerEntry);    SetDuration(duration ? duration : spell->GetDuration());    SetObjectScale(1);    SetGuidValue(AREATRIGGER_FIELD_CASTER, caster->GetGUID128());    SetUInt32Value(AREATRIGGER_FIELD_SPELL_ID, spell->Id);    SetUInt32Value(AREATRIGGER_FIELD_SPELL_VISUAL_ID, spell->SpellVisual[0]);    SetUInt32Value(AREATRIGGER_FIELD_DURATION, spell->GetDuration());    SetFloatValue(AREATRIGGER_FIELD_EXPLICIT_SCALE, 1.f);    _radius = radius;    if (!GetMap()->AddToMap(this))        return false;    return true;}
开发者ID:GlassFace,项目名称:Skyfire-6.1.2-version,代码行数:29,


示例7: SetMap

bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, SpellInfo const* spell, Position const& pos, float radius, DynamicObjectType type){    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        TC_LOG_ERROR("misc", "DynamicObject (spell %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spell->Id, GetPositionX(), GetPositionY());        return false;    }    WorldObject::_Create(ObjectGuid::Create<HighGuid::DynamicObject>(GetMapId(), spell->Id, guidlow));    SetPhaseMask(caster->GetPhaseMask(), false);    SetEntry(spell->Id);    SetObjectScale(1.0f);    SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetGUID());    SetUInt32Value(DYNAMICOBJECT_BYTES, spell->GetSpellVisual(GetMap()->GetDifficultyID()) | (type << 28));    SetUInt32Value(DYNAMICOBJECT_SPELLID, spell->Id);    SetFloatValue(DYNAMICOBJECT_RADIUS, radius);    SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());    if (IsWorldObject())        setActive(true);    //must before add to map to be put in world container    Transport* transport = caster->GetTransport();    if (transport)    {        float x, y, z, o;        pos.GetPosition(x, y, z, o);        transport->CalculatePassengerOffset(x, y, z, &o);        m_movementInfo.transport.pos.Relocate(x, y, z, o);        // This object must be added to transport before adding to map for the client to properly display it        transport->AddPassenger(this);    }    if (!GetMap()->AddToMap(this))    {        // Returning false will cause the object to be deleted - remove from transport        if (transport)            transport->RemovePassenger(this);        return false;    }    return true;}
开发者ID:gearsofdeath,项目名称:DeathCore_6.x-1,代码行数:46,


示例8: Draw

void BonusTile::Update(){    if (IsRemoved())        return;    if (GAME_STATE_PAUSED(sGame.GetGameState()))    {        Draw(animationFinished ? &imageUsed : NULL, true);        return;    }    SpecialTile::Update();    if (isUsed && animating && !animationFinished)    {        animating = true;        if (movingUp)        {            SetPositionY(GetPositionY() - 9.0f);            if (GetPositionY() < startPosition.y - 40.0f)                movingUp = false;        }        else        {            SetPositionY(GetPositionY() + 9.0f);            if (GetPositionY() >= startPosition.y)            {                SetPositionY(startPosition.y);                movingUp = true;                animating = false;                animationFinished = true;                sf::Texture imageCoin;                imageCoin.loadFromFile("Graphics/Tiles/coin_gold.png");                switch (urand(0, 1))                {                    case 0:                        sGame.AddCoin(new Coin(window, sf::Vector2f(GetPositionX(), GetPositionY() - 70.0f), imageCoin));                        break;                    case 1:                        sGame.AddCoin(new Coin(window, sf::Vector2f(GetPositionX(), GetPositionY() - 70.0f), imageCoin));                        break;                    default:                        std::cout << "Typo in BonusTile::Update switch (urand)" << std::endl;                        break;                }            }        }    }    if (sf::Keyboard::isKeyPressed(sf::Keyboard::F2))    {        SetPosition(startPosition.x, startPosition.y);        animationFinished = false;        movingUp = true;    }    Draw(animationFinished ? &imageUsed : NULL, true);}
开发者ID:Discover-,项目名称:Platformer-SFML,代码行数:62,


示例9: GetPositionX

bool AreaTrigger::CheckIsInPolygon2D(Position const* pos) const{    float testX = pos->GetPositionX();    float testY = pos->GetPositionY();    //this method uses the ray tracing algorithm to determine if the point is in the polygon    bool locatedInPolygon = false;    for (std::size_t vertex = 0; vertex < _polygonVertices.size(); ++vertex)    {        std::size_t nextVertex;        //repeat loop for all sets of points        if (vertex == (_polygonVertices.size() - 1))        {            //if i is the last vertex, let j be the first vertex            nextVertex = 0;        }        else        {            //for all-else, let j=(i+1)th vertex            nextVertex = vertex + 1;        }        float vertX_i = GetPositionX() + _polygonVertices[vertex].GetPositionX();        float vertY_i = GetPositionY() + _polygonVertices[vertex].GetPositionY();        float vertX_j = GetPositionX() + _polygonVertices[nextVertex].GetPositionX();        float vertY_j = GetPositionY() + _polygonVertices[nextVertex].GetPositionY();        // following statement checks if testPoint.Y is below Y-coord of i-th vertex        bool belowLowY = vertY_i > testY;        // following statement checks if testPoint.Y is below Y-coord of i+1-th vertex        bool belowHighY = vertY_j > testY;        /* following statement is true if testPoint.Y satisfies either (only one is possible)        -->(i).Y < testPoint.Y < (i+1).Y        OR        -->(i).Y > testPoint.Y > (i+1).Y        (Note)        Both of the conditions indicate that a point is located within the edges of the Y-th coordinate        of the (i)-th and the (i+1)- th vertices of the polygon. If neither of the above        conditions is satisfied, then it is assured that a semi-infinite horizontal line draw        to the right from the testpoint will NOT cross the line that connects vertices i and i+1        of the polygon        */        bool withinYsEdges = belowLowY != belowHighY;        if (withinYsEdges)        {            // this is the slope of the line that connects vertices i and i+1 of the polygon            float slopeOfLine = (vertX_j - vertX_i) / (vertY_j - vertY_i);            // this looks up the x-coord of a point lying on the above line, given its y-coord            float pointOnLine = (slopeOfLine* (testY - vertY_i)) + vertX_i;            //checks to see if x-coord of testPoint is smaller than the point on the line with the same y-coord            bool isLeftToLine = testX < pointOnLine;            if (isLeftToLine)            {                //this statement changes true to false (and vice-versa)                locatedInPolygon = !locatedInPolygon;            }//end if (isLeftToLine)        }//end if (withinYsEdges    }    return locatedInPolygon;}
开发者ID:Rochet2,项目名称:TrinityCore,代码行数:68,


示例10: SetMap

bool AreaTrigger::CreateAreaTrigger(uint32 guidlow, uint32 triggerEntry, Unit* caster, SpellInfo const* spell, Position const& pos){    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        TC_LOG_ERROR("misc", "AreaTrigger (spell %u) not created. Invalid coordinates (X: %f Y: %f)", spell->Id, GetPositionX(), GetPositionY());        return false;    }    WorldObject::_Create(guidlow, HIGHGUID_AREATRIGGER, caster->GetPhaseMask());    SetEntry(triggerEntry);    SetDuration(spell->GetDuration());    SetObjectScale(1);    SetUInt32Value(AREATRIGGER_SPELLID, spell->Id);    SetUInt32Value(AREATRIGGER_SPELLVISUALID, spell->SpellVisual[0]);    SetUInt32Value(AREATRIGGER_DURATION, spell->GetDuration());    SetFloatValue(AREATRIGGER_FINAL_POS + 0, pos.GetPositionX());    SetFloatValue(AREATRIGGER_FINAL_POS + 1, pos.GetPositionY());    SetFloatValue(AREATRIGGER_FINAL_POS + 2, pos.GetPositionZ());    for (auto phase : caster->GetPhases())        SetInPhase(phase, false, true);    if (!GetMap()->AddToMap(this))        return false;    return true;}
开发者ID:Myst,项目名称:ElunaTrinityCata,代码行数:31,


示例11: Move

bool Ship::Move(float frametime){    Object::Move(m_Direction * (Definitions::DefShipSpeedX * frametime), Definitions::DefShipSinMult * std::sinf(GetPositionX()) * frametime);    return true;}
开发者ID:ftbmynameis,项目名称:SpaceInvaders,代码行数:5,


示例12: AI

//.........这里部分代码省略.........    // Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime    // ... arrive | ... delay ... | departure    //      event /         event /    for (;;)    {        if (timer >= _currentFrame->ArriveTime)        {            if (!_triggeredArrivalEvent)            {                DoEventIfAny(*_currentFrame, false);                _triggeredArrivalEvent = true;            }            if (timer < _currentFrame->DepartureTime)            {                SetMoving(false);                justStopped = true;                if (_pendingStop && GetGoState() != GO_STATE_READY)                {                    SetGoState(GO_STATE_READY);                    m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetTransportPeriod());                    m_goValue.Transport.PathProgress *= GetTransportPeriod();                    m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;                }                break;  // its a stop frame and we are waiting            }        }        if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)        {            DoEventIfAny(*_currentFrame, true); // departure event            _triggeredDepartureEvent = true;        }        // not waiting anymore        SetMoving(true);        // Enable movement        if (GetGOInfo()->moTransport.allowstopping)            SetGoState(GO_STATE_ACTIVE);        if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)            break;  // found current waypoint        MoveToNextWaypoint();        sScriptMgr->OnRelocate(this, _currentFrame->Node->NodeIndex, _currentFrame->Node->ContinentID, _currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z);        TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->NodeIndex, _currentFrame->Node->ContinentID, _currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z);        // Departure event        if (_currentFrame->IsTeleportFrame())            if (TeleportTransport(_nextFrame->Node->ContinentID, _nextFrame->Node->Loc.X, _nextFrame->Node->Loc.Y, _nextFrame->Node->Loc.Z, _nextFrame->InitialOrientation))                return; // Update more in new map thread    }    // Add model to map after we are fully done with moving maps    if (_delayedAddModel)    {        _delayedAddModel = false;        if (m_model)            GetMap()->InsertGameObjectModel(*m_model);    }    // Set position    _positionChangeTimer.Update(diff);    if (_positionChangeTimer.Passed())    {        _positionChangeTimer.Reset(positionUpdateDelay);        if (IsMoving())        {            float t = !justStopped ? CalculateSegmentPos(float(timer) * 0.001f) : 1.0f;            G3D::Vector3 pos, dir;            _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);            _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);            UpdatePosition(pos.x, pos.y, pos.z, std::atan2(dir.y, dir.x) + float(M_PI));        }        else if (justStopped)            UpdatePosition(_currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z, _currentFrame->InitialOrientation);        else        {            /* There are four possible scenarios that trigger loading/unloading passengers:              1. transport moves from inactive to active grid              2. the grid that transport is currently in becomes active              3. transport moves from active to inactive grid              4. the grid that transport is currently in unloads            */            bool gridActive = GetMap()->IsGridLoaded(GetPositionX(), GetPositionY());            if (_staticPassengers.empty() && gridActive) // 2.                LoadStaticPassengers();            else if (!_staticPassengers.empty() && !gridActive)                // 4. - if transports stopped on grid edge, some passengers can remain in active grids                //      unload all static passengers otherwise passengers won't load correctly when the grid that transport is currently in becomes active                UnloadStaticPassengers();        }    }    sScriptMgr->OnTransportUpdate(this, diff);}
开发者ID:Asandru,项目名称:TrinityCore,代码行数:101,


示例13: AI

void Transport::Update(uint32 diff){    uint32 const positionUpdateDelay = 200;    if (AI())        AI()->UpdateAI(diff);    else if (!AIM_Initialize())        TC_LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");    if (GetKeyFrames().size() <= 1)        return;    if (IsMoving() || !_pendingStop)        m_goValue.Transport.PathProgress += diff;    uint32 timer = m_goValue.Transport.PathProgress % GetPeriod();    // Set current waypoint    // Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime    // ... arrive | ... delay ... | departure    //      event /         event /    for (;;)    {        if (timer >= _currentFrame->ArriveTime)        {            if (!_triggeredArrivalEvent)            {                DoEventIfAny(*_currentFrame, false);                _triggeredArrivalEvent = true;            }            if (timer < _currentFrame->DepartureTime)            {                SetMoving(false);                if (_pendingStop && GetGoState() != GO_STATE_READY)                {                    SetGoState(GO_STATE_READY);                    m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod());                    m_goValue.Transport.PathProgress *= GetPeriod();                    m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;                }                break;  // its a stop frame and we are waiting            }        }        if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)        {            DoEventIfAny(*_currentFrame, true); // departure event            _triggeredDepartureEvent = true;        }        // not waiting anymore        SetMoving(true);        // Enable movement        if (GetGOInfo()->moTransport.canBeStopped)            SetGoState(GO_STATE_ACTIVE);        if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)            break;  // found current waypoint        MoveToNextWaypoint();        sScriptMgr->OnRelocate(this, _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);        TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);        // Departure event        if (_currentFrame->IsTeleportFrame())            if (TeleportTransport(_nextFrame->Node->mapid, _nextFrame->Node->x, _nextFrame->Node->y, _nextFrame->Node->z, _nextFrame->InitialOrientation))                return; // Update more in new map thread    }    // Set position    _positionChangeTimer.Update(diff);    if (_positionChangeTimer.Passed())    {        _positionChangeTimer.Reset(positionUpdateDelay);        if (IsMoving())        {            float t = CalculateSegmentPos(float(timer) * 0.001f);            G3D::Vector3 pos, dir;            _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);            _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);            UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.y, dir.x) + M_PI);        }        else        {            /* There are four possible scenarios that trigger loading/unloading passengers:              1. transport moves from inactive to active grid              2. the grid that transport is currently in becomes active              3. transport moves from active to inactive grid              4. the grid that transport is currently in unloads            */            if (_staticPassengers.empty() && GetMap()->IsGridLoaded(GetPositionX(), GetPositionY())) // 2.                LoadStaticPassengers();        }    }    sScriptMgr->OnTransportUpdate(this, diff);//.........这里部分代码省略.........
开发者ID:BravadoToDeath,项目名称:ArkCORE-NG,代码行数:101,


示例14: 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,


示例15: SetMap

bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius ){    WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());    SetMap(caster->GetMap());    Relocate(x, y, z, 0);    if(!IsPositionValid())    {        sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());        return false;    }    SetEntry(spellId);    SetFloatValue( OBJECT_FIELD_SCALE_X, 2 );    SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() );    SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 );    SetUInt32Value( DYNAMICOBJECT_SPELLID, spellId );    SetFloatValue( DYNAMICOBJECT_RADIUS, radius);    SetUInt32Value( DYNAMICOBJECT_CASTTIME, getMSTime() );  // new 2.4.0    m_aliveDuration = duration;    m_radius = radius;    m_effIndex = effIndex;    m_spellId = spellId;    // set to active for far sight case    if(SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId))        m_isActiveObject = IsSpellHaveEffect(spellEntry,SPELL_EFFECT_ADD_FARSIGHT);    return true;}
开发者ID:sc0rpio0o,项目名称:diamondcore,代码行数:31,


示例16: SetMap

bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type){    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        TC_LOG_ERROR("misc", "DynamicObject (spell %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, GetPositionX(), GetPositionY());        return false;    }    WorldObject::_Create(guidlow, HighGuid::DynamicObject, caster->GetPhaseMask());    SetEntry(spellId);    SetObjectScale(1);    SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetGUID());    // The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden    // by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane.    // If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but    // precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells    // I saw sniffed...    SetByteValue(DYNAMICOBJECT_BYTES, 0, type);    SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);    SetFloatValue(DYNAMICOBJECT_RADIUS, radius);    SetUInt32Value(DYNAMICOBJECT_CASTTIME, GameTime::GetGameTimeMS());    if (IsWorldObject())        setActive(true);    //must before add to map to be put in world container    Transport* transport = caster->GetTransport();    if (transport)    {        float x, y, z, o;        pos.GetPosition(x, y, z, o);        transport->CalculatePassengerOffset(x, y, z, &o);        m_movementInfo.transport.pos.Relocate(x, y, z, o);        // This object must be added to transport before adding to map for the client to properly display it        transport->AddPassenger(this);    }    if (!GetMap()->AddToMap(this))    {        // Returning false will cause the object to be deleted - remove from transport        if (transport)            transport->RemovePassenger(this);        return false;    }    return true;}
开发者ID:AvariusProject,项目名称:AvariusCore,代码行数:51,


示例17: SetMap

bool AreaTrigger::CreateAreaTrigger(uint32 guidlow, uint32 triggerEntry, Unit* caster, SpellInfo const* spell, Position const& pos){    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        sLog->outError(LOG_FILTER_GENERAL, "AreaTrigger (spell %u) not created. Invalid coordinates (X: %f Y: %f)", spell->Id, GetPositionX(), GetPositionY());        return false;    }    WorldObject::_Create(guidlow, HIGHGUID_AREATRIGGER, caster->GetPhaseMask());    SetEntry(triggerEntry);    SetDuration(spell->GetDuration());    SetObjectScale(1);    SetUInt64Value(AREATRIGGER_CASTER, caster->GetGUID());    SetUInt32Value(AREATRIGGER_SPELLID, spell->Id);    SetUInt32Value(AREATRIGGER_SPELLVISUALID, spell->SpellVisual[0]);    SetUInt32Value(AREATRIGGER_DURATION, spell->GetDuration());    switch (spell->Id)    {        case 116011:// Rune of Power            SetVisualRadius(3.5f);            break;        case 116235:// Amethyst Pool            SetVisualRadius(3.5f);            break;        default:            break;    }    if (!GetMap()->AddToMap(this))        return false;    return true;}
开发者ID:AwkwardDev,项目名称:SurgeCore-505,代码行数:38,


示例18: GetCreatureAddon

void Vehicle::InstallAllAccessories(){    if(!GetMap())       return;    CreatureDataAddon const *cainfo = GetCreatureAddon();    if(!cainfo || !cainfo->passengers)        return;    for (CreatureDataAddonPassengers const* cPassanger = cainfo->passengers; cPassanger->seat_idx != -1; ++cPassanger)    {        // Continue if seat already taken        if(GetPassenger(cPassanger->seat_idx))            continue;        uint32 guid = 0;        bool isVehicle = false;        // Set guid and check whatever it is        if(cPassanger->guid != 0)            guid = cPassanger->guid;        else        {            CreatureDataAddon const* passAddon;            passAddon = ObjectMgr::GetCreatureTemplateAddon(cPassanger->entry);            if(passAddon && passAddon->vehicle_id != 0)                isVehicle = true;            else                guid = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT);        }        // Create it        Creature *pPassenger = new Creature;        if(!isVehicle)        {            uint32 entry = cPassanger->entry;            if(entry == 0)            {                CreatureData const* data = sObjectMgr.GetCreatureData(guid);                if(!data)                {                    delete pPassenger;                    continue;                }                entry = data->id;            }                 if(!pPassenger->Create(guid, GetMap(), GetPhaseMask(), entry, 0))            {                delete pPassenger;                continue;            }            pPassenger->LoadFromDB(guid, GetMap());            pPassenger->Relocate(GetPositionX(), GetPositionY(), GetPositionZ());            GetMap()->Add(pPassenger);            pPassenger->AIM_Initialize();        }        else            pPassenger = (Creature*)SummonVehicle(cPassanger->entry, GetPositionX(), GetPositionY(), GetPositionZ(), 0);        // Enter vehicle...        pPassenger->EnterVehicle(this, cPassanger->seat_idx, true);        // ...and send update. Without this, client wont show this new creature/vehicle...        WorldPacket data;        pPassenger->BuildHeartBeatMsg(&data);        pPassenger->SendMessageToSet(&data, false);    }}
开发者ID:3raZar3,项目名称:Dark-Ice,代码行数:63,


示例19: SetMap

bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, const Position &pos, int32 duration, float radius){    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        sLog->outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, effIndex, GetPositionX(), GetPositionY());        return false;    }    WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());    SetEntry(spellId);    SetFloatValue(OBJECT_FIELD_SCALE_X, 1);    SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID());    // The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden    // by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane.    // If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but    // precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells    // I saw sniffed...    SetUInt32Value(DYNAMICOBJECT_BYTES, 0x00000001);    SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);    SetFloatValue(DYNAMICOBJECT_RADIUS, radius);    SetFloatValue(DYNAMICOBJECT_POS_X, pos.m_positionX);    SetFloatValue(DYNAMICOBJECT_POS_Y, pos.m_positionY);    SetFloatValue(DYNAMICOBJECT_POS_Z, pos.m_positionZ);    SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());    m_aliveDuration = duration;    m_radius = radius;    m_effIndex = effIndex;    m_spellId = spellId;    m_casterGuid = caster->GetGUID();    m_updateTimer = 0;    if (m_effIndex == 4)        m_isWorldObject = true;    return true;}
开发者ID:Caydan,项目名称:TBCPvP,代码行数:41,


示例20: SetMap

bool AreaTrigger::Create(uint32 spellMiscId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, uint32 spellXSpellVisualId, ObjectGuid const& castId, AuraEffect const* aurEff){    _targetGuid = target ? target->GetGUID() : ObjectGuid::Empty;    _aurEff = aurEff;    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (spellMiscId %u) not created. Invalid coordinates (X: %f Y: %f)", spellMiscId, GetPositionX(), GetPositionY());        return false;    }    _areaTriggerMiscTemplate = sAreaTriggerDataStore->GetAreaTriggerMiscTemplate(spellMiscId);    if (!_areaTriggerMiscTemplate)    {        TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (spellMiscId %u) not created. Invalid areatrigger miscid (%u)", spellMiscId, spellMiscId);        return false;    }    Object::_Create(ObjectGuid::Create<HighGuid::AreaTrigger>(GetMapId(), GetTemplate()->Id, caster->GetMap()->GenerateLowGuid<HighGuid::AreaTrigger>()));    SetEntry(GetTemplate()->Id);    SetDuration(duration);    SetObjectScale(1.0f);    SetGuidValue(AREATRIGGER_CASTER, caster->GetGUID());    SetGuidValue(AREATRIGGER_CREATING_EFFECT_GUID, castId);    SetUInt32Value(AREATRIGGER_SPELLID, spell->Id);    SetUInt32Value(AREATRIGGER_SPELL_FOR_VISUALS, spell->Id);    SetUInt32Value(AREATRIGGER_SPELL_X_SPELL_VISUAL_ID, spellXSpellVisualId);    SetUInt32Value(AREATRIGGER_TIME_TO_TARGET_SCALE, GetMiscTemplate()->TimeToTargetScale != 0 ? GetMiscTemplate()->TimeToTargetScale : GetUInt32Value(AREATRIGGER_DURATION));    SetFloatValue(AREATRIGGER_BOUNDS_RADIUS_2D, GetTemplate()->MaxSearchRadius);    SetUInt32Value(AREATRIGGER_DECAL_PROPERTIES_ID, GetMiscTemplate()->DecalPropertiesId);    for (uint8 scaleCurveIndex = 0; scaleCurveIndex < MAX_AREATRIGGER_SCALE; ++scaleCurveIndex)        if (GetMiscTemplate()->ExtraScale.Data.Raw[scaleCurveIndex])            SetUInt32Value(AREATRIGGER_EXTRA_SCALE_CURVE + scaleCurveIndex, GetMiscTemplate()->ExtraScale.Data.Raw[scaleCurveIndex]);    PhasingHandler::InheritPhaseShift(this, caster);    if (target && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))    {        m_movementInfo.transport.guid = target->GetGUID();    }    UpdateShape();    uint32 timeToTarget = GetMiscTemplate()->TimeToTarget != 0 ? GetMiscTemplate()->TimeToTarget : GetUInt32Value(AREATRIGGER_DURATION);    if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_CIRCULAR_MOVEMENT))    {        AreaTriggerCircularMovementInfo cmi = GetMiscTemplate()->CircularMovementInfo;        if (target && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))            cmi.PathTarget = target->GetGUID();        else            cmi.Center = pos;        InitCircularMovement(cmi, timeToTarget);    }    else if (GetMiscTemplate()->HasSplines())    {        InitSplineOffsets(GetMiscTemplate()->SplinePoints, timeToTarget);    }    // movement on transport of areatriggers on unit is handled by themself    Transport* transport = m_movementInfo.transport.guid.IsEmpty() ? caster->GetTransport() : nullptr;    if (transport)    {        float x, y, z, o;        pos.GetPosition(x, y, z, o);        transport->CalculatePassengerOffset(x, y, z, &o);        m_movementInfo.transport.pos.Relocate(x, y, z, o);        // This object must be added to transport before adding to map for the client to properly display it        transport->AddPassenger(this);    }    AI_Initialize();    // Relocate areatriggers with circular movement again    if (HasCircularMovement())        Relocate(CalculateCircularMovementPosition());    if (!GetMap()->AddToMap(this))    {        // Returning false will cause the object to be deleted - remove from transport        if (transport)            transport->RemovePassenger(this);        return false;    }    caster->_RegisterAreaTrigger(this);    _ai->OnCreate();    return true;}
开发者ID:Rochet2,项目名称:TrinityCore,代码行数:100,


示例21: SetInstanceId

bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius ){    SetInstanceId(caster->GetInstanceId());    WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetMapId());    Relocate(x,y,z,0);    if(!IsPositionValid())    {        sLog.outError("ERROR: DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());        return false;    }    SetEntry(spellId);    SetFloatValue( OBJECT_FIELD_SCALE_X, 1 );    SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() );    SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 );    SetUInt32Value( DYNAMICOBJECT_SPELLID, spellId );    SetFloatValue( DYNAMICOBJECT_RADIUS, radius);    SetFloatValue( DYNAMICOBJECT_POS_X, x );    SetFloatValue( DYNAMICOBJECT_POS_Y, y );    SetFloatValue( DYNAMICOBJECT_POS_Z, z );    SetUInt32Value( DYNAMICOBJECT_CASTTIME, getMSTime() );  // new 2.4.0    m_aliveDuration = duration;    m_radius = radius;    m_effIndex = effIndex;    m_spellId = spellId;    m_casterGuid = caster->GetGUID();    return true;}
开发者ID:Actionfox,项目名称:mangos,代码行数:31,


示例22: 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(lowguid, 0, HIGHGUID_CORPSE);    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);    SetOwnerGuid(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());//.........这里部分代码省略.........
开发者ID:krullgor,项目名称:mangos-wotlk,代码行数:101,


示例23: GetPositionInTilesCoordsX

int Player::GetPositionInTilesCoordsX() const{	return static_cast<int>(GetPositionX() / TILE_SIZE);}
开发者ID:PiGames,项目名称:Bomberman,代码行数:4,


示例24: SetMap

bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius ){    WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());    SetMap(caster->GetMap());    Relocate(x, y, z, 0);    if(!IsPositionValid())    {        sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());        return false;    }    SetEntry(spellId);    SetObjectScale(DEFAULT_OBJECT_SCALE);    SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetObjectGuid());    /* Bytes field, so it's really 4 bit fields. These flags are unknown, but we do know that 0x00000001 is set for most.       Farsight for example, does not have this flag, instead it has 0x80000002.       Flags are set dynamically with some conditions, so one spell may have different flags set, depending on those conditions.       The size of the visual may be controlled to some degree with these flags.    uint32 bytes = 0x00000000;    bytes |= 0x01;    bytes |= 0x00 << 8;    bytes |= 0x00 << 16;    bytes |= 0x00 << 24;    */    SetUInt32Value(DYNAMICOBJECT_BYTES, 0x00000001);    SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);    SetFloatValue(DYNAMICOBJECT_RADIUS, radius);    SetUInt32Value(DYNAMICOBJECT_CASTTIME, WorldTimer::getMSTime());    // new 2.4.0    m_aliveDuration = duration;    m_radius = radius;    m_effIndex = effIndex;    m_spellId = spellId;    m_positive = IsPositiveEffect(m_spellId, m_effIndex);    return true;}
开发者ID:MgCore,项目名称:Mangos_Cataclysm,代码行数:42,


示例25: SetMap

bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type){    SetMap(caster->GetMap());    Relocate(pos);    if (!IsPositionValid())    {        sLog->outError("DynamicObject (spell %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, GetPositionX(), GetPositionY());        return false;    }    WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());    SetEntry(spellId);    SetFloatValue(OBJECT_FIELD_SCALE_X, 1);    SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID());    // The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden    // by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane.    // If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but    // precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells    // I saw sniffed...    SetByteValue(DYNAMICOBJECT_BYTES, 0, type);    SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);    SetFloatValue(DYNAMICOBJECT_RADIUS, radius);    SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());    m_isWorldObject = active;	if (active)		setActive(true);    //must before add to map to be put in world container	if (!GetMap()->AddToMap(this))		return false;    return true;}
开发者ID:glararan,项目名称:TrinityCore,代码行数:35,



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


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