PDA

View Full Version : [TrinityCore] Visual Spells NPC (+ script + SQL)



Wise
03-11-14, 09:51 PM
Hey. I just looked online for any similar script and I didn't find it at the updated version, so I just had in mind to release one of my own!
It's my first release! :D

The creature:

INSERT INTO `creature_template` (`entry`,`difficulty_entry_1`,`difficulty_entry_2` ,`difficulty_entry_3`,`KillCredit1`,`KillCredit2`, `modelid1`,`modelid2`,`modelid3`,`modelid4`,`name` ,`subname`,`IconName`,`gossip_menu_id`,`minlevel`, `maxlevel`,`exp`,`faction`,`npcflag`,`speed_walk`, `speed_run`,`scale`,`rank`,`mindmg`,`maxdmg`,`dmgs chool`,`attackpower`,`dmg_multiplier`,`baseattackt ime`,`rangeattacktime`,`unit_class`,`unit_flags`,` unit_flags2`,`dynamicflags`,`family`,`trainer_type `,`trainer_spell`,`trainer_class`,`trainer_race`,` minrangedmg`,`maxrangedmg`,`rangedattackpower`,`ty pe`,`type_flags`,`lootid`,`pickpocketloot`,`skinlo ot`,`resistance1`,`resistance2`,`resistance3`,`res istance4`,`resistance5`,`resistance6`,`spell1`,`sp ell2`,`spell3`,`spell4`,`spell5`,`spell6`,`spell7` ,`spell8`,`PetSpellDataId`,`VehicleId`,`mingold`,` maxgold`,`AIName`,`MovementType`,`InhabitType`,`Ho verHeight`,`Health_mod`,`Mana_mod`,`Armor_mod`,`Ra cialLeader`,`questItem1`,`questItem2`,`questItem3` ,`questItem4`,`questItem5`,`questItem6`,`movementI d`,`RegenHealth`,`mechanic_immune_mask`,`flags_ext ra`,`ScriptName`,`VerifiedBuild`) VALUES (199934, 0, 0, 0, 0, 0, 23445, 0, 0, 0, 'Visual NPC', 'Sub-Name', '', 0, 1, 1, 0, 35, 1, 1, 1, 0.13, 0, 1, 2, 0, 0, 20, 2000, 2000, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 1, 1, 1, 300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 'Visual_NPC', 1);

The item (Visual Coin - tradeable)

INSERT INTO `item_template` (`entry`,`class`,`subclass`,`SoundOverrideSubclass `,`name`,`displayid`,`Quality`,`Flags`,`FlagsExtra `,`BuyCount`,`BuyPrice`,`SellPrice`,`InventoryType `,`AllowableClass`,`AllowableRace`,`ItemLevel`,`Re quiredLevel`,`RequiredSkill`,`RequiredSkillRank`,` requiredspell`,`requiredhonorrank`,`RequiredCityRa nk`,`RequiredReputationFaction`,`RequiredReputatio nRank`,`maxcount`,`stackable`,`ContainerSlots`,`St atsCount`,`stat_type1`,`stat_value1`,`stat_type2`, `stat_value2`,`stat_type3`,`stat_value3`,`stat_typ e4`,`stat_value4`,`stat_type5`,`stat_value5`,`stat _type6`,`stat_value6`,`stat_type7`,`stat_value7`,` stat_type8`,`stat_value8`,`stat_type9`,`stat_value 9`,`stat_type10`,`stat_value10`,`ScalingStatDistri bution`,`ScalingStatValue`,`dmg_min1`,`dmg_max1`,` dmg_type1`,`dmg_min2`,`dmg_max2`,`dmg_type2`,`armo r`,`holy_res`,`fire_res`,`nature_res`,`frost_res`, `shadow_res`,`arcane_res`,`delay`,`ammo_type`,`Ran gedModRange`,`spellid_1`,`spelltrigger_1`,`spellch arges_1`,`spellppmRate_1`,`spellcooldown_1`,`spell category_1`,`spellcategorycooldown_1`,`spellid_2`, `spelltrigger_2`,`spellcharges_2`,`spellppmRate_2` ,`spellcooldown_2`,`spellcategory_2`,`spellcategor ycooldown_2`,`spellid_3`,`spelltrigger_3`,`spellch arges_3`,`spellppmRate_3`,`spellcooldown_3`,`spell category_3`,`spellcategorycooldown_3`,`spellid_4`, `spelltrigger_4`,`spellcharges_4`,`spellppmRate_4` ,`spellcooldown_4`,`spellcategory_4`,`spellcategor ycooldown_4`,`spellid_5`,`spelltrigger_5`,`spellch arges_5`,`spellppmRate_5`,`spellcooldown_5`,`spell category_5`,`spellcategorycooldown_5`,`bonding`,`d escription`,`PageText`,`LanguageID`,`PageMaterial` ,`startquest`,`lockid`,`Material`,`sheath`,`Random Property`,`RandomSuffix`,`block`,`itemset`,`MaxDur ability`,`area`,`Map`,`BagFamily`,`TotemCategory`, `socketColor_1`,`socketContent_1`,`socketColor_2`, `socketContent_2`,`socketColor_3`,`socketContent_3 `,`socketBonus`,`GemProperties`,`RequiredDisenchan tSkill`,`ArmorDamageModifier`,`duration`,`ItemLimi tCategory`,`HolidayId`,`ScriptName`,`DisenchantID` ,`FoodType`,`minMoneyLoot`,`maxMoneyLoot`,`flagsCu stom`,`VerifiedBuild`) VALUES (123456, 0, 0, -1, "Visual Coin", 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 'Use the Visual NPC to get visuals!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 12340);

The script:


enum Spells
{
VISUAL_1 = 60451, //spell 1
VISUAL_2 = 56075, //spell 2
VISUAL_3 = 42438, //spell 3
VISUAL_4 = 45948, //spell 4
VISUAL_5 = 37805, //spell 5
VISUAL_6 = 35466, //spell 6
VISUAL_7 = 37810, //spell 7
VISUAL_8 = 20373, //spell 8
VISUAL_9 = 20374, //spell 9
VISUAL_10 = 20370 //spell 10
};

enum Items
{
REQUIRED_ITEM = 123456 //item required to cast spells
};


class VisualNPC : public CreatureScript
{
public:
VisualNPC() : CreatureScript("Visual_NPC") { }

bool OnGossipHello(Player* player, Creature* creature)
{
player->ADD_GOSSIP_ITEM(4, "Visual Name 1", GOSSIP_SENDER_MAIN, 1001);
player->ADD_GOSSIP_ITEM(4, "Visual Name 2", GOSSIP_SENDER_MAIN, 1002);
player->ADD_GOSSIP_ITEM(4, "Visual Name 3", GOSSIP_SENDER_MAIN, 1003);
player->ADD_GOSSIP_ITEM(4, "Visual Name 4", GOSSIP_SENDER_MAIN, 1004);
player->ADD_GOSSIP_ITEM(4, "Visual Name 5", GOSSIP_SENDER_MAIN, 1005);
player->ADD_GOSSIP_ITEM(4, "Visual Name 6", GOSSIP_SENDER_MAIN, 1006);
player->ADD_GOSSIP_ITEM(4, "Visual Name 7", GOSSIP_SENDER_MAIN, 1007);
player->ADD_GOSSIP_ITEM(4, "Visual Name 8", GOSSIP_SENDER_MAIN, 1008);
player->ADD_GOSSIP_ITEM(4, "Visual Name 9", GOSSIP_SENDER_MAIN, 1009);
player->ADD_GOSSIP_ITEM(4, "Visual Name 10", GOSSIP_SENDER_MAIN, 1010);
player->SEND_GOSSIP_MENU(1, creature->GetGUID()); // This sends the menu to the player
return true;
}

bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*uiSender*/, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{

char moveon[500]; //if the player has the item - send this message
sprintf(moveon, "You got the visual you wanted.");
char error[500]; //if the player does not have the item - send this message
sprintf(error, "You do not have the required item to continue.");


///////////START ACTIONS//////////////////
case 1001: //visual #1
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_1, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1002: //visual #2
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_2, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1003: //visual #3
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_3, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;




case 1004: //visual #4
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_4, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1005: //visual #5
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_5, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1006: //visual #6
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_6, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1007: //visual #7
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_7, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1008: //visual #8
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_8, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1009: //visual #9
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_9, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;



case 1010: //visual #10
if (player->HasItemCount(REQUIRED_ITEM, 1, true))
{
player->DestroyItemCount(REQUIRED_ITEM, 1, true, false);
player->AddAura(VISUAL_10, player);
player->Whisper(moveon, LANG_UNIVERSAL, player, true);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->Whisper(error, LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU();
}
break;

return true;
}


}

};

void AddSC_VisualNPC()
{
new VisualNPC();
}


HOW TO ADD YOUR OWN VISUAL OR SPELL:
Go to the beggining of the script, and add there the same as it says there BUT add to the previous line a comma ( , ) at the end. Then replace 10 with 11, and insert the spell ID you want it to be.
Now we've confirmed the spell and it'll work within the script!

Now, go to the menu (player->ADD_SOSSIP) thing and copy the last line in there, which is

player->ADD_GOSSIP_ITEM(4, "Visual Name 10", GOSSIP_SENDER_MAIN, 1010);
Then paste it onto a new line and replace the following: "Visual Name 10", "1010".
In our case, it'll be

player->ADD_GOSSIP_ITEM(4, "Visual Name 11", GOSSIP_SENDER_MAIN, 1011);
Last thing to do, roll down till you see the case "1010". Copy ALL OF IT starting from "case 1010:" to "break;".
Now replace the following:
"case 1010:" to "case 1011" and VISUAL_10 to VISUAL_11.

It should work now with your own customized option.
Feel free to edit it as you wish! Enjoy,


Credits Zeraax

jhoancito
09-05-18, 04:14 AM
gives the error when compiling



3>scripts.lib(custom_script_loader.obj) : error LNK2019: unresolved external symbol "void __cdecl AddSC_VisualNPC(void)" (?AddSC_VisualNPC@@YAXXZ) referenced in function "void __cdecl AddCustomScripts(void)" (?AddCustomScripts@@YAXXZ)