aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authormaximius <none@none>2009-09-26 16:01:30 -0700
committermaximius <none@none>2009-09-26 16:01:30 -0700
commit7396b641ae82adcf5afd2591957ff944b7964203 (patch)
treeb6d54ca311e779ae4e77b569b9a367dc26a4938a /src/game
parentff3f556423bc90f8476c8b09bacb60cd621b2664 (diff)
*Gundrak: GO Handling & Slad Ran script by Tartalo
*Cleanup, and don't consider creatures to be in combat if they have no victim, or if their victim is a GM. --HG-- branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r--src/game/Creature.cpp3
-rw-r--r--src/game/CreatureEventAIMgr.cpp8
-rw-r--r--src/game/DynamicObject.cpp14
-rw-r--r--src/game/Level3.cpp55
-rw-r--r--src/game/Unit.cpp2
5 files changed, 42 insertions, 40 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index a7e5153e255..6f24dbe1631 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -544,7 +544,8 @@ void Creature::Update(uint32 diff)
if(!isAlive())
break;
- bool bNotInCombatOrIsPolymorphed = (!isInCombat() || IsPolymorphed());
+ bool bNotInCombatOrIsPolymorphed = (!isInCombat() || IsPolymorphed() || !getVictim() ||
+ getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()->isGameMaster());
if(m_regenTimer > diff && !bNotInCombatOrIsPolymorphed)
m_regenTimer -= diff;
diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp
index 901ec541455..5325edff4a9 100644
--- a/src/game/CreatureEventAIMgr.cpp
+++ b/src/game/CreatureEventAIMgr.cpp
@@ -147,13 +147,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons()
//Add to map
m_CreatureEventAI_Summon_Map[i] = temp;
++Count;
- }while (result->NextRow());
+ } while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u CreatureEventAI summon definitions", Count);
- }else
+ }
+ else
{
barGoLink bar(1);
bar.step();
@@ -728,7 +729,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog.outString();
sLog.outString(">> Loaded %u CreatureEventAI scripts", Count);
- }else
+ }
+ else
{
barGoLink bar(1);
bar.step();
diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp
index 5dd4059e21c..e616dc2f809 100644
--- a/src/game/DynamicObject.cpp
+++ b/src/game/DynamicObject.cpp
@@ -113,7 +113,7 @@ void DynamicObject::Update(uint32 p_time)
{
// caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
Unit* caster = GetCaster();
- if(!caster)
+ if (!caster)
{
Delete();
return;
@@ -126,17 +126,17 @@ void DynamicObject::Update(uint32 p_time)
else
deleteThis = true;
- if(m_effMask)
+ if (m_effMask)
{
- if(m_updateTimer < p_time)
+ if (m_updateTimer < p_time)
{
Trinity::DynamicObjectUpdater notifier(*this,caster);
VisitNearbyObject(GetRadius(), notifier);
m_updateTimer = 500; // is this official-like?
- }else m_updateTimer -= p_time;
+ } else m_updateTimer -= p_time;
}
- if(deleteThis)
+ if (deleteThis)
{
caster->RemoveDynObjectWithGUID(GetGUID());
Delete();
@@ -153,9 +153,9 @@ void DynamicObject::Delete()
void DynamicObject::Delay(int32 delaytime)
{
m_aliveDuration -= delaytime;
- for(AffectedSet::iterator iunit= m_affected.begin(); iunit != m_affected.end(); ++iunit)
+ for (AffectedSet::iterator iunit = m_affected.begin(); iunit != m_affected.end(); ++iunit)
if (*iunit)
- (*iunit)->DelayAura(m_spellId, GetCaster()->GetGUID() , delaytime);
+ (*iunit)->DelayAura(m_spellId, GetCaster()->GetGUID(), delaytime);
}
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index b14710c5191..bd4208c9647 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -1393,7 +1393,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
char* arg1 = strtok((char*)args, " ");
char* arg2 = strtok(NULL, " ");
- if(getSelectedPlayer() && arg1 && !arg2)
+ if (getSelectedPlayer() && arg1 && !arg2)
{
targetAccountId = getSelectedPlayer()->GetSession()->GetAccountId();
accmgr.GetName(targetAccountId, targetAccountName);
@@ -1401,7 +1401,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
gm = atoi(arg1);
// Check for invalid specified GM level.
- if ( (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR) )
+ if (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR)
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
@@ -1410,7 +1410,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
// Check if targets GM level and specified GM level is not higher than current gm level
targetSecurity = targetPlayer->GetSession()->GetSecurity();
- if(targetSecurity >= m_session->GetSecurity() || gm >= m_session->GetSecurity() )
+ if (targetSecurity >= m_session->GetSecurity() || gm >= m_session->GetSecurity())
{
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
SetSentErrorMessage(true);
@@ -1418,24 +1418,23 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
}
// Decide which string to show
- if(m_session->GetPlayer()!=targetPlayer)
- {
+ if (m_session->GetPlayer() != targetPlayer)
PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
- }else{
+ else
PSendSysMessage(LANG_YOURS_SECURITY_CHANGED, m_session->GetPlayer()->GetName(), gm);
- }
loginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId);
return true;
- }else
+ }
+ else
{
// Check for second parameter
- if(!arg2)
+ if (!arg2)
return false;
// Check for account
targetAccountName = arg1;
- if(!AccountMgr::normalizeString(targetAccountName))
+ if (!AccountMgr::normalizeString(targetAccountName))
{
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str());
SetSentErrorMessage(true);
@@ -1444,7 +1443,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
// Check for invalid specified GM level.
gm = atoi(arg2);
- if ( (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR) )
+ if (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR)
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
@@ -1458,7 +1457,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
/// can set security level only for target with less security and to less security that we have
/// This is also reject self apply in fact
targetSecurity = accmgr.GetSecurity(targetAccountId);
- if(targetSecurity >= plSecurity || gm >= plSecurity )
+ if (targetSecurity >= plSecurity || gm >= plSecurity)
{
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
SetSentErrorMessage(true);
@@ -1486,7 +1485,7 @@ bool ChatHandler::HandleAccountSetPasswordCommand(const char* args)
return false;
std::string account_name = szAccount;
- if(!AccountMgr::normalizeString(account_name))
+ if (!AccountMgr::normalizeString(account_name))
{
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
SetSentErrorMessage(true);
@@ -1503,7 +1502,7 @@ bool ChatHandler::HandleAccountSetPasswordCommand(const char* args)
/// can set password only for target with less security
/// This is also reject self apply in fact
- if(HasLowerSecurityAccount (NULL,targetAccountId,true))
+ if (HasLowerSecurityAccount (NULL,targetAccountId,true))
return false;
if (strcmp(szPassword1,szPassword2))
@@ -1515,7 +1514,7 @@ bool ChatHandler::HandleAccountSetPasswordCommand(const char* args)
AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1);
- switch(result)
+ switch (result)
{
case AOR_OK:
SendSysMessage(LANG_COMMAND_PASSWORD);
@@ -1556,12 +1555,12 @@ bool ChatHandler::HandleSetSkillCommand(const char* args)
{
// number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r
char* skill_p = extractKeyFromLink((char*)args,"Hskill");
- if(!skill_p)
+ if (!skill_p)
return false;
char *level_p = strtok (NULL, " ");
- if( !level_p)
+ if (!level_p)
return false;
char *max_p = strtok (NULL, " ");
@@ -1577,7 +1576,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args)
int32 level = atol (level_p);
Player * target = getSelectedPlayer();
- if(!target)
+ if (!target)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
@@ -1585,7 +1584,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args)
}
SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
- if(!sl)
+ if (!sl)
{
PSendSysMessage(LANG_INVALID_SKILL_ID, skill);
SetSentErrorMessage(true);
@@ -1594,7 +1593,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args)
std::string tNameLink = GetNameLink(target);
- if(!target->GetSkillValue(skill))
+ if (!target->GetSkillValue(skill))
{
PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, sl->name[0]);
SetSentErrorMessage(true);
@@ -1603,7 +1602,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args)
int32 max = max_p ? atol (max_p) : target->GetPureMaxSkillValue(skill);
- if( level <= 0 || level > max || max <= 0 )
+ if (level <= 0 || level > max || max <= 0)
return false;
target->SetSkill(skill, level, max);
@@ -1619,21 +1618,21 @@ bool ChatHandler::HandleUnLearnCommand(const char* args)
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
uint32 spell_id = extractSpellIdFromLink((char*)args);
- if(!spell_id)
+ if (!spell_id)
return false;
char const* allStr = strtok(NULL," ");
bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false;
Player* target = getSelectedPlayer();
- if(!target)
+ if (!target)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
}
- if(allRanks)
+ if (allRanks)
spell_id = spellmgr.GetFirstSpellInChain (spell_id);
if (target->HasSpell(spell_id))
@@ -1641,7 +1640,7 @@ bool ChatHandler::HandleUnLearnCommand(const char* args)
else
SendSysMessage(LANG_FORGET_SPELL);
- if(GetTalentSpellCost(spell_id))
+ if (GetTalentSpellCost(spell_id))
target->SendTalentsInfoData(false);
return true;
@@ -1650,7 +1649,7 @@ bool ChatHandler::HandleUnLearnCommand(const char* args)
bool ChatHandler::HandleCooldownCommand(const char* args)
{
Player* target = getSelectedPlayer();
- if(!target)
+ if (!target)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
@@ -1668,10 +1667,10 @@ bool ChatHandler::HandleCooldownCommand(const char* args)
{
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spell_id = extractSpellIdFromLink((char*)args);
- if(!spell_id)
+ if (!spell_id)
return false;
- if(!sSpellStore.LookupEntry(spell_id))
+ if (!sSpellStore.LookupEntry(spell_id))
{
PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetMangosString(LANG_YOU) : tNameLink.c_str());
SetSentErrorMessage(true);
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 4ab2f05dc49..067d953e381 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -217,7 +217,7 @@ void Unit::Update( uint32 p_time )
{
m_AurasCheck = 2000;
_UpdateAura();
- }else
+ } else
m_AurasCheck -= p_time;*/
// WARNING! Order of execution here is important, do not change.