diff --git a/src/game/Map.cpp b/src/game/Map.cpp index c8b0b92a2..97d849a30 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -3484,6 +3484,28 @@ void Map::ScriptsProcess() pSource->PlayDirectSound(step.script->datalong,pTarget); break; } + case SCRIPT_COMMAND_CREATE_ITEM: + { + if (!target && !source) + { + sLog.outError("SCRIPT_COMMAND_CREATE_ITEM call for NULL object."); + break; + } + + // only Player + if ((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) + { + sLog.outError("SCRIPT_COMMAND_CREATE_ITEM call for non-player (TypeIdSource: %u)(TypeIdTarget: %u), skipping.", source ? source->GetTypeId() : 0, target ? target->GetTypeId() : 0); + break; + } + + Player* pReceiver = target && target->GetTypeId() == TYPEID_PLAYER ? (Player*)target : (Player*)source; + + if (Item* pItem = pReceiver->StoreNewItemInInventorySlot(step.script->datalong, step.script->datalong2)) + pReceiver->SendNewItem(pItem, step.script->datalong2, true, false); + + break; + } default: sLog.outError("Unknown script command %u called.",step.script->command); break; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 473511b25..04981f0fb 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4370,6 +4370,22 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) } break; } + case SCRIPT_COMMAND_CREATE_ITEM: + { + if (!GetItemPrototype(tmp.datalong)) + { + sLog.outErrorDb("Table `%s` has nonexistent item (entry: %u) in SCRIPT_COMMAND_CREATE_ITEM for script id %u", + tablename, tmp.datalong, tmp.id); + continue; + } + if (!tmp.datalong2) + { + sLog.outErrorDb("Table `%s` SCRIPT_COMMAND_CREATE_ITEM but amount is %u for script id %u", + tablename, tmp.datalong2, tmp.id); + continue; + } + break; + } } if (scripts.find(tmp.id) == scripts.end()) diff --git a/src/game/World.h b/src/game/World.h index c3f1d213c..7547ddb6e 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -369,6 +369,7 @@ enum RealmZone #define SCRIPT_COMMAND_REMOVE_AURA 14 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id #define SCRIPT_COMMAND_CAST_SPELL 15 // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s #define SCRIPT_COMMAND_PLAY_SOUND 16 // source = any object, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent) +#define SCRIPT_COMMAND_CREATE_ITEM 17 // source or target must be player, datalong = item entry, datalong2 = amount /// Storage class for commands issued for delayed execution struct CliCommandHolder diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index aaab945fc..ffcd3d8fa 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9575" + #define REVISION_NR "9576" #endif // __REVISION_NR_H__