Extend clientless bots with browser queues, PvP intents and test automation
This commit is contained in:
1 parent
649915e575
commit
69b5a1c4a1
245 files changed
+49535
-114
No files matched your search
@@ -41,43 +41,65 @@ bool ClientlessTravelGraphMgr::ResolvePortalUse(uint32 spawnId,
|
||||
portal = {};
|
||||
auto const* spawn = sObjectMgr->GetGameObjectData(spawnId);
|
||||
auto const* info = spawn ? sObjectMgr->GetGameObjectTemplate(spawn->id) : nullptr;
|
||||
if (!info || info->type != GAMEOBJECT_TYPE_SPELLCASTER)
|
||||
bool const caster=info && info->type==GAMEOBJECT_TYPE_SPELLCASTER;
|
||||
bool const goober=info && info->type==GAMEOBJECT_TYPE_GOOBER;
|
||||
if(!caster && !goober)
|
||||
{error="spawn must be a static clickable spellcaster or goober portal";return false;}
|
||||
if(goober && (info->goober.open || info->goober.questID || info->goober.eventID ||
|
||||
info->goober.pageID || info->goober.gossipID || info->goober.linkedTrap || info->goober.consumable))
|
||||
{error="quest, event, locked or consumable goober needs a dedicated interaction";return false;}
|
||||
uint32 rootSpell=caster?info->spellcaster.spell:info->goober.spell;
|
||||
uint8 mask=(caster?info->spellcaster.playerCast:info->goober.playerCast)?3:2;
|
||||
SpellInfo const* spell=sSpellMgr->GetSpellInfo(rootSpell);
|
||||
SpellTargetPosition resolved;
|
||||
SpellTargetPosition const* destination=nullptr;
|
||||
std::unordered_set<uint32> seen;
|
||||
uint32 delay=0;
|
||||
for(unsigned depth=0;spell && depth<5;++depth)
|
||||
{
|
||||
error = "spawn must be a static SPELLCASTER GameObject (type 22)";
|
||||
return false;
|
||||
}
|
||||
SpellInfo const* spell = sSpellMgr->GetSpellInfo(info->spellcaster.spell);
|
||||
SpellTargetPosition const* destination = nullptr;
|
||||
if (spell)
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
if(!seen.insert(spell->Id).second)break;
|
||||
portal.Requirements.emplace_back(spell->Id,mask);
|
||||
uint32 next=0;
|
||||
for(uint8 i=0;i<MAX_SPELL_EFFECTS;++i)
|
||||
{
|
||||
auto const& effect = spell->Effects[i];
|
||||
if (effect.Effect != SPELL_EFFECT_TELEPORT_UNITS)
|
||||
continue;
|
||||
// Only explicit database destinations are unambiguous. Homebind,
|
||||
// script-selected destinations and triggered spell chains need
|
||||
// their own interaction definitions, not guessed target nodes.
|
||||
if (destination || (effect.TargetA.GetTarget() != TARGET_DEST_DB &&
|
||||
effect.TargetB.GetTarget() != TARGET_DEST_DB))
|
||||
auto const& effect=spell->Effects[i];
|
||||
if(effect.Effect==SPELL_EFFECT_TELEPORT_UNITS)
|
||||
{
|
||||
error = "portal spell has an ambiguous or non-DB destination";
|
||||
return false;
|
||||
if(destination || next || (effect.TargetA.GetTarget()!=TARGET_DEST_DB && effect.TargetB.GetTarget()!=TARGET_DEST_DB))
|
||||
{error="portal spell has an ambiguous or non-DB destination";return false;}
|
||||
destination=sSpellMgr->GetSpellTargetPosition(spell->Id,SpellEffIndex(i));
|
||||
if(!destination){error="portal teleport effect has no native spell_target_position";return false;}
|
||||
}
|
||||
destination = sSpellMgr->GetSpellTargetPosition(spell->Id, SpellEffIndex(i));
|
||||
if (!destination)
|
||||
else if(effect.Effect==SPELL_EFFECT_SCRIPT_EFFECT)
|
||||
{
|
||||
error = "portal teleport effect has no native spell_target_position";
|
||||
return false;
|
||||
auto script=sSpellScripts.find(uint32(spell->Id | (uint32(i)<<24)));
|
||||
if(script==sSpellScripts.end() || script->second.empty())continue;
|
||||
if(destination || next || script->second.size()!=1)
|
||||
{error="portal script must have exactly one deterministic action";return false;}
|
||||
auto const& action=script->second.begin()->second;
|
||||
if(script->second.begin()->first>3-delay)
|
||||
{error="portal script delay exceeds native interaction timeout reserve";return false;}
|
||||
delay+=script->second.begin()->first;
|
||||
if(action.command==SCRIPT_COMMAND_CAST_SPELL && action.CastSpell.Flags==SF_CASTSPELL_TARGET_TO_TARGET &&
|
||||
(action.CastSpell.CreatureEntry==0 || action.CastSpell.CreatureEntry==1))
|
||||
next=action.CastSpell.SpellID;
|
||||
else if(action.command==SCRIPT_COMMAND_TELEPORT_TO && !action.TeleportTo.Flags)
|
||||
{
|
||||
resolved.target_mapId=action.TeleportTo.MapID;
|
||||
resolved.target_X=action.TeleportTo.DestX;resolved.target_Y=action.TeleportTo.DestY;
|
||||
resolved.target_Z=action.TeleportTo.DestZ;resolved.target_Orientation=action.TeleportTo.Orientation;
|
||||
destination=&resolved;
|
||||
}
|
||||
else {error="portal script is not a fixed visitor teleport";return false;}
|
||||
}
|
||||
}
|
||||
if (!destination)
|
||||
{
|
||||
error = "portal requires a direct teleport spell with a fixed DB destination";
|
||||
return false;
|
||||
if(destination)break;
|
||||
spell=next?sSpellMgr->GetSpellInfo(next):nullptr;mask=3;
|
||||
}
|
||||
if(!destination){error="portal requires an unambiguous native fixed teleport destination";return false;}
|
||||
portal.SpawnId = spawnId;
|
||||
portal.Entry = spawn->id;
|
||||
portal.SpellId = spell->Id;
|
||||
portal.SpellId = rootSpell;
|
||||
portal.Source.Key = "portal_go_" + std::to_string(spawnId) + "_source";
|
||||
portal.Source.Type = "portal";
|
||||
portal.Source.WorldPointKey = portal.Source.Key;
|
||||
@@ -107,12 +129,11 @@ bool ClientlessTravelGraphMgr::PortalPrerequisites(Player const* player,uint32 e
|
||||
{
|
||||
auto portal=GetPortalUse(edgeDatabaseId);
|
||||
auto info=portal?sObjectMgr->GetGameObjectTemplate(portal->Entry):nullptr;
|
||||
if(!info || info->type!=GAMEOBJECT_TYPE_SPELLCASTER)return false;
|
||||
// Native Spell::CheckCast sees caster,target. Public portals either let the
|
||||
// player cast on themself or let the object cast on the visiting player.
|
||||
uint8 playerTargets=info->spellcaster.playerCast?3:2;
|
||||
return sConditionMgr->IsPlayerMeetingPrerequisiteConditions(CONDITION_SOURCE_TYPE_SPELL,
|
||||
portal->SpellId,player,playerTargets);
|
||||
if(!info || (info->type!=GAMEOBJECT_TYPE_SPELLCASTER && info->type!=GAMEOBJECT_TYPE_GOOBER))return false;
|
||||
for(auto const& requirement:portal->Requirements)
|
||||
if(!sConditionMgr->IsPlayerMeetingPrerequisiteConditions(CONDITION_SOURCE_TYPE_SPELL,
|
||||
requirement.first,player,requirement.second))return false;
|
||||
return !portal->Requirements.empty();
|
||||
}
|
||||
|
||||
bool ClientlessTravelGraphMgr::Reload()
|
||||
|
||||
Reference in new issue
Block a user