LordPsyan Posted January 3, 2017 Report Posted January 3, 2017 Finding any information on the changes to SD3 has been, well, let's just say I wont need a hair anytime soon. I have pulled all my hair out. Everything looks about the same with SD3, but I cannot get any of my custom scripts to work. This is a small script, that has a couple of checks (IsInCombat, IsMoving) This script summons an npc when you right click an item... or that is how it is supposed to work. #include "precompiled.h" struct summon : public CreatureScript { summon() : CreatureScript("summon") {} bool ItemUse_item_icerune(Player* pPlayer, Item* pItem, SpellCastTargets const& /*targets*/) { uint32 sSpell = 18282; //Icerune Visual Spell when used if (pPlayer->IsInCombat()) { pPlayer->GetSession()->SendNotification("You are in combat."); } else if (pPlayer->isMoving()) { pPlayer->GetSession()->SendNotification("You can not do that while moving."); } else { float x, y, z, o = pPlayer->GetOrientation(); o = o + 3.141592; Creature* pCreature = pPlayer->SummonCreature(100000,pPlayer->GetPositionX() ,pPlayer->GetPositionY(), pPlayer->GetPositionZ()+2, 0,TEMPSUMMON_TIMED_DESPAWN,120000); pCreature->CastSpell(pCreature, 40162, true); return false; } return false; } }; void AddSC_summon() { Script* s; s = new summon(); s->RegisterSelf(); } I have added an entry into script_bindings. I do not get any errors in the scripdev3 logs (except something about ale... unrelated) During compile I watch it check the cpp file, and there are no errors. Right clicking on the item does nothing. What am I missing? EDIT: to test to see if the script was seen by the core, I removed the scipt_binding entry. I got: 2017-01-03 06:53:04 Script registering but ScriptName summon is not assigned in database. Script will not be used. so I know the core sees it. I just cant click on the item.
H0zen Posted January 3, 2017 Report Posted January 3, 2017 Your script has two major issues: If you want to script an item, then your handler has to be derived from ItemScript, not CreatureScript. In the handler, the method you have to override is called, simply, OnUse So, the proper script can be written as: struct summon : public ItemScript { summon() : ItemScript("summon") {} bool OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& /*targets*/) { uint32 sSpell = 18282; //Icerune Visual Spell when used if (pPlayer->IsInCombat()) { pPlayer->GetSession()->SendNotification("You are in combat."); } ... } }; You may also look for sample item scripts here.
LordPsyan Posted January 12, 2017 Author Report Posted January 12, 2017 Thanks. I was converting these from TC scrtipts, and wasn't thinking when converting. Have been out of town the past week, and thanks for the reply.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.