Last active
December 15, 2015 21:38
-
-
Save saqirmdev/5326652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npc_flame_orb | |
enum FlameOrb | |
{ | |
SPELL_FLAME_ORB_DAMAGE = 86719, | |
FLAME_ORB_DISTANCE = 120 | |
}; | |
class npc_flame_orb : public CreatureScript | |
{ | |
public: | |
npc_flame_orb() : CreatureScript("npc_flame_orb") {} | |
struct npc_flame_orbAI : public ScriptedAI | |
{ | |
npc_flame_orbAI(Creature *creature) : ScriptedAI(creature) | |
{ | |
x = me->GetPositionX(); | |
y = me->GetPositionY(); | |
z = me->GetOwner()->GetPositionZ()+2; | |
o = me->GetOrientation(); | |
me->NearTeleportTo(x, y, z, o, true); | |
angle = me->GetOwner()->GetAngle(me); | |
newx = me->GetPositionX() + FLAME_ORB_DISTANCE/2 * cos(angle); | |
newy = me->GetPositionY() + FLAME_ORB_DISTANCE/2 * sin(angle); | |
CombatCheck = false; | |
} | |
float x, y, z, o, newx, newy, angle; | |
bool CombatCheck; | |
uint32 DespawnTimer; | |
uint32 DespawnCheckTimer; | |
uint32 DamageTimer; | |
void EnterCombat(Unit* /*target*/) | |
{ | |
me->GetMotionMaster()->MoveCharge(newx, newy, z, 1.14286f); // Normal speed | |
DespawnTimer = 15 * IN_MILLISECONDS; | |
CombatCheck = true; | |
} | |
void Reset() | |
{ | |
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_NON_ATTACKABLE); | |
me->AddUnitMovementFlag(MOVEMENTFLAG_FLYING); | |
me->SetReactState(REACT_PASSIVE); | |
if (CombatCheck == true) | |
DespawnTimer = 15 * IN_MILLISECONDS; | |
else | |
DespawnTimer = 4 * IN_MILLISECONDS; | |
DamageTimer = 1 * IN_MILLISECONDS; | |
me->GetMotionMaster()->MovePoint(0, newx, newy, z); | |
} | |
void UpdateAI(const uint32 diff) | |
{ | |
if (!me->isInCombat() && CombatCheck == false) | |
{ | |
me->SetSpeed(MOVE_RUN, 2, true); | |
me->SetSpeed(MOVE_FLIGHT, 2, true); | |
} | |
if (DespawnTimer <= diff) | |
{ | |
me->SetVisible(false); | |
me->DisappearAndDie(); | |
} | |
else | |
DespawnTimer -= diff; | |
if (DamageTimer <= diff) | |
{ | |
if (Unit* target = me->SelectNearestTarget(15)) | |
DoCast(target, SPELL_FLAME_ORB_DAMAGE); | |
DamageTimer = 1 * IN_MILLISECONDS; | |
} | |
else | |
DamageTimer -= diff; | |
} | |
}; | |
CreatureAI* GetAI(Creature* creature) const | |
{ | |
return new npc_flame_orbAI(creature); | |
} | |
}; | |
// npc_frostfire_orb | |
enum FrostfireOrb | |
{ | |
SPELL_FROSTFIRE_ORB_DAMAGE_RANK_1 = 95969, | |
SPELL_FROSTFIRE_ORB_DAMAGE_RANK_2 = 84721, | |
FROSTFIRE_ORB_DISTANCE = 120 | |
}; | |
class npc_frostfire_orb : public CreatureScript | |
{ | |
public: | |
npc_frostfire_orb() : CreatureScript("npc_frostfire_orb") {} | |
struct npc_frostfire_orbAI : public ScriptedAI | |
{ | |
npc_frostfire_orbAI(Creature* creature) : ScriptedAI(creature) | |
{ | |
x = me->GetPositionX(); | |
y = me->GetPositionY(); | |
z = me->GetOwner()->GetPositionZ()+2; | |
o = me->GetOrientation(); | |
me->NearTeleportTo(x, y, z, o, true); | |
angle = me->GetOwner()->GetAngle(me); | |
newx = me->GetPositionX() + FROSTFIRE_ORB_DISTANCE/2 * cos(angle); | |
newy = me->GetPositionY() + FROSTFIRE_ORB_DISTANCE/2 * sin(angle); | |
CombatCheck = false; | |
} | |
float x,y,z,o,newx,newy,angle; | |
bool CombatCheck; | |
uint32 despawnTimer; | |
uint32 despawnCheckTimer; | |
uint32 damageTimer; | |
void EnterCombat(Unit* /*target*/) | |
{ | |
me->GetMotionMaster()->MoveCharge(newx, newy, z, 1.14286f); // Normal speed | |
despawnTimer = 15 * IN_MILLISECONDS; | |
CombatCheck = true; | |
} | |
void Reset() | |
{ | |
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); | |
me->AddUnitMovementFlag(MOVEMENTFLAG_FLYING); | |
me->SetReactState(REACT_PASSIVE); | |
if (CombatCheck == true) | |
despawnTimer = 15 * IN_MILLISECONDS; | |
else | |
despawnTimer = 4 * IN_MILLISECONDS; | |
damageTimer = 1 * IN_MILLISECONDS; | |
me->GetMotionMaster()->MovePoint(0, newx, newy, z); | |
} | |
void UpdateAI(const uint32 diff) | |
{ | |
if (!me->isInCombat() && CombatCheck == false) | |
{ | |
me->SetSpeed(MOVE_RUN, 2, true); | |
me->SetSpeed(MOVE_FLIGHT, 2, true); | |
} | |
if (despawnTimer <= diff) | |
me->DisappearAndDie(); | |
else | |
despawnTimer -= diff; | |
if (damageTimer <= diff) | |
{ | |
if (Unit* target = me->SelectNearestTarget(15)) | |
if (me->GetOwner()->HasAura(84726)) | |
DoCast(target, SPELL_FROSTFIRE_ORB_DAMAGE_RANK_1); | |
else | |
DoCast(target, SPELL_FROSTFIRE_ORB_DAMAGE_RANK_2); | |
damageTimer = 1 * IN_MILLISECONDS; | |
} | |
else | |
damageTimer -= diff; | |
} | |
}; | |
CreatureAI* GetAI(Creature* creature) const | |
{ | |
return new npc_frostfire_orbAI(creature); | |
} | |
}; | |
@@void AddSC_npcs_special() | |
new npc_flame_orb(); | |
new npc_frostfire_orb(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment