Skip to content

Commit

Permalink
Implement areatrigger_teleport condition_id
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife authored and Fabi committed Jan 3, 2017
1 parent 3212ed5 commit a242d1e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
1 change: 1 addition & 0 deletions sql/base/mangos.sql
Expand Up @@ -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';

Expand Down
2 changes: 2 additions & 0 deletions 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;

6 changes: 6 additions & 0 deletions src/game/MiscHandler.cpp
Expand Up @@ -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);
}
Expand Down
15 changes: 12 additions & 3 deletions src/game/ObjectMgr.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -5809,6 +5810,13 @@ void ObjectMgr::LoadAreaTriggerTeleports()
}
}

if (at.conditionId)
{
const PlayerCondition* condition = sConditionStorage.LookupEntry<PlayerCondition>(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)
{
Expand Down Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions src/game/ObjectMgr.h
Expand Up @@ -85,6 +85,7 @@ struct AreaTrigger
float target_Y;
float target_Z;
float target_Orientation;
uint32 conditionId;

// Operators
bool IsMinimal() const
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a242d1e

Please sign in to comment.