Script/Wormhole: Correct randomize logic for underground option

This commit is contained in:
kaelima
2012-05-09 13:49:49 +02:00
parent d50b23d9f9
commit cb36825a3a
+28 -6
View File
@@ -2254,17 +2254,34 @@ enum WormholeSpells
SPELL_HOWLING_FJORD = 67838, SPELL_HOWLING_FJORD = 67838,
SPELL_UNDERGROUND = 68081, SPELL_UNDERGROUND = 68081,
TEXT_WORMHOLE = 907 TEXT_WORMHOLE = 907,
DATA_SHOW_UNDERGROUND = 1,
}; };
class npc_wormhole : public CreatureScript class npc_wormhole : public CreatureScript
{ {
public: public:
npc_wormhole() : CreatureScript("npc_wormhole") npc_wormhole() : CreatureScript("npc_wormhole") {}
struct npc_wormholeAI : public PassiveAI
{ {
showUnderground = urand(0, 100) == 0; // Guessed value, it is really rare though npc_wormholeAI(Creature* creature) : PassiveAI(creature) {}
void InitializeAI()
{
_showUnderground = urand(0, 100) == 0; // Guessed value, it is really rare though
} }
uint32 GetData(uint32 type)
{
return (type == DATA_SHOW_UNDERGROUND && _showUnderground) ? 1 : 0;
}
private:
bool _showUnderground;
};
bool OnGossipHello(Player* player, Creature* creature) bool OnGossipHello(Player* player, Creature* creature)
{ {
if (creature->isSummon()) if (creature->isSummon())
@@ -2277,12 +2294,13 @@ class npc_wormhole : public CreatureScript
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
if (showUnderground) if (creature->AI()->GetData(DATA_SHOW_UNDERGROUND))
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
player->PlayerTalkClass->SendGossipMenu(TEXT_WORMHOLE, creature->GetGUID()); player->PlayerTalkClass->SendGossipMenu(TEXT_WORMHOLE, creature->GetGUID());
} }
} }
return true; return true;
} }
@@ -2317,10 +2335,14 @@ class npc_wormhole : public CreatureScript
creature->CastSpell(player, SPELL_UNDERGROUND, false); creature->CastSpell(player, SPELL_UNDERGROUND, false);
break; break;
} }
return true; return true;
} }
private:
bool showUnderground; CreatureAI* GetAI(Creature* creature) const
{
return new npc_wormholeAI(creature);
}
}; };
/*###### /*######