Updated all spell scripts
This commit is contained in:
@@ -74,7 +74,7 @@ namespace Game.Scripting
|
||||
var constructors = type.GetConstructors();
|
||||
if (constructors.Length == 0)
|
||||
{
|
||||
Log.outError(LogFilter.Scripts, "Script: {0} contains no Public Constructors. Can't load script.", type.Name);
|
||||
Log.outError(LogFilter.Scripts, $"Script: {type.Name} contains no Public Constructors. Can't load script.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -84,16 +84,15 @@ namespace Game.Scripting
|
||||
string name = type.Name;
|
||||
|
||||
bool validArgs = true;
|
||||
int i = 0;
|
||||
foreach (var constructor in constructors)
|
||||
{
|
||||
var parameters = constructor.GetParameters();
|
||||
if (parameters.Length != attribute.Args.Length)
|
||||
continue;
|
||||
|
||||
foreach (var arg in constructor.GetParameters())
|
||||
for (var i = 0; i < parameters.Length; ++i)
|
||||
{
|
||||
if (arg.ParameterType != attribute.Args[i++].GetType())
|
||||
if (attribute.Args[i] != null && attribute.Args[i].GetType() != parameters[i].ParameterType)
|
||||
{
|
||||
validArgs = false;
|
||||
break;
|
||||
@@ -110,6 +109,9 @@ namespace Game.Scripting
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!attribute.Name.IsEmpty())
|
||||
name = attribute.Name;
|
||||
|
||||
switch (type.BaseType.Name)
|
||||
{
|
||||
case nameof(SpellScript):
|
||||
@@ -129,6 +131,9 @@ namespace Game.Scripting
|
||||
case nameof(ConversationAI):
|
||||
genericType = typeof(GenericConversationScript<>).MakeGenericType(type);
|
||||
break;
|
||||
case nameof(BattlegroundScript):
|
||||
genericType = typeof(GenericBattlegroundMapScript<>).MakeGenericType(type);
|
||||
break;
|
||||
case "SpellScriptLoader":
|
||||
case "AuraScriptLoader":
|
||||
case "WorldScript":
|
||||
@@ -161,22 +166,16 @@ namespace Game.Scripting
|
||||
case "AchievementScript":
|
||||
case "BattlefieldScript":
|
||||
case "EventScript":
|
||||
if (!attribute.Name.IsEmpty())
|
||||
name = attribute.Name;
|
||||
|
||||
if (attribute.Args.Empty())
|
||||
Activator.CreateInstance(genericType);
|
||||
else
|
||||
Activator.CreateInstance(genericType, new object[] { name }.Combine(attribute.Args));
|
||||
Activator.CreateInstance(genericType, name, attribute.Args);
|
||||
continue;
|
||||
default:
|
||||
genericType = typeof(GenericCreatureScript<>).MakeGenericType(type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!attribute.Name.IsEmpty())
|
||||
name = attribute.Name;
|
||||
|
||||
Activator.CreateInstance(genericType, name, attribute.Args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Game.Scripting
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ValidateSpellInfo(params uint[] spellIds)
|
||||
public static bool ValidateSpellInfo(params uint[] spellIds)
|
||||
{
|
||||
bool allValid = true;
|
||||
foreach (uint spellId in spellIds)
|
||||
@@ -45,7 +45,7 @@ namespace Game.Scripting
|
||||
return allValid;
|
||||
}
|
||||
|
||||
public bool ValidateSpellEffect(params (uint spellId, uint effectIndex)[] pairs)
|
||||
public static bool ValidateSpellEffect(params (uint spellId, uint effectIndex)[] pairs)
|
||||
{
|
||||
bool allValid = true;
|
||||
foreach (var (spellId, effectIndex) in pairs)
|
||||
@@ -56,7 +56,7 @@ namespace Game.Scripting
|
||||
return allValid;
|
||||
}
|
||||
|
||||
public bool ValidateSpellEffect(uint spellId, uint effectIndex)
|
||||
public static bool ValidateSpellEffect(uint spellId, uint effectIndex)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
|
||||
if (spellInfo == null)
|
||||
|
||||
Reference in New Issue
Block a user