diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp | 151 | ||||
-rw-r--r-- | src/game/GroupHandler.cpp | 6 | ||||
-rw-r--r-- | src/game/MiscHandler.cpp | 41 | ||||
-rw-r--r-- | src/game/World.cpp | 4 | ||||
-rw-r--r-- | src/game/World.h | 2 | ||||
-rw-r--r-- | src/trinitycore/trinitycore.conf.dist | 11 |
6 files changed, 101 insertions, 114 deletions
diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp index 20bf8076b27..dbf8a3427df 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp @@ -62,7 +62,10 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { boss_moroesAI(Creature *c) : ScriptedAI(c) { - FirstTime = true; + for(int i = 0; i < 4; i++) + { + AddId[i] = 0; + } pInstance = ((ScriptedInstance*)c->GetInstanceData()); } @@ -77,7 +80,6 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI uint32 CheckAdds_Timer; uint32 AddId[4]; - bool FirstTime; bool InVanish; bool Enrage; @@ -91,12 +93,10 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI Enrage = false; InVanish = false; - - SpawnAdds(); - - m_creature->setFaction(16); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if(m_creature->GetHealth() > 0) + { + SpawnAdds(); + } if(pInstance) pInstance->SetData(DATA_MOROES_EVENT, NOT_STARTED); @@ -106,6 +106,8 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { if(pInstance) pInstance->SetData(DATA_MOROES_EVENT, IN_PROGRESS); + + DoZoneInCombat(); } void Aggro(Unit* who) @@ -129,7 +131,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI void JustDied(Unit* victim) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, m_creature); if (pInstance) pInstance->SetData(DATA_MOROES_EVENT, DONE); @@ -153,27 +155,15 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI } } - uint8 CheckAdd(uint64 guid) - { - Unit* pUnit = Unit::GetUnit((*m_creature), guid); - if (pUnit) - { - if (!pUnit->isAlive()) - return 1; // Exists but is dead - else - return 2; // Exists and is alive - } - return 0; // Does not exist - } - void SpawnAdds() { - Creature *pCreature = NULL; - - if (FirstTime) + DeSpawnAdds(); + if(isAddlistEmpty()) { + Creature *pCreature = NULL; std::vector<uint32> AddList; + for(uint8 i = 0; i < 6; ++i) AddList.push_back(Adds[i]); @@ -193,48 +183,44 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI } ++i; } - - FirstTime = false; - } - else + }else { - for(uint8 i = 0; i < 4; ++i) + for(int i = 0; i < 4; i++) { - switch(CheckAdd(AddGUID[i])) + Creature *pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + if (pCreature) { - case 0: - pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if (pCreature) - AddGUID[i] = pCreature->GetGUID(); - break; - case 1: - pCreature = (Unit::GetCreature((*m_creature), AddGUID[i])); - if (pCreature) - { - pCreature->Respawn(); - pCreature->AI()->EnterEvadeMode(); - } - break; - case 2: - pCreature = (Unit::GetCreature((*m_creature), AddGUID[i])); - if (!pCreature->IsInEvadeMode()) - pCreature->AI()->EnterEvadeMode(); - break; + AddGUID[i] = pCreature->GetGUID(); } } } } + bool isAddlistEmpty() + { + for(int i = 0; i < 4; i++) + { + if(AddId[i] == 0) + return true; + } + return false; + } + void DeSpawnAdds() { for(uint8 i = 0; i < 4 ; ++i) { - Unit* Temp = NULL; + Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Unit::GetUnit((*m_creature),AddGUID[i]); + Temp = Creature::GetCreature((*m_creature),AddGUID[i]); if (Temp && Temp->isAlive()) + { + (*Temp).GetMotionMaster()->Clear(true); Temp->DealDamage(Temp, Temp->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + Temp->RemoveCorpse(); + } + } } } @@ -243,13 +229,13 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { for(uint8 i = 0; i < 4; ++i) { - Unit* Temp = NULL; + Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Unit::GetUnit((*m_creature),AddGUID[i]); + Temp = Creature::GetCreature((*m_creature),AddGUID[i]); if (Temp && Temp->isAlive()) { - ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); + Temp->AI()->AttackStart(m_creature->getVictim()); DoZoneInCombat(Temp); }else EnterEvadeMode(); @@ -295,37 +281,12 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI //Cast Vanish, then Garrote random victim if (Vanish_Timer < diff) { - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); DoCast(m_creature, SPELL_VANISH); InVanish = true; Vanish_Timer = 30000; Wait_Timer = 5000; }else Vanish_Timer -= diff; - if (InVanish) - { - if (Wait_Timer < diff) - { - switch(rand()%2) - { - case 0: DoScriptText(SAY_SPECIAL_1, m_creature); break; - case 1: DoScriptText(SAY_SPECIAL_2, m_creature); break; - } - - if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - target->CastSpell(target, SPELL_GARROTE,true); - - m_creature->setFaction(16); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->AI()->AttackStart(m_creature->getVictim()); - InVanish = false; - }else Wait_Timer -= diff; - } - - //Gouge highest aggro, and attack second highest if (Gouge_Timer < diff) { DoCast(m_creature->getVictim(), SPELL_GOUGE); @@ -334,27 +295,29 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI if (Blind_Timer < diff) { - Unit* target = NULL; - std::list<HostilReference*> t_list = m_creature->getThreatManager().getThreatList(); + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 5, true); + if (target && m_creature->IsWithinMeleeRange(target)) + DoCast(target, SPELL_BLIND); - if (t_list.empty()) - return; + Blind_Timer = 40000; + }else Blind_Timer -= diff; + } - std::vector<Unit*> target_list; - for (std::list<HostilReference*>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + if (InVanish) + { + if (Wait_Timer < diff) + { + switch(rand()%2) { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if (target && target->GetDistance2d(m_creature) < 5) - target_list.push_back(target); + case 0: DoScriptText(SAY_SPECIAL_1, m_creature); break; + case 1: DoScriptText(SAY_SPECIAL_2, m_creature); break; } - if (target_list.size()) - target = *(target_list.begin()+rand()%target_list.size()); - if (target) - DoCast(target, SPELL_BLIND); + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + target->CastSpell(target, SPELL_GARROTE,true); - Blind_Timer = 40000; - }else Blind_Timer -= diff; + InVanish = false; + }else Wait_Timer -= diff; } if (!InVanish) diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index f63505ae24a..67c6ca5053a 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -83,6 +83,12 @@ void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data ) return; } + // restrict invite to GMs + if (!sWorld.getConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->isGameMaster() && player->isGameMaster()) + { + SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET); + return; + } // can't group with if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 1bed4c6a483..34ed7fd3aab 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -46,6 +46,7 @@ #include "Pet.h" #include "SocialMgr.h" #include "CellImpl.h" +#include "AccountMgr.h" void WorldSession::HandleRepopRequestOpcode( WorldPacket & /*recv_data*/ ) { @@ -555,12 +556,13 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) sLog.outDebug( "WORLD: %s asked to add friend : '%s'", GetPlayer()->GetName(), friendName.c_str() ); - CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race FROM characters WHERE name = '%s'", friendName.c_str()); + CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race, account FROM characters WHERE name = '%s'", friendName.c_str()); } void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote) { uint64 friendGuid; + uint64 friendAcctid; uint32 team; FriendsResult friendResult; @@ -576,33 +578,34 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc { friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); team = Player::TeamForRace((*result)[1].GetUInt8()); + friendAcctid = (*result)[2].GetUInt32(); delete result; - if(friendGuid) - { - if(friendGuid==session->GetPlayer()->GetGUID()) - friendResult = FRIEND_SELF; - else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) - friendResult = FRIEND_ENEMY; - else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) - friendResult = FRIEND_ALREADY; - else + if ( session->GetSecurity() >= SEC_MODERATOR || sWorld.getConfig(CONFIG_ALLOW_GM_FRIEND) || accmgr.GetSecurity(friendAcctid) < SEC_MODERATOR) + if(friendGuid) { - Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); - if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) - friendResult = FRIEND_ADDED_ONLINE; + if(friendGuid==session->GetPlayer()->GetGUID()) + friendResult = FRIEND_SELF; + else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) + friendResult = FRIEND_ENEMY; + else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) + friendResult = FRIEND_ALREADY; else - friendResult = FRIEND_ADDED_OFFLINE; - if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) { - friendResult = FRIEND_LIST_FULL; - sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); + Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); + if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) + friendResult = FRIEND_ADDED_ONLINE; + else + friendResult = FRIEND_ADDED_OFFLINE; + if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) + { + friendResult = FRIEND_LIST_FULL; + sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); + } } - session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); } - } } sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, GUID_LOPART(friendGuid), false); diff --git a/src/game/World.cpp b/src/game/World.cpp index 7517fb0b96d..d1f5490ba55 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -768,7 +768,9 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_GM_IN_GM_LIST] = sConfig.GetBoolDefault("GM.InGMList",false); m_configs[CONFIG_GM_IN_WHO_LIST] = sConfig.GetBoolDefault("GM.InWhoList",false); m_configs[CONFIG_GM_LOG_TRADE] = sConfig.GetBoolDefault("GM.LogTrade", false); - m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1); + m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1); + m_configs[CONFIG_ALLOW_GM_GROUP] = sConfig.GetBoolDefault("GM.AllowInvite", false); + m_configs[CONFIG_ALLOW_GM_FRIEND] = sConfig.GetBoolDefault("GM.AllowFriend", false); if(m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL]) { sLog.outError("GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..%u. Set to %u.", diff --git a/src/game/World.h b/src/game/World.h index 01586b592e1..513d8894640 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -130,6 +130,8 @@ enum WorldConfigs CONFIG_GM_IN_WHO_LIST, CONFIG_GM_LOG_TRADE, CONFIG_START_GM_LEVEL, + CONFIG_ALLOW_GM_GROUP, + CONFIG_ALLOW_GM_FRIEND, CONFIG_GROUP_VISIBILITY, CONFIG_MAIL_DELIVERY_DELAY, CONFIG_UPTIME_UPDATE, diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist index ffb5f311bb8..d7b892320d9 100644 --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/trinitycore/trinitycore.conf.dist @@ -884,6 +884,15 @@ Channel.SilentlyGMJoin = 0 # GM starting level (1-255) # Default: 1 # +# GM.AllowInvite +# Is GM accepting invites from players by default or not +# Default: 0 (false) +# 1 (true) +# +# GM.AllowFriend +# Are players allowed to add GMs to their friend list +# Default: 0 (false) +# 1 (true) ################################################################################################################### GM.LoginState = 2 @@ -894,6 +903,8 @@ GM.InGMList = 0 GM.InWhoList = 0 GM.LogTrade = 1 GM.StartLevel = 70 +GM.AllowInvite = 0 +GM.AllowFriend = 0 ################################################################################################################### # VISIBILITY AND RADIUSES |