mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[9576] Implement SCRIPT_COMMAND_CREATE_ITEM to use when no spell exist
Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
a12fecab0d
commit
dbbc45828a
4 changed files with 40 additions and 1 deletions
|
|
@ -3484,6 +3484,28 @@ void Map::ScriptsProcess()
|
||||||
pSource->PlayDirectSound(step.script->datalong,pTarget);
|
pSource->PlayDirectSound(step.script->datalong,pTarget);
|
||||||
break;
|
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:
|
default:
|
||||||
sLog.outError("Unknown script command %u called.",step.script->command);
|
sLog.outError("Unknown script command %u called.",step.script->command);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -4370,6 +4370,22 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
|
||||||
}
|
}
|
||||||
break;
|
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())
|
if (scripts.find(tmp.id) == scripts.end())
|
||||||
|
|
|
||||||
|
|
@ -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_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_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_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
|
/// Storage class for commands issued for delayed execution
|
||||||
struct CliCommandHolder
|
struct CliCommandHolder
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9575"
|
#define REVISION_NR "9576"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue