From 5651828bf74edb760d67700942fc65d51c816e0a Mon Sep 17 00:00:00 2001 From: Neo2003 Date: Sat, 4 Oct 2008 06:17:19 -0500 Subject: [svn] * Added ACE for Linux and Windows (Thanks Derex for Linux part and partial Windows part) * Updated to 6721 and 676 * Fixed TrinityScript logo * Version updated to 0.2.6721.676 --HG-- branch : trunk rename : 6700-670 => 6721-676 --- src/bindings/scripts/include/sc_creature.cpp | 1224 +++++++++++++------------- src/bindings/scripts/include/sc_gossip.h | 366 ++++---- 2 files changed, 795 insertions(+), 795 deletions(-) (limited to 'src/bindings/scripts/include') diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index afdbf590c65..2663f4585b5 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -1,612 +1,612 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#include "precompiled.h" -#include "Item.h" -#include "Spell.h" -#include "WorldPacket.h" - -// Spell summary for ScriptedAI::SelectSpell -struct TSpellSummary { - uint8 Targets; // set of enum SelectTarget - uint8 Effects; // set of enum SelectEffect -} *SpellSummary; - -bool ScriptedAI::IsVisible(Unit* who) const -{ - if (!who) - return false; - - return (m_creature->GetDistance(who) < VISIBLE_RANGE) && who->isVisibleForOrDetect(m_creature,true); -} - -void ScriptedAI::MoveInLineOfSight(Unit *who) -{ - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } -} - -void ScriptedAI::AttackStart(Unit* who) -{ - if (!who) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackAndMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } -} - -void ScriptedAI::UpdateAI(const uint32 diff) -{ - //Check if we have a current target - if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) - { - if( m_creature->isAttackReady() ) - { - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - } - } -} - -void ScriptedAI::EnterEvadeMode() -{ - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - m_creature->LoadCreaturesAddon(); - - if( m_creature->isAlive() ) - m_creature->GetMotionMaster()->MoveTargetedHome(); - - m_creature->SetLootRecipient(NULL); - - InCombat = false; - Reset(); -} - -void ScriptedAI::JustRespawned() -{ - InCombat = false; - Reset(); -} - -void ScriptedAI::DoStartAttackAndMovement(Unit* victim, float distance, float angle) -{ - if (!victim) - return; - - if ( m_creature->Attack(victim, true) ) - { - m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); - m_creature->AddThreat(victim, 0.0f); - } -} - -void ScriptedAI::DoStartAttackNoMovement(Unit* victim) -{ - if (!victim) - return; - - if ( m_creature->Attack(victim, true) ) - { - m_creature->AddThreat(victim, 0.0f); - } -} - - -void ScriptedAI::DoMeleeAttackIfReady() -{ - //Make sure our attack is ready and we aren't currently casting before checking distance - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) - { - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - } -} - -void ScriptedAI::DoStopAttack() -{ - if( m_creature->getVictim() != NULL ) - { - m_creature->AttackStop(); - } -} - -void ScriptedAI::DoCast(Unit* victim, uint32 spellId, bool triggered) -{ - if (!victim || m_creature->IsNonMeleeSpellCasted(false)) - return; - - m_creature->StopMoving(); - m_creature->CastSpell(victim, spellId, triggered); -} - -void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered) -{ - if (!who || m_creature->IsNonMeleeSpellCasted(false)) - return; - - m_creature->StopMoving(); - m_creature->CastSpell(who, spellInfo, triggered); -} - -void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target) -{ - if (target)m_creature->Say(text, language, target->GetGUID()); - else m_creature->Say(text, language, 0); -} - -void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target) -{ - if (target)m_creature->Yell(text, language, target->GetGUID()); - else m_creature->Yell(text, language, 0); -} - -void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote) -{ - if (target)m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); - else m_creature->TextEmote(text, 0, IsBossEmote); -} - -void ScriptedAI::DoWhisper(const char* text, Unit* reciever, bool IsBossWhisper) -{ - if (!reciever || reciever->GetTypeId() != TYPEID_PLAYER) - return; - - m_creature->Whisper(text, reciever->GetGUID(), IsBossWhisper); -} - -void ScriptedAI::DoPlaySoundToSet(Unit* unit, uint32 sound) -{ - if (!unit) - return; - - if (!GetSoundEntriesStore()->LookupEntry(sound)) - { - error_log("SD2: Invalid soundId %u used in DoPlaySoundToSet (by unit TypeId %u, guid %u)", sound, unit->GetTypeId(), unit->GetGUID()); - return; - } - - WorldPacket data(4); - data.SetOpcode(SMSG_PLAY_SOUND); - data << uint32(sound); - unit->SendMessageToSet(&data,false); -} - -Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime) -{ - return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TempSummonType)type, despawntime); -} - -Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 position) -{ - //ThreatList m_threatlist; - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); - std::list::reverse_iterator r = m_threatlist.rbegin(); - - if (position >= m_threatlist.size() || !m_threatlist.size()) - return NULL; - - switch (target) - { - case SELECT_TARGET_RANDOM: - advance ( i , position + (rand() % (m_threatlist.size() - position ) )); - return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - break; - - case SELECT_TARGET_TOPAGGRO: - advance ( i , position); - return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - break; - - case SELECT_TARGET_BOTTOMAGGRO: - advance ( r , position); - return Unit::GetUnit((*m_creature),(*r)->getUnitGuid()); - break; - } - - return NULL; -} - -SpellEntry const* ScriptedAI::SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTarget Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effects) -{ - //No target so we can't cast - if (!Target) - return false; - - //Silenced so we can't cast - if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - return false; - - //Using the extended script system we first create a list of viable spells - SpellEntry const* Spell[4]; - Spell[0] = 0; - Spell[1] = 0; - Spell[2] = 0; - Spell[3] = 0; - - uint32 SpellCount = 0; - - SpellEntry const* TempSpell; - SpellRangeEntry const* TempRange; - - //Check if each spell is viable(set it to null if not) - for (uint32 i = 0; i < 4; i++) - { - TempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]); - - //This spell doesn't exist - if (!TempSpell) - continue; - - // Targets and Effects checked first as most used restrictions - //Check the spell targets if specified - if ( Targets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (Targets-1))) ) - continue; - - //Check the type of spell if we are looking for a specific spell type - if ( Effects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (Effects-1))) ) - continue; - - //Check for school if specified - if (School >= 0 && TempSpell->SchoolMask & School) - continue; - - //Check for spell mechanic if specified - if (Mechanic >= 0 && TempSpell->Mechanic != Mechanic) - continue; - - //Make sure that the spell uses the requested amount of power - if (PowerCostMin && TempSpell->manaCost < PowerCostMin) - continue; - - if (PowerCostMax && TempSpell->manaCost > PowerCostMax) - continue; - - //Continue if we don't have the mana to actually cast this spell - if (TempSpell->manaCost > m_creature->GetPower((Powers)TempSpell->powerType)) - continue; - - //Get the Range - TempRange = GetSpellRangeStore()->LookupEntry(TempSpell->rangeIndex); - - //Spell has invalid range store so we can't use it - if (!TempRange) - continue; - - //Check if the spell meets our range requirements - if (RangeMin && TempRange->maxRange < RangeMin) - continue; - if (RangeMax && TempRange->maxRange > RangeMax) - continue; - - //Check if our target is in range - if (m_creature->IsWithinDistInMap(Target, TempRange->minRange) || !m_creature->IsWithinDistInMap(Target, TempRange->maxRange)) - continue; - - //All good so lets add it to the spell list - Spell[SpellCount] = TempSpell; - SpellCount++; - } - - //We got our usable spells so now lets randomly pick one - if (!SpellCount) - return NULL; - - return Spell[rand()%SpellCount]; -} - -bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered) -{ - //No target so we can't cast - if (!Target || !Spell) - return false; - - //Silenced so we can't cast - if (!Triggered && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - return false; - - //Check for power - if (!Triggered && m_creature->GetPower((Powers)Spell->powerType) < Spell->manaCost) - return false; - - SpellRangeEntry const *TempRange = NULL; - - TempRange = GetSpellRangeStore()->LookupEntry(Spell->rangeIndex); - - //Spell has invalid range store so we can't use it - if (!TempRange) - return false; - - //Unit is out of range of this spell - if (m_creature->GetDistance(Target) > TempRange->maxRange || m_creature->GetDistance(Target) < TempRange->minRange) - return false; - - return true; -} - -void FillSpellSummary() -{ - SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()]; - - SpellEntry const* TempSpell; - - for (int i=0; i < GetSpellStore()->GetNumRows(); i++ ) - { - SpellSummary[i].Effects = 0; - SpellSummary[i].Targets = 0; - - TempSpell = GetSpellStore()->LookupEntry(i); - //This spell doesn't exist - if (!TempSpell) - continue; - - for (int j=0; j<3; j++) - { - //Spell targets self - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1); - - //Spell targets a single enemy - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || - TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1); - - //Spell targets AoE at enemy - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1); - - //Spell targets an enemy - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || - TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1); - - //Spell targets a single friend(or self) - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1); - - //Spell targets aoe friends - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1); - - //Spell targets any friend(or self) - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1); - - //Make sure that this spell includes a damage effect - if ( TempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || - TempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL || - TempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE || - TempSpell->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ) - SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1); - - //Make sure that this spell includes a healing effect (or an apply aura with a periodic heal) - if ( TempSpell->Effect[j] == SPELL_EFFECT_HEAL || - TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH || - TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL || - (TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA && TempSpell->EffectApplyAuraName[j]== 8 )) - SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1); - - //Make sure that this spell applies an aura - if ( TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA ) - SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1); - } - } -} - -void ScriptedAI::DoZoneInCombat(Unit* pUnit) -{ - if (!pUnit) - pUnit = m_creature; - - Map *map = pUnit->GetMap(); - - if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated - { - error_log("SD2: DoZoneInCombat call for map that isn't an instance (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); - return; - } - - if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty()) - { - error_log("SD2: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); - - return; - } - - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; - for (i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if(!(*i)->isGameMaster()) - pUnit->AddThreat(*i, 0.0f); - } -} - -void ScriptedAI::DoResetThreat() -{ - if (!m_creature->CanHaveThreatList() || m_creature->getThreatManager().isThreatListEmpty()) - { - error_log("SD2: DoResetThreat called for creature that either cannot have threat list or has empty threat list (m_creature entry = %d)", m_creature->GetEntry()); - - return; - } - - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator itr; - - for(itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr) - { - Unit* pUnit = NULL; - pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); - if(pUnit && m_creature->getThreatManager().getThreat(pUnit)) - m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); - } -} - -void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o) -{ - if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) - { - if(pUnit) - error_log("SD2: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", m_creature->GetGUID(), m_creature->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), x, y, z, o); - return; - } - - ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); -} - -Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) -{ - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Unit* pUnit = NULL; - - MostHPMissingInRange u_check(m_creature, range, MinHPDiff); - MaNGOS::UnitLastSearcher searcher(pUnit, u_check); - - /* - typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; - This means that if we only search grid then we cannot possibly return pets or players so this is safe - */ - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap())); - return pUnit; -} - -std::list ScriptedAI::DoFindFriendlyCC(float range) -{ - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list pList; - - FriendlyCCedInRange u_check(m_creature, range); - MaNGOS::CreatureListSearcher searcher(pList, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); - - return pList; -} - -std::list ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 spellid) -{ - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list pList; - - FriendlyMissingBuffInRange u_check(m_creature, range, spellid); - MaNGOS::CreatureListSearcher searcher(pList, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); - - return pList; -} - -void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who) -{ - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } -} - -void Scripted_NoMovementAI::AttackStart(Unit* who) -{ - if (!who) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackNoMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#include "precompiled.h" +#include "Item.h" +#include "Spell.h" +#include "WorldPacket.h" + +// Spell summary for ScriptedAI::SelectSpell +struct TSpellSummary { + uint8 Targets; // set of enum SelectTarget + uint8 Effects; // set of enum SelectEffect +} *SpellSummary; + +bool ScriptedAI::IsVisible(Unit* who) const +{ + if (!who) + return false; + + return (m_creature->GetDistance(who) < VISIBLE_RANGE) && who->isVisibleForOrDetect(m_creature,true); +} + +void ScriptedAI::MoveInLineOfSight(Unit *who) +{ + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } +} + +void ScriptedAI::AttackStart(Unit* who) +{ + if (!who) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + DoStartAttackAndMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } +} + +void ScriptedAI::UpdateAI(const uint32 diff) +{ + //Check if we have a current target + if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) + { + if( m_creature->isAttackReady() ) + { + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + } + } +} + +void ScriptedAI::EnterEvadeMode() +{ + m_creature->InterruptNonMeleeSpells(true); + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + m_creature->LoadCreaturesAddon(); + + if( m_creature->isAlive() ) + m_creature->GetMotionMaster()->MoveTargetedHome(); + + m_creature->SetLootRecipient(NULL); + + InCombat = false; + Reset(); +} + +void ScriptedAI::JustRespawned() +{ + InCombat = false; + Reset(); +} + +void ScriptedAI::DoStartAttackAndMovement(Unit* victim, float distance, float angle) +{ + if (!victim) + return; + + if ( m_creature->Attack(victim, true) ) + { + m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); + m_creature->AddThreat(victim, 0.0f); + } +} + +void ScriptedAI::DoStartAttackNoMovement(Unit* victim) +{ + if (!victim) + return; + + if ( m_creature->Attack(victim, true) ) + { + m_creature->AddThreat(victim, 0.0f); + } +} + + +void ScriptedAI::DoMeleeAttackIfReady() +{ + //Make sure our attack is ready and we aren't currently casting before checking distance + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + { + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + } +} + +void ScriptedAI::DoStopAttack() +{ + if( m_creature->getVictim() != NULL ) + { + m_creature->AttackStop(); + } +} + +void ScriptedAI::DoCast(Unit* victim, uint32 spellId, bool triggered) +{ + if (!victim || m_creature->IsNonMeleeSpellCasted(false)) + return; + + m_creature->StopMoving(); + m_creature->CastSpell(victim, spellId, triggered); +} + +void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered) +{ + if (!who || m_creature->IsNonMeleeSpellCasted(false)) + return; + + m_creature->StopMoving(); + m_creature->CastSpell(who, spellInfo, triggered); +} + +void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target) +{ + if (target)m_creature->Say(text, language, target->GetGUID()); + else m_creature->Say(text, language, 0); +} + +void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target) +{ + if (target)m_creature->Yell(text, language, target->GetGUID()); + else m_creature->Yell(text, language, 0); +} + +void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote) +{ + if (target)m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); + else m_creature->TextEmote(text, 0, IsBossEmote); +} + +void ScriptedAI::DoWhisper(const char* text, Unit* reciever, bool IsBossWhisper) +{ + if (!reciever || reciever->GetTypeId() != TYPEID_PLAYER) + return; + + m_creature->Whisper(text, reciever->GetGUID(), IsBossWhisper); +} + +void ScriptedAI::DoPlaySoundToSet(Unit* unit, uint32 sound) +{ + if (!unit) + return; + + if (!GetSoundEntriesStore()->LookupEntry(sound)) + { + error_log("SD2: Invalid soundId %u used in DoPlaySoundToSet (by unit TypeId %u, guid %u)", sound, unit->GetTypeId(), unit->GetGUID()); + return; + } + + WorldPacket data(4); + data.SetOpcode(SMSG_PLAY_SOUND); + data << uint32(sound); + unit->SendMessageToSet(&data,false); +} + +Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime) +{ + return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TempSummonType)type, despawntime); +} + +Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 position) +{ + //ThreatList m_threatlist; + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); + std::list::reverse_iterator r = m_threatlist.rbegin(); + + if (position >= m_threatlist.size() || !m_threatlist.size()) + return NULL; + + switch (target) + { + case SELECT_TARGET_RANDOM: + advance ( i , position + (rand() % (m_threatlist.size() - position ) )); + return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + break; + + case SELECT_TARGET_TOPAGGRO: + advance ( i , position); + return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + break; + + case SELECT_TARGET_BOTTOMAGGRO: + advance ( r , position); + return Unit::GetUnit((*m_creature),(*r)->getUnitGuid()); + break; + } + + return NULL; +} + +SpellEntry const* ScriptedAI::SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTarget Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effects) +{ + //No target so we can't cast + if (!Target) + return false; + + //Silenced so we can't cast + if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + return false; + + //Using the extended script system we first create a list of viable spells + SpellEntry const* Spell[4]; + Spell[0] = 0; + Spell[1] = 0; + Spell[2] = 0; + Spell[3] = 0; + + uint32 SpellCount = 0; + + SpellEntry const* TempSpell; + SpellRangeEntry const* TempRange; + + //Check if each spell is viable(set it to null if not) + for (uint32 i = 0; i < 4; i++) + { + TempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]); + + //This spell doesn't exist + if (!TempSpell) + continue; + + // Targets and Effects checked first as most used restrictions + //Check the spell targets if specified + if ( Targets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (Targets-1))) ) + continue; + + //Check the type of spell if we are looking for a specific spell type + if ( Effects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (Effects-1))) ) + continue; + + //Check for school if specified + if (School >= 0 && TempSpell->SchoolMask & School) + continue; + + //Check for spell mechanic if specified + if (Mechanic >= 0 && TempSpell->Mechanic != Mechanic) + continue; + + //Make sure that the spell uses the requested amount of power + if (PowerCostMin && TempSpell->manaCost < PowerCostMin) + continue; + + if (PowerCostMax && TempSpell->manaCost > PowerCostMax) + continue; + + //Continue if we don't have the mana to actually cast this spell + if (TempSpell->manaCost > m_creature->GetPower((Powers)TempSpell->powerType)) + continue; + + //Get the Range + TempRange = GetSpellRangeStore()->LookupEntry(TempSpell->rangeIndex); + + //Spell has invalid range store so we can't use it + if (!TempRange) + continue; + + //Check if the spell meets our range requirements + if (RangeMin && TempRange->maxRange < RangeMin) + continue; + if (RangeMax && TempRange->maxRange > RangeMax) + continue; + + //Check if our target is in range + if (m_creature->IsWithinDistInMap(Target, TempRange->minRange) || !m_creature->IsWithinDistInMap(Target, TempRange->maxRange)) + continue; + + //All good so lets add it to the spell list + Spell[SpellCount] = TempSpell; + SpellCount++; + } + + //We got our usable spells so now lets randomly pick one + if (!SpellCount) + return NULL; + + return Spell[rand()%SpellCount]; +} + +bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered) +{ + //No target so we can't cast + if (!Target || !Spell) + return false; + + //Silenced so we can't cast + if (!Triggered && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + return false; + + //Check for power + if (!Triggered && m_creature->GetPower((Powers)Spell->powerType) < Spell->manaCost) + return false; + + SpellRangeEntry const *TempRange = NULL; + + TempRange = GetSpellRangeStore()->LookupEntry(Spell->rangeIndex); + + //Spell has invalid range store so we can't use it + if (!TempRange) + return false; + + //Unit is out of range of this spell + if (m_creature->GetDistance(Target) > TempRange->maxRange || m_creature->GetDistance(Target) < TempRange->minRange) + return false; + + return true; +} + +void FillSpellSummary() +{ + SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()]; + + SpellEntry const* TempSpell; + + for (int i=0; i < GetSpellStore()->GetNumRows(); i++ ) + { + SpellSummary[i].Effects = 0; + SpellSummary[i].Targets = 0; + + TempSpell = GetSpellStore()->LookupEntry(i); + //This spell doesn't exist + if (!TempSpell) + continue; + + for (int j=0; j<3; j++) + { + //Spell targets self + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1); + + //Spell targets a single enemy + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || + TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1); + + //Spell targets AoE at enemy + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1); + + //Spell targets an enemy + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || + TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1); + + //Spell targets a single friend(or self) + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1); + + //Spell targets aoe friends + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1); + + //Spell targets any friend(or self) + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1); + + //Make sure that this spell includes a damage effect + if ( TempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || + TempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL || + TempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE || + TempSpell->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ) + SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1); + + //Make sure that this spell includes a healing effect (or an apply aura with a periodic heal) + if ( TempSpell->Effect[j] == SPELL_EFFECT_HEAL || + TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH || + TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL || + (TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA && TempSpell->EffectApplyAuraName[j]== 8 )) + SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1); + + //Make sure that this spell applies an aura + if ( TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA ) + SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1); + } + } +} + +void ScriptedAI::DoZoneInCombat(Unit* pUnit) +{ + if (!pUnit) + pUnit = m_creature; + + Map *map = pUnit->GetMap(); + + if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated + { + error_log("SD2: DoZoneInCombat call for map that isn't an instance (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); + return; + } + + if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty()) + { + error_log("SD2: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); + + return; + } + + InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); + InstanceMap::PlayerList::const_iterator i; + for (i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + if(!(*i)->isGameMaster()) + pUnit->AddThreat(*i, 0.0f); + } +} + +void ScriptedAI::DoResetThreat() +{ + if (!m_creature->CanHaveThreatList() || m_creature->getThreatManager().isThreatListEmpty()) + { + error_log("SD2: DoResetThreat called for creature that either cannot have threat list or has empty threat list (m_creature entry = %d)", m_creature->GetEntry()); + + return; + } + + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator itr; + + for(itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr) + { + Unit* pUnit = NULL; + pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + if(pUnit && m_creature->getThreatManager().getThreat(pUnit)) + m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); + } +} + +void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o) +{ + if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) + { + if(pUnit) + error_log("SD2: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", m_creature->GetGUID(), m_creature->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), x, y, z, o); + return; + } + + ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); +} + +Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) +{ + CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + Unit* pUnit = NULL; + + MostHPMissingInRange u_check(m_creature, range, MinHPDiff); + MaNGOS::UnitLastSearcher searcher(pUnit, u_check); + + /* + typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; + This means that if we only search grid then we cannot possibly return pets or players so this is safe + */ + TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap())); + return pUnit; +} + +std::list ScriptedAI::DoFindFriendlyCC(float range) +{ + CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list pList; + + FriendlyCCedInRange u_check(m_creature, range); + MaNGOS::CreatureListSearcher searcher(pList, u_check); + + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); + + return pList; +} + +std::list ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 spellid) +{ + CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list pList; + + FriendlyMissingBuffInRange u_check(m_creature, range, spellid); + MaNGOS::CreatureListSearcher searcher(pList, u_check); + + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); + + return pList; +} + +void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who) +{ + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackNoMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } +} + +void Scripted_NoMovementAI::AttackStart(Unit* who) +{ + if (!who) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + DoStartAttackNoMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } +} diff --git a/src/bindings/scripts/include/sc_gossip.h b/src/bindings/scripts/include/sc_gossip.h index af304a2d63f..48d9786a4ed 100644 --- a/src/bindings/scripts/include/sc_gossip.h +++ b/src/bindings/scripts/include/sc_gossip.h @@ -1,183 +1,183 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_PLAYER_H -#define SC_PLAYER_H - -#include "Player.h" -#include "GossipDef.h" -#include "QuestDef.h" - -// Gossip Item Text -#define GOSSIP_TEXT_BROWSE_GOODS "I'd like to browse your goods." -#define GOSSIP_TEXT_TRAIN "Train me!" - -#define GOSSIP_TEXT_BANK "The Bank" -#define GOSSIP_TEXT_WINDRIDER "Wind rider master" -#define GOSSIP_TEXT_GRYPHON "Gryphon Master" -#define GOSSIP_TEXT_BATHANDLER "Bat Handler" -#define GOSSIP_TEXT_HIPPOGRYPH "Hippogryph Master" -#define GOSSIP_TEXT_FLIGHTMASTER "Flight Master" -#define GOSSIP_TEXT_AUCTIONHOUSE "Auction House" -#define GOSSIP_TEXT_GUILDMASTER "Guild Master" -#define GOSSIP_TEXT_INN "The Inn" -#define GOSSIP_TEXT_MAILBOX "Mailbox" -#define GOSSIP_TEXT_STABLEMASTER "Stable Master" -#define GOSSIP_TEXT_WEAPONMASTER "Weapons Trainer" -#define GOSSIP_TEXT_BATTLEMASTER "Battlemaster" -#define GOSSIP_TEXT_CLASSTRAINER "Class Trainer" -#define GOSSIP_TEXT_PROFTRAINER "Profession Trainer" -#define GOSSIP_TEXT_OFFICERS "The officers` lounge" - -#define GOSSIP_TEXT_ALTERACVALLEY "Alterac Valley" -#define GOSSIP_TEXT_ARATHIBASIN "Arathi Basin" -#define GOSSIP_TEXT_WARSONGULCH "Warsong Gulch" -#define GOSSIP_TEXT_ARENA "Arena" -#define GOSSIP_TEXT_EYEOFTHESTORM "Eye of The Storm" - -#define GOSSIP_TEXT_DRUID "Druid" -#define GOSSIP_TEXT_HUNTER "Hunter" -#define GOSSIP_TEXT_PRIEST "Priest" -#define GOSSIP_TEXT_ROGUE "Rogue" -#define GOSSIP_TEXT_WARRIOR "Warrior" -#define GOSSIP_TEXT_PALADIN "Paladin" -#define GOSSIP_TEXT_SHAMAN "Shaman" -#define GOSSIP_TEXT_MAGE "Mage" -#define GOSSIP_TEXT_WARLOCK "Warlock" - -#define GOSSIP_TEXT_ALCHEMY "Alchemy" -#define GOSSIP_TEXT_BLACKSMITHING "Blacksmithing" -#define GOSSIP_TEXT_COOKING "Cooking" -#define GOSSIP_TEXT_ENCHANTING "Enchanting" -#define GOSSIP_TEXT_ENGINEERING "Engineering" -#define GOSSIP_TEXT_FIRSTAID "First Aid" -#define GOSSIP_TEXT_HERBALISM "Herbalism" -#define GOSSIP_TEXT_LEATHERWORKING "Leatherworking" -#define GOSSIP_TEXT_POISONS "Poisons" -#define GOSSIP_TEXT_TAILORING "Tailoring" -#define GOSSIP_TEXT_MINING "Mining" -#define GOSSIP_TEXT_FISHING "Fishing" -#define GOSSIP_TEXT_SKINNING "Skinning" -#define GOSSIP_TEXT_JEWELCRAFTING "Jewelcrafting" - -#define GOSSIP_TEXT_IRONFORGE_BANK "Bank of Ironforge" -#define GOSSIP_TEXT_STORMWIND_BANK "Bank of Stormwind" -#define GOSSIP_TEXT_DEEPRUNTRAM "Deeprun Tram" -#define GOSSIP_TEXT_ZEPPLINMASTER "Zeppelin master" -#define GOSSIP_TEXT_FERRY "Rut'theran Ferry" - -// Skill defines - -#define TRADESKILL_ALCHEMY 1 -#define TRADESKILL_BLACKSMITHING 2 -#define TRADESKILL_COOKING 3 -#define TRADESKILL_ENCHANTING 4 -#define TRADESKILL_ENGINEERING 5 -#define TRADESKILL_FIRSTAID 6 -#define TRADESKILL_HERBALISM 7 -#define TRADESKILL_LEATHERWORKING 8 -#define TRADESKILL_POISONS 9 -#define TRADESKILL_TAILORING 10 -#define TRADESKILL_MINING 11 -#define TRADESKILL_FISHING 12 -#define TRADESKILL_SKINNING 13 -#define TRADESKILL_JEWLCRAFTING 14 - -#define TRADESKILL_LEVEL_NONE 0 -#define TRADESKILL_LEVEL_APPRENTICE 1 -#define TRADESKILL_LEVEL_JOURNEYMAN 2 -#define TRADESKILL_LEVEL_EXPERT 3 -#define TRADESKILL_LEVEL_ARTISAN 4 -#define TRADESKILL_LEVEL_MASTER 5 - -// Gossip defines - -#define GOSSIP_ACTION_TRADE 1 -#define GOSSIP_ACTION_TRAIN 2 -#define GOSSIP_ACTION_TAXI 3 -#define GOSSIP_ACTION_GUILD 4 -#define GOSSIP_ACTION_BATTLE 5 -#define GOSSIP_ACTION_BANK 6 -#define GOSSIP_ACTION_INN 7 -#define GOSSIP_ACTION_HEAL 8 -#define GOSSIP_ACTION_TABARD 9 -#define GOSSIP_ACTION_AUCTION 10 -#define GOSSIP_ACTION_INN_INFO 11 -#define GOSSIP_ACTION_UNLEARN 12 -#define GOSSIP_ACTION_INFO_DEF 1000 - -#define GOSSIP_SENDER_MAIN 1 -#define GOSSIP_SENDER_INN_INFO 2 -#define GOSSIP_SENDER_INFO 3 -#define GOSSIP_SENDER_SEC_PROFTRAIN 4 -#define GOSSIP_SENDER_SEC_CLASSTRAIN 5 -#define GOSSIP_SENDER_SEC_BATTLEINFO 6 -#define GOSSIP_SENDER_SEC_BANK 7 -#define GOSSIP_SENDER_SEC_INN 8 -#define GOSSIP_SENDER_SEC_MAILBOX 9 -#define GOSSIP_SENDER_SEC_STABLEMASTER 10 - -#define DEFAULT_GOSSIP_MESSAGE 0xffffff - -extern uint32 GetSkillLevel(Player *player,uint32 skill); - -// Defined fuctions to use with player. - -// This fuction add's a menu item, -// a - Icon Id -// b - Text -// c - Sender(this is to identify the current Menu with this item) -// d - Action (identifys this Menu Item) -// e - Text to be displayed in pop up box -// f - Money value in pop up box -#define ADD_GOSSIP_ITEM(a,b,c,d) PlayerTalkClass->GetGossipMenu()->AddMenuItem(a,b,c,d,"",0) -#define ADD_GOSSIP_ITEM_EXTENDED(a,b,c,d,e,f) PlayerTalkClass->GetGossipMenu()->AddMenuItem(a,b,c,d,e,f) - -// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32) , b - npc guid(uint64) -#define SEND_GOSSIP_MENU(a,b) PlayerTalkClass->SendGossipMenu(a,b) - -// This fuction shows POI(point of interest) to client. -// a - position X -// b - position Y -// c - Icon Id -// d - Flags -// e - Data -// f - Location Name -#define SEND_POI(a,b,c,d,e,f) PlayerTalkClass->SendPointOfInterest(a,b,c,d,e,f) - -// Closes the Menu -#define CLOSE_GOSSIP_MENU() PlayerTalkClass->CloseGossip() - -// Fuction to tell to client the details -// a - quest object -// b - npc guid(uint64) -// c - Activate accept(bool) -#define SEND_QUEST_DETAILS(a,b,c) PlayerTalkClass->SendQuestDetails(a,b,c) - -// Fuction to tell to client the requested items to complete quest -// a - quest object -// b - npc guid(uint64) -// c - Iscompletable(bool) -// d - close at cancel(bool) - in case single incomplite ques -#define SEND_REQUESTEDITEMS(a,b,c,d) PlayerTalkClass->SendRequestedItems(a,b,c,d) - -// Fuctions to send NPC lists, a - is always the npc guid(uint64) -#define SEND_VENDORLIST(a) GetSession()->SendListInventory(a) -#define SEND_TRAINERLIST(a) GetSession()->SendTrainerList(a) -#define SEND_BANKERLIST(a) GetSession()->SendShowBank(a) -#define SEND_TABARDLIST(a) GetSession()->SendTabardVendorActivate(a) -#define SEND_AUCTIONLIST(a) GetSession()->SendAuctionHello(a) -#define SEND_TAXILIST(a) GetSession()->SendTaxiStatus(a) - -// Ressurect's the player if is dead. -#define SEND_SPRESURRECT() GetSession()->SendSpiritResurrect() - -// Get the player's honor rank. -#define GET_HONORRANK() GetHonorRank() -// ----------------------------------- - -// defined fuctions to use with Creature - -#define QUEST_DIALOG_STATUS(a,b,c) GetSession()->getDialogStatus(a,b,c) -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef SC_PLAYER_H +#define SC_PLAYER_H + +#include "Player.h" +#include "GossipDef.h" +#include "QuestDef.h" + +// Gossip Item Text +#define GOSSIP_TEXT_BROWSE_GOODS "I'd like to browse your goods." +#define GOSSIP_TEXT_TRAIN "Train me!" + +#define GOSSIP_TEXT_BANK "The Bank" +#define GOSSIP_TEXT_WINDRIDER "Wind rider master" +#define GOSSIP_TEXT_GRYPHON "Gryphon Master" +#define GOSSIP_TEXT_BATHANDLER "Bat Handler" +#define GOSSIP_TEXT_HIPPOGRYPH "Hippogryph Master" +#define GOSSIP_TEXT_FLIGHTMASTER "Flight Master" +#define GOSSIP_TEXT_AUCTIONHOUSE "Auction House" +#define GOSSIP_TEXT_GUILDMASTER "Guild Master" +#define GOSSIP_TEXT_INN "The Inn" +#define GOSSIP_TEXT_MAILBOX "Mailbox" +#define GOSSIP_TEXT_STABLEMASTER "Stable Master" +#define GOSSIP_TEXT_WEAPONMASTER "Weapons Trainer" +#define GOSSIP_TEXT_BATTLEMASTER "Battlemaster" +#define GOSSIP_TEXT_CLASSTRAINER "Class Trainer" +#define GOSSIP_TEXT_PROFTRAINER "Profession Trainer" +#define GOSSIP_TEXT_OFFICERS "The officers` lounge" + +#define GOSSIP_TEXT_ALTERACVALLEY "Alterac Valley" +#define GOSSIP_TEXT_ARATHIBASIN "Arathi Basin" +#define GOSSIP_TEXT_WARSONGULCH "Warsong Gulch" +#define GOSSIP_TEXT_ARENA "Arena" +#define GOSSIP_TEXT_EYEOFTHESTORM "Eye of The Storm" + +#define GOSSIP_TEXT_DRUID "Druid" +#define GOSSIP_TEXT_HUNTER "Hunter" +#define GOSSIP_TEXT_PRIEST "Priest" +#define GOSSIP_TEXT_ROGUE "Rogue" +#define GOSSIP_TEXT_WARRIOR "Warrior" +#define GOSSIP_TEXT_PALADIN "Paladin" +#define GOSSIP_TEXT_SHAMAN "Shaman" +#define GOSSIP_TEXT_MAGE "Mage" +#define GOSSIP_TEXT_WARLOCK "Warlock" + +#define GOSSIP_TEXT_ALCHEMY "Alchemy" +#define GOSSIP_TEXT_BLACKSMITHING "Blacksmithing" +#define GOSSIP_TEXT_COOKING "Cooking" +#define GOSSIP_TEXT_ENCHANTING "Enchanting" +#define GOSSIP_TEXT_ENGINEERING "Engineering" +#define GOSSIP_TEXT_FIRSTAID "First Aid" +#define GOSSIP_TEXT_HERBALISM "Herbalism" +#define GOSSIP_TEXT_LEATHERWORKING "Leatherworking" +#define GOSSIP_TEXT_POISONS "Poisons" +#define GOSSIP_TEXT_TAILORING "Tailoring" +#define GOSSIP_TEXT_MINING "Mining" +#define GOSSIP_TEXT_FISHING "Fishing" +#define GOSSIP_TEXT_SKINNING "Skinning" +#define GOSSIP_TEXT_JEWELCRAFTING "Jewelcrafting" + +#define GOSSIP_TEXT_IRONFORGE_BANK "Bank of Ironforge" +#define GOSSIP_TEXT_STORMWIND_BANK "Bank of Stormwind" +#define GOSSIP_TEXT_DEEPRUNTRAM "Deeprun Tram" +#define GOSSIP_TEXT_ZEPPLINMASTER "Zeppelin master" +#define GOSSIP_TEXT_FERRY "Rut'theran Ferry" + +// Skill defines + +#define TRADESKILL_ALCHEMY 1 +#define TRADESKILL_BLACKSMITHING 2 +#define TRADESKILL_COOKING 3 +#define TRADESKILL_ENCHANTING 4 +#define TRADESKILL_ENGINEERING 5 +#define TRADESKILL_FIRSTAID 6 +#define TRADESKILL_HERBALISM 7 +#define TRADESKILL_LEATHERWORKING 8 +#define TRADESKILL_POISONS 9 +#define TRADESKILL_TAILORING 10 +#define TRADESKILL_MINING 11 +#define TRADESKILL_FISHING 12 +#define TRADESKILL_SKINNING 13 +#define TRADESKILL_JEWLCRAFTING 14 + +#define TRADESKILL_LEVEL_NONE 0 +#define TRADESKILL_LEVEL_APPRENTICE 1 +#define TRADESKILL_LEVEL_JOURNEYMAN 2 +#define TRADESKILL_LEVEL_EXPERT 3 +#define TRADESKILL_LEVEL_ARTISAN 4 +#define TRADESKILL_LEVEL_MASTER 5 + +// Gossip defines + +#define GOSSIP_ACTION_TRADE 1 +#define GOSSIP_ACTION_TRAIN 2 +#define GOSSIP_ACTION_TAXI 3 +#define GOSSIP_ACTION_GUILD 4 +#define GOSSIP_ACTION_BATTLE 5 +#define GOSSIP_ACTION_BANK 6 +#define GOSSIP_ACTION_INN 7 +#define GOSSIP_ACTION_HEAL 8 +#define GOSSIP_ACTION_TABARD 9 +#define GOSSIP_ACTION_AUCTION 10 +#define GOSSIP_ACTION_INN_INFO 11 +#define GOSSIP_ACTION_UNLEARN 12 +#define GOSSIP_ACTION_INFO_DEF 1000 + +#define GOSSIP_SENDER_MAIN 1 +#define GOSSIP_SENDER_INN_INFO 2 +#define GOSSIP_SENDER_INFO 3 +#define GOSSIP_SENDER_SEC_PROFTRAIN 4 +#define GOSSIP_SENDER_SEC_CLASSTRAIN 5 +#define GOSSIP_SENDER_SEC_BATTLEINFO 6 +#define GOSSIP_SENDER_SEC_BANK 7 +#define GOSSIP_SENDER_SEC_INN 8 +#define GOSSIP_SENDER_SEC_MAILBOX 9 +#define GOSSIP_SENDER_SEC_STABLEMASTER 10 + +#define DEFAULT_GOSSIP_MESSAGE 0xffffff + +extern uint32 GetSkillLevel(Player *player,uint32 skill); + +// Defined fuctions to use with player. + +// This fuction add's a menu item, +// a - Icon Id +// b - Text +// c - Sender(this is to identify the current Menu with this item) +// d - Action (identifys this Menu Item) +// e - Text to be displayed in pop up box +// f - Money value in pop up box +#define ADD_GOSSIP_ITEM(a,b,c,d) PlayerTalkClass->GetGossipMenu().AddMenuItem(a,b,c,d,"",0) +#define ADD_GOSSIP_ITEM_EXTENDED(a,b,c,d,e,f,g) PlayerTalkClass->GetGossipMenu().AddMenuItem(a,b,c,d,e,f,g) + +// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32) , b - npc guid(uint64) +#define SEND_GOSSIP_MENU(a,b) PlayerTalkClass->SendGossipMenu(a,b) + +// This fuction shows POI(point of interest) to client. +// a - position X +// b - position Y +// c - Icon Id +// d - Flags +// e - Data +// f - Location Name +#define SEND_POI(a,b,c,d,e,f) PlayerTalkClass->SendPointOfInterest(a,b,c,d,e,f) + +// Closes the Menu +#define CLOSE_GOSSIP_MENU() PlayerTalkClass->CloseGossip() + +// Fuction to tell to client the details +// a - quest object +// b - npc guid(uint64) +// c - Activate accept(bool) +#define SEND_QUEST_DETAILS(a,b,c) PlayerTalkClass->SendQuestDetails(a,b,c) + +// Fuction to tell to client the requested items to complete quest +// a - quest object +// b - npc guid(uint64) +// c - Iscompletable(bool) +// d - close at cancel(bool) - in case single incomplite ques +#define SEND_REQUESTEDITEMS(a,b,c,d) PlayerTalkClass->SendRequestedItems(a,b,c,d) + +// Fuctions to send NPC lists, a - is always the npc guid(uint64) +#define SEND_VENDORLIST(a) GetSession()->SendListInventory(a) +#define SEND_TRAINERLIST(a) GetSession()->SendTrainerList(a) +#define SEND_BANKERLIST(a) GetSession()->SendShowBank(a) +#define SEND_TABARDLIST(a) GetSession()->SendTabardVendorActivate(a) +#define SEND_AUCTIONLIST(a) GetSession()->SendAuctionHello(a) +#define SEND_TAXILIST(a) GetSession()->SendTaxiStatus(a) + +// Ressurect's the player if is dead. +#define SEND_SPRESURRECT() GetSession()->SendSpiritResurrect() + +// Get the player's honor rank. +#define GET_HONORRANK() GetHonorRank() +// ----------------------------------- + +// defined fuctions to use with Creature + +#define QUEST_DIALOG_STATUS(a,b,c) GetSession()->getDialogStatus(a,b,c) +#endif -- cgit v1.2.3