refactor(Core/Scripts): restyle scripts lib with astyle (#3467)

This commit is contained in:
Kargatum
2020-10-11 15:35:34 +07:00
committed by GitHub
parent 4cca286a4d
commit 5e20b46812
538 changed files with 92888 additions and 91297 deletions

View File

@@ -72,7 +72,7 @@ public:
void SetControl(Player* player, bool on)
{
WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, me->GetPackGUID().size()+1);
WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, me->GetPackGUID().size() + 1);
data.append(me->GetPackGUID());
data << uint8(on ? 1 : 0);
player->GetSession()->SendPacket(&data);
@@ -100,16 +100,16 @@ public:
Talk(EYE_TEXT_LAUNCH, me->GetCharmerOrOwnerPlayerOrPlayerItself());
break;
case EVENT_LAUNCH:
{
me->SetSpeed(MOVE_FLIGHT, 5.0f, true);
{
me->SetSpeed(MOVE_FLIGHT, 5.0f, true);
const Position EYE_DESTINATION_1 = { me->GetPositionX()-40.0f, me->GetPositionY(), me->GetPositionZ()+10.0f, 0.0f };
const Position EYE_DESTINATION_2 = { 1768.0f, -5876.0f, 153.0f, 0.0f };
const Position EYE_DESTINATION_1 = { me->GetPositionX() - 40.0f, me->GetPositionY(), me->GetPositionZ() + 10.0f, 0.0f };
const Position EYE_DESTINATION_2 = { 1768.0f, -5876.0f, 153.0f, 0.0f };
me->GetMotionMaster()->MovePoint(EYE_POINT_DESTINATION_1, EYE_DESTINATION_1);
me->GetMotionMaster()->MovePoint(EYE_POINT_DESTINATION_2, EYE_DESTINATION_2);
break;
}
me->GetMotionMaster()->MovePoint(EYE_POINT_DESTINATION_1, EYE_DESTINATION_1);
me->GetMotionMaster()->MovePoint(EYE_POINT_DESTINATION_2, EYE_DESTINATION_2);
break;
}
case EVENT_REGAIN_CONTROL:
if (Player* player = me->GetCharmerOrOwnerPlayerOrPlayerItself())
{
@@ -127,30 +127,30 @@ public:
class spell_q12641_death_comes_from_on_high_summon_ghouls : public SpellScriptLoader
{
public:
spell_q12641_death_comes_from_on_high_summon_ghouls() : SpellScriptLoader("spell_q12641_death_comes_from_on_high_summon_ghouls") { }
public:
spell_q12641_death_comes_from_on_high_summon_ghouls() : SpellScriptLoader("spell_q12641_death_comes_from_on_high_summon_ghouls") { }
class spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript : public SpellScript
class spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript : public SpellScript
{
PrepareSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript);
void HandleScriptEffect(SpellEffIndex effIndex)
{
PrepareSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript);
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 54522, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript();
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 54522, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript();
}
};
enum deathsChallenge
@@ -261,11 +261,11 @@ public:
me->GetMotionMaster()->MoveFollow(caster, 2.0f, 0.0f);
events.ScheduleEvent(EVENT_SPEAK, 3000);
events.ScheduleEvent(EVENT_SPEAK+1, 7000);
events.ScheduleEvent(EVENT_SPEAK+2, 8000);
events.ScheduleEvent(EVENT_SPEAK+3, 9000);
events.ScheduleEvent(EVENT_SPEAK+4, 10000);
events.ScheduleEvent(EVENT_SPEAK+5, 11000);
events.ScheduleEvent(EVENT_SPEAK + 1, 7000);
events.ScheduleEvent(EVENT_SPEAK + 2, 8000);
events.ScheduleEvent(EVENT_SPEAK + 3, 9000);
events.ScheduleEvent(EVENT_SPEAK + 4, 10000);
events.ScheduleEvent(EVENT_SPEAK + 5, 11000);
}
}
@@ -279,7 +279,7 @@ public:
{
damage = 0;
events.ScheduleEvent(EVENT_DUEL_LOST, 2000);
events.ScheduleEvent(EVENT_DUEL_LOST+1, 6000);
events.ScheduleEvent(EVENT_DUEL_LOST + 1, 6000);
_duelGUID = 0;
_duelInProgress = 0;
@@ -315,16 +315,16 @@ public:
Talk(SAY_DUEL, ObjectAccessor::GetPlayer(*me, _duelGUID));
break;
case EVENT_SPEAK+1:
Talk(SAY_DUEL+1, ObjectAccessor::GetPlayer(*me, _duelGUID));
Talk(SAY_DUEL + 1, ObjectAccessor::GetPlayer(*me, _duelGUID));
break;
case EVENT_SPEAK+2:
Talk(SAY_DUEL+2, ObjectAccessor::GetPlayer(*me, _duelGUID));
Talk(SAY_DUEL + 2, ObjectAccessor::GetPlayer(*me, _duelGUID));
break;
case EVENT_SPEAK+3:
Talk(SAY_DUEL+3, ObjectAccessor::GetPlayer(*me, _duelGUID));
Talk(SAY_DUEL + 3, ObjectAccessor::GetPlayer(*me, _duelGUID));
break;
case EVENT_SPEAK+4:
Talk(SAY_DUEL+4, ObjectAccessor::GetPlayer(*me, _duelGUID));
Talk(SAY_DUEL + 4, ObjectAccessor::GetPlayer(*me, _duelGUID));
break;
case EVENT_SPEAK+5:
me->setFaction(FACTION_HOSTILE);
@@ -377,63 +377,63 @@ enum GiftOfTheHarvester
class spell_item_gift_of_the_harvester : public SpellScriptLoader
{
public:
spell_item_gift_of_the_harvester() : SpellScriptLoader("spell_item_gift_of_the_harvester") { }
public:
spell_item_gift_of_the_harvester() : SpellScriptLoader("spell_item_gift_of_the_harvester") { }
class spell_item_gift_of_the_harvester_SpellScript : public SpellScript
class spell_item_gift_of_the_harvester_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_gift_of_the_harvester_SpellScript);
SpellCastResult CheckRequirement()
{
PrepareSpellScript(spell_item_gift_of_the_harvester_SpellScript);
SpellCastResult CheckRequirement()
std::list<Creature*> ghouls;
GetCaster()->GetAllMinionsByEntry(ghouls, NPC_GHOUL);
if (ghouls.size() >= MAX_GHOULS)
{
std::list<Creature*> ghouls;
GetCaster()->GetAllMinionsByEntry(ghouls, NPC_GHOUL);
if (ghouls.size() >= MAX_GHOULS)
{
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_TOO_MANY_GHOULS);
return SPELL_FAILED_CUSTOM_ERROR;
}
return SPELL_CAST_OK;
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_TOO_MANY_GHOULS);
return SPELL_FAILED_CUSTOM_ERROR;
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_item_gift_of_the_harvester_SpellScript::CheckRequirement);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_gift_of_the_harvester_SpellScript();
return SPELL_CAST_OK;
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_item_gift_of_the_harvester_SpellScript::CheckRequirement);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_gift_of_the_harvester_SpellScript();
}
};
class spell_q12698_the_gift_that_keeps_on_giving : public SpellScriptLoader
{
public:
spell_q12698_the_gift_that_keeps_on_giving() : SpellScriptLoader("spell_q12698_the_gift_that_keeps_on_giving") { }
public:
spell_q12698_the_gift_that_keeps_on_giving() : SpellScriptLoader("spell_q12698_the_gift_that_keeps_on_giving") { }
class spell_q12698_the_gift_that_keeps_on_giving_SpellScript : public SpellScript
class spell_q12698_the_gift_that_keeps_on_giving_SpellScript : public SpellScript
{
PrepareSpellScript(spell_q12698_the_gift_that_keeps_on_giving_SpellScript);
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
PrepareSpellScript(spell_q12698_the_gift_that_keeps_on_giving_SpellScript);
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
if (GetOriginalCaster() && GetHitUnit())
GetOriginalCaster()->CastSpell(GetHitUnit(), urand(0, 1) ? GetEffectValue() : SPELL_SUMMON_SCARLET_GHOST, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12698_the_gift_that_keeps_on_giving_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_q12698_the_gift_that_keeps_on_giving_SpellScript();
if (GetOriginalCaster() && GetHitUnit())
GetOriginalCaster()->CastSpell(GetHitUnit(), urand(0, 1) ? GetEffectValue() : SPELL_SUMMON_SCARLET_GHOST, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12698_the_gift_that_keeps_on_giving_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_q12698_the_gift_that_keeps_on_giving_SpellScript();
}
};
class npc_scarlet_ghoul : public CreatureScript
@@ -507,7 +507,7 @@ public:
me->SetReactState(REACT_DEFENSIVE);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, frand(0.0f, 2*M_PI));
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, frand(0.0f, 2 * M_PI));
events.PopEvent();
events.ScheduleEvent(EVENT_GHOUL_CHECK_COMBAT, 1000);
return;
@@ -567,7 +567,7 @@ public:
creature->CastSpell(owner, 52517, true);
creature->AI()->SetGUID(me->GetGUID());
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
}
}
@@ -611,7 +611,7 @@ public:
if (summonAttackers >= 15000)
{
for (uint8 i = 0; i < 15; ++i)
if (Creature* summon = me->SummonCreature(28834 /*NPC_SCARLET_FLEET_DEFENDER*/, 2192.56f+irand(-10, 10), -6147.90f+irand(-10, 10), 5.2f, 4.7f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 45000))
if (Creature* summon = me->SummonCreature(28834 /*NPC_SCARLET_FLEET_DEFENDER*/, 2192.56f + irand(-10, 10), -6147.90f + irand(-10, 10), 5.2f, 4.7f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 45000))
{
summon->SetHomePosition(me->GetHomePosition());
summon->AI()->AttackStart(me);
@@ -770,103 +770,103 @@ public:
{
switch (phase)
{
case PHASE_CHAINED:
if (!anchorGUID)
{
if (Creature* anchor = me->FindNearestCreature(29521, 30))
case PHASE_CHAINED:
if (!anchorGUID)
{
anchor->AI()->SetGUID(me->GetGUID());
anchor->CastSpell(me, SPELL_SOUL_PRISON_CHAIN, true);
anchorGUID = anchor->GetGUID();
}
float dist = 99.0f;
GameObject* prison = nullptr;
for (uint8 i = 0; i < 12; ++i)
{
if (GameObject* temp_prison = me->FindNearestGameObject(acherus_soul_prison[i], 100))
if (Creature* anchor = me->FindNearestCreature(29521, 30))
{
if (temp_prison && me->IsWithinDist(temp_prison, dist, false))
anchor->AI()->SetGUID(me->GetGUID());
anchor->CastSpell(me, SPELL_SOUL_PRISON_CHAIN, true);
anchorGUID = anchor->GetGUID();
}
float dist = 99.0f;
GameObject* prison = nullptr;
for (uint8 i = 0; i < 12; ++i)
{
if (GameObject* temp_prison = me->FindNearestGameObject(acherus_soul_prison[i], 100))
{
dist = me->GetDistance2d(temp_prison);
prison = temp_prison;
if (temp_prison && me->IsWithinDist(temp_prison, dist, false))
{
dist = me->GetDistance2d(temp_prison);
prison = temp_prison;
}
}
}
if (prison)
prison->ResetDoorOrButton();
}
break;
case PHASE_TO_EQUIP:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->GetMotionMaster()->MovePoint(1, anchorX, anchorY, me->GetPositionZ());
//sLog->outDebug(LOG_FILTER_TSCR, "npc_unworthy_initiateAI: move to %f %f %f", anchorX, anchorY, me->GetPositionZ());
phase = PHASE_EQUIPING;
wait_timer = 0;
}
}
break;
case PHASE_TO_ATTACK:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->setFaction(14);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
phase = PHASE_ATTACKING;
if (Player* target = ObjectAccessor::GetPlayer(*me, playerGUID))
AttackStart(target);
wait_timer = 0;
}
}
break;
case PHASE_ATTACKING:
if (!UpdateVictim())
return;
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_ICY_TOUCH:
DoCastVictim(SPELL_ICY_TOUCH);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_ICY_TOUCH, 5000, GCD_CAST);
break;
case EVENT_PLAGUE_STRIKE:
DoCastVictim(SPELL_PLAGUE_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_PLAGUE_STRIKE, 5000, GCD_CAST);
break;
case EVENT_BLOOD_STRIKE:
DoCastVictim(SPELL_BLOOD_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_BLOOD_STRIKE, 5000, GCD_CAST);
break;
case EVENT_DEATH_COIL:
DoCastVictim(SPELL_DEATH_COIL);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_DEATH_COIL, 5000, GCD_CAST);
break;
}
}
if (prison)
prison->ResetDoorOrButton();
}
break;
case PHASE_TO_EQUIP:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->GetMotionMaster()->MovePoint(1, anchorX, anchorY, me->GetPositionZ());
//sLog->outDebug(LOG_FILTER_TSCR, "npc_unworthy_initiateAI: move to %f %f %f", anchorX, anchorY, me->GetPositionZ());
phase = PHASE_EQUIPING;
wait_timer = 0;
}
}
break;
case PHASE_TO_ATTACK:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->setFaction(14);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
phase = PHASE_ATTACKING;
if (Player* target = ObjectAccessor::GetPlayer(*me, playerGUID))
AttackStart(target);
wait_timer = 0;
}
}
break;
case PHASE_ATTACKING:
if (!UpdateVictim())
return;
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_ICY_TOUCH:
DoCastVictim(SPELL_ICY_TOUCH);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_ICY_TOUCH, 5000, GCD_CAST);
break;
case EVENT_PLAGUE_STRIKE:
DoCastVictim(SPELL_PLAGUE_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_PLAGUE_STRIKE, 5000, GCD_CAST);
break;
case EVENT_BLOOD_STRIKE:
DoCastVictim(SPELL_BLOOD_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_BLOOD_STRIKE, 5000, GCD_CAST);
break;
case EVENT_DEATH_COIL:
DoCastVictim(SPELL_DEATH_COIL);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_DEATH_COIL, 5000, GCD_CAST);
break;
}
}
DoMeleeAttackIfReady();
break;
default:
break;
DoMeleeAttackIfReady();
break;
default:
break;
}
}
};
@@ -942,7 +942,7 @@ public:
{
npc_scarlet_miner_cartAI(Creature* creature) : PassiveAI(creature), minerGUID(0)
{
me->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
me->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->setFaction(35);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid1); // Modelid2 is a horse.
}
@@ -965,7 +965,7 @@ public:
me->SetSpeed(MOVE_RUN, 1.25f);
me->GetMotionMaster()->MoveFollow(miner, 1.0f, 0);
me->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
me->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->setFaction(35);
}
}
@@ -1076,7 +1076,7 @@ public:
{
me->SetFacingToObject(car);
// xinef: add some flags
car->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
car->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
car->setFaction(35);
}
Talk(SAY_SCARLET_MINER_0);
@@ -1118,7 +1118,8 @@ public:
car->AI()->DoAction(0);
IntroPhase = 0;
}
} else IntroTimer-=diff;
}
else IntroTimer -= diff;
}
npc_escortAI::UpdateAI(diff);
}
@@ -1158,7 +1159,7 @@ public:
}
}
}
return true;
}