mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +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
|
|
@ -218,8 +218,15 @@ spell_scripts
|
|||
* datalong3 = creature search radius
|
||||
* data_flags = flag_original_source_as_target = 0x02
|
||||
flag_buddy_as_target = 0x04 (When this flag is not set, buddy will be the attacker when buddy is defined)
|
||||
|
||||
27 SCRIPT_COMMAND_GO_LOCK_STATE source or target must be WorldObject
|
||||
* datalong = flag_go_lock = 0x01, flag_go_unlock = 0x02,
|
||||
flag_go_nonInteract = 0x04, flag_go_interact = 0x08
|
||||
* datalong2 = go entry (searching closest to source (if worldobject) or target
|
||||
* datalong3 = go search radius
|
||||
|
||||
28 SCRIPT_COMMAND_EMOTE source = Unit (or WorldObject when creature entry defined), target = Unit (or none)
|
||||
* datalong = stand state (enum UnitStandStateType)
|
||||
* datalong2 = creature entry (searching for a buddy, closest to source)
|
||||
* datalong3 = creature search radius
|
||||
* data_flags = flag_target_as_source = 0x01
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -559,6 +559,25 @@ void ScriptMgr::LoadScripts(ScriptMapMap& scripts, const char* tablename)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SCRIPT_COMMAND_STAND_STATE:
|
||||
{
|
||||
if (tmp.standState.stand_state > UNIT_STAND_STATE_CUSTOM)
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` has invalid stand state (datalong = %u) in SCRIPT_COMMAND_STAND_STATE for script id %u", tablename, tmp.standState.stand_state, tmp.id);
|
||||
continue;
|
||||
}
|
||||
if (tmp.standState.creatureEntry && !ObjectMgr::GetCreatureTemplate(tmp.standState.creatureEntry))
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` has datalong2 = %u in SCRIPT_COMMAND_STAND_STATE for script id %u, but this creature_template does not exist.", tablename, tmp.standState.creatureEntry, tmp.id);
|
||||
continue;
|
||||
}
|
||||
if (tmp.standState.creatureEntry && !tmp.standState.searchRadius)
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` has datalong2 = %u in SCRIPT_COMMAND_STAND_STATE for script id %u, but search radius is too small (datalong3 = %u).", tablename, tmp.standState.creatureEntry, tmp.id, tmp.standState.searchRadius);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (scripts.find(tmp.id) == scripts.end())
|
||||
|
|
|
|||
|
|
@ -95,6 +95,10 @@ enum eScriptCommand
|
|||
SCRIPT_COMMAND_GO_LOCK_STATE = 27, // source or target must be WorldObject
|
||||
// datalong= 1=lock, 2=unlock, 4=set not-interactable, 8=set interactable
|
||||
// datalong2= go entry, datalong3= go search radius
|
||||
SCRIPT_COMMAND_STAND_STATE = 28, // source = Unit (or WorldObject when creature entry defined), target = Unit (or none)
|
||||
// datalong = stand state (enum UnitStandStateType)
|
||||
// datalong2 = creature entry (searching for a buddy, closest to source), datalong3 = creature search radius
|
||||
// data_flags = flag_target_as_source = 0x01
|
||||
};
|
||||
|
||||
#define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK
|
||||
|
|
@ -294,6 +298,15 @@ struct ScriptInfo
|
|||
uint32 searchRadius; // datalong3
|
||||
} goLockState;
|
||||
|
||||
struct // SCRIPT_COMMAND_STAND_STATE (28)
|
||||
{
|
||||
uint32 stand_state; // datalong
|
||||
uint32 creatureEntry; // datalong2
|
||||
uint32 searchRadius; // datalong3
|
||||
uint32 unused1; // datalong4
|
||||
uint32 flags; // data_flags
|
||||
} standState;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 data[9];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11581"
|
||||
#define REVISION_NR "11582"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue