本文整理汇总了C++中Player类的典型用法代码示例。如果您正苦于以下问题:C++ Player类的具体用法?C++ Player怎么用?C++ Player使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DEBUG_LOG
void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
{
uint32 type;
uint32 lang;
recv_data >> type;
recv_data >> lang;
if (type >= MAX_CHAT_MSG_TYPE)
{
sLog.outError("CHAT: Wrong message type received: %u", type);
return;
}
DEBUG_LOG("CHAT: packet received. type %u, lang %u", type, lang);
// prevent talking at unknown language (cheating)
LanguageDesc const* langDesc = GetLanguageDescByID(lang);
if (!langDesc)
{
SendNotification(LANG_UNKNOWN_LANGUAGE);
return;
}
if (langDesc->skill_id != 0 && !_player->HasSkill(langDesc->skill_id))
{
// also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
Unit::AuraList const& langAuras = _player->GetAurasByType(SPELL_AURA_COMPREHEND_LANGUAGE);
bool foundAura = false;
for (Unit::AuraList::const_iterator i = langAuras.begin(); i != langAuras.end(); ++i)
{
if ((*i)->GetModifier()->m_miscvalue == int32(lang))
{
foundAura = true;
break;
}
}
if (!foundAura)
{
SendNotification(LANG_NOT_LEARNED_LANGUAGE);
return;
}
}
if (lang == LANG_ADDON)
{
// Disabled addon channel?
if (!sWorld.getConfig(CONFIG_BOOL_ADDON_CHANNEL))
return;
}
// LANG_ADDON should not be changed nor be affected by flood control
else
{
// send in universal language if player in .gmon mode (ignore spell effects)
if (_player->isGameMaster())
lang = LANG_UNIVERSAL;
else
{
// send in universal language in two side iteration allowed mode
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT))
lang = LANG_UNIVERSAL;
else
{
switch (type)
{
case CHAT_MSG_PARTY:
case CHAT_MSG_RAID:
case CHAT_MSG_RAID_LEADER:
case CHAT_MSG_RAID_WARNING:
// allow two side chat at group channel if two side group allowed
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP))
lang = LANG_UNIVERSAL;
break;
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
// allow two side chat at guild channel if two side guild allowed
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD))
lang = LANG_UNIVERSAL;
break;
}
}
// but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
Unit::AuraList const& ModLangAuras = _player->GetAurasByType(SPELL_AURA_MOD_LANGUAGE);
if (!ModLangAuras.empty())
lang = ModLangAuras.front()->GetModifier()->m_miscvalue;
}
if (type != CHAT_MSG_AFK && type != CHAT_MSG_DND)
{
if (!_player->CanSpeak())
{
std::string timeStr = secsToTimeString(m_muteTime - time(nullptr));
SendNotification(GetMangosString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str());
return;
}
GetPlayer()->UpdateSpeakTime();
}
}
//.........这里部分代码省略.........
示例2: applyEffects
void MagicBottle::applyEffects(Player& entity) {
entity.setMagic(100);
}
示例3: DEBUG_LOG
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
{
DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
uint64 Guid;
recv_data >> Guid;
Player *player = sObjectMgr.GetPlayer(Guid);
if(!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
data.appendPackGUID(Guid);
data << uint32(GROUP_UPDATE_FLAG_STATUS);
data << uint8(MEMBER_STATUS_OFFLINE);
SendPacket(&data);
return;
}
Pet *pet = player->GetPet();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << player->GetPackGUID();
uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
if(pet)
mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
Powers powerType = player->getPowerType();
data << uint32(mask1); // group update mask
data << uint8(MEMBER_STATUS_ONLINE); // member's online status
data << uint16(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint16(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
data << uint8(powerType); // GROUP_UPDATE_FLAG_POWER_TYPE
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
data << uint16(player->GetZoneId()); // GROUP_UPDATE_FLAG_ZONE
data << uint16(player->GetPositionX()); // GROUP_UPDATE_FLAG_POSITION
data << uint16(player->GetPositionY()); // GROUP_UPDATE_FLAG_POSITION
uint32 auramask = 0;
size_t maskPos = data.wpos();
data << uint32(auramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 aura = player->GetUInt32Value(UNIT_FIELD_AURA + i))
{
auramask |= (uint32(1) << i);
data << uint16(aura);
}
}
data.put<uint32>(maskPos,auramask); // GROUP_UPDATE_FLAG_AURAS
if(pet)
{
Powers petpowertype = pet->getPowerType();
data << uint64(pet->GetGUID()); // GROUP_UPDATE_FLAG_PET_GUID
data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
data << uint16(pet->GetDisplayId()); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << uint16(pet->GetHealth()); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << uint16(pet->GetMaxHealth()); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << uint8(petpowertype); // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << uint16(pet->GetPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << uint16(pet->GetMaxPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_MAX_POWER
uint32 petauramask = 0;
size_t petMaskPos = data.wpos();
data << uint32(petauramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 petaura = pet->GetUInt32Value(UNIT_FIELD_AURA + i))
{
petauramask |= (uint32(1) << i);
data << uint16(petaura);
}
}
data.put<uint32>(petMaskPos,petauramask); // GROUP_UPDATE_FLAG_PET_AURAS
}
else
{
data << uint8(0); // GROUP_UPDATE_FLAG_PET_NAME
data << uint32(0); // GROUP_UPDATE_FLAG_PET_AURAS
}
SendPacket(&data);
}
示例4: sendHome
void TaeTurn::doCombatTurn() {
std::set<uint32_t>::iterator itcurr;
Game* game = Game::getGame();
OrderManager* ordermanager = game->getOrderManager();
ObjectManager* objectmanager = game->getObjectManager();
ObjectTypeManager* obtm = game->getObjectTypeManager();
PlayerManager* playermanager = game->getPlayerManager();
containerids.clear();
// Do orders
std::set<uint32_t> objects = objectmanager->getAllIds();
for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
IGObject * ob = objectmanager->getObject(*itcurr);
if(ob->getType() == planettype || ob->getType() == fleettype){
OrderQueueObjectParam* oqop = dynamic_cast<OrderQueueObjectParam*>(ob->getParameterByType(obpT_Order_Queue));
if(oqop != NULL){
OrderQueue* orderqueue = ordermanager->getOrderQueue(oqop->getQueueId());
if(orderqueue != NULL){
Order * currOrder = orderqueue->getFirstOrder();
if(currOrder != NULL){
if(currOrder->doOrder(ob)) {
orderqueue->removeFirstOrder();
} else {
orderqueue->updateFirstOrder();
}
}
if(ob->getContainerType() >= 1){
containerids.insert(ob->getID());
}
objectmanager->doneWithObject((ob)->getID());
}
}
}
}
//Determine winner
uint32_t winner = 0;
uint32_t loser = 0;
for(map<uint32_t, int>::iterator i = strength.begin(); i != strength.end(); ++i) {
if(winner == 0) {
winner = i->first;
} else {
if(strength[winner] < i->second) {
winner = i->first;
} else {
loser = i->first;
}
}
}
//Remove losing combatants
uint32_t losingRegion;
uint32_t winningRegion;
set<uint32_t> removedSystems;
if(isInternal) {
//Internal combat removes losing leader and awards one point to the winner
for(map<uint32_t, uint32_t>::iterator i = combatants.begin(); i != combatants.end(); ++i) {
IGObject* ob = objectmanager->getObject(i->first);
Fleet* f = (Fleet*) ob->getObjectBehaviour();
if(f->getOwner() != winner) {
sendHome(i->first);
Player* p = playermanager->getPlayer(winner);
p->setScore(2, p->getScore(2) + 1);
losingRegion = i->second;
winningRegion = losingRegion;
}
}
objects = objectmanager->getAllIds();
for(itcurr = objects.begin(); itcurr!= objects.end(); ++itcurr) {
IGObject* ob = objectmanager->getObject(*itcurr);
if(ob->getType() == obtm->getObjectTypeByName("Star System")) {
StarSystem* sysData = (StarSystem*) ob->getObjectBehaviour();
if(sysData->getRegion() == losingRegion) {
sysData->setRegion(0);
removedSystems.insert(*itcurr);
}
}
}
} else {
//External combat removes the losing leader and losing colonies.
//1 point is awarded for the leader and each colony removed
string shipType;
//set shiptype, losing/winning regions, and send home the losing leader
for(map<uint32_t, uint32_t>::iterator i = combatants.begin(); i != combatants.end(); ++i) {
IGObject* ob = objectmanager->getObject(i->first);
Fleet* f = (Fleet*) ob->getObjectBehaviour();
if(f->getOwner() != winner) {
losingRegion = i->second;
shipType = ob->getName();
sendHome(i->first);
} else {
winningRegion = i->second;
}
}
//set the correct resource type
int resourceType;
//.........这里部分代码省略.........
示例5: awardArtifacts
//Award artifacts to any players who have a merchant leader
//in a region with two artifacts
void TaeTurn::awardArtifacts() {
Game* game = Game::getGame();
ObjectTypeManager* obtm = game->getObjectTypeManager();
ObjectManager* objectmanager = game->getObjectManager();
std::set<uint32_t> artifacts;
std::set<uint32_t> regions;
std::set<uint32_t> objects = objectmanager->getAllIds();
std::set<uint32_t>::iterator itcurr;
//Find any regions with 2 or more alien artifacts
for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
IGObject * ob = objectmanager->getObject(*itcurr);
if(ob->getType() == obtm->getObjectTypeByName("Planet")) {
Planet* p = (Planet*) ob->getObjectBehaviour();
if(p->getResource(3) > 0) {
StarSystem* sys = (StarSystem*)(objectmanager->getObject(ob->getParent())->getObjectBehaviour());
if(sys->getRegion() != 0) {
if(regions.count(sys->getRegion()) > 0) {
artifacts.insert(*itcurr);
} else {
regions.insert(sys->getRegion());
}
}
}
}
}
if(!artifacts.empty()) {
uint32_t type;
DesignStore* ds = game->getDesignStore();
PlayerManager* pm = game->getPlayerManager();
std::set<unsigned int> designs = ds->getDesignIds();
//get leader ID
for(itcurr = designs.begin(); itcurr != designs.end(); ++itcurr) {
if(ds->getDesign(*itcurr)->getName().compare("MerchantLeaderShip")) {
type = *itcurr;
}
}
//Search the objects for a merchant leader
for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
IGObject * ob = objectmanager->getObject(*itcurr);
if(ob->getType() == obtm->getObjectTypeByName("Fleet")) {
Fleet* f = (Fleet*) (ob->getObjectBehaviour());
if(f->getShips().count(type) > 0) {
IGObject* parent = objectmanager->getObject(ob->getParent());
if(parent->getType() == obtm->getObjectTypeByName("Star System")) {
StarSystem* parentData = (StarSystem*) (parent->getObjectBehaviour());
//See if this leader is in a region with
//2 or more alien artifacts
for(std::set<uint32_t>::iterator i = artifacts.begin(); i != artifacts.end(); ++i) {
IGObject* obj = objectmanager->getObject(*i);
Planet* p = (Planet*) obj->getObjectBehaviour();
StarSystem* sys = (StarSystem*)(objectmanager->getObject(obj->getParent())->getObjectBehaviour());
if(sys->getRegion() == parentData->getRegion()) {
//+1 to leader's owner's artifact score
Player* owner = pm->getPlayer(f->getOwner());
owner->setScore(5, owner->getScore(5) + 1);
p->removeResource(3, 1);
artifacts.erase(*i);
}
}
}
}
}
}
}
}
示例6:
void ConfusedMovementGenerator<Player>::Finalize(Player& unit)
{
unit.clearUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE);
unit.StopMoving();
}
示例7: MANGOS_ASSERT
/**
* This function will Unboard a passenger
*
* @param passenger MUST be provided. This Unit will be unboarded from the vehicle
* @param changeVehicle If set, the passenger is expected to be directly boarded to another vehicle,
* and hence he will not be unboarded but only removed from this vehicle.
*/
void VehicleInfo::UnBoard(Unit* passenger, bool changeVehicle)
{
MANGOS_ASSERT(passenger);
DEBUG_LOG("VehicleInfo::Unboard: passenger: %s", passenger->GetGuidStr().c_str());
PassengerMap::const_iterator itr = m_passengers.find(passenger);
MANGOS_ASSERT(itr != m_passengers.end());
VehicleSeatEntry const* seatEntry = GetSeatEntry(itr->second->GetTransportSeat());
MANGOS_ASSERT(seatEntry);
UnBoardPassenger(passenger); // Use TransportBase to remove the passenger from storage list
// Remove passenger modifications
RemoveSeatMods(passenger, seatEntry->m_flags);
if (!changeVehicle) // Send expected unboarding packages
{
// Update movementInfo
passenger->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT);
passenger->m_movementInfo.ClearTransportData();
if (passenger->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)passenger;
pPlayer->ResummonPetTemporaryUnSummonedIfAny();
pPlayer->SetFallInformation(0, pPlayer->GetPositionZ());
// SMSG_PET_DISMISS_SOUND (?)
}
if (passenger->IsRooted())
passenger->SetRoot(false);
Movement::MoveSplineInit init(*passenger);
// ToDo: Set proper unboard coordinates
init.MoveTo(m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ());
init.SetExitVehicle();
init.Launch();
// Despawn if passenger was accessory
if (passenger->GetTypeId() == TYPEID_UNIT && m_accessoryGuids.find(passenger->GetObjectGuid()) != m_accessoryGuids.end())
{
Creature* cPassenger = static_cast<Creature*>(passenger);
// TODO Same TODO as in VehicleInfo::RemoveAccessoriesFromMap
cPassenger->ForcedDespawn(5000);
m_accessoryGuids.erase(passenger->GetObjectGuid());
}
}
// Some creature vehicles get despawned after passenger unboarding
if (m_owner->GetTypeId() == TYPEID_UNIT)
{
// TODO: Guesswork, but seems to be fairly near correct
// Only if the passenger was on control seat? Also depending on some flags
if ((seatEntry->m_flags & SEAT_FLAG_CAN_CONTROL) &&
!(m_vehicleEntry->m_flags & (VEHICLE_FLAG_UNK4 | VEHICLE_FLAG_NOT_DISMISSED)))
{
if (((Creature*)m_owner)->IsTemporarySummon())
((Creature*)m_owner)->ForcedDespawn(1000);
}
}
}
示例8: if
/// Add control and such modifiers to a passenger if required
void VehicleInfo::ApplySeatMods(Unit* passenger, uint32 seatFlags)
{
Unit* pVehicle = (Unit*)m_owner; // Vehicles are alawys Unit
if (seatFlags & SEAT_FLAG_NOT_SELECTABLE)
passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
// ToDo: change passenger model id for SEAT_FLAG_HIDE_PASSENGER?
if (passenger->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)passenger;
// group update
if (pPlayer->GetGroup())
pPlayer->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_VEHICLE_SEAT);
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
pPlayer->GetCamera().SetView(pVehicle);
pPlayer->SetCharm(pVehicle);
pVehicle->SetCharmer(pPlayer);
pVehicle->GetMotionMaster()->Clear();
pVehicle->GetMotionMaster()->MoveIdle();
pVehicle->StopMoving(true);
pVehicle->addUnitState(UNIT_STAT_POSSESSED);
pVehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
pVehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
pPlayer->UpdateClientControl(pVehicle, true);
pPlayer->SetMover(pVehicle);
// Unconfirmed - default speed handling
if (pVehicle->GetTypeId() == TYPEID_UNIT)
{
if (!pPlayer->IsWalking() && pVehicle->IsWalking())
{
((Creature*)pVehicle)->SetWalk(false, true);
}
else if (pPlayer->IsWalking() && !pVehicle->IsWalking())
{
((Creature*)pVehicle)->SetWalk(true, true);
}
// set vehicle faction as per the controller faction
((Creature*)pVehicle)->SetFactionTemporary(pPlayer->getFaction(), TEMPFACTION_NONE);
// set vehicle react state to passive; player will control the vehicle
pVehicle->AI()->SetReactState(REACT_PASSIVE);
}
}
if (seatFlags & SEAT_FLAG_CAN_CAST)
{
CharmInfo* charmInfo = pVehicle->InitCharmInfo(pVehicle);
charmInfo->InitVehicleCreateSpells();
pPlayer->PossessSpellInitialize();
}
}
else if (passenger->GetTypeId() == TYPEID_UNIT)
{
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
passenger->SetCharm(pVehicle);
pVehicle->SetCharmer(passenger);
// Change vehicle react state; ToDo: also change the vehicle faction?
if (pVehicle->GetTypeId() == TYPEID_UNIT)
pVehicle->AI()->SetReactState(passenger->AI()->GetReactState());
}
((Creature*)passenger)->AI()->SetCombatMovement(false);
// Not entirely sure how this must be handled in relation to CONTROL
// But in any way this at least would require some changes in the movement system most likely
passenger->GetMotionMaster()->Clear(false, true);
passenger->GetMotionMaster()->MoveIdle();
}
}
示例9: TC_LOG_ERROR
void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
{
uint32 type;
uint32 lang;
recvData >> type;
recvData >> lang;
if (type >= MAX_CHAT_MSG_TYPE)
{
TC_LOG_ERROR("network", "CHAT: Wrong message type received: %u", type);
recvData.rfinish();
return;
}
if (lang == LANG_UNIVERSAL && type != CHAT_MSG_AFK && type != CHAT_MSG_DND)
{
TC_LOG_ERROR("network", "CMSG_MESSAGECHAT: Possible hacking-attempt: %s tried to send a message in universal language", GetPlayerInfo().c_str());
SendNotification(LANG_UNKNOWN_LANGUAGE);
recvData.rfinish();
return;
}
Player* sender = GetPlayer();
//TC_LOG_DEBUG("CHAT: packet received. type %u, lang %u", type, lang);
// prevent talking at unknown language (cheating)
LanguageDesc const* langDesc = GetLanguageDescByID(lang);
if (!langDesc)
{
SendNotification(LANG_UNKNOWN_LANGUAGE);
recvData.rfinish();
return;
}
if (langDesc->skill_id != 0 && !sender->HasSkill(langDesc->skill_id))
{
// also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
Unit::AuraEffectList const& langAuras = sender->GetAuraEffectsByType(SPELL_AURA_COMPREHEND_LANGUAGE);
bool foundAura = false;
for (Unit::AuraEffectList::const_iterator i = langAuras.begin(); i != langAuras.end(); ++i)
{
if ((*i)->GetMiscValue() == int32(lang))
{
foundAura = true;
break;
}
}
if (!foundAura)
{
SendNotification(LANG_NOT_LEARNED_LANGUAGE);
recvData.rfinish();
return;
}
}
if (lang == LANG_ADDON)
{
// LANG_ADDON is only valid for the following message types
switch (type)
{
case CHAT_MSG_PARTY:
case CHAT_MSG_RAID:
case CHAT_MSG_GUILD:
case CHAT_MSG_BATTLEGROUND:
case CHAT_MSG_WHISPER:
// check if addon messages are disabled
if (!sWorld->getBoolConfig(CONFIG_ADDON_CHANNEL))
{
recvData.rfinish();
return;
}
break;
default:
TC_LOG_ERROR("network", "Player %s (GUID: %u) sent a chatmessage with an invalid language/message type combination",
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
recvData.rfinish();
return;
}
}
// LANG_ADDON should not be changed nor be affected by flood control
else
{
// send in universal language if player in .gmon mode (ignore spell effects)
if (sender->IsGameMaster())
lang = LANG_UNIVERSAL;
else
{
Unit::AuraEffectList const& ModLangAuras = sender->GetAuraEffectsByType(SPELL_AURA_MOD_LANGUAGE);
if (!ModLangAuras.empty())
lang = ModLangAuras.front()->GetMiscValue();
else if (HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHAT))
lang = LANG_UNIVERSAL;
else
{
switch (type)
{
case CHAT_MSG_PARTY:
//.........这里部分代码省略.........
示例10: UpdateAI
void UpdateAI(const uint32 uiDiff)
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
if (!m_bIsEnraged && m_creature->GetHealthPercent() < 25.0f)
{
if (!m_creature->IsNonMeleeSpellCasted(false))
{
m_bIsEnraged = true;
DoScriptText(SAY_ENRAGE, m_creature);
DoCastSpellIfCan(m_creature, SPELL_ENRAGE);
}
}
if (uiCrystalChainTimer < uiDiff)
{
if (!m_creature->IsNonMeleeSpellCasted(false))
{
if (m_bIsRegularMode)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
{
if (Player* pPlayer = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
DoCastSpellIfCan(pPlayer, SPELL_CRYSTAL_CHAINS);
uiCrystalChainTimer = 30000;
}
}
else
{
if (Unit* pSource = m_creature->getVictim())
{
uiCrystalChainTimer = 15000;
Player* pPlayer = pSource->GetCharmerOrOwnerPlayerOrPlayerItself();
if (!pPlayer)
return;
if (Group* pGroup = pPlayer->GetGroup())
{
for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
{
if (Player* pMember = pRef->getSource())
{
if (pMember->isAlive() && pMember->IsWithinDistInMap(m_creature, 50.0f))
m_creature->CastSpell(pMember, SPELL_CRYSTAL_CHAINS, true);
}
}
}
else
m_creature->CastSpell(pPlayer, SPELL_CRYSTAL_CHAINS, false);
}
}
}
}
else
uiCrystalChainTimer -= uiDiff;
if (uiTailSweepTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_TAIL_SWEEP) == CAST_OK)
uiTailSweepTimer = urand(2500, 7500);
}
else
uiCrystalChainTimer -= uiDiff;
if (uiCrystalfireBreathTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_CRYSTALFIRE_BREATH : SPELL_CRYSTALFIRE_BREATH_H) == CAST_OK)
uiCrystalfireBreathTimer = urand(15000, 20000);
}
else
uiCrystalfireBreathTimer -= uiDiff;
if (!m_bIsRegularMode)
{
if (uiCrystallizeTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_CRYSTALLIZE) == CAST_OK)
{
uiCrystallizeTimer = urand(15000, 25000);
DoScriptText(SAY_CRYSTAL_NOVA, m_creature);
}
}
else
uiCrystallizeTimer -= uiDiff;
}
DoMeleeAttackIfReady();
}
示例11: GUID_LOPART
bool ArenaTeam::AddMember(const uint64& PlayerGuid)
{
std::string plName;
uint8 plClass;
uint32 plPRating;
uint32 plMMRating;
// arena team is full (can't have more than type * 2 players!)
if (GetMembersSize() >= GetType() * 2)
return false;
Player *pl = sObjectMgr->GetPlayer(PlayerGuid);
if (pl)
{
if (pl->GetArenaTeamId(GetSlot()))
{
sLog->outError("Arena::AddMember() : player already in this sized team");
return false;
}
plClass = pl->getClass();
plName = pl->GetName();
}
else
{
// 0 1
QueryResult result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", GUID_LOPART(PlayerGuid));
if (!result)
return false;
plName = (*result)[0].GetString();
plClass = (*result)[1].GetUInt8();
// check if player already in arenateam of that size
if (Player::GetArenaTeamIdFromDB(PlayerGuid, GetType()) != 0)
{
sLog->outError("Arena::AddMember() : player already in this sized team");
return false;
}
}
plMMRating = sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
plPRating = 0;
if (sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0)
plPRating = sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
else if (GetRating() >= 1000)
plPRating = 1000;
sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
QueryResult result = CharacterDatabase.PQuery("SELECT matchmaker_rating FROM character_arena_stats WHERE guid='%u' AND slot='%u'", GUID_LOPART(PlayerGuid), GetSlot());
if (result)
plMMRating = (*result)[0].GetUInt32();
// remove all player signs from another petitions
// this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
Player::RemovePetitionsAndSigns(PlayerGuid, GetType());
ArenaTeamMember newmember;
newmember.name = plName;
newmember.guid = PlayerGuid;
newmember.Class = plClass;
newmember.games_season = 0;
newmember.games_week = 0;
newmember.wins_season = 0;
newmember.wins_week = 0;
newmember.personal_rating = plPRating;
newmember.matchmaker_rating = plMMRating;
m_members.push_back(newmember);
CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid) VALUES ('%u', '%u')", m_TeamId, GUID_LOPART(newmember.guid));
if (pl)
{
pl->SetInArenaTeam(m_TeamId, GetSlot(), GetType());
pl->SetArenaTeamIdInvited(0);
// hide promote/remove buttons
if (m_CaptainGuid != PlayerGuid)
pl->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
sLog->outArena("Player: %s [GUID: %u] joined arena team type: %u [Id: %u].", pl->GetName(), pl->GetGUIDLow(), GetType(), GetId());
}
return true;
}
示例12: WaypointReached
void WaypointReached(uint32 i)
{
Player* pPlayer = GetPlayerForEscort();
if (!pPlayer)
return;
switch(i)
{
case 23:
DoScriptText(SAY_OOX_AMBUSH, me);
break;
case 24:
for (uint8 i = 0; i < 3; ++i)
{
float x, y, z;
switch (i)
{
case 0:
me->GetNearPoint(x, y, z, 0.0f, 15.0f, 0.0f);
me->SummonCreature(SPAWN_FIRST, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
case 1:
me->GetNearPoint(x, y, z, 0.0f, 15.0f, 2.0f);
me->SummonCreature(SPAWN_FIRST, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
case 2:
me->GetNearPoint(x, y, z, 0.0f, 15.0f, 4.0f);
me->SummonCreature(SPAWN_FIRST, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
}
}
break;
case 57:
DoScriptText(SAY_OOX_AMBUSH, me);
break;
case 58:
for (uint8 i = 0; i < 3; ++i)
{
float x, y, z;
switch (i)
{
case 0:
me->GetNearPoint(x, y, z, 0.0f, 15.0f, 0.0f);
me->SummonCreature(SPAWN_SECOND_1, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
case 1:
me->GetNearPoint(x, y, z, 0.0f, 15.0f, 2.0f);
me->SummonCreature(SPAWN_SECOND_2, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
case 2:
me->GetNearPoint(x, y, z, 0.0f, 15.0f, 4.0f);
me->SummonCreature(SPAWN_SECOND_2, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
}
}
break;
case 88:
if (pPlayer)
{
DoScriptText(SAY_OOX_END, me);
pPlayer->GroupEventHappens(Q_OOX17, me);
}
break;
}
}
示例13: ObjectGuid
/**
* Handles the packet sent by the client when taking an item from the mail.
*/
void WorldSession::HandleMailTakeItem(WorldPacket& recv_data)
{
ObjectGuid mailboxGuid;
uint32 mailId;
recv_data >> mailboxGuid;
recv_data >> mailId;
if (!CheckMailBox(mailboxGuid))
return;
Player* pl = _player;
Mail* m = pl->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr))
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
}
// prevent cheating with skip client money check
if (pl->GetMoney() < m->COD)
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
uint32 itemId = m->items[0].item_template;
uint32 itemGuid = m->items[0].item_guid;
Item* it = pl->GetMItem(itemGuid);
ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false);
if (msg == EQUIP_ERR_OK)
{
m->RemoveItem(itemGuid);
m->removedItems.push_back(itemGuid);
if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail
{
ObjectGuid sender_guid = ObjectGuid(HIGHGUID_PLAYER, m->sender);
Player* sender = sObjectMgr.GetPlayer(sender_guid);
uint32 sender_accId = 0;
if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{
std::string sender_name;
if (sender)
{
sender_accId = sender->GetSession()->GetAccountId();
sender_name = sender->GetName();
}
else if (sender_guid)
{
// can be calculated early
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
if (!sObjectMgr.GetPlayerNameByGUID(sender_guid, sender_name))
sender_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
}
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
}
else if (!sender)
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
// check player existence
if (sender || sender_accId)
{
MailDraft(m->subject)
.SetMoney(m->COD)
.SendMailTo(MailReceiver(sender, sender_guid), _player, MAIL_CHECK_MASK_COD_PAYMENT);
}
pl->ModifyMoney(-int32(m->COD));
}
m->COD = 0;
m->state = MAIL_STATE_CHANGED;
pl->m_mailsUpdated = true;
pl->RemoveMItem(it->GetGUIDLow());
uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
pl->MoveItemToInventory(dest, it, true);
CharacterDatabase.BeginTransaction();
pl->SaveInventoryAndGoldToDB();
pl->_SaveMail();
CharacterDatabase.CommitTransaction();
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count);
}
else
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg);
}
示例14: RemoveSeatMods
/// Remove control and such modifiers to a passenger if they were added
void VehicleInfo::RemoveSeatMods(Unit* passenger, uint32 seatFlags)
{
Unit* pVehicle = (Unit*)m_owner;
if (seatFlags & SEAT_FLAG_NOT_SELECTABLE)
passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
// ToDo: reset passenger model id for SEAT_FLAG_HIDE_PASSENGER?
if (passenger->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)passenger;
// group update
if (pPlayer->GetGroup())
pPlayer->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_VEHICLE_SEAT);
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
pPlayer->SetCharm(nullptr);
pVehicle->SetCharmer(nullptr);
pPlayer->UpdateClientControl(pVehicle, false);
pPlayer->SetMover(nullptr);
pVehicle->StopMoving(true);
pVehicle->GetMotionMaster()->Clear();
pVehicle->clearUnitState(UNIT_STAT_POSSESSED);
pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
// must be called after movement control unapplying
pPlayer->GetCamera().ResetView();
if (pVehicle->GetTypeId() == TYPEID_UNIT)
{
// reset vehicle faction
((Creature*)pVehicle)->ClearTemporaryFaction();
// Reset react state
if (!(GetVehicleEntry()->m_flags & VEHICLE_FLAG_PASSIVE))
pVehicle->AI()->SetReactState(REACT_AGGRESSIVE);
}
}
if (seatFlags & SEAT_FLAG_CAN_CAST)
pPlayer->RemovePetActionBar();
}
else if (passenger->GetTypeId() == TYPEID_UNIT)
{
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
passenger->SetCharm(nullptr);
pVehicle->SetCharmer(nullptr);
}
// Reinitialize movement
if (((Creature*)passenger)->AI())
((Creature*)passenger)->AI()->SetCombatMovement(true, true);
if (!passenger->getVictim())
passenger->GetMotionMaster()->Initialize();
}
}
示例15: DETAIL_LOG
/**
* Handles the Packet sent by the client when sending a mail.
*
* This methods takes the packet sent by the client and performs the following actions:
* - Checks whether the mail is valid: i.e. can he send the selected items,
* does he have enough money, etc.
* - Creates a MailDraft and adds the needed items, money, cost data.
* - Sends the mail.
*
* Depending on the outcome of the checks performed the player will recieve a different
* MailResponseResult.
*
* @see MailResponseResult
* @see SendMailResult()
*
* @param recv_data the WorldPacket containing the data sent by the client.
*/
void WorldSession::HandleSendMail(WorldPacket& recv_data)
{
ObjectGuid mailboxGuid;
ObjectGuid itemGuid;
uint64 unk3;
std::string receiver, subject, body;
uint32 unk1, unk2, money, COD;
uint8 unk4;
recv_data >> mailboxGuid;
recv_data >> receiver;
recv_data >> subject;
recv_data >> body;
recv_data >> unk1; // stationery?
recv_data >> unk2; // 0x00000000
recv_data >> itemGuid;
recv_data >> money >> COD; // money and cod
recv_data >> unk3; // const 0
recv_data >> unk4; // const 0
// packet read complete, now do check
if (!CheckMailBox(mailboxGuid))
return;
if (receiver.empty())
return;
Player* pl = _player;
ObjectGuid rc;
if (normalizePlayerName(receiver))
rc = sObjectMgr.GetPlayerGuidByName(receiver);
if (!rc)
{
DETAIL_LOG("%s is sending mail to %s (GUID: nonexistent!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",
pl->GetGuidStr().c_str(), receiver.c_str(), subject.c_str(), body.c_str(), itemGuid ? 1 : 0, money, COD, unk1, unk2);
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
return;
}
DETAIL_LOG("%s is sending mail to %s with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",
pl->GetGuidStr().c_str(), rc.GetString().c_str(), subject.c_str(), body.c_str(), itemGuid ? 1 : 0, money, COD, unk1, unk2);
if (pl->GetObjectGuid() == rc)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF);
return;
}
uint32 reqmoney = money + 30;
if (pl->GetMoney() < reqmoney)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
Player* receive = sObjectMgr.GetPlayer(rc);
Team rc_team;
uint8 mails_count = 0; // do not allow to send to one player more than 100 mails
if (receive)
{
rc_team = receive->GetTeam();
mails_count = receive->GetMailSize();
}
else
{
rc_team = sObjectMgr.GetPlayerTeamByGUID(rc);
if (QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(*) FROM mail WHERE receiver = '%u'", rc.GetCounter()))
{
Field* fields = result->Fetch();
mails_count = fields[0].GetUInt32();
delete result;
}
}
//.........这里部分代码省略.........