Skip to content

Commit

Permalink
Implement SCRIPT_COMMAND_UPDATE_TEMPLATE
Browse files Browse the repository at this point in the history
(based on cmangos/mangos-wotlk@775a3b7)

Signed-off-by: Xfurry <xfurry@cmangos.net>
  • Loading branch information
killerwife authored and xfurry committed May 21, 2016
1 parent faccd0b commit ea420cc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/game/ScriptMgr.cpp
Expand Up @@ -745,6 +745,20 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
}
case SCRIPT_COMMAND_RESET_GO: // 43
break;
case SCRIPT_COMMAND_UPDATE_TEMPLATE: // 44
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>(tmp.updateTemplate.newTemplate))
{
sLog.outErrorDb("Table `%s` uses nonexistent creature entry %u in SCRIPT_COMMAND_UPDATE_TEMPLATE for script id %u.", tablename, tmp.updateTemplate.newTemplate, tmp.id);
continue;
}
if (tmp.updateTemplate.newFactionTeam != 0 && tmp.updateTemplate.newFactionTeam != 1)
{
sLog.outErrorDb("Table `%s` uses nonexistent faction team %u in SCRIPT_COMMAND_UPDATE_TEMPLATE for script id %u.", tablename, tmp.updateTemplate.newFactionTeam, tmp.id);
continue;
}
break;
}
default:
{
sLog.outErrorDb("Table `%s` unknown command %u, skipping.", tablename, tmp.command);
Expand Down Expand Up @@ -2064,6 +2078,19 @@ bool ScriptAction::HandleScriptStep()
}
break;
}
case SCRIPT_COMMAND_UPDATE_TEMPLATE:
{
if (LogIfNotCreature(pSource))
return false;

Creature* pCSource = static_cast<Creature*>(pSource);

if (pCSource->GetEntry() != m_script->updateTemplate.newTemplate)
pCSource->UpdateEntry(m_script->updateTemplate.newTemplate, m_script->updateTemplate.newFactionTeam ? HORDE : ALLIANCE);
else
sLog.outErrorDb(" DB-SCRIPTS: Process table `%s` id %u, command %u failed. Source already has specified creature entry.", m_table, m_script->id, m_script->command);
break;
}
default:
sLog.outErrorDb(" DB-SCRIPTS: Process table `%s` id %u, command %u unknown command used.", m_table, m_script->id, m_script->command);
break;
Expand Down
9 changes: 9 additions & 0 deletions src/game/ScriptMgr.h
Expand Up @@ -127,6 +127,9 @@ enum ScriptCommand // resSource, resTar
// datalong = resetDefault: bool 0=false, 1=true
// dataint = main hand slot; dataint2 = off hand slot; dataint3 = ranged slot
SCRIPT_COMMAND_RESET_GO = 43, // resTarget = GameObject
SCRIPT_COMMAND_UPDATE_TEMPLATE = 44, // resSource = Creature
// datalong = new Creature entry
// datalong2 = Alliance(0) Horde(1), other values throw error
};

#define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK, SCRIPT_COMMAND_EMOTE, SCRIPT_COMMAND_CAST_SPELL, SCRIPT_COMMAND_TERMINATE_SCRIPT
Expand Down Expand Up @@ -392,6 +395,12 @@ struct ScriptInfo

// datalong unsed // SCRIPT_COMMAND_RESET_GO (43)

struct // SCRIPT_COMMAND_UPDATE_TEMPLATE (44)
{
uint32 newTemplate; // datalong
uint32 newFactionTeam; // datalong2
} updateTemplate;

struct
{
uint32 data[2];
Expand Down

0 comments on commit ea420cc

Please sign in to comment.