mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11582] Implement SCRIPT_COMMAND_STAND_STATE to use in *_scripts tables
Set the stand state (enum UnitStandStateType) of any Unit* Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
6dd7f784cf
commit
70d9d4ef24
5 changed files with 91 additions and 1 deletions
|
|
@ -2905,6 +2905,57 @@ void Map::ScriptsProcess()
|
|||
pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
|
||||
}
|
||||
}
|
||||
case SCRIPT_COMMAND_STAND_STATE:
|
||||
{
|
||||
if (!source)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_STAND_STATE (script id %u) call for NULL source.", step.script->id);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!source->isType(TYPEMASK_WORLDOBJECT))
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_STAND_STATE (script id %u) call for non-worldobject (TypeId: %u), skipping.", step.script->id, source->GetTypeId());
|
||||
break;
|
||||
}
|
||||
// When creatureEntry is not defined, GameObject can not be source
|
||||
else if (!step.script->standState.creatureEntry)
|
||||
{
|
||||
if (!source->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_STAND_STATE (script id %u) are missing datalong2 (creature entry). Unsupported call for non-unit (TypeId: %u), skipping.", step.script->id, source->GetTypeId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WorldObject* pSource = (WorldObject*)source;
|
||||
Creature* pBuddy = NULL;
|
||||
|
||||
// flag_target_as_source 0x01
|
||||
|
||||
// If target is Unit* and should change it's stand state (or should be source of searcher below)
|
||||
if (target && target->isType(TYPEMASK_UNIT) && step.script->standState.flags & 0x01)
|
||||
pSource = (WorldObject*)target;
|
||||
|
||||
// If step has a buddy entry defined, search for it.
|
||||
if (step.script->standState.creatureEntry)
|
||||
{
|
||||
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*pSource, step.script->standState.creatureEntry, true, step.script->standState.searchRadius);
|
||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pBuddy, u_check);
|
||||
|
||||
Cell::VisitGridObjects(pSource, searcher, step.script->standState.searchRadius);
|
||||
|
||||
// If buddy found, then use it or break (break since we must assume pBuddy was defined for a reason)
|
||||
if (pBuddy)
|
||||
pSource = (WorldObject*)pBuddy;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// Must be safe cast to Unit* here
|
||||
((Unit*)pSource)->SetStandState(step.script->standState.stand_state);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sLog.outError("Unknown SCRIPT_COMMAND_ %u called for script id %u.",step.script->command, step.script->id);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue