Skip to content
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

Adds thrash to firemaw, tested on the latest core, is working. #6

Open
wants to merge 14 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, pSource->GetZoneId());
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
17 changes: 14 additions & 3 deletions scripts/eastern_kingdoms/blackwing_lair/boss_firemaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

/* ScriptData
SDName: Boss_Firemaw
SD%Complete: 80
SDComment: Thrash missing
SD%Complete: 100%
SDComment:
SDCategory: Blackwing Lair
EndScriptData */

Expand All @@ -32,7 +32,7 @@ enum
SPELL_SHADOW_FLAME = 22539,
SPELL_WING_BUFFET = 23339,
SPELL_FLAME_BUFFET = 23341,
SPELL_THRASH = 3391, // TODO, missing
SPELL_THRASH = 3391
};

struct MANGOS_DLL_DECL boss_firemawAI : public ScriptedAI
Expand All @@ -48,12 +48,14 @@ struct MANGOS_DLL_DECL boss_firemawAI : public ScriptedAI
uint32 m_uiShadowFlameTimer;
uint32 m_uiWingBuffetTimer;
uint32 m_uiFlameBuffetTimer;
uint32 m_uiThrashTimer;

void Reset()
{
m_uiShadowFlameTimer = 30000; // These times are probably wrong
m_uiWingBuffetTimer = 24000;
m_uiFlameBuffetTimer = 5000;
m_uiThrashTimer = 25000;
}

void Aggro(Unit* pWho)
Expand Down Expand Up @@ -110,6 +112,15 @@ struct MANGOS_DLL_DECL boss_firemawAI : public ScriptedAI
}
else
m_uiFlameBuffetTimer -= uiDiff;

// Thrash Timer
if (m_uiThrashTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_THRASH) == CAST_OK)
m_uiThrashTimer = 20000;
}
else
m_uiThrashTimer -= uiDiff;

DoMeleeAttackIfReady();
}
Expand Down
57 changes: 15 additions & 42 deletions scripts/eastern_kingdoms/deadmines/deadmines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct MANGOS_DLL_DECL boss_mr_smiteAI : public ScriptedAI

m_creature->SetStandState(UNIT_STAND_STATE_STAND);
m_uiPhase = PHASE_EQUIP_END;
m_uiEquipTimer = 5000;
m_uiEquipTimer = 1000;

Unit* pVictim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 0);

Expand All @@ -157,14 +157,6 @@ struct MANGOS_DLL_DECL boss_mr_smiteAI : public ScriptedAI
EnterEvadeMode();
return;
}

// Takes longer to run further distance. Not accurate, but will probably be sufficient for most cases
if (m_creature->IsWithinDistInMap(pVictim, ATTACK_DISTANCE))
m_uiEquipTimer -= 1000;
else if (m_creature->IsWithinDistInMap(pVictim, 2*ATTACK_DISTANCE))
m_uiEquipTimer -= 2000;
else
m_uiEquipTimer -= 3000;
}

void PhaseEquipEnd()
Expand Down Expand Up @@ -251,6 +243,7 @@ struct MANGOS_DLL_DECL boss_mr_smiteAI : public ScriptedAI
m_uiPhase = PHASE_EQUIP_START;
m_uiEquipTimer = 2500;

// will clear getVictim (m_attacking)
m_creature->AttackStop(true);
m_creature->RemoveAurasDueToSpell(SPELL_THRASH);
}
Expand Down Expand Up @@ -281,51 +274,31 @@ CreatureAI* GetAI_boss_mr_smite(Creature* pCreature)
return new boss_mr_smiteAI(pCreature);
}

bool GOUse_go_door_lever_dm(Player* pPlayer, GameObject* pGo)
{
ScriptedInstance* pInstance = (ScriptedInstance*)pGo->GetInstanceData();

if (!pInstance)
return false;

GameObject* pGoDoor = pInstance->GetSingleGameObjectFromStorage(GO_IRON_CLAD_DOOR);

if (pGoDoor && pGoDoor->GetGoState() == GO_STATE_READY)
return false;

return true;
}

bool GOUse_go_defias_cannon(Player* pPlayer, GameObject* pGo)
{
ScriptedInstance* pInstance = (ScriptedInstance*)pGo->GetInstanceData();

if (!pInstance)
return false;

if (pInstance->GetData(TYPE_DEFIAS_ENDDOOR) == DONE || pInstance->GetData(TYPE_DEFIAS_ENDDOOR) == IN_PROGRESS)
if (pInstance->GetData(TYPE_IRON_CLAD_DOOR) == DONE)
return false;

pInstance->SetData(TYPE_DEFIAS_ENDDOOR, IN_PROGRESS);
pInstance->SetData(TYPE_IRON_CLAD_DOOR, DONE);
return false;
}

void AddSC_deadmines()
{
Script *newscript;

newscript = new Script;
newscript->Name = "boss_mr_smite";
newscript->GetAI = &GetAI_boss_mr_smite;
newscript->RegisterSelf();

newscript = new Script;
newscript->Name = "go_door_lever_dm";
newscript->pGOUse = &GOUse_go_door_lever_dm;
newscript->RegisterSelf();

newscript = new Script;
newscript->Name = "go_defias_cannon";
newscript->pGOUse = &GOUse_go_defias_cannon;
newscript->RegisterSelf();
Script* pNewScript;

pNewScript = new Script;
pNewScript->Name = "boss_mr_smite";
pNewScript->GetAI = &GetAI_boss_mr_smite;
pNewScript->RegisterSelf();

pNewScript = new Script;
pNewScript->Name = "go_defias_cannon";
pNewScript->pGOUse = &GOUse_go_defias_cannon;
pNewScript->RegisterSelf();
}
Loading