*Wintergrasp: Prevent defenders team to click the relic. Patch by Spp.

*Zum'Rah Area Trigger Script, Zum'Rah should become hostile when approached. By totoro.
*Judgement of Light PPM based, not 100%. By Drevi.
*Fix Deflection Exploit. By manuel, thanks to TheNecromancer and Gyullo.
*Correct Wintergrasp Tenacity formulas, by Gyullo.
*A Spirit Guide Escort Quest, code from SD2, patch by manuel.
*TrullyOne/MeanMachine Waypoint System Restored. Patch by XTElite1.

--HG--
branch : trunk
This commit is contained in:
maximius
2009-09-19 12:13:08 -07:00
parent 15d85229fa
commit 0cf75ef9ea
17 changed files with 248 additions and 102 deletions
+6 -21
View File
@@ -182,7 +182,7 @@ void Creature::AddToWorld()
m_zoneScript->OnCreatureCreate(this, true);
ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
SearchFormationAndPath();
SearchFormation();
AIM_Initialize();
if(IsVehicle())
GetVehicleKit()->Install();
@@ -212,7 +212,7 @@ void Creature::DisappearAndDie()
RemoveCorpse();
}
void Creature::SearchFormationAndPath()
void Creature::SearchFormation()
{
if(isSummon())
return;
@@ -221,28 +221,9 @@ void Creature::SearchFormationAndPath()
if(!lowguid)
return;
bool usePath = (GetDefaultMovementType() == WAYPOINT_MOTION_TYPE);
CreatureGroupInfoType::iterator frmdata = CreatureGroupMap.find(lowguid);
if(frmdata != CreatureGroupMap.end())
{
if(usePath && lowguid != frmdata->second->leaderGUID)
{
SetDefaultMovementType(IDLE_MOTION_TYPE);
usePath = false;
}
formation_mgr.AddCreatureToGroup(frmdata->second->leaderGUID, this);
}
if(usePath)
{
if(WaypointMgr.GetPath(lowguid * 10))
SetWaypointPathId(lowguid * 10);
else
{
sLog.outErrorDb("Creature DBGUID %u has waypoint motion type, but it does not have a waypoint path!", lowguid);
SetDefaultMovementType(IDLE_MOTION_TYPE);
}
}
}
void Creature::RemoveCorpse()
@@ -2271,6 +2252,10 @@ bool Creature::LoadCreaturesAddon(bool reload)
if (cainfo->move_flags != 0)
SetUnitMovementFlags(cainfo->move_flags);
//Load Path
if (cainfo->path_id != 0)
m_path_id = cainfo->path_id;
if(cainfo->auras)
{
for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura)
+5 -4
View File
@@ -317,6 +317,7 @@ struct CreatureDataAddonAura
struct CreatureDataAddon
{
uint32 guidOrEntry;
uint32 path_id;
uint32 mount;
uint32 bytes1;
uint32 bytes2;
@@ -696,13 +697,13 @@ class TRINITY_DLL_SPEC Creature : public Unit
uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
uint32 GetWaypointPathId() const { return m_pathId; }
void SetWaypointPathId(uint32 pathid) { m_pathId = pathid; }
uint32 GetWaypointPath(){return m_path_id;}
void LoadPath(uint32 pathid) { m_path_id = pathid; }
uint32 GetCurrentWaypointID(){return m_waypointID;}
void UpdateWaypointID(uint32 wpID){m_waypointID = wpID;}
void SearchFormationAndPath();
void SearchFormation();
CreatureGroup *GetFormation() {return m_formation;}
void SetFormation(CreatureGroup *formation) {m_formation = formation;}
@@ -777,7 +778,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
private:
//WaypointMovementGenerator vars
uint32 m_waypointID;
uint32 m_pathId;
uint32 m_path_id;
//Formation var
CreatureGroup *m_formation;
+18 -37
View File
@@ -1162,7 +1162,7 @@ bool ChatHandler::HandleNpcAddMoveCommand(const char* args)
// update movement type
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid);
if(pCreature && pCreature->GetWaypointPathId())
if(pCreature && pCreature->GetWaypointPath())
{
pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
pCreature->GetMotionMaster()->Initialize();
@@ -1487,7 +1487,7 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(const char* args)
{
// update movement type
if(doNotDelete == false)
pCreature->SetWaypointPathId(0);
pCreature->LoadPath(0);
pCreature->SetDefaultMovementType(move_type);
pCreature->GetMotionMaster()->Initialize();
@@ -2300,7 +2300,7 @@ bool ChatHandler::HandleWpAddCommand(const char* args)
if (!path_number)
{
if(target)
pathid = target->GetWaypointPathId();
pathid = target->GetWaypointPath();
else
{
QueryResult *result = WorldDatabase.PQuery( "SELECT MAX(id) FROM waypoint_data");
@@ -2384,7 +2384,6 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
return true;
}
/*
guidlow = target->GetDBTableGUIDLow();
QueryResult *result = WorldDatabase.PQuery( "SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow);
@@ -2395,11 +2394,10 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
}
else
WorldDatabase.PExecute("INSERT INTO creature_addon(guid,path_id) VALUES ('%u','%u')", guidlow, pathid);
*/
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow);
target->SetWaypointPathId(pathid);
target->LoadPath(pathid);
target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
target->GetMotionMaster()->Initialize();
target->MonsterSay("Path loaded.",0,0);
@@ -2433,39 +2431,22 @@ bool ChatHandler::HandleWpUnLoadPathCommand(const char *args)
return true;
}
if(target->GetWaypointPathId())
if(target->GetCreatureAddon())
{
uint32 pathId = target->GetDBTableGUIDLow() * 10;
if(target->GetWaypointPathId() == pathId)
if(target->GetCreatureAddon()->path_id != 0)
{
for(uint32 i = 1; i < 11; ++i)
{
if(i == 10)
{
PSendSysMessage("%s%s|r", "|cffff33ff", "Target cannot have more than 9 script paths. Unloading failed.");
break;
}
if(WaypointMgr.GetPath(++pathId))
continue;
WorldDatabase.PExecute("UPDATE waypoint_data SET id = %u WHERE id = %u", pathId, target->GetDBTableGUIDLow() * 10);
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
target->SetWaypointPathId(0);
target->UpdateWaypointID(0);
target->SetDefaultMovementType(IDLE_MOTION_TYPE);
target->GetMotionMaster()->Initialize();
target->GetMotionMaster()->MoveTargetedHome();
PSendSysMessage("Path unloaded.");
break;
}
WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow());
target->UpdateWaypointID(0);
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
target->LoadPath(0);
target->SetDefaultMovementType(IDLE_MOTION_TYPE);
target->GetMotionMaster()->MoveTargetedHome();
target->GetMotionMaster()->Initialize();
target->MonsterSay("Path unloaded.",0,0);
return true;
}
else
PSendSysMessage("%s%s|r", "|cffff33ff", "Target has path but that path is not its default path. Unloading failed.");
PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path.");
}
else
PSendSysMessage("%s%s|r", "|cffff33ff", "Target has no loaded path.");
return true;
}
@@ -2926,7 +2907,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
return false;
}
pathid = target->GetWaypointPathId();
pathid = target->GetWaypointPath();
}
else
{
@@ -4221,7 +4202,7 @@ bool ChatHandler::HandleNpcAddFormationCommand(const char* args)
group_member->groupAI = 0;
CreatureGroupMap[lowguid] = group_member;
pCreature->SearchFormationAndPath();
pCreature->SearchFormation();
WorldDatabase.PExecuteLog("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u','%u','%f', '%f', '%u')",
leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI);
+8
View File
@@ -7533,6 +7533,14 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
trigger_spell_id = 26470;
break;
}
// Deflection
case 52420:
{
if(GetHealth()*100 / GetMaxHealth() >= 35)
return false;
break;
}
// Cheat Death
case 28845:
{
+6 -14
View File
@@ -24,12 +24,12 @@
#include "ProgressBar.h"
#include "MapManager.h"
WaypointPathMap WaypointPathHolder;
UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
WaypointStore WaypointMgr;
void WaypointStore::Free()
{
WaypointPathHolder.clear();
waypoint_map.clear();
}
void WaypointStore::Load()
@@ -88,7 +88,7 @@ void WaypointStore::Load()
path_data->push_back(wp);
if(id != last_id)
WaypointPathHolder[id] = path_data;
waypoint_map[id] = path_data;
last_id = id;
@@ -99,16 +99,8 @@ void WaypointStore::Load()
void WaypointStore::UpdatePath(uint32 id)
{
// Prevent memory leak, deallocate allocated memory instead of just clearing from object holder
WaypointPathMap::iterator itr = WaypointPathHolder.find(id);
if(itr != WaypointPathHolder.end())
{
for(WaypointPath::iterator jtr = WaypointPathHolder[id]->begin(); jtr != WaypointPathHolder[id]->end(); ++jtr)
{
delete (*jtr);
}
delete itr->second;
}
if(waypoint_map.find(id)!= waypoint_map.end())
waypoint_map[id]->clear();
QueryResult *result;
@@ -150,7 +142,7 @@ void WaypointStore::UpdatePath(uint32 id)
}
while (result->NextRow());
WaypointPathHolder[id] = path_data;
waypoint_map[id] = path_data;
delete result;
}
+4 -7
View File
@@ -34,9 +34,7 @@ struct WaypointData
};
typedef std::vector<WaypointData*> WaypointPath;
typedef UNORDERED_MAP<uint32, WaypointPath*> WaypointPathMap;
extern WaypointPathMap WaypointPathHolder;
extern UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
class WaypointStore
{
@@ -50,10 +48,9 @@ class WaypointStore
WaypointPath* GetPath(uint32 id)
{
WaypointPathMap::iterator itr = WaypointPathHolder.find(id);
if(itr != WaypointPathHolder.end())
return itr->second;
return NULL;
if(waypoint_map.find(id) != waypoint_map.end())
return waypoint_map[id];
else return 0;
}
inline uint32 GetRecordsCount() { return records; }
+3 -3
View File
@@ -97,7 +97,7 @@ WaypointMovementGenerator<Creature>::Initialize(Creature &u)
//i_nextMoveTime.Reset(0);
StopedByPlayer = false;
if(!path_id)
path_id = u.GetWaypointPathId();
path_id = u.GetWaypointPath();
waypoints = WaypointMgr.GetPath(path_id);
i_currentNode = 0;
if(waypoints && waypoints->size())
@@ -223,7 +223,7 @@ template bool WaypointMovementGenerator<Player>::Update(Player &, const uint32 &
template void WaypointMovementGenerator<Player>::MovementInform(Player &);
//----------------------------------------------------//
void FlightPathMovementGenerator::SetWaypointPathId(Player &)
void FlightPathMovementGenerator::LoadPath(Player &)
{
objmgr.GetTaxiPathNodes(i_pathId, i_path,i_mapIds);
}
@@ -248,7 +248,7 @@ void FlightPathMovementGenerator::Initialize(Player &player)
player.getHostilRefManager().setOnlineOfflineState(false);
player.addUnitState(UNIT_STAT_IN_FLIGHT);
player.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
SetWaypointPathId(player);
LoadPath(player);
Traveller<Player> traveller(player);
// do not send movement, it was sent already
i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false);
+2 -2
View File
@@ -50,7 +50,7 @@ class TRINITY_DLL_SPEC PathMovementBase
bool MovementInProgress(void) const { return i_currentNode < i_path.Size(); }
void SetWaypointPathId(T &);
void LoadPath(T &);
void ReloadPath(T &);
uint32 GetCurrentNode() const { return i_currentNode; }
@@ -104,7 +104,7 @@ public PathMovementBase<Player>
bool Update(Player &, const uint32 &);
MovementGeneratorType GetMovementGeneratorType() { return FLIGHT_MOTION_TYPE; }
void SetWaypointPathId(Player &);
void LoadPath(Player &);
void ReloadPath(Player &) { /* don't reload flight path */ }
Path& GetPath() { return i_path; }
+11 -6
View File
@@ -634,6 +634,10 @@ bool OPvPWintergrasp::UpdateGameObjectInfo(GameObject *go) const
case 190763:
go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[m_defender]);
return true;
// Titan relic
case 192829:
go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[OTHER_TEAM(m_defender)]);
return true;
}
// Note: this is only for test, still need db support
@@ -742,9 +746,9 @@ void OPvPWintergrasp::UpdateTenacityStack()
if(allianceNum && hordeNum)
{
if(allianceNum < hordeNum)
newStack = hordeNum / allianceNum - 1; // positive, should cast on alliance
newStack = (hordeNum / allianceNum - 1)*4; // positive, should cast on alliance
else if(allianceNum > hordeNum)
newStack = 1 - int32(allianceNum / hordeNum); // negative, should cast on horde
newStack = (1 - int32(allianceNum / hordeNum))*4; // negative, should cast on horde
}
if(newStack == m_tenacityStack)
@@ -774,11 +778,12 @@ void OPvPWintergrasp::UpdateTenacityStack()
{
TeamId team = newStack > 0 ? TEAM_ALLIANCE : TEAM_HORDE;
if(newStack < 0) newStack = -newStack;
int32 auraStack = newStack > 20 ? 20 : newStack; //Dont let it be higher than 20
for(PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if((*itr)->getLevel() > 69)
(*itr)->SetAuraStack(SPELL_TENACITY, *itr, newStack);
(*itr)->SetAuraStack(SPELL_TENACITY, *itr, auraStack);
for(CreatureSet::iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
(*itr)->SetAuraStack(SPELL_TENACITY_VEHICLE, *itr, newStack);
(*itr)->SetAuraStack(SPELL_TENACITY_VEHICLE, *itr, auraStack);
}
}
@@ -942,13 +947,13 @@ void OPvPWintergrasp::EndBattle()
}
}
TeamId loser = OTHER_TEAM(m_defender);
/*TeamId loser = OTHER_TEAM(m_defender);
for(PlayerSet::iterator itr = m_players[loser].begin(); itr != m_players[loser].end();)
{
Player *plr = *itr;
++itr;
plr->CastSpell(plr, SPELL_TELEPORT_DALARAN, true);
}
}*/
// remove auras from players who are not online
CharacterDatabase.PExecute("DELETE FROM character_aura WHERE spell IN (%u,%u,%u)", SPELL_RECRUIT, SPELL_CORPORAL, SPELL_LIEUTENANT);