*Allow ItemExpire events to be scripted.
*Add .debug itemexpire command *Add script for Disgusting Jar and Mysterious Egg - original patch by Elron. --HG-- branch : trunk
This commit is contained in:
@@ -1876,6 +1876,15 @@ bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets)
|
||||
return tmpscript->pItemUse(player,_Item,targets);
|
||||
}
|
||||
|
||||
TRINITY_DLL_EXPORT
|
||||
bool ItemExpire( Player *player, ItemPrototype const * _ItemProto)
|
||||
{
|
||||
Script *tmpscript = m_scripts[_ItemProto->ScriptId];
|
||||
if (!tmpscript || !tmpscript->pItemExpire) return true;
|
||||
|
||||
return tmpscript->pItemExpire(player,_ItemProto);
|
||||
}
|
||||
|
||||
TRINITY_DLL_EXPORT
|
||||
bool EffectDummyCreature(Unit *caster, uint32 spellId, uint32 effIndex, Creature *crTarget )
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ class SpellCastTargets;
|
||||
class Map;
|
||||
class Unit;
|
||||
class WorldObject;
|
||||
struct ItemPrototype;
|
||||
|
||||
#define MAX_SCRIPTS 5000 //72 bytes each (approx 351kb)
|
||||
#define VISIBLE_RANGE (166.0f) //MAX visible range (size of grid)
|
||||
@@ -34,7 +35,7 @@ struct Script
|
||||
pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL),
|
||||
pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL),
|
||||
pChooseReward(NULL), pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL),
|
||||
pGOQuestAccept(NULL), pGOChooseReward(NULL),pItemUse(NULL),
|
||||
pGOQuestAccept(NULL), pGOChooseReward(NULL),pItemUse(NULL), pItemExpire(NULL),
|
||||
pEffectDummyCreature(NULL), pEffectDummyGameObj(NULL), pEffectDummyItem(NULL),
|
||||
GetAI(NULL), GetInstanceData(NULL)
|
||||
{}
|
||||
@@ -60,6 +61,7 @@ struct Script
|
||||
bool (*pGOQuestAccept )(Player*, GameObject*, Quest const* );
|
||||
bool (*pGOChooseReward )(Player*, GameObject*, Quest const*, uint32 );
|
||||
bool (*pItemUse )(Player*, Item*, SpellCastTargets const& );
|
||||
bool (*pItemExpire )(Player*, ItemPrototype const *);
|
||||
bool (*pEffectDummyCreature )(Unit*, uint32, uint32, Creature* );
|
||||
bool (*pEffectDummyGameObj )(Unit*, uint32, uint32, GameObject* );
|
||||
bool (*pEffectDummyItem )(Unit*, uint32, uint32, Item* );
|
||||
|
||||
@@ -526,6 +526,36 @@ bool ItemUse_item_incendiary_explosives(Player *player, Item* _Item, SpellCastTa
|
||||
}
|
||||
}
|
||||
|
||||
/*#####
|
||||
# item_mysterious_egg
|
||||
#####*/
|
||||
|
||||
bool ItemExpire_item_mysterious_egg(Player *player, ItemPrototype const * _ItemProto)
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 39883, 1); // Cracked Egg
|
||||
if( msg == EQUIP_ERR_OK )
|
||||
{
|
||||
player->StoreNewItem( dest, 39883, true, Item::GenerateItemRandomPropertyId(39883));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*#####
|
||||
# item_disgusting_jar
|
||||
#####*/
|
||||
|
||||
bool ItemExpire_item_disgusting_jar(Player *player, ItemPrototype const * _ItemProto)
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 44718, 1); // Ripe Disgusting Jar
|
||||
if( msg == EQUIP_ERR_OK )
|
||||
{
|
||||
player->StoreNewItem( dest, 44718, true, Item::GenerateItemRandomPropertyId(44718));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AddSC_item_scripts()
|
||||
{
|
||||
Script *newscript;
|
||||
@@ -639,5 +669,15 @@ void AddSC_item_scripts()
|
||||
newscript->Name="item_incendiary_explosives";
|
||||
newscript->pItemUse = &ItemUse_item_incendiary_explosives;
|
||||
newscript->RegisterSelf();
|
||||
|
||||
newscript = new Script;
|
||||
newscript->Name="item_mysterious_egg";
|
||||
newscript->pItemExpire = &ItemExpire_item_mysterious_egg;
|
||||
newscript->RegisterSelf();
|
||||
|
||||
newscript = new Script;
|
||||
newscript->Name="item_disgusting_jar";
|
||||
newscript->pItemExpire = &ItemExpire_item_disgusting_jar;
|
||||
newscript->RegisterSelf();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "entervehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugEnterVehicle, "", NULL },
|
||||
{ "uws", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL },
|
||||
{ "update", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateCommand, "", NULL },
|
||||
{ "itemexpire", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateCommand, "", NULL },
|
||||
{ "itemexpire", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugItemExpireCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ class ChatHandler
|
||||
bool HandleDebugMod32ValueCommand(const char* args);
|
||||
bool HandleDebugSetAuraStateCommand(const char * args);
|
||||
bool HandleDebugSetItemFlagCommand(const char * args);
|
||||
bool HandleDebugItemExpireCommand(const char * args);
|
||||
bool HandleDebugSetVehicleId(const char * args);
|
||||
bool HandleDebugEnterVehicle(const char * args);
|
||||
bool HandleDebugSetValueCommand(const char* args);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "ScriptCalls.h"
|
||||
|
||||
bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args)
|
||||
{
|
||||
@@ -845,6 +846,28 @@ bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleDebugItemExpireCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* e = strtok((char*)args, " ");
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
uint32 guid = (uint32)atoi(e);
|
||||
|
||||
Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
|
||||
|
||||
if (!i)
|
||||
return false;
|
||||
|
||||
m_session->GetPlayer()->DestroyItem( i->GetBagSlot(),i->GetSlot(), true);
|
||||
Script->ItemExpire(m_session->GetPlayer(),i->GetProto());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//show animation
|
||||
bool ChatHandler::HandleDebugAnimCommand(const char* args)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "ItemEnchantmentMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "ScriptCalls.h"
|
||||
|
||||
void AddItemsSetItem(Player*player,Item *item)
|
||||
{
|
||||
@@ -285,6 +286,7 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
|
||||
if (GetUInt32Value(ITEM_FIELD_DURATION)<=diff)
|
||||
{
|
||||
owner->DestroyItem(GetBagSlot(), GetSlot(), true);
|
||||
Script->ItemExpire(owner, GetProto());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -10603,7 +10603,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo
|
||||
uint8 bag = pos >> 8;
|
||||
uint8 slot = pos & 255;
|
||||
|
||||
sLog.outDebug( "STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), count);
|
||||
sLog.outDebug( "STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u, guid = %u", bag, slot, pItem->GetEntry(), count, pItem->GetGUIDLow());
|
||||
|
||||
Item *pItem2 = GetItemByPos( bag, slot );
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ bool LoadScriptingModule(char const* libName)
|
||||
||!(testScript->ItemQuestAccept =(scriptCallItemQuestAccept )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"ItemQuestAccept" ))
|
||||
||!(testScript->GOQuestAccept =(scriptCallGOQuestAccept )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"GOQuestAccept" ))
|
||||
||!(testScript->ItemUse =(scriptCallItemUse )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"ItemUse" ))
|
||||
||!(testScript->ItemExpire =(scriptCallItemExpire )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"ItemExpire" ))
|
||||
||!(testScript->EffectDummyGameObj =(scriptCallEffectDummyGameObj )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyGameObj" ))
|
||||
||!(testScript->EffectDummyCreature =(scriptCallEffectDummyCreature )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyCreature" ))
|
||||
||!(testScript->EffectDummyItem =(scriptCallEffectDummyItem )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyItem" ))
|
||||
|
||||
@@ -59,6 +59,7 @@ typedef bool(TRINITY_IMPORT * scriptCallItemQuestAccept)(Player *player, Item *,
|
||||
typedef bool(TRINITY_IMPORT * scriptCallGOQuestAccept)(Player *player, GameObject *, Quest const*);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallGOChooseReward)(Player *player, GameObject *, Quest const*, uint32 opt );
|
||||
typedef bool(TRINITY_IMPORT * scriptCallItemUse) (Player *player, Item *_Item, SpellCastTargets const& targets);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallItemExpire) (Player *player, ItemPrototype const *_ItemProto);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallEffectDummyGameObj) (Unit *caster, uint32 spellId, uint32 effIndex, GameObject *gameObjTarget);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallEffectDummyCreature) (Unit *caster, uint32 spellId, uint32 effIndex, Creature *crTarget);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallEffectDummyItem) (Unit *caster, uint32 spellId, uint32 effIndex, Item *itemTarget);
|
||||
@@ -89,6 +90,7 @@ typedef struct
|
||||
scriptCallItemQuestAccept ItemQuestAccept;
|
||||
scriptCallGOQuestAccept GOQuestAccept;
|
||||
scriptCallItemUse ItemUse;
|
||||
scriptCallItemExpire ItemExpire;
|
||||
scriptCallEffectDummyGameObj EffectDummyGameObj;
|
||||
scriptCallEffectDummyCreature EffectDummyCreature;
|
||||
scriptCallEffectDummyItem EffectDummyItem;
|
||||
|
||||
@@ -4463,7 +4463,7 @@ void AuraEffect::HandleModStateImmunityMask(bool apply, bool Real, bool /*change
|
||||
if (GetMiscValue() & (1<<7))
|
||||
immunity_list.push_back(SPELL_AURA_MOD_DISARM);
|
||||
if (GetMiscValue() & (1<<1))
|
||||
immunity_list.push_back(SPELL_AURA_MOD_TAUNT);
|
||||
immunity_list.push_back(SPELL_AURA_TRANSFORM);
|
||||
|
||||
// These flag can be recognized wrong:
|
||||
if (GetMiscValue() & (1<<6))
|
||||
|
||||
+3
-2
@@ -6442,7 +6442,8 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
|
||||
case SPELLFAMILY_SHAMAN:
|
||||
{
|
||||
switch(dummySpell->Id)
|
||||
{
// Shaman T8 Elemental 4P Bonus
|
||||
{
|
||||
// Shaman T8 Elemental 4P Bonus
|
||||
case 64928:
|
||||
{
|
||||
basepoints0 = int32( triggerAmount * damage / 100 );
|
||||
@@ -12653,6 +12654,7 @@ bool InitTriggerAuraData()
|
||||
isTriggerAura[SPELL_AURA_MOD_STEALTH] = true;
|
||||
isTriggerAura[SPELL_AURA_MOD_FEAR] = true; // Aura not have charges but need remove him on trigger
|
||||
isTriggerAura[SPELL_AURA_MOD_ROOT] = true;
|
||||
isTriggerAura[SPELL_AURA_TRANSFORM] = true;
|
||||
isTriggerAura[SPELL_AURA_REFLECT_SPELLS] = true;
|
||||
isTriggerAura[SPELL_AURA_DAMAGE_IMMUNITY] = true;
|
||||
isTriggerAura[SPELL_AURA_PROC_TRIGGER_SPELL] = true;
|
||||
@@ -13876,7 +13878,6 @@ void Unit::SetToNotify()
|
||||
|
||||
void Unit::Kill(Unit *pVictim, bool durabilityLoss)
|
||||
{
|
||||
assert(pVictim->IsInWorld() && pVictim->FindMap());
|
||||
// Prevent killing unit twice (and giving reward from kill twice)
|
||||
if (!pVictim->GetHealth())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user