Skip to content

Vael corrections #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ be a part of any redistributable packages made from this software. No licenses
should be removed from this software if you are making redistributable copies.


Development
-----------
The **develop** branch is where the development of *scriptdev0* is done. Any
of the commits submitted here may or may not become part of the next release.

It is recommended to use the **master** branch for stable systems, and only use
the **develop** branch if you intend to test commits and submit issues and/or
reports.


Compatibility
-------------
The *scriptdev0* bindings are compatible with [mangos-zero revision 1765][10]
Expand Down
50 changes: 30 additions & 20 deletions ScriptMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void InitScriptLibrary()
/**
* Function that does script text
*
* @param iTextEntry Entry of the text, stored in SD2-database
* @param iTextEntry Entry of the text, stored in SD0-database
* @param pSource Source of the text
* @param pTarget Can be NULL (depending on CHAT_TYPE of iTextEntry). Possible target for the text
*/
Expand All @@ -169,7 +169,6 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
}

const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);

if (!pData)
{
error_log("SD0: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.",
Expand All @@ -184,7 +183,18 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
if (pData->uiSoundId)
{
if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
pSource->PlayDirectSound(pData->uiSoundId);
{
if (pData->uiType == CHAT_TYPE_ZONE_YELL)
pSource->GetMap()->PlayDirectSoundToMap(pData->uiSoundId);
else if (pData->uiType == CHAT_TYPE_WHISPER || pData->uiType == CHAT_TYPE_BOSS_WHISPER)
{
// An error will be displayed for the text
if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
pSource->PlayDirectSound(pData->uiSoundId, (Player*)pTarget);
}
else
pSource->PlayDirectSound(pData->uiSoundId);
}
else
error_log("SD0: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
}
Expand Down Expand Up @@ -238,7 +248,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
/**
* Function that either simulates or does script text for a map
*
* @param iTextEntry Entry of the text, stored in SD2-database, only type CHAT_TYPE_ZONE_YELL supported
* @param iTextEntry Entry of the text, stored in SD0-database, only type CHAT_TYPE_ZONE_YELL supported
* @param uiCreatureEntry Id of the creature of whom saying will be simulated
* @param pMap Given Map on which the map-wide text is displayed
* @param pCreatureSource Can be NULL. If pointer to Creature is given, then the creature does the map-wide text
Expand All @@ -248,51 +258,51 @@ void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map*
{
if (!pMap)
{
error_log("SD2: DoOrSimulateScriptTextForMap entry %i, invalid Map pointer.", iTextEntry);
error_log("SD0: DoOrSimulateScriptTextForMap entry %i, invalid Map pointer.", iTextEntry);
return;
}

if (iTextEntry >= 0)
{
error_log("SD2: DoOrSimulateScriptTextForMap with source entry %u for map %u attempts to process text entry %i, but text entry must be negative.", uiCreatureEntry, pMap->GetId(), iTextEntry);
error_log("SD0: DoOrSimulateScriptTextForMap with source entry %u for map %u attempts to process text entry %i, but text entry must be negative.", uiCreatureEntry, pMap->GetId(), iTextEntry);
return;
}

CreatureInfo const* pInfo = GetCreatureTemplateStore(uiCreatureEntry);
if (!pInfo)
{
error_log("SD2: DoOrSimulateScriptTextForMap has invalid source entry %u for map %u.", uiCreatureEntry, pMap->GetId());
error_log("SD0: DoOrSimulateScriptTextForMap has invalid source entry %u for map %u.", uiCreatureEntry, pMap->GetId());
return;
}

const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);

if (!pData)
{
error_log("SD2: DoOrSimulateScriptTextForMap with source entry %u for map %u could not find text entry %i.", uiCreatureEntry, pMap->GetId(), iTextEntry);
error_log("SD0: DoOrSimulateScriptTextForMap with source entry %u for map %u could not find text entry %i.", uiCreatureEntry, pMap->GetId(), iTextEntry);
return;
}

debug_log("SD2: DoOrSimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
debug_log("SD0: DoOrSimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);

if (pData->uiType != CHAT_TYPE_ZONE_YELL)
{
error_log("SD0: DoSimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
return;
}

if (pData->uiSoundId)
{
if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
pMap->PlayDirectSoundToMap(pData->uiSoundId);
else
error_log("SD2: DoOrSimulateScriptTextForMap entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
error_log("SD0: DoOrSimulateScriptTextForMap entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
}

if (pData->uiType == CHAT_TYPE_ZONE_YELL)
{
if (pCreatureSource) // If provided pointer for sayer, use direct version
pMap->MonsterYellToMap(pCreatureSource->GetObjectGuid(), iTextEntry, pData->uiLanguage, pTarget);
else // Simulate yell
pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget);
}
else
error_log("SD2: DoSimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
if (pCreatureSource) // If provided pointer for sayer, use direct version
pMap->MonsterYellToMap(pCreatureSource->GetObjectGuid(), iTextEntry, pData->uiLanguage, pTarget);
else // Simulate yell
pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget);
}

//*********************************
Expand Down
1 change: 0 additions & 1 deletion VC100/100ScriptDev0.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
<ClCompile Include="..\scripts\eastern_kingdoms\sunken_temple\instance_sunken_temple.cpp" />
<ClCompile Include="..\scripts\eastern_kingdoms\sunken_temple\sunken_temple.cpp" />
<ClCompile Include="..\scripts\eastern_kingdoms\uldaman\boss_archaedas.cpp" />
<ClCompile Include="..\scripts\eastern_kingdoms\uldaman\boss_ironaya.cpp" />
<ClCompile Include="..\scripts\eastern_kingdoms\uldaman\uldaman.cpp" />
<ClCompile Include="..\scripts\eastern_kingdoms\uldaman\instance_uldaman.cpp" />
<ClCompile Include="..\scripts\eastern_kingdoms\zulgurub\boss_arlokk.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions VC100/100ScriptDev0.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,6 @@
<ClCompile Include="..\scripts\eastern_kingdoms\uldaman\boss_archaedas.cpp">
<Filter>scripts\eastern_kingdoms\uldaman</Filter>
</ClCompile>
<ClCompile Include="..\scripts\eastern_kingdoms\uldaman\boss_ironaya.cpp">
<Filter>scripts\eastern_kingdoms\uldaman</Filter>
</ClCompile>
<ClCompile Include="..\scripts\eastern_kingdoms\uldaman\uldaman.cpp">
<Filter>scripts\eastern_kingdoms\uldaman</Filter>
</ClCompile>
Expand Down
4 changes: 0 additions & 4 deletions VC90/90ScriptDev0.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -1302,10 +1302,6 @@
RelativePath="..\scripts\eastern_kingdoms\uldaman\boss_archaedas.cpp"
>
</File>
<File
RelativePath="..\scripts\eastern_kingdoms\uldaman\boss_ironaya.cpp"
>
</File>
<File
RelativePath="..\scripts\eastern_kingdoms\uldaman\uldaman.cpp"
>
Expand Down
15 changes: 11 additions & 4 deletions base/escort_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ void npc_escortAI::AttackStart(Unit* pWho)

void npc_escortAI::EnterCombat(Unit* pEnemy)
{
// Store combat start position
m_creature->SetCombatStartPosition(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());

if (!pEnemy)
return;

Expand Down Expand Up @@ -234,10 +237,11 @@ void npc_escortAI::EnterEvadeMode()

if (HasEscortState(STATE_ESCORT_ESCORTING))
{
debug_log("SD0: EscortAI has left combat and is now returning to CombatStartPosition.");

if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
// We have left our path
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
{
debug_log("SD0: EscortAI has left combat and is now returning to CombatStartPosition.");

AddEscortState(STATE_ESCORT_RETURNING);

float fPosX, fPosY, fPosZ;
Expand Down Expand Up @@ -400,12 +404,15 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId)
//Make sure that we are still on the right waypoint
if (CurrentWP->uiId != uiPointId)
{
error_log("SD0: EscortAI reached waypoint out of order %u, expected %u.", uiPointId, CurrentWP->uiId);
error_log("SD0: EscortAI for Npc %u reached waypoint out of order %u, expected %u.", m_creature->GetEntry(), uiPointId, CurrentWP->uiId);
return;
}

debug_log("SD0: EscortAI waypoint %u reached.", CurrentWP->uiId);

// In case we were moving while in combat, we should evade back to this position
m_creature->SetCombatStartPosition(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());

//Call WP function
WaypointReached(CurrentWP->uiId);

Expand Down
16 changes: 8 additions & 8 deletions include/sc_creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,22 +458,22 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float fMinimumRange)
return pPlayer;
}

void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand, int32 uiOffHand, int32 uiRanged)
void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 iMainHand, int32 iOffHand, int32 iRanged)
{
if (bLoadDefault)
{
m_creature->LoadEquipment(m_creature->GetCreatureInfo()->equipmentId,true);
m_creature->LoadEquipment(m_creature->GetCreatureInfo()->equipmentId, true);
return;
}

if (uiMainHand >= 0)
m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(uiMainHand));
if (iMainHand >= 0)
m_creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_0, iMainHand);

if (uiOffHand >= 0)
m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, uint32(uiOffHand));
if (iOffHand >= 0)
m_creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_1, iOffHand);

if (uiRanged >= 0)
m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, uint32(uiRanged));
if (iRanged >= 0)
m_creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_2, iRanged);
}

void ScriptedAI::SetCombatMovement(bool bCombatMove)
Expand Down
2 changes: 1 addition & 1 deletion include/sc_creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
//Checks if you can cast the specified spell
bool CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered = false);

void SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand = EQUIP_NO_CHANGE, int32 uiOffHand = EQUIP_NO_CHANGE, int32 uiRanged = EQUIP_NO_CHANGE);
void SetEquipmentSlots(bool bLoadDefault, int32 iMainHand = EQUIP_NO_CHANGE, int32 iOffHand = EQUIP_NO_CHANGE, int32 iRanged = EQUIP_NO_CHANGE);

//Generally used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims
void SetCombatMovement(bool bCombatMove);
Expand Down
81 changes: 45 additions & 36 deletions scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum
SPELL_FIRE_NOVA = 23462,
SPELL_TAIL_SWEEP = 15847,
SPELL_BURNING_ADRENALINE = 23620,
SPELL_CLEAVE = 20684, // Chain cleave is most likely named something different and contains a dummy effect
SPELL_CLEAVE = 19983, // Chain cleave is most likely named something different and contains a dummy effect

SPELL_NEFARIUS_CORRUPTION = 23642,

Expand Down Expand Up @@ -83,8 +83,8 @@ struct MANGOS_DLL_DECL boss_vaelastraszAI : public ScriptedAI
uint32 m_uiCleaveTimer;
uint32 m_uiFlameBreathTimer;
uint32 m_uiFireNovaTimer;
uint32 m_uiBurningAdrenalineCasterTimer;
uint32 m_uiBurningAdrenalineTankTimer;
uint32 m_uiBurningAdrenalineTimer;
uint32 m_uiBurningAdrenalineTarget; // 0,1 caster 2 tank
uint32 m_uiTailSweepTimer;
bool m_bHasYelled;

Expand All @@ -96,10 +96,10 @@ struct MANGOS_DLL_DECL boss_vaelastraszAI : public ScriptedAI
m_uiIntroPhase = 0;
m_uiSpeechTimer = 0;
m_uiSpeechNum = 0;
m_uiCleaveTimer = 8000; // These times are probably wrong
m_uiCleaveTimer = 6000; // These times are probably wrong
m_uiFlameBreathTimer = 11000;
m_uiBurningAdrenalineCasterTimer = 15000;
m_uiBurningAdrenalineTankTimer = 45000;
m_uiBurningAdrenalineTimer = 15000;
m_uiBurningAdrenalineTarget = 0;
m_uiFireNovaTimer = 5000;
m_uiTailSweepTimer = 20000;
m_bHasYelled = false;
Expand Down Expand Up @@ -171,6 +171,29 @@ struct MANGOS_DLL_DECL boss_vaelastraszAI : public ScriptedAI
}
}

Unit *GetManaUserForBA()
{
std::vector<Unit*> vManaPlayers;

// Scan for mana targets in threat list
ThreatList const& tList = m_creature->getThreatManager().getThreatList();
vManaPlayers.reserve(tList.size());
for (ThreatList::const_iterator iter = tList.begin();iter != tList.end(); ++iter)
{
Unit* pTempTarget = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());

if (pTempTarget && pTempTarget->getPowerType() == POWER_MANA && pTempTarget->GetTypeId() == TYPEID_PLAYER)
vManaPlayers.push_back(pTempTarget);
}

if (!vManaPlayers.empty())
{
return vManaPlayers[urand(0, vManaPlayers.size() - 1)];
}

return NULL;
}

void UpdateAI(const uint32 uiDiff)
{
if (m_uiIntroTimer)
Expand Down Expand Up @@ -257,7 +280,7 @@ struct MANGOS_DLL_DECL boss_vaelastraszAI : public ScriptedAI
if (m_uiCleaveTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CLEAVE) == CAST_OK)
m_uiCleaveTimer = 15000;
m_uiCleaveTimer = 6000;
}
else
m_uiCleaveTimer -= uiDiff;
Expand All @@ -272,43 +295,29 @@ struct MANGOS_DLL_DECL boss_vaelastraszAI : public ScriptedAI
m_uiFlameBreathTimer -= uiDiff;

// Burning Adrenaline Caster Timer
if (m_uiBurningAdrenalineCasterTimer < uiDiff)
if (m_uiBurningAdrenalineTimer < uiDiff)
{
std::vector<Unit*> vManaPlayers;
Unit * pTarget = NULL;

// Scan for mana targets in threat list
ThreatList const& tList = m_creature->getThreatManager().getThreatList();
vManaPlayers.reserve(tList.size());
for (ThreatList::const_iterator iter = tList.begin();iter != tList.end(); ++iter)
if (m_uiBurningAdrenalineTarget < 2)
{
Unit* pTempTarget = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());

if (pTempTarget && pTempTarget->getPowerType() == POWER_MANA && pTempTarget->GetTypeId() == TYPEID_PLAYER)
vManaPlayers.push_back(pTempTarget);
pTarget = GetManaUserForBA();
} else {
pTarget = m_creature->getVictim();
}

if (vManaPlayers.empty())
return;

Unit* pTarget = vManaPlayers[urand(0, vManaPlayers.size() - 1)];
pTarget->CastSpell(pTarget, SPELL_BURNING_ADRENALINE, true, NULL, NULL, m_creature->GetObjectGuid());

m_uiBurningAdrenalineCasterTimer = 15000;
}
else
m_uiBurningAdrenalineCasterTimer -= uiDiff;

// Burning Adrenaline Tank Timer
if (m_uiBurningAdrenalineTankTimer < uiDiff)
{
// have the victim cast the spell on himself otherwise the third effect aura will be applied
// to Vael instead of the player
m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_BURNING_ADRENALINE, true, NULL, NULL, m_creature->GetObjectGuid());
if (pTarget)
{
// have the victim cast the spell on himself otherwise the third effect aura will be applied
// to Vael instead of the player
pTarget->CastSpell(pTarget, SPELL_BURNING_ADRENALINE, true, NULL, NULL, m_creature->GetObjectGuid());
}

m_uiBurningAdrenalineTankTimer = 45000;
m_uiBurningAdrenalineTimer = 15000;
m_uiBurningAdrenalineTarget = (m_uiBurningAdrenalineTarget + 1) % 3;
}
else
m_uiBurningAdrenalineTankTimer -= uiDiff;
m_uiBurningAdrenalineTimer -= uiDiff;

// Fire Nova Timer
if (m_uiFireNovaTimer < uiDiff)
Expand Down
Loading