Core/Scripts: add creature_text to pet mojo

Scripts/Karazhan/Moroes: cleanup a bit (should fixes mem leak)
This commit is contained in:
joschiwald
2013-08-31 16:48:37 +02:00
parent a2ee732a38
commit ae36ddefec
3 changed files with 100 additions and 133 deletions

View File

@@ -0,0 +1,10 @@
DELETE FROM `creature_text` WHERE `entry`=24480;
INSERT INTO `creature_text` (`entry`, `groupid`, `id`, `text`, `type`, `language`, `probability`, `emote`, `duration`, `sound`, `comment`) VALUES
(24480, 0, 0, 'I thought you''d never ask!', 15, 0, 100, 0, 0, 0, 'Mojo'),
(24480, 0, 1, 'I promise not to give you warts...', 15, 0, 100, 0, 0, 0, 'Mojo'),
(24480, 0, 2, 'This won''t take long, did it?', 15, 0, 100, 0, 0, 0, 'Mojo'),
(24480, 0, 3, 'Now that''s what I call froggy-style!', 15, 0, 100, 0, 0, 0, 'Mojo'),
(24480, 0, 4, 'Listen, $n, I know of a little swamp not too far from here....', 15, 0, 100, 0, 0, 0, 'Mojo'),
(24480, 0, 5, 'Your lily pad or mine?', 15, 0, 100, 0, 0, 0, 'Mojo'),
(24480, 0, 6, 'Feelin'' a little froggy, are ya?', 15, 0, 100, 0, 0, 0, 'Mojo'),
(24480, 0, 7, 'There''s just never enough Mojo to go around...', 15, 0, 100, 0, 0, 0, 'Mojo');

View File

@@ -73,14 +73,12 @@ enum Spells
SPELL_SHIELDWALL = 29390
};
#define POS_Z 81.73f
float Locations[4][3]=
Position const Locations[4] =
{
{-10991.0f, -1884.33f, 0.614315f},
{-10989.4f, -1885.88f, 0.904913f},
{-10978.1f, -1887.07f, 2.035550f},
{-10975.9f, -1885.81f, 2.253890f},
{-10991.0f, -1884.33f, 81.73f, 0.614315f},
{-10989.4f, -1885.88f, 81.73f, 0.904913f},
{-10978.1f, -1887.07f, 81.73f, 2.035550f},
{-10975.9f, -1885.81f, 81.73f, 2.253890f},
};
const uint32 Adds[6]=
@@ -137,7 +135,7 @@ public:
Enrage = false;
InVanish = false;
if (me->GetHealth())
if (me->IsAlive())
SpawnAdds();
if (instance)
@@ -183,39 +181,34 @@ public:
void SpawnAdds()
{
DeSpawnAdds();
if (isAddlistEmpty())
{
Creature* creature = NULL;
std::vector<uint32> AddList;
std::list<uint32> AddList;
for (uint8 i = 0; i < 6; ++i)
AddList.push_back(Adds[i]);
while (AddList.size() > 4)
AddList.erase((AddList.begin())+(rand()%AddList.size()));
Trinity::Containers::RandomResizeList(AddList, 4);
uint8 i = 0;
for (std::vector<uint32>::const_iterator itr = AddList.begin(); itr != AddList.end(); ++itr)
for (std::list<uint32>::const_iterator itr = AddList.begin(); itr != AddList.end() && i < 4; ++itr, ++i)
{
uint32 entry = *itr;
creature = me->SummonCreature(entry, Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
if (creature)
if (Creature* creature = me->SummonCreature(entry, Locations[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000))
{
AddGUID[i] = creature->GetGUID();
AddId[i] = entry;
}
++i;
}
}else
}
else
{
for (uint8 i = 0; i < 4; ++i)
{
Creature* creature = me->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
if (creature)
{
if (Creature* creature = me->SummonCreature(AddId[i], Locations[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000))
AddGUID[i] = creature->GetGUID();
}
}
}
}
@@ -235,9 +228,8 @@ public:
{
if (AddGUID[i])
{
Creature* temp = Creature::GetCreature((*me), AddGUID[i]);
if (temp && temp->IsAlive())
temp->DisappearAndDie();
if (Creature* temp = ObjectAccessor::GetCreature(*me, AddGUID[i]))
temp->DespawnOrUnsummon();
}
}
}

View File

@@ -1575,130 +1575,95 @@ public:
## npc_brewfest_reveler
####*/
class npc_brewfest_reveler : public CreatureScript
enum BrewfestReveler
{
public:
npc_brewfest_reveler() : CreatureScript("npc_brewfest_reveler") { }
struct npc_brewfest_revelerAI : public ScriptedAI
{
npc_brewfest_revelerAI(Creature* creature) : ScriptedAI(creature) {}
void ReceiveEmote(Player* player, uint32 emote) OVERRIDE
{
if (!IsHolidayActive(HOLIDAY_BREWFEST))
return;
if (emote == TEXT_EMOTE_DANCE)
me->CastSpell(player, 41586, false);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
return new npc_brewfest_revelerAI(creature);
}
SPELL_BREWFEST_TOAST = 41586
};
class npc_brewfest_reveler : public CreatureScript
{
public:
npc_brewfest_reveler() : CreatureScript("npc_brewfest_reveler") { }
#define SAY_RANDOM_MOJO0 "Now that's what I call froggy-style!"
#define SAY_RANDOM_MOJO1 "Your lily pad or mine?"
#define SAY_RANDOM_MOJO2 "This won't take long, did it?"
#define SAY_RANDOM_MOJO3 "I thought you'd never ask!"
#define SAY_RANDOM_MOJO4 "I promise not to give you warts..."
#define SAY_RANDOM_MOJO5 "Feelin' a little froggy, are ya?"
#define SAY_RANDOM_MOJO6a "Listen, "
#define SAY_RANDOM_MOJO6b ", I know of a little swamp not too far from here...."
#define SAY_RANDOM_MOJO7 "There's just never enough Mojo to go around..."
struct npc_brewfest_revelerAI : public ScriptedAI
{
npc_brewfest_revelerAI(Creature* creature) : ScriptedAI(creature) { }
void ReceiveEmote(Player* player, uint32 emote) OVERRIDE
{
if (!IsHolidayActive(HOLIDAY_BREWFEST))
return;
if (emote == TEXT_EMOTE_DANCE)
me->CastSpell(player, SPELL_BREWFEST_TOAST, false);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
return new npc_brewfest_revelerAI(creature);
}
};
enum Mojo
{
SAY_MOJO = 0,
SPELL_FEELING_FROGGY = 43906,
SPELL_SEDUCTION_VISUAL = 43919
};
class npc_mojo : public CreatureScript
{
public:
npc_mojo() : CreatureScript("npc_mojo") { }
public:
npc_mojo() : CreatureScript("npc_mojo") { }
struct npc_mojoAI : public ScriptedAI
{
npc_mojoAI(Creature* creature) : ScriptedAI(creature) {Reset();}
uint32 hearts;
uint64 victimGUID;
void Reset() OVERRIDE
struct npc_mojoAI : public ScriptedAI
{
victimGUID = 0;
hearts = 15000;
if (Unit* own = me->GetOwner())
me->GetMotionMaster()->MoveFollow(own, 0, 0);
}
npc_mojoAI(Creature* creature) : ScriptedAI(creature) { }
void EnterCombat(Unit* /*who*/)OVERRIDE {}
void UpdateAI(uint32 diff) OVERRIDE
{
if (me->HasAura(20372))
void Reset() OVERRIDE
{
if (hearts <= diff)
_victimGUID = 0;
if (Unit* owner = me->GetOwner())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
}
void EnterCombat(Unit* /*who*/) OVERRIDE { }
void UpdateAI(uint32 diff) OVERRIDE { }
void ReceiveEmote(Player* player, uint32 emote) OVERRIDE
{
me->HandleEmoteCommand(emote);
Unit* owner = me->GetOwner();
if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
owner->ToPlayer()->GetTeam() != player->GetTeam())
{
me->RemoveAurasDueToSpell(20372);
hearts = 15000;
} hearts -= diff;
}
}
return;
}
void ReceiveEmote(Player* player, uint32 emote) OVERRIDE
Talk(SAY_MOJO, player->GetGUID());
if (_victimGUID)
if (Player* victim = ObjectAccessor::GetPlayer(*me, _victimGUID))
victim->RemoveAura(SPELL_FEELING_FROGGY);
_victimGUID = player->GetGUID();
DoCast(player, SPELL_FEELING_FROGGY, true);
DoCast(me, SPELL_SEDUCTION_VISUAL, true);
me->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
}
private:
uint64 _victimGUID;
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
me->HandleEmoteCommand(emote);
Unit* owner = me->GetOwner();
if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
owner->ToPlayer()->GetTeam() != player->GetTeam())
{
return;
}
std::string whisp = "";
switch (rand() % 8)
{
case 0:
whisp.append(SAY_RANDOM_MOJO0);
break;
case 1:
whisp.append(SAY_RANDOM_MOJO1);
break;
case 2:
whisp.append(SAY_RANDOM_MOJO2);
break;
case 3:
whisp.append(SAY_RANDOM_MOJO3);
break;
case 4:
whisp.append(SAY_RANDOM_MOJO4);
break;
case 5:
whisp.append(SAY_RANDOM_MOJO5);
break;
case 6:
whisp.append(SAY_RANDOM_MOJO6a);
whisp.append(player->GetName());
whisp.append(SAY_RANDOM_MOJO6b);
break;
case 7:
whisp.append(SAY_RANDOM_MOJO7);
break;
}
me->MonsterWhisper(whisp.c_str(), player->GetGUID());
if (victimGUID)
if (Player* victim = ObjectAccessor::GetPlayer(*me, victimGUID))
victim->RemoveAura(43906); // remove polymorph frog thing
me->AddAura(43906, player); // add polymorph frog thing
victimGUID = player->GetGUID();
DoCast(me, 20372, true); // tag.hearts
me->GetMotionMaster()->MoveFollow(player, 0, 0);
hearts = 15000;
return new npc_mojoAI(creature);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
return new npc_mojoAI(creature);
}
};
enum TrainingDummy