这篇教程C++ GetMap函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetMap函数的典型用法代码示例。如果您正苦于以下问题:C++ GetMap函数的具体用法?C++ GetMap怎么用?C++ GetMap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetMap函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: cellvoid MapManager::LoadGrid(int mapid, float x, float y, const WorldObject* obj, bool no_unload){ CellPair p = MaNGOS::ComputeCellPair(x,y); Cell cell(p); GetMap(mapid, obj)->LoadGrid(cell,no_unload);}
开发者ID:Artea,项目名称:mangos-svn,代码行数:6,
示例2: SetMapbool 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,
示例3: resultvoid CUser::SelectCharacter(Packet & pkt){ Packet result(WIZ_SEL_CHAR); uint8 bResult, bInit; if (isBanned()) { Disconnect(); return; } pkt >> bResult >> bInit; result << bResult; if (bResult == 0 || !GetZoneID()) goto fail_return; m_pMap = g_pMain->GetZoneByID(GetZoneID()); if (GetMap() == nullptr) goto fail_return; if (g_pMain->m_nServerNo != GetMap()->m_nServerNo) { _ZONE_SERVERINFO *pInfo = g_pMain->m_ServerArray.GetData(GetMap()->m_nServerNo); if (pInfo == nullptr) goto fail_return; SendServerChange(pInfo->strServerIP, bInit); return; } if (!g_pMain->isWarOpen() && GetFame() == COMMAND_CAPTAIN) m_bFame = CHIEF; // Disallow players from relogging in the opposite nation's home zone when an invasion's not running. if (((GetZoneID() != GetNation() && GetZoneID() <= ZONE_ELMORAD && !g_pMain->m_byBattleOpen) // also disallow players from logging back into war zones that aren't currently active... || (GetMap()->isWarZone() && !g_pMain->m_byBattleOpen) // Chaos, bdw and juraid montuain || isInTempleEventZone() // Ronark Land, Ardream, RLB, Bifrost, Krowaz Dominion. || (g_pMain->m_byBattleOpen && (GetZoneID() == ZONE_RONARK_LAND || GetZoneID() == ZONE_ARDREAM || GetZoneID() == ZONE_RONARK_LAND_BASE || GetZoneID() == ZONE_BIFROST || GetZoneID() == ZONE_KROWAZ_DOMINION))) && !isGM()) { NativeZoneReturn(); Disconnect(); return; } SetLogInInfoToDB(bInit); result << GetZoneID() << GetSPosX() << GetSPosZ() << GetSPosY() << g_pMain->m_byOldVictory; m_bSelectedCharacter = true; Send(&result); SetUserAbility(false); if (GetLevel() > MAX_LEVEL) { Disconnect(); return; } m_iMaxExp = g_pMain->GetExpByLevel(GetLevel()); SetRegion(GetNewRegionX(), GetNewRegionZ()); if (GetClanID() == -1) { SetClanID(0); m_bFame = 0; return; } else if (GetClanID() != 0 && GetZoneID() > 2) { result.Initialize(WIZ_KNIGHTS_PROCESS); result << uint8(KNIGHTS_LIST_REQ) << GetClanID(); g_pMain->AddDatabaseRequest(result, this); } return;fail_return: Send(&result);}
开发者ID:sailei1,项目名称:X-ShieldProject,代码行数:87,
示例4: GetInstanceIdvoid DungeonPersistentState::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry){ DungeonEncounterMapBounds bounds = sObjectMgr.GetDungeonEncounterBounds(creditEntry); for (DungeonEncounterMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) { DungeonEncounterEntry const* dbcEntry = iter->second->dbcEntry; if (iter->second->creditType == type && Difficulty(dbcEntry->Difficulty) == GetDifficulty() && dbcEntry->mapId == GetMapId()) { m_completedEncountersMask |= 1 << dbcEntry->encounterIndex; CharacterDatabase.PExecute("UPDATE instance SET encountersMask = '%u' WHERE id = '%u'", m_completedEncountersMask, GetInstanceId()); DEBUG_LOG("DungeonPersistentState: Dungeon %s (Id %u) completed encounter %s", GetMap()->GetMapName(), GetInstanceId(), dbcEntry->encounterName[sWorld.GetDefaultDbcLocale()]); if (/*uint32 dungeonId =*/ iter->second->lastEncounterDungeon) { DEBUG_LOG("DungeonPersistentState:: Dungeon %s (Instance-Id %u) completed last encounter %s", GetMap()->GetMapName(), GetInstanceId(), dbcEntry->encounterName[sWorld.GetDefaultDbcLocale()]); // Place LFG reward here } return; } }}
开发者ID:krullgor,项目名称:mangos-tbc,代码行数:24,
示例5: GetMapbool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z){ Map const* oldMap = GetMap(); if (oldMap->GetId() != newMapid) { Map* newMap = sMapMgr->CreateBaseMap(newMapid); Map::PlayerList const& oldPlayers = GetMap()->GetPlayers(); if (!oldPlayers.isEmpty()) { UpdateData data(GetMapId()); BuildOutOfRangeUpdateBlock(&data); WorldPacket packet; data.BuildPacket(&packet); for (Map::PlayerList::const_iterator itr = oldPlayers.begin(); itr != oldPlayers.end(); ++itr) if (itr->GetSource()->GetTransport() != this) itr->GetSource()->SendDirectMessage(&packet); } UnloadStaticPassengers(); GetMap()->RemoveFromMap<Transport>(this, false); SetMap(newMap); Map::PlayerList const& newPlayers = GetMap()->GetPlayers(); if (!newPlayers.isEmpty()) { for (Map::PlayerList::const_iterator itr = newPlayers.begin(); itr != newPlayers.end(); ++itr) { if (itr->GetSource()->GetTransport() != this) { UpdateData data(newMapid); BuildCreateUpdateBlockForPlayer(&data, itr->GetSource()); WorldPacket packet; data.BuildPacket(&packet); itr->GetSource()->SendDirectMessage(&packet); } } } for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();) { WorldObject* obj = (*itr++); float destX, destY, destZ, destO; obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO); TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation()); switch (obj->GetTypeId()) { case TYPEID_PLAYER: if (!obj->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT)) _passengers.erase(obj); break; default: RemovePassenger(obj); break; } } Relocate(x, y, z, GetOrientation()); GetMap()->AddToMap<Transport>(this); return true; } else { UpdatePosition(x, y, z, GetOrientation()); return false; }}
开发者ID:Caydan,项目名称:WoWSCore548,代码行数:69,
示例6: switch//.........这里部分代码省略......... { 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( !GetGoState() ) 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 GetMap()->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 if(m_cooldownTime >= time(NULL)) return; bool IsBattleGroundTrap = false; //FIXME: this is activation radius (in different casting radius that must be selected from spell data) //TODO: move activated state code (cast itself) to GO_ACTIVATED, in this place only check activating and set state float radius = goInfo->trap.radius; if(!radius) { if(goInfo->trap.cooldown != 3) // cast in other case (at some triggering/linked go/etc explicit call) return; else { if(m_respawnTime > 0) break; radius = goInfo->trap.cooldown; // battlegrounds gameobjects has data2 == 0 && data5 == 3 IsBattleGroundTrap = true; }
开发者ID:Actionfox,项目名称:mangos,代码行数:67,
示例7: IsMapbool EscValue::HasNumberField(const char *id) const{ return IsMap() && GetMap().Find(id) >= 0;}
开发者ID:ultimatepp,项目名称:mirror,代码行数:4,
示例8: GetSkillValuebool Player::OnSurvey(uint32& entry, float& x, float& y, float& z, float &orientation){ entry = 0; uint16 skill_now = GetSkillValue(SKILL_ARCHAEOLOGY); if (!skill_now) return false; uint16 site_id = GetResearchSiteID(); if (!site_id) return false; uint8 i = 0; for(; i < MAX_RESEARCH_SITES; ++i) if (GetUInt16Value(PLAYER_FIELD_RESERACH_SITE_1 + i / 2, i % 2) == site_id) break; MANGOS_ASSERT(i < MAX_RESEARCH_SITES); DigSite &site = _digSites[i]; if (site.site_id != site_id) { if (!GenerateDigSiteLoot(site_id, site)) return false; site.site_id = site_id; } orientation = GetAngle(site.loot_x, site.loot_y); float dist_now = GetDistance2d(site.loot_x, site.loot_y); if (dist_now >= ARCHAEOLOGY_DIG_SITE_FAR_DIST) { entry = GO_FAR_SURVEYBOT; return false; } if (dist_now >= ARCHAEOLOGY_DIG_SITE_MED_DIST) { entry = GO_MEDIUM_SURVEYBOT; return false; } if (dist_now >= ARCHAEOLOGY_DIG_SITE_FIND_DIST) { entry = GO_CLOSE_SURVEYBOT; return false; } if (skill_now < 50) UpdateSkill(SKILL_ARCHAEOLOGY, 1); entry = site.find_id; x = site.loot_x; y = site.loot_y; z = GetMap()->GetTerrain()->GetHeightStatic(x, y, GetPositionZ(), true, 5); if (site.count < 2) { ++site.count; if (!GenerateDigSiteLoot(site_id, site)) return true; } else { site.clear(); UseResearchSite(site_id); } _archaeologyChanged = true; return true;}
开发者ID:Jojo2323,项目名称:mangos3,代码行数:71,
示例9: GMsvoid CUser::Chat(Packet & pkt){ Packet result; uint16 sessID; uint8 type = pkt.read<uint8>(), bNation; string chatstr, finalstr, strSender, * strMessage; bool isAnnouncement = false; if (isMuted()) return; pkt >> chatstr; if (chatstr.empty() || chatstr.size() > 128) return; // Process GM commands if (isGM() && ProcessChatCommand(chatstr)) return;#if 0 // Removed this - all it seems to do is cause chat to break for GMs (is it 19xx+ only?) if( isGM() && type == GENERAL_CHAT) type = 0x14;#endif // Handle GM notice & announcement commands if (type == PUBLIC_CHAT || type == ANNOUNCEMENT_CHAT) { // Trying to use a GM command without authorisation? Bad player! if (!isGM()) return; if (type == ANNOUNCEMENT_CHAT) type = WAR_SYSTEM_CHAT; // This is horrible, but we'll live with it for now. // Pull the notice string (#### NOTICE : %s ####) from the database. // Format the chat string around it, so our chat data is within the notice g_pMain->GetServerResource(IDP_ANNOUNCEMENT, &finalstr, chatstr.c_str()); isAnnouncement = true; } if (isAnnouncement) { // GM notice/announcements show no name, so don't bother setting it. strMessage = &finalstr; // use the formatted message from the user bNation = KARUS; // arbitrary nation sessID = -1; } else { strMessage = &chatstr; // use the raw message from the user strSender = GetName(); // everything else uses a name, so set it bNation = GetNation(); sessID = GetSocketID(); } ChatPacket::Construct(&result, type, strMessage, &strSender, bNation, sessID); switch (type) { case GENERAL_CHAT: g_pMain->Send_NearRegion(&result, GetMap(), GetRegionX(), GetRegionZ(), GetX(), GetZ()); break; case PRIVATE_CHAT: { CUser *pUser = g_pMain->GetUserPtr(m_sPrivateChatUser); if (pUser != nullptr) pUser->Send(&result); } break; case PARTY_CHAT: if (isInParty()) g_pMain->Send_PartyMember(m_sPartyIndex, &result); break; case SHOUT_CHAT: if (m_sMp < (m_iMaxMp / 5)) break; // Characters under level 35 require 3,000 coins to shout. if (!isGM() && GetLevel() < 35 && !GoldLose(SHOUT_COIN_REQUIREMENT)) break; MSpChange(-(m_iMaxMp / 5)); SendToRegion(&result); break; case KNIGHTS_CHAT: if (isInClan()) g_pMain->Send_KnightsMember(GetClanID(), &result); break; case PUBLIC_CHAT: case ANNOUNCEMENT_CHAT: if (isGM()) g_pMain->Send_All(&result);//.........这里部分代码省略.........
开发者ID:Kocu,项目名称:snoxd-koserver,代码行数:101,
示例10: AIvoid 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 % GetTransportPeriod(); bool justStopped = false; // 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); 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 {//.........这里部分代码省略.........
开发者ID:Asandru,项目名称:TrinityCore,代码行数:101,
示例11: switchvoid 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:de-dima,项目名称:243,代码行数:101,
示例12: Unwindbool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { if (GetMap() == nullptr) { // Without a map object, we can't do anything. error_ = BACKTRACE_UNWIND_ERROR_MAP_MISSING; return false; } error_ = BACKTRACE_UNWIND_NO_ERROR; if (ucontext) { BACK_LOGW("Unwinding from a specified context not supported yet."); error_ = BACKTRACE_UNWIND_ERROR_UNSUPPORTED_OPERATION; return false; } if (!Init()) { return false; } unw_cursor_t cursor; int ret = unw_init_remote(&cursor, addr_space_, upt_info_); if (ret < 0) { BACK_LOGW("unw_init_remote failed %d", ret); error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED; return false; } size_t num_frames = 0; do { unw_word_t pc; ret = unw_get_reg(&cursor, UNW_REG_IP, &pc); if (ret < 0) { BACK_LOGW("Failed to read IP %d", ret); break; } unw_word_t sp; ret = unw_get_reg(&cursor, UNW_REG_SP, &sp); if (ret < 0) { BACK_LOGW("Failed to read SP %d", ret); break; } if (num_ignore_frames == 0) { frames_.resize(num_frames+1); backtrace_frame_data_t* frame = &frames_.at(num_frames); frame->num = num_frames; frame->pc = static_cast<uintptr_t>(pc); frame->sp = static_cast<uintptr_t>(sp); frame->stack_size = 0; if (num_frames > 0) { backtrace_frame_data_t* prev = &frames_.at(num_frames-1); prev->stack_size = frame->sp - prev->sp; } FillInMap(frame->pc, &frame->map); if (BacktraceMap::IsValid(frame->map)) { frame->rel_pc = frame->pc - frame->map.start + frame->map.load_bias; } else { frame->rel_pc = frame->pc; } frame->func_name = GetFunctionName(frame->pc, &frame->func_offset, &frame->map); num_frames++; // If the pc is in a device map, then don't try to step. if (frame->map.flags & PROT_DEVICE_MAP) { break; } } else { // If the pc is in a device map, then don't try to step. backtrace_map_t map; FillInMap(pc, &map); if (map.flags & PROT_DEVICE_MAP) { break; } num_ignore_frames--; } // Verify the sp is not in a device map. backtrace_map_t map; FillInMap(sp, &map); if (map.flags & PROT_DEVICE_MAP) { break; } ret = unw_step (&cursor); } while (ret > 0 && num_frames < MAX_BACKTRACE_FRAMES); return true;}
开发者ID:BenzoRoms,项目名称:system_core,代码行数:89,
示例13: GetMapbool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, float o){ Map const* oldMap = GetMap(); if (oldMap->GetId() != newMapid) { Map* newMap = sMapMgr->CreateBaseMap(newMapid); UnloadStaticPassengers(); GetMap()->RemoveFromMap<Transport>(this, false); SetMap(newMap); for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();) { WorldObject* obj = (*itr++); float destX, destY, destZ, destO; obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO); TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o); switch (obj->GetTypeId()) { case TYPEID_UNIT: if (!IS_PLAYER_GUID(obj->ToUnit()->GetOwnerGUID())) // pets should be teleported with player obj->ToCreature()->FarTeleportTo(newMap, destX, destY, destZ, destO); break; case TYPEID_GAMEOBJECT: { GameObject* go = obj->ToGameObject(); go->GetMap()->RemoveFromMap(go, false); go->Relocate(destX, destY, destZ, destO); go->SetMap(newMap); newMap->AddToMap(go); break; } case TYPEID_PLAYER: if (!obj->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT)) _passengers.erase(obj); break; case TYPEID_DYNAMICOBJECT: obj->AddObjectToRemoveList(); break; default: break; } } Relocate(x, y, z, o); UpdateModelPosition(); GetMap()->AddToMap<Transport>(this); return true; } else { // Teleport players, they need to know it for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr) { if ((*itr)->GetTypeId() == TYPEID_PLAYER) { float destX, destY, destZ, destO; (*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO); TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o); (*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO); } } UpdatePosition(x, y, z, o); return false; }}
开发者ID:BravadoToDeath,项目名称:ArkCORE-NG,代码行数:70,
示例14: AIvoid 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,
示例15: PathBuildint PathBuild(void* data){ auto enemy = static_cast<Enemy*>(data); std::vector<Vector2D> result; auto m_searchPath = enemy->GetSearhPath(); if(m_searchPath.size() > 0) { std::vector<std::pair<Vector2D, Vector2D>> path; Vector2D prev = m_searchPath[0]; for(int i=1; i<m_searchPath.size(); i++) { auto first = prev; auto second = m_searchPath[i]; prev = second; std::pair<Vector2D, Vector2D> pair(first, second); path.push_back(pair); } for(auto v : path) { auto first = v.first; first.x *= enemy->GetMap()->GetTileWidth(); first.y *= enemy->GetMap()->GetTileHeight(); first.x += ENEMY_SPRITE_SIZE/2; first.y += ENEMY_SPRITE_SIZE/2; auto last = v.second; last.x *= enemy->GetMap()->GetTileWidth(); last.y *= enemy->GetMap()->GetTileHeight(); last.x += ENEMY_SPRITE_SIZE/2; last.y += ENEMY_SPRITE_SIZE/2; auto slope = 1; if(last.x-first.x != 0) { slope = (last.y-first.y)/(last.x-first.x); } bool normalX = (first.x <= last.x) ? true : false; bool normalY = (first.y <= last.y) ? true : false; if(normalX) { for(int x=first.x; x<last.x; x++) { auto y=slope*(x-first.x)+first.y; result.push_back(Vector2D(x, y)); } } else { for(int x=first.x; x>last.x; x--) { auto y=slope*(x-first.x)+first.y; result.push_back(Vector2D(x, y)); } } if(slope==1) { if(normalY) { for(int y=first.y; y<last.y; y++) { result.push_back(Vector2D(first.x, y)); } } else { for(int y=first.y; y>last.y; y--) { result.push_back(Vector2D(first.x, y)); } } } } } enemy->SetPathBuildResult(result); return 1;}
开发者ID:zulis,项目名称:Platformer,代码行数:87,
示例16: ASSERTvoid CUser::Regene(uint8 regene_type, uint32 magicid /*= 0*/){ ASSERT(GetMap() != nullptr); _OBJECT_EVENT* pEvent = nullptr; _HOME_INFO* pHomeInfo = nullptr; float x = 0.0f, z = 0.0f; if (!isDead()) return; if (regene_type != 1 && regene_type != 2) regene_type = 1; if (regene_type == 2) { magicid = 490041; // The Stone of Ressurection magic ID // Is our level high enough to be able to resurrect using this skill? if (GetLevel() <= 5 // Do we have enough resurrection stones? || !RobItem(379006000, 3 * GetLevel())) return; } // If we're in a home zone, we'll want the coordinates from there. Otherwise, assume our own home zone. pHomeInfo = g_pMain->m_HomeArray.GetData(GetZoneID() <= ZONE_ELMORAD ? GetZoneID() : GetNation()); if (pHomeInfo == nullptr) return; UserInOut(INOUT_OUT); pEvent = GetMap()->GetObjectEvent(m_sBind); // If we're not using a spell to resurrect. if (magicid == 0) { // Resurrect at a bind/respawn point if (pEvent != nullptr && pEvent->byLife == 1) { SetPosition(pEvent->fPosX + x, 0.0f, pEvent->fPosZ + z); } // Are we trying to respawn in a home zone? else if (GetZoneID() <= ZONE_ELMORAD) { // Use the proper respawn area for our nation, as the opposite nation can // enter this zone at a war's invasion stage. if (GetNation() == KARUS) { x = (float)(pHomeInfo->KarusZoneX + myrand(0, pHomeInfo->KarusZoneLX)); z = (float)(pHomeInfo->KarusZoneZ + myrand(0, pHomeInfo->KarusZoneLZ)); } else { x = (float)(pHomeInfo->ElmoZoneX + myrand(0, pHomeInfo->ElmoZoneLX)); z = (float)(pHomeInfo->ElmoZoneZ + myrand(0, pHomeInfo->ElmoZoneLZ)); } } else { // If we're in a war zone (aside from snow wars, which apparently use different coords), use BattleZone coordinates. if (GetZoneID() != ZONE_SNOW_BATTLE && GetZoneID() == (ZONE_BATTLE_BASE + g_pMain->m_byBattleZone)) { x = (float)(pHomeInfo->BattleZoneX + myrand(0, pHomeInfo->BattleZoneLX)); z = (float)(pHomeInfo->BattleZoneZ + myrand(0, pHomeInfo->BattleZoneLZ)); } // If we died in the Moradon arena, we need to spawn near the Arena. else if (GetZoneID() == ZONE_MORADON && isInArena()) { x = (float)(MINI_ARENA_RESPAWN_X + myrand(-MINI_ARENA_RESPAWN_RADIUS, MINI_ARENA_RESPAWN_RADIUS)); z = (float)(MINI_ARENA_RESPAWN_Z + myrand(-MINI_ARENA_RESPAWN_RADIUS, MINI_ARENA_RESPAWN_RADIUS)); } // For all else, just grab the start position (/town coordinates) from the START_POSITION table. else { short sx, sz; GetStartPosition(sx, sz); x = sx; z = sz; } } SetPosition(x, 0.0f, z); m_bResHpType = USER_STANDING; m_bRegeneType = REGENE_NORMAL; } else // we're respawning using a resurrect skill. { _MAGIC_TYPE5 * pType = g_pMain->m_Magictype5Array.GetData(magicid); if (pType == nullptr) return; MSpChange(-m_iMaxMp); // reset us to 0 MP. if (m_sWhoKilledMe == -1) ExpChange((m_iLostExp * pType->bExpRecover) / 100); // Restore //.........这里部分代码省略.........
开发者ID:drCihaTKAYA,项目名称:koserver,代码行数:101,
示例17: GetMapvoid Transport::CheckForEvent(uint32 entry, uint32 wp_id){ uint32 key = entry*100+wp_id; if (sObjectMgr->TransportEventMap.find(key) != sObjectMgr->TransportEventMap.end()) GetMap()->ScriptsStart(sEventScripts, sObjectMgr->TransportEventMap[key], this, NULL);}
开发者ID:Bootz,项目名称:SF1,代码行数:6,
示例18: GetPlayerInput//-------------------------------- Update -------------------------------------//// calls the update function of each entity//-----------------------------------------------------------------------------void Raven_Game::Update(){ //don't update if the user has paused the game if (m_bPaused) return; m_pGraveMarkers->Update(); //get any player keyboard input GetPlayerInput(); //update all the queued searches in the path manager m_pPathManager->UpdateSearches(); //update any doors std::vector<Raven_Door*>::iterator curDoor =m_pMap->GetDoors().begin(); for (curDoor; curDoor != m_pMap->GetDoors().end(); ++curDoor) { (*curDoor)->Update(); } //update any current projectiles std::list<Raven_Projectile*>::iterator curW = m_Projectiles.begin(); while (curW != m_Projectiles.end()) { //test for any dead projectiles and remove them if necessary if (!(*curW)->isDead()) { (*curW)->Update(); ++curW; } else { delete *curW; curW = m_Projectiles.erase(curW); } } //update the bots bool bSpawnPossible = true; std::list<Raven_Bot*>::iterator curBot = m_Bots.begin(); for (curBot; curBot != m_Bots.end(); ++curBot) { //if this bot's status is 'respawning' attempt to resurrect it from //an unoccupied spawn point if ((*curBot)->isSpawning() && bSpawnPossible) { bSpawnPossible = AttemptToAddBot(*curBot); } //if this bot's status is 'dead' add a grave at its current location //then change its status to 'respawning' else if ((*curBot)->isDead()) { //create a grave GraveMarkers::GraveRecord grave = m_pGraveMarkers->AddGrave((*curBot)->Pos(), (*curBot)->GetTeamId(), (*curBot)->GetWeaponSys()->GetCurrentWeaponId()); GraveMarkers::GraveRecord* gravePtr = ` if ((*curBot)->GetWeaponSys()->GetCurrentWeaponId() != 0) { GetMap()->AddTeam_Giver((*curBot)->GetTeamId(), (*curBot)->GetWeaponSys()->GetCurrentWeaponId(), (*curBot)->Pos(), (*curBot)->GetPathPlanner()->GetClosestNodeToPosition((*curBot)->Pos()), grave); } std::list<Raven_Bot*>::iterator curBot2 = m_Bots.begin(); for (curBot2; curBot2 != m_Bots.end(); ++curBot2) { //send a message to all my team if ((*curBot2)->GetTeamId() == (*curBot)->GetTeamId()) { Dispatcher->DispatchMsg(SEND_MSG_IMMEDIATELY, (*curBot)->ID(), (*curBot2)->ID(), Msg_IWasKilledAndIHadWeapons, (void*)gravePtr); //debug_con << "Bot " << ttos((*curBot)->ID()) << " : I'm dead : team (" << ttos(gravePtr->teamId) << ") "; } } //change its status to spawning (*curBot)->SetSpawning(); } //if this bot is alive update it. else if ( (*curBot)->isAlive()) { (*curBot)->Update();//.........这里部分代码省略.........
开发者ID:armagone,项目名称:Logique-Floue,代码行数:101,
示例19: LTIMINGEscValue EscValue::MapGet(EscValue key) const{ LTIMING("MapGet"); return GetMap().Get(key, EscValue());}
开发者ID:ultimatepp,项目名称:mirror,代码行数:5,
示例20: GetCreatureAddonvoid 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,
示例21: mainintmain (int argc,char *argv[]){ static VString filename = ""; static VString filename1 = ""; static VString filename2 = ""; static VShort first = 2; static VShort length = 0; static VShort type = 0; static VShort minval = 0; static VShort nproc = 4; static VOptionDescRec options[] = { {"in1",VStringRepn,1,(VPointer) &filename1,VRequiredOpt,NULL,"first input file"}, {"in2",VStringRepn,1,(VPointer) &filename2,VRequiredOpt,NULL,"second input file"}, {"mask",VStringRepn,1,(VPointer) &filename,VRequiredOpt,NULL,"mask"}, {"type",VShortRepn,1,(VPointer) &type,VOptionalOpt,TYPDict,"type of concordance measure"}, {"minval",VShortRepn,1,(VPointer) &minval,VOptionalOpt,NULL,"signal threshold"}, {"first",VShortRepn,1,(VPointer) &first,VOptionalOpt,NULL,"first timestep to use"}, {"length",VShortRepn,1,(VPointer) &length,VOptionalOpt,NULL, "length of time series to use, '0' to use full length"}, {"j",VShortRepn,1,(VPointer) &nproc,VOptionalOpt,NULL,"number of processors to use, '0' to use all"} }; FILE *out_file,*fp; VAttrList list=NULL,list1=NULL,list2=NULL,out_list=NULL; VAttrListPosn posn; VImage mask=NULL,map=NULL,dest=NULL,disc=NULL; float *A1=NULL,*A2=NULL,u=0,tiny=1.0e-6; int b,r,c; char *prg = "vccm2"; VParseFilterCmd (VNumber (options),options,argc,argv,NULL,&out_file); if (type > 3) VError("illegal type"); /* ** read mask */ fp = VOpenInputFile (filename, TRUE); list = VReadFile (fp, NULL); if (! list) VError("Error reading mask file"); fclose(fp); for (VFirstAttr (list, & posn); VAttrExists (& posn); VNextAttr (& posn)) { if (VGetAttrRepn (& posn) != VImageRepn) continue; VGetAttrValue (& posn, NULL,VImageRepn, & mask); if (VPixelRepn(mask) == VFloatRepn || VPixelRepn(mask) == VDoubleRepn) { mask = NULL; continue; } } if (mask == NULL) VError(" no mask found"); /* read files */ fp = VOpenInputFile (filename1, TRUE); list1 = VReadFile (fp, NULL); if (! list1) VError("Error reading 1st input file"); fclose(fp); fp = VOpenInputFile (filename2, TRUE); list2 = VReadFile (fp, NULL); if (! list2) VError("Error reading 2nd input file"); fclose(fp); /* get voxel map */ map = GetMap(list1,list2,mask,minval); /* omp-stuff */#ifdef _OPENMP int num_procs=omp_get_num_procs(); if (nproc > 0 && nproc < num_procs) num_procs = nproc; printf("using %d cores/n",(int)num_procs); omp_set_num_threads(num_procs);#endif /* _OPENMP */ /* compute corr matrices */ A1 = VCorrMatrix(list1,map,first,length); A2 = VCorrMatrix(list2,map,first,length); /* get concordance between two corr matrices */ dest = VCCM2(A1,A2,map,(int)type); /* invert to get discordant map */ disc = VCreateImageLike(dest); VFillImage(disc,VAllBands,0); if (type < 2) { for (b=0; b<VImageNBands(dest); b++) { for (r=0; r<VImageNRows(dest); r++) { for (c=0; c<VImageNColumns(dest); c++) { if (VGetPixel(mask,b,r,c) < 1) continue; u = VPixel(dest,b,r,c,VFloat); if (u < tiny) continue; VPixel(disc,b,r,c,VFloat) = 1-u; } //.........这里部分代码省略.........
开发者ID:hahtse,项目名称:Lipsia,代码行数:101,
示例22: AIvoid 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; 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) SetGoState(GO_STATE_READY); break; // its a stop frame and we are waiting } } if (_pendingStop && timer >= _currentFrame->DepartureTime && GetGoState() == GO_STATE_READY) { m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod()); m_goValue.Transport.PathProgress *= GetPeriod(); m_goValue.Transport.PathProgress += _currentFrame->ArriveTime; break; } if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent) { DoEventIfAny(*_currentFrame, true); // departure event _triggeredDepartureEvent = true; } if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime) break; // found current waypoint MoveToNextWaypoint(); // not waiting anymore SetMoving(true); // Enable movement if (GetGOInfo()->moTransport.canBeStopped) SetGoState(GO_STATE_ACTIVE); 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)) 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 = 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.x, dir.y)); } } sScriptMgr->OnTransportUpdate(this, diff);}
开发者ID:Caydan,项目名称:WoWSCore548,代码行数:100,
示例23: GetMapbool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z){ Map const* oldMap = GetMap(); if (oldMap->GetId() != newMapid) { Map* newMap = sMapMgr->CreateBaseMap(newMapid); Map::PlayerList const& oldPlayers = GetMap()->GetPlayers(); if (!oldPlayers.isEmpty()) { UpdateData data; BuildOutOfRangeUpdateBlock(&data); WorldPacket packet; data.BuildPacket(&packet); for (Map::PlayerList::const_iterator itr = oldPlayers.begin(); itr != oldPlayers.end(); ++itr) if (itr->GetSource()->GetTransport() != this) itr->GetSource()->SendDirectMessage(&packet); } UnloadStaticPassengers(); GetMap()->RemoveFromMap<Transport>(this, false); SetMap(newMap); Map::PlayerList const& newPlayers = GetMap()->GetPlayers(); if (!newPlayers.isEmpty()) { for (Map::PlayerList::const_iterator itr = newPlayers.begin(); itr != newPlayers.end(); ++itr) { if (itr->GetSource()->GetTransport() != this) { UpdateData data; BuildCreateUpdateBlockForPlayer(&data, itr->GetSource()); WorldPacket packet; data.BuildPacket(&packet); itr->GetSource()->SendDirectMessage(&packet); } } } for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();) { WorldObject* obj = (*itr++); float destX, destY, destZ, destO; obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO); TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation()); switch (obj->GetTypeId()) { case TYPEID_UNIT: if (!IS_PLAYER_GUID(obj->ToUnit()->GetOwnerGUID())) // pets should be teleported with player obj->ToCreature()->FarTeleportTo(newMap, destX, destY, destZ, destO); break; case TYPEID_GAMEOBJECT: { GameObject* go = obj->ToGameObject(); go->GetMap()->RemoveFromMap(go, false); go->Relocate(destX, destY, destZ, destO); go->SetMap(newMap); newMap->AddToMap(go); break; } case TYPEID_PLAYER: if (!obj->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT)) _passengers.erase(obj); break; default: break; } } Relocate(x, y, z, GetOrientation()); GetMap()->AddToMap<Transport>(this); return true; } else { // Teleport players, they need to know it for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr) { if ((*itr)->GetTypeId() == TYPEID_PLAYER) { float destX, destY, destZ, destO; (*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO); TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation()); (*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO); } } UpdatePosition(x, y, z, GetOrientation()); return false; }}
开发者ID:MICHAL53Q,项目名称:TrinityCore,代码行数:94,
示例24: int32void AreaTrigger::UpdateSplinePosition(uint32 diff){ if (_reachedDestination) return; if (!HasSplines()) return; _movementTime += diff; if (_movementTime >= GetTimeToTarget()) { _reachedDestination = true; _lastSplineIndex = int32(_spline->last()); G3D::Vector3 lastSplinePosition = _spline->getPoint(_lastSplineIndex); GetMap()->AreaTriggerRelocation(this, lastSplinePosition.x, lastSplinePosition.y, lastSplinePosition.z, GetOrientation());#ifdef TRINITY_DEBUG DebugVisualizePosition();#endif _ai->OnSplineIndexReached(_lastSplineIndex); _ai->OnDestinationReached(); return; } float currentTimePercent = float(_movementTime) / float(GetTimeToTarget()); if (currentTimePercent <= 0.f) return; if (GetMiscTemplate()->MoveCurveId) { float progress = sDB2Manager.GetCurveValueAt(GetMiscTemplate()->MoveCurveId, currentTimePercent); if (progress < 0.f || progress > 1.f) { TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (Id: %u, SpellMiscId: %u) has wrong progress (%f) caused by curve calculation (MoveCurveId: %u)", GetTemplate()->Id, GetMiscTemplate()->MiscId, progress, GetMiscTemplate()->MorphCurveId); } else currentTimePercent = progress; } int lastPositionIndex = 0; float percentFromLastPoint = 0; _spline->computeIndex(currentTimePercent, lastPositionIndex, percentFromLastPoint); G3D::Vector3 currentPosition; _spline->evaluate_percent(lastPositionIndex, percentFromLastPoint, currentPosition); float orientation = GetOrientation(); if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_FACE_MOVEMENT_DIR)) { G3D::Vector3 const& nextPoint = _spline->getPoint(lastPositionIndex + 1); orientation = GetAngle(nextPoint.x, nextPoint.y); } GetMap()->AreaTriggerRelocation(this, currentPosition.x, currentPosition.y, currentPosition.z, orientation);#ifdef TRINITY_DEBUG DebugVisualizePosition();#endif if (_lastSplineIndex != lastPositionIndex) { _lastSplineIndex = lastPositionIndex; _ai->OnSplineIndexReached(_lastSplineIndex); }}
开发者ID:Rochet2,项目名称:TrinityCore,代码行数:68,
示例25: mainint main(const int argc, const char *argv[]) { if (argc != 4) { std::cout << "ERROR!!! Specify all arguments/n"; std::cout << "Usage:/n"; std::cout << "/tVITDatasetCreator DIR_WITH_ETALONS ALPHABET_FILE OUTPUT_DIR/n"; return 1; } const char *kInputDirectory = argv[1]; const char *kAlphabetFile = argv[2]; const char *kOutputDir = argv[3]; auto alphabet = ReadAlphabetFromFile(kAlphabetFile); for (auto elem : alphabet.GetMap()) { fs::path directory_path = fs::path(kOutputDir) / fs::path(elem.second.name); if (!fs::is_directory(fs::status(directory_path)) && !fs::create_directory(directory_path)) { std::cout << "Can't create directory: " << directory_path << std::endl; return 1; } } std::string process_dir = kInputDirectory; auto img_paths = DirFiles(process_dir, ".jpg"); std::cout << "There are " << img_paths.size() << " images/n"; int processed = 0; for (auto impath : img_paths) { if (processed % 100 == 0) { std::cout << "Processed " << processed << " files of " << img_paths.size() << std::endl; } auto etalon_path = fs::path(impath).replace_extension("txt"); DataInfo dinfo; try { dinfo = ReadEtalonsFromFile(etalon_path.string()); if (0 == dinfo.pinfo.size()) continue; } catch(std::exception &e) { std::cout << "Skip " << impath << ", reason: " << e.what() << std::endl; continue; } //Export file to filesystem cv::Mat original_image = cv::imread(impath.string(), CV_LOAD_IMAGE_GRAYSCALE); for (auto p : dinfo.pinfo) { //std::cout << p.to_string() << std::endl; for (int i = 0; i < p.symbols.size(); i++) { std::string dir_name = alphabet.GetElemName(p.symbols[i].text); if (!dir_name.length()) { std::cout << "Unknown symbol: " << p.symbols[i].text << std::endl; continue; } fs::path output_dir = fs::path(kOutputDir) / fs::path(dir_name); auto save_image = [&output_dir](const cv::Mat& image) { std::string image_name = GetGUID() + ".bmp"; cv::Mat output_image; cv::resize(image, output_image, cv::Size(10, 12), 0, 0, CV_INTER_LANCZOS4); cv::imwrite((output_dir / fs::path(image_name)).c_str(), output_image); }; auto equalize = [](const cv::Mat& image) { cv::Mat result; cv::equalizeHist(image, result); return result; }; auto get_symbol_by_roi = [&original_image](cv::Rect r, int left_pad, int right_pad, int top_pad, int bottom_pad) { cv::Rect new_roi = r; int width = r.width; int height = r.height; new_roi.x = std::max(0, new_roi.x - width * left_pad / 100); new_roi.y = std::max(0, new_roi.y - height * top_pad / 100); int new_x2 = std::min(original_image.cols, r.x + width * (1 + right_pad / 100)); int new_y2 = std::min(original_image.rows, r.y + height * (1 + bottom_pad / 100)); new_roi.width = new_x2 - new_roi.x; new_roi.height = new_y2 - new_roi.y; return original_image(new_roi); }; cv::Rect symbol_roi = p.symbols[i].rect; //todo: rewrite using cycles//.........这里部分代码省略.........
开发者ID:drozdvadym,项目名称:VITDatasetCreator,代码行数:101,
示例26: IsInWorldbool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const{ return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);}
开发者ID:krullgor,项目名称:mangos-wotlk,代码行数:4,
示例27: GetMapvoid MapManager::LoadGrid(int mapid, float x, float y, bool no_unload){ CellPair p = MaNGOS::ComputeCellPair(x,y); Cell cell = RedZone::GetZone(p); GetMap(mapid)->LoadGrid(cell,no_unload);}
开发者ID:Artea,项目名称:mangos-svn,代码行数:6,
示例28: GetMapstd::string UnwindStackPtrace::GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) { return ::GetFunctionName(Pid(), GetMap(), pc, offset);}
开发者ID:BenzoRoms,项目名称:system_core,代码行数:3,
注:本文中的GetMap函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetMapId函数代码示例 C++ GetManager函数代码示例 |