aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQAston <none@none>2009-08-04 01:44:14 +0200
committerQAston <none@none>2009-08-04 01:44:14 +0200
commit2e34af64cf83d79b7352636da71b60132b512106 (patch)
treecea5dcc663fed54b74f728c3af730b47da0e9096 /src
parent29c9d709b908bae35b03dc24e5ba64481c1d547e (diff)
*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
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/ScriptMgr.cpp9
-rw-r--r--src/bindings/scripts/ScriptMgr.h4
-rw-r--r--src/bindings/scripts/scripts/item/item_scripts.cpp40
-rw-r--r--src/game/Chat.cpp2
-rw-r--r--src/game/Chat.h1
-rw-r--r--src/game/Debugcmds.cpp23
-rw-r--r--src/game/Item.cpp2
-rw-r--r--src/game/Player.cpp2
-rw-r--r--src/game/ScriptCalls.cpp1
-rw-r--r--src/game/ScriptCalls.h2
-rw-r--r--src/game/SpellAuras.cpp2
-rw-r--r--src/game/Unit.cpp5
12 files changed, 87 insertions, 6 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp
index 27835f8e23e..478c2b904f3 100644
--- a/src/bindings/scripts/ScriptMgr.cpp
+++ b/src/bindings/scripts/ScriptMgr.cpp
@@ -1877,6 +1877,15 @@ bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& 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 )
{
Script *tmpscript = m_scripts[crTarget->GetScriptId()];
diff --git a/src/bindings/scripts/ScriptMgr.h b/src/bindings/scripts/ScriptMgr.h
index 719cf7932e9..06830532c9b 100644
--- a/src/bindings/scripts/ScriptMgr.h
+++ b/src/bindings/scripts/ScriptMgr.h
@@ -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* );
diff --git a/src/bindings/scripts/scripts/item/item_scripts.cpp b/src/bindings/scripts/scripts/item/item_scripts.cpp
index a58edb58fa2..3b72aab6529 100644
--- a/src/bindings/scripts/scripts/item/item_scripts.cpp
+++ b/src/bindings/scripts/scripts/item/item_scripts.cpp
@@ -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();
}
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index e6677070599..06822627460 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -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 }
};
diff --git a/src/game/Chat.h b/src/game/Chat.h
index be4ad5f31c2..ee01b7b61f4 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -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);
diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp
index a3faf1ec746..69b3bcb1284 100644
--- a/src/game/Debugcmds.cpp
+++ b/src/game/Debugcmds.cpp
@@ -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)
{
diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index 2277637701a..484fa766da0 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -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;
}
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index c6f0b9aafc1..6e92e7d4b6a 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -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 );
diff --git a/src/game/ScriptCalls.cpp b/src/game/ScriptCalls.cpp
index fec1afb08ae..b8870c2a1dd 100644
--- a/src/game/ScriptCalls.cpp
+++ b/src/game/ScriptCalls.cpp
@@ -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" ))
diff --git a/src/game/ScriptCalls.h b/src/game/ScriptCalls.h
index 4e23f9f576d..0eae69cb505 100644
--- a/src/game/ScriptCalls.h
+++ b/src/game/ScriptCalls.h
@@ -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;
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 9c202b8307c..6e893611304 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -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))
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 514a7b8d33a..396f944f33b 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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;