Core/Script: Code style and some rewriting.

MoveInLineOfSight(Unit* unit) -> MoveInLineOfSight(Unit* who)

Signed-off-by: Gyx <[email protected]>
This commit is contained in:
Gyx
2012-04-01 19:56:41 +08:00
parent 00264e45cf
commit a1c4786ba0
66 changed files with 417 additions and 471 deletions
@@ -951,7 +951,7 @@ struct dummy_dragonAI : public ScriptedAI
return;
// Twilight Revenge to main boss
if (Unit* pSartharion = Unit::GetUnit((*me), instance->GetData64(DATA_SARTHARION)))
if (Unit* pSartharion = Unit::GetUnit(*me, instance->GetData64(DATA_SARTHARION)))
if (pSartharion->isAlive())
{
pSartharion->RemoveAurasDueToSpell(uiSpellId);
@@ -414,8 +414,8 @@ public:
void JustDied(Unit* /*killer*/)
{
if (me->isSummon())
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
if (TempSummon* summ = me->ToTempSummon())
if (Unit* summoner = summ->GetSummoner())
if (summoner->isAlive())
summoner->GetAI()->SetData(1, 0);
}
@@ -292,7 +292,7 @@ struct boss_faction_championsAI : public ScriptedAI
std::list<HostileReference*> const& tList = me->getThreatManager().getThreatList();
for (std::list<HostileReference*>::const_iterator itr = tList.begin(); itr != tList.end(); ++itr)
{
Unit* unit = Unit::GetUnit((*me), (*itr)->getUnitGuid());
Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid());
if (unit && me->getThreatManager().getThreat(unit))
{
if (unit->GetTypeId()==TYPEID_PLAYER)
@@ -384,7 +384,7 @@ struct boss_faction_championsAI : public ScriptedAI
Unit* target;
for (iter = tList.begin(); iter!=tList.end(); ++iter)
{
target = Unit::GetUnit((*me), (*iter)->getUnitGuid());
target = Unit::GetUnit(*me, (*iter)->getUnitGuid());
if (target && target->getPowerType() == POWER_MANA)
return target;
}
@@ -399,7 +399,7 @@ struct boss_faction_championsAI : public ScriptedAI
Unit* target;
for (iter = tList.begin(); iter!=tList.end(); ++iter)
{
target = Unit::GetUnit((*me), (*iter)->getUnitGuid());
target = Unit::GetUnit(*me, (*iter)->getUnitGuid());
if (target && me->GetDistance2d(target) < distance)
++count;
}
@@ -136,10 +136,10 @@ public:
if (!instance)
return false;
Creature* Thane = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_THANE)));
Creature* Lady = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_LADY)));
Creature* Baron = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_BARON)));
Creature* Sir = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_SIR)));
Creature* Thane = Unit::GetCreature(*me, instance->GetData64(DATA_THANE));
Creature* Lady = Unit::GetCreature(*me, instance->GetData64(DATA_LADY));
Creature* Baron = Unit::GetCreature(*me, instance->GetData64(DATA_BARON));
Creature* Sir = Unit::GetCreature(*me, instance->GetData64(DATA_SIR));
if (Thane && Lady && Baron && Sir)
{
@@ -667,7 +667,7 @@ public:
if (!instance || instance->IsEncounterInProgress() || instance->GetBossState(BOSS_KELTHUZAD) == DONE)
return false;
Creature* pKelthuzad = CAST_CRE(Unit::GetUnit(*player, instance->GetData64(DATA_KELTHUZAD)));
Creature* pKelthuzad = Unit::GetCreature(*player, instance->GetData64(DATA_KELTHUZAD));
if (!pKelthuzad)
return false;
@@ -714,7 +714,6 @@ public:
return true;
}
};
class npc_kelthuzad_abomination : public CreatureScript
@@ -726,16 +725,13 @@ class npc_kelthuzad_abomination : public CreatureScript
{
npc_kelthuzad_abominationAI(Creature* creature) : ScriptedAI(creature)
{
instance = me->GetInstanceScript();
_instance = creature->GetInstanceScript();
}
InstanceScript* instance;
EventMap events;
void Reset()
{
events.Reset();
events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(2000, 5000));
_events.Reset();
_events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(2000, 5000));
DoCast(me, SPELL_FRENZY, true);
}
@@ -744,15 +740,15 @@ class npc_kelthuzad_abomination : public CreatureScript
if (!UpdateVictim())
return;
events.Update(diff);
_events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_MORTAL_WOUND:
DoCastVictim(SPELL_MORTAL_WOUND, true);
events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(10000, 15000));
_events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(10000, 15000));
break;
default:
break;
@@ -762,9 +758,13 @@ class npc_kelthuzad_abomination : public CreatureScript
void JustDied(Unit* /*killer*/)
{
if (instance)
instance->SetData(DATA_ABOMINATION_KILLED, instance->GetData(DATA_ABOMINATION_KILLED) + 1);
if (_instance)
_instance->SetData(DATA_ABOMINATION_KILLED, _instance->GetData(DATA_ABOMINATION_KILLED) + 1);
}
private:
InstanceScript* _instance;
EventMap _events;
};
CreatureAI* GetAI(Creature* creature) const
@@ -776,9 +776,7 @@ class npc_kelthuzad_abomination : public CreatureScript
class achievement_just_cant_get_enough : public AchievementCriteriaScript
{
public:
achievement_just_cant_get_enough() : AchievementCriteriaScript("achievement_just_cant_get_enough")
{
}
achievement_just_cant_get_enough() : AchievementCriteriaScript("achievement_just_cant_get_enough") { }
bool OnCheck(Player* /*player*/, Unit* target)
{
@@ -195,7 +195,7 @@ public:
std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
for (; i != me->getThreatManager().getThreatList().end(); ++i)
{
Unit* temp = Unit::GetUnit((*me), (*i)->getUnitGuid());
Unit* temp = Unit::GetUnit(*me, (*i)->getUnitGuid());
if (temp && temp->GetTypeId() == TYPEID_PLAYER && temp->getClass() == Healer)
{
target = temp;
@@ -371,15 +371,15 @@ class npc_scorch_ground : public CreatureScript
creature->SetDisplayId(16925); //model 2 in db cannot overwrite wdb fields
}
void MoveInLineOfSight(Unit* unit)
void MoveInLineOfSight(Unit* who)
{
if (!_heat)
{
if (unit->GetEntry() == NPC_IRON_CONSTRUCT)
if (who->GetEntry() == NPC_IRON_CONSTRUCT)
{
if (!unit->HasAura(SPELL_HEAT) || !unit->HasAura(SPELL_MOLTEN))
if (!who->HasAura(SPELL_HEAT) || !who->HasAura(SPELL_MOLTEN))
{
_constructGUID = unit->GetGUID();
_constructGUID = who->GetGUID();
_heat = true;
}
}
@@ -344,7 +344,7 @@ public:
{
if (type != POINT_MOTION_TYPE)
return;
Unit* ingvar = Unit::GetUnit((*me), instance ? instance->GetData64(DATA_INGVAR) : 0);
Unit* ingvar = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_INGVAR) : 0);
if (ingvar)
{
switch (id)
@@ -93,7 +93,7 @@ public:
ghost = (me->GetEntry() == MOB_SKARVALD_GHOST);
if (!ghost && instance)
{
Unit* dalronn = Unit::GetUnit((*me), instance->GetData64(DATA_DALRONN));
Unit* dalronn = Unit::GetUnit(*me, instance->GetData64(DATA_DALRONN));
if (dalronn && dalronn->isDead())
CAST_CRE(dalronn)->Respawn();
@@ -107,7 +107,7 @@ public:
{
DoScriptText(YELL_SKARVALD_AGGRO, me);
Unit* dalronn = Unit::GetUnit((*me), instance->GetData64(DATA_DALRONN));
Unit* dalronn = Unit::GetUnit(*me, instance->GetData64(DATA_DALRONN));
if (dalronn && dalronn->isAlive() && !dalronn->getVictim())
dalronn->getThreatManager().addThreat(who, 0.0f);
@@ -119,7 +119,7 @@ public:
{
if (!ghost && instance)
{
Unit* dalronn = Unit::GetUnit((*me), instance->GetData64(DATA_DALRONN));
Unit* dalronn = Unit::GetUnit(*me, instance->GetData64(DATA_DALRONN));
if (dalronn)
{
if (dalronn->isDead())
@@ -250,7 +250,7 @@ public:
ghost = me->GetEntry() == MOB_DALRONN_GHOST;
if (!ghost && instance)
{
Unit* skarvald = Unit::GetUnit((*me), instance->GetData64(DATA_SKARVALD));
Unit* skarvald = Unit::GetUnit(*me, instance->GetData64(DATA_SKARVALD));
if (skarvald && skarvald->isDead())
CAST_CRE(skarvald)->Respawn();
@@ -262,7 +262,7 @@ public:
{
if (!ghost && instance)
{
Unit* skarvald = Unit::GetUnit((*me), instance->GetData64(DATA_SKARVALD));
Unit* skarvald = Unit::GetUnit(*me, instance->GetData64(DATA_SKARVALD));
if (skarvald && skarvald->isAlive() && !skarvald->getVictim())
skarvald->getThreatManager().addThreat(who, 0.0f);
@@ -277,7 +277,7 @@ public:
{
if (!ghost && instance)
{
Unit* skarvald = Unit::GetUnit((*me), instance->GetData64(DATA_SKARVALD));
Unit* skarvald = Unit::GetUnit(*me, instance->GetData64(DATA_SKARVALD));
if (skarvald)
{
if (skarvald->isDead())
@@ -306,10 +306,9 @@ public:
if (me->isDead())
return;
if (me->isSummon())
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
if (summoner)
me->GetMotionMaster()->MovePoint(0, summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ());
if (TempSummon* summ = me->ToTempSummon())
if (Unit* summoner = summ->GetSummoner())
me->GetMotionMaster()->MovePoint(0, summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ());
Reset();
}
+18 -18
View File
@@ -567,9 +567,9 @@ public:
enter_timer -= diff;
}
void MoveInLineOfSight(Unit* unit)
void MoveInLineOfSight(Unit* who)
{
if (!unit || !drakeGUID)
if (!who || !drakeGUID)
return;
Creature* drake = Unit::GetCreature(*me, drakeGUID);
@@ -581,21 +581,21 @@ public:
if (!me->IsOnVehicle(drake) && !me->HasAura(SPELL_ICE_PRISON))
{
if (unit->IsVehicle() && me->IsWithinDist(unit, 25.0f, true) && unit->ToCreature() && unit->ToCreature()->GetEntry() == 29709)
if (who->IsVehicle() && me->IsWithinDist(who, 25.0f, true) && who->ToCreature() && who->ToCreature()->GetEntry() == 29709)
{
uint8 seat = unit->GetVehicleKit()->GetNextEmptySeat(0, true);
uint8 seat = who->GetVehicleKit()->GetNextEmptySeat(0, true);
if (seat <= 0)
return;
me->EnterVehicle(unit, seat);
me->EnterVehicle(who, seat);
me->SendMovementFlagUpdate();
hasEmptySeats = false;
}
}
if (unit->ToCreature() && me->IsOnVehicle(drake))
if (who->ToCreature() && me->IsOnVehicle(drake))
{
if (unit->ToCreature()->GetEntry() == NPC_QUEST_GIVER && me->IsWithinDist(unit, 15.0f, false))
if (who->ToCreature()->GetEntry() == NPC_QUEST_GIVER && me->IsWithinDist(who, 15.0f, false))
{
Unit* rider = drake->GetVehicleKit()->GetPassenger(0);
if (!rider)
@@ -616,7 +616,7 @@ public:
if (rider->ToPlayer())
rider->ToPlayer()->KilledMonsterCredit(29709, 0);
drake->ToCreature()->ForcedDespawn(0);
drake->ForcedDespawn(0);
}
}
}
@@ -748,14 +748,14 @@ class npc_hyldsmeet_protodrake : public CreatureScript
void AddSC_storm_peaks()
{
new npc_agnetta_tyrsdottar;
new npc_frostborn_scout;
new npc_thorim;
new npc_victorious_challenger;
new npc_loklira_crone;
new npc_injured_goblin;
new npc_roxi_ramrocket;
new npc_brunnhildar_prisoner;
new npc_icefang;
new npc_hyldsmeet_protodrake;
new npc_agnetta_tyrsdottar();
new npc_frostborn_scout();
new npc_thorim();
new npc_victorious_challenger();
new npc_loklira_crone();
new npc_injured_goblin();
new npc_roxi_ramrocket();
new npc_brunnhildar_prisoner();
new npc_icefang();
new npc_hyldsmeet_protodrake();
}