mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[7518] Implement new script command SCRIPT_COMMAND_PLAY_SOUND (look in World.h for args)
* Also rewrite use SMSG_PLAY_OBJECT_SOUND/SMSG_PLAY_SOUND Now WorldObject have 2 function for sound level dependent from distance (PlayDistanceSound) and for not depednet (PlayDirectSound) * Old Player::PlaySound function removed and uses need to be updated to WorldObject functions Note: function called for _source_ of sound in different from old function. * chat command .debug ps removed and .debug playsound can used for bother packects test: if no selection used SMSG_PLAY_SOUND, if selection exist including self then SMSG_PLAY_OBJECT_SOUND.
This commit is contained in:
parent
b14bf188c5
commit
ab2bdc3e69
13 changed files with 100 additions and 50 deletions
|
|
@ -2237,6 +2237,47 @@ void World::ScriptsProcess()
|
|||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_PLAY_SOUND:
|
||||
{
|
||||
if(!source)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for NULL creature.");
|
||||
break;
|
||||
}
|
||||
|
||||
WorldObject* pSource = dynamic_cast<WorldObject*>(source);
|
||||
if(!pSource)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for non-world object (TypeId: %u), skipping.",source->GetTypeId());
|
||||
break;
|
||||
}
|
||||
|
||||
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
|
||||
Player* pTarget = NULL;
|
||||
if(step.script->datalong2 & 1)
|
||||
{
|
||||
if(!target)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for NULL target.");
|
||||
break;
|
||||
}
|
||||
|
||||
if(target->GetTypeId()!=TYPEID_PLAYER)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for non-player (TypeId: %u), skipping.",target->GetTypeId());
|
||||
break;
|
||||
}
|
||||
|
||||
pTarget = (Player*)target;
|
||||
}
|
||||
|
||||
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
|
||||
if(step.script->datalong2 & 2)
|
||||
pSource->PlayDistanceSound(step.script->datalong,pTarget);
|
||||
else
|
||||
pSource->PlayDirectSound(step.script->datalong,pTarget);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sLog.outError("Unknown script command %u called.",step.script->command);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue