Skip to content

Instantly share code, notes, and snippets.

@Langerz82
Created January 28, 2019 09:43
Show Gist options
  • Save Langerz82/dd7c5dc0fdcdf3243a9eca2f05c5f583 to your computer and use it in GitHub Desktop.
Save Langerz82/dd7c5dc0fdcdf3243a9eca2f05c5f583 to your computer and use it in GitHub Desktop.
#include "ScriptPCH.h"
#include "ScriptedGossip.h"
#include "WorldSession.h"
#include "SpellAuras.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "GossipDef.h"
#include "Creature.h"
class Try_Script : public CreatureScript
{
public:
Try_Script() : CreatureScript("Try_Script") { }
static bool OnGossipHelloMain(Player *player, Creature * creature)
{
AddGossipItemFor(player, 10, "Select Fighter Spells", GOSSIP_SENDER_INFO, 100);
AddGossipItemFor(player, 10, "Select Mage Spells", GOSSIP_SENDER_INFO, 200);
SendGossipMenuFor(player, 1, creature->GetGUID());
return true;
}
static bool OnGossipHelloFighterSpells(Player *player, Creature * creature)
{
AddGossipItemFor(player, 10, "|TInterface/icons/spell_deathknight_summondeathcharger:26:26:-22:0|t|r New Shadowform", GOSSIP_SENDER_INFO, 101);
AddGossipItemFor(player, 10, "|TInterface/icons/ability_mount_celestialhorse:26:26:-22:0|t|r Corruption of Time", GOSSIP_SENDER_INFO, 102);
AddGossipItemFor(player, 10, "Back", GOSSIP_SENDER_INFO, 0);
SendGossipMenuFor(player, 2, creature->GetGUID());
return true;
}
static bool OnGossipHelloMageSpells(Player *player, Creature * creature)
{
AddGossipItemFor(player, 10, "|TInterface/icons/inv_misc_bone_08:26:26:-22:0|t|r Ghost Aura", GOSSIP_SENDER_INFO, 201);
AddGossipItemFor(player, 10, "|TInterface/icons/inv_misc_bone_07:26:26:-22:0|t|r Headless Horseman Burning", GOSSIP_SENDER_INFO, 202);
AddGossipItemFor(player, 10, "Back", GOSSIP_SENDER_INFO, 0);
SendGossipMenuFor(player, 2, creature->GetGUID());
return true;
}
static bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
if (sender == GOSSIP_SENDER_INFO)
{
switch (uiAction)
{
// Fighter Spells
case 100:
return OnGossipHelloFighterSpells(player, creature);
case 101:
player->LearnSpell(55086, player);
break;
case 102:
player->LearnSpell(60451, player);
break;
// Mage Spells
case 200:
return OnGossipHelloMageSpells(player, creature);
case 201:
player->LearnSpell(8326, player);
break;
case 202:
player->LearnSpell(43184, player);
break;
}
}
return OnGossipHelloMain(player, creature);
return true;
}
struct MyAI : public ScriptedAI
{
MyAI(Creature* m_creature) : ScriptedAI(m_creature) { }
bool GossipHello(Player* player) override
{
const uint64 maxSpellCount = 200;
PlayerSpellMap* spellMap = &player->GetSpellMap();
if (spellMap->size() >= maxSpellCount) return false;
return OnGossipHelloMain(player, me);
}
bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override
{
uint32 sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
return OnGossipSelect(player, me, sender, action);
}
};
CreatureAI* GetAI(Creature* m_creature) const override
{
return new MyAI(m_creature);
}
};
void AddSC_Try_Script()
{
new Try_Script();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment