aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorNay <dnpd.dd@gmail.com>2012-01-07 17:13:42 +0000
committerNay <dnpd.dd@gmail.com>2012-01-07 17:13:42 +0000
commit9c26ce8da559e1d7cd83011885f84f83360819fc (patch)
tree3eb0164d9f93ccecf6ca737a902489a679b36b5b /src/server/game/AI/SmartScripts
parentccf8b3889b8a67c18d5c5c79ce3c0cd32d7647f6 (diff)
parenta79ea3dcdfc865896bd120edc864105685fc43f4 (diff)
Merge branch 'master' into 4.x
Conflicts: src/server/game/Achievements/AchievementMgr.cpp src/server/game/Achievements/AchievementMgr.h src/server/game/Entities/Corpse/Corpse.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Quests/QuestDef.cpp src/server/shared/Database/Implementation/CharacterDatabase.cpp src/server/shared/Database/Implementation/CharacterDatabase.h
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp28
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h4
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp24
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp13
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h2
6 files changed, 59 insertions, 14 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 7dd793a302b..b5fdf38a4b6 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -431,12 +431,36 @@ void SmartAI::MovementInform(uint32 MovementType, uint32 Data)
MovepointReached(Data);
}
+void SmartAI::RemoveAuras()
+{
+ Unit::AuraApplicationMap appliedAuras = me->GetAppliedAuras();
+ for (Unit::AuraApplicationMap::iterator iter = appliedAuras.begin(); iter != appliedAuras.end();)
+ {
+ Aura const* aura = iter->second->GetBase();
+ if (!aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) && !(iter->second->GetTarget() == me && aura->GetCaster() == me))
+ me->_UnapplyAura(iter, AURA_REMOVE_BY_DEFAULT);
+ else
+ ++iter;
+ }
+
+ Unit::AuraMap ownedAuras = me->GetOwnedAuras();
+ for (Unit::AuraMap::iterator iter = ownedAuras.begin(); iter != ownedAuras.end();)
+ {
+ Aura* aura = iter->second;
+ if (!aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE))
+ me->RemoveOwnedAura(iter, AURA_REMOVE_BY_DEFAULT);
+ else
+ ++iter;
+ }
+}
+
void SmartAI::EnterEvadeMode()
{
if (!me->isAlive())
return;
- me->RemoveAllAuras();
+ RemoveAuras();
+
me->DeleteThreatList();
me->CombatStop(true);
me->LoadCreaturesAddon();
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index dc1f901d477..b33bfebf912 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -193,6 +193,8 @@ class SmartAI : public CreatureAI
mDespawnState = t ? 1 : 0;
}
void StartDespawn() { mDespawnState = 2; }
+
+ void RemoveAuras();
private:
uint32 mFollowCreditType;
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 34d465a5e7e..a2e70e9cbf2 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -1321,9 +1321,25 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
return;
- bool run = e.action.setRun.run ? true : false;
- CAST_AI(SmartAI, me->AI())->SetRun(run);
- me->GetMotionMaster()->MovePoint(0, e.target.x, e.target.y, e.target.z);
+ WorldObject* target = NULL;
+
+ if (e.GetTargetType() == SMART_TARGET_CREATURE_RANGE || e.GetTargetType() == SMART_TARGET_CREATURE_GUID ||
+ e.GetTargetType() == SMART_TARGET_CREATURE_DISTANCE || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_RANGE ||
+ e.GetTargetType() == SMART_TARGET_GAMEOBJECT_GUID || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_DISTANCE ||
+ e.GetTargetType() == SMART_TARGET_CLOSEST_CREATURE || e.GetTargetType() == SMART_TARGET_CLOSEST_GAMEOBJECT ||
+ e.GetTargetType() == SMART_TARGET_OWNER_OR_SUMMONER)
+ {
+ ObjectList* targets = GetTargets(e, unit);
+ if (!targets)
+ return;
+
+ target = targets->front();
+ }
+
+ if(!target)
+ me->GetMotionMaster()->MovePoint(0, e.target.x, e.target.y, e.target.z);
+ else
+ me->GetMotionMaster()->MovePoint(0, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
break;
}
case SMART_ACTION_RESPAWN_TARGET:
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index 7ebe8ca500f..0193ac2bfb6 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 1df5849ca75..63595b2439f 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -36,7 +36,7 @@ void SmartWaypointMgr::LoadFromDB()
waypoint_map.clear();
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_SMARTAI_WP);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_SMARTAI_WP);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -99,7 +99,7 @@ void SmartAIMgr::LoadSmartAIFromDB()
for (uint8 i = 0; i < SMART_SCRIPT_TYPE_MAX; i++)
mEventMap[i].clear(); //Drop Existing SmartAI List
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_SMART_SCRIPTS);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_SMART_SCRIPTS);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -254,12 +254,14 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e)
}
case SMART_TARGET_CREATURE_GUID:
{
- if (e.target.unitGUID.entry && !IsCreatureValid(e, e.target.unitGUID.entry)) return false;
+ if (e.target.unitGUID.entry && !IsCreatureValid(e, e.target.unitGUID.entry))
+ return false;
break;
}
case SMART_TARGET_GAMEOBJECT_GUID:
{
- if (e.target.goGUID.entry && !IsGameObjectValid(e, e.target.goGUID.entry)) return false;
+ if (e.target.goGUID.entry && !IsGameObjectValid(e, e.target.goGUID.entry))
+ return false;
break;
}
case SMART_TARGET_PLAYER_DISTANCE:
@@ -287,6 +289,7 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e)
case SMART_TARGET_THREAT_LIST:
case SMART_TARGET_CLOSEST_GAMEOBJECT:
case SMART_TARGET_CLOSEST_CREATURE:
+ case SMART_TARGET_STORED:
break;
default:
sLog->outErrorDb("SmartAIMgr: Not handled target_type(%u), Entry %d SourceType %u Event %u Action %u, skipped.", e.GetTargetType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index b12ef959847..f56cf478bf8 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the