[9576] Implement SCRIPT_COMMAND_CREATE_ITEM to use when no spell exist

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-03-12 16:18:27 +01:00
parent a12fecab0d
commit dbbc45828a
4 changed files with 40 additions and 1 deletions

View file

@ -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;