From a242d1ebc9eddd2a6bea5422e3d1a7392061504e Mon Sep 17 00:00:00 2001 From: killerwife Date: Fri, 2 Dec 2016 19:25:53 +0100 Subject: [PATCH] Implement areatrigger_teleport condition_id --- sql/base/mangos.sql | 1 + .../mangos/areatriggerteleport_condition.sql | 2 ++ src/game/MiscHandler.cpp | 6 +++++ src/game/ObjectMgr.cpp | 15 +++++++++--- src/game/ObjectMgr.h | 24 ++++++++++--------- 5 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 sql/updates/mangos/areatriggerteleport_condition.sql diff --git a/sql/base/mangos.sql b/sql/base/mangos.sql index 03063c0eb4..764661531d 100644 --- a/sql/base/mangos.sql +++ b/sql/base/mangos.sql @@ -146,6 +146,7 @@ CREATE TABLE `areatrigger_teleport` ( `target_position_y` float NOT NULL DEFAULT '0', `target_position_z` float NOT NULL DEFAULT '0', `target_orientation` float NOT NULL DEFAULT '0', + `condition_id` INT(11) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Trigger System'; diff --git a/sql/updates/mangos/areatriggerteleport_condition.sql b/sql/updates/mangos/areatriggerteleport_condition.sql new file mode 100644 index 0000000000..96dd2b3eba --- /dev/null +++ b/sql/updates/mangos/areatriggerteleport_condition.sql @@ -0,0 +1,2 @@ +ALTER TABLE areatrigger_teleport ADD COLUMN `condition_id` INT(11) unsigned NOT NULL default '0' AFTER target_orientation; + diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 9f786c9985..4558bae430 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -807,6 +807,12 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) player->SpawnCorpseBones(); } + if (at->conditionId && !sObjectMgr.IsPlayerMeetToCondition(at->conditionId, player, player->GetMap(), nullptr, CONDITION_FROM_AREATRIGGER_TELEPORT)) + { + /*TODO player->GetSession()->SendAreaTriggerMessage("%s", "YOU SHALL NOT PASS!");*/ + return; + } + // teleport player (trigger requirement will be checked on TeleportTo) player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT, at); } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index c74508d792..21a4c5cc43 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -5704,8 +5704,8 @@ void ObjectMgr::LoadAreaTriggerTeleports() uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult* result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, required_quest_done, required_quest_done_heroic, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + QueryResult* result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, required_quest_done, required_quest_done_heroic, target_map, target_position_x, target_position_y, target_position_z, target_orientation, condition_id FROM areatrigger_teleport"); if (!result) { BarGoLink bar(1); @@ -5741,6 +5741,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() at.target_Y = fields[10].GetFloat(); at.target_Z = fields[11].GetFloat(); at.target_Orientation = fields[12].GetFloat(); + at.conditionId = fields[13].GetUInt32(); AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); if (!atEntry) @@ -5809,6 +5810,13 @@ void ObjectMgr::LoadAreaTriggerTeleports() } } + if (at.conditionId) + { + const PlayerCondition* condition = sConditionStorage.LookupEntry(at.conditionId); + if (!condition) // condition does not exist for some reason + sLog.outErrorDb("Table `areatrigger_teleport` entry %u has `condition_id` = %u but does not exist.", Trigger_ID, at.conditionId); + } + MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); if (!mapEntry) { @@ -7906,7 +7914,8 @@ char const* conditionSourceToStr[] = "spell_area check", // CONDITION_FROM_SPELL_AREA "npc_spellclick_spells check", // CONDITION_FROM_SPELLCLICK "DBScript engine", // CONDITION_FROM_DBSCRIPTS - "trainer's spell check", // CONDITION_FROM_TRAINER + "trainer's spell check", // CONDITION_FROM_TRAINER + "areatrigger teleport check", // CONDITION_FROM_AREATRIGGER_TELEPORT }; // Checks if player meets the condition diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 9161e34c82..75dda20055 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -85,6 +85,7 @@ struct AreaTrigger float target_Y; float target_Z; float target_Orientation; + uint32 conditionId; // Operators bool IsMinimal() const @@ -402,17 +403,18 @@ enum ConditionType enum ConditionSource // From where was the condition called? { - CONDITION_FROM_LOOT = 0, // Used to check a *_loot_template entry - CONDITION_FROM_REFERING_LOOT = 1, // Used to check a entry refering to a reference_loot_template entry - CONDITION_FROM_GOSSIP_MENU = 2, // Used to check a gossip menu menu-text - CONDITION_FROM_GOSSIP_OPTION = 3, // Used to check a gossip menu option-item - CONDITION_FROM_EVENTAI = 4, // Used to check EventAI Event "On Receive Emote" - CONDITION_FROM_HARDCODED = 5, // Used to check a hardcoded event - not actually a condition - CONDITION_FROM_VENDOR = 6, // Used to check a condition from a vendor - CONDITION_FROM_SPELL_AREA = 7, // Used to check a condition from spell_area table - CONDITION_FROM_SPELLCLICK = 8, // Used to check a condition from npc_spellclick_spells table - CONDITION_FROM_DBSCRIPTS = 9, // Used to check a condition from DB Scripts Engine - CONDITION_FROM_TRAINER = 10, // Used to check a condition from npc_trainer and npc_trainer_template + CONDITION_FROM_LOOT = 0, // Used to check a *_loot_template entry + CONDITION_FROM_REFERING_LOOT = 1, // Used to check a entry refering to a reference_loot_template entry + CONDITION_FROM_GOSSIP_MENU = 2, // Used to check a gossip menu menu-text + CONDITION_FROM_GOSSIP_OPTION = 3, // Used to check a gossip menu option-item + CONDITION_FROM_EVENTAI = 4, // Used to check EventAI Event "On Receive Emote" + CONDITION_FROM_HARDCODED = 5, // Used to check a hardcoded event - not actually a condition + CONDITION_FROM_VENDOR = 6, // Used to check a condition from a vendor + CONDITION_FROM_SPELL_AREA = 7, // Used to check a condition from spell_area table + CONDITION_FROM_SPELLCLICK = 8, // Used to check a condition from npc_spellclick_spells table + CONDITION_FROM_DBSCRIPTS = 9, // Used to check a condition from DB Scripts Engine + CONDITION_FROM_TRAINER = 10, // Used to check a condition from npc_trainer and npc_trainer_template + CONDITION_FROM_AREATRIGGER_TELEPORT = 11, // Used to check a condition from areatrigger_teleport }; class PlayerCondition