Skip to content

Commit

Permalink
Implement SCRIPT_COMMAND_CAST_CUSTOM_SPELL
Browse files Browse the repository at this point in the history
Example of command usage: boarding a passenger into a vehicle on a
predefined seat id

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information
xfurry committed Dec 30, 2017
1 parent f94c280 commit df14c11
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,8 @@ Defining a buddy could be done in several way:
* source and target of command define source and target of launched dbscript
* datalong = dbscripts_on_relay id
* datalong2 = dbscript_random_templates id

46 SCRIPT_COMMAND_CAST_CUSTOM_SPELL resultingSource = Unit, cast spell at resultingTarget = Unit
* datalong = spell id
* datalong2 = TriggerCastFlags
* dataint1-dataint3 define the &bp for the spell. At least one field is required.
25 changes: 25 additions & 0 deletions src/game/DBScripts/ScriptMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,21 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
}
break;
}
case SCRIPT_COMMAND_CAST_CUSTOM_SPELL: // 46
{
if (!sSpellTemplate.LookupEntry<SpellEntry>(tmp.castSpell.spellId))
{
sLog.outErrorDb("Table `%s` using nonexistent spell (id: %u) in SCRIPT_COMMAND_CAST_CUSTOM_SPELL for script id %u",
tablename, tmp.castSpell.spellId, tmp.id);
continue;
}
if (tmp.textId[0] == 0 && tmp.textId[1] == 0 && tmp.textId[2] == 0)
{
sLog.outErrorDb("Table `%s` has invalid BP values (dataint = %u, dataint2 = %u, dataint3 = %u) in SCRIPT_COMMAND_CAST_CUSTOM_SPELL for script id %u. At least one field has to be populated.", tablename, tmp.textId[0], tmp.textId[1], tmp.textId[2], tmp.id);
continue;
}
break;
}
default:
{
sLog.outErrorDb("Table `%s` unknown command %u, skipping.", tablename, tmp.command);
Expand Down Expand Up @@ -2319,6 +2334,16 @@ bool ScriptAction::HandleScriptStep()
m_map->ScriptsStart(sRelayScripts, chosenId, pSource, pTarget);
break;
}
case SCRIPT_COMMAND_CAST_CUSTOM_SPELL: // 46
{
if (LogIfNotUnit(pTarget))
break;
if (LogIfNotUnit(pSource))
break;

((Unit*)pSource)->CastCustomSpell((Unit*)pTarget, m_script->castCustomSpell.spellId, &m_script->textId[0], &m_script->textId[1], &m_script->textId[2], m_script->castCustomSpell.castFlags);
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
10 changes: 10 additions & 0 deletions src/game/DBScripts/ScriptMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ enum ScriptCommand // resSource, resTar
// datalong = new Creature entry
// datalong2 = Alliance(0) Horde(1), other values throw error
SCRIPT_COMMAND_START_RELAY_SCRIPT = 45, // datalong = relayId, datalong2 = random template Id
SCRIPT_COMMAND_CAST_CUSTOM_SPELL = 46, // resSource = Unit, cast spell at resTarget = Unit
// datalong=spellid
// datalong2=castFlags, enum TriggerCastFlags
// dataint1-3 define the &bp value for the spell. At least one field is required.
};

#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 @@ -406,6 +410,12 @@ struct ScriptInfo
uint32 templateId; // datalong2
} relayScript;

struct // SCRIPT_COMMAND_CAST_CUSTOM_SPELL (46)
{
uint32 spellId; // datalong
uint32 castFlags; // datalong2
} castCustomSpell;

struct
{
uint32 data[3];
Expand Down

0 comments on commit df14c11

Please sign in to comment.