Fix Loading of scripts
This commit is contained in:
@@ -77,34 +77,39 @@ namespace Game.Scripting
|
|||||||
|
|
||||||
foreach (var type in asm.GetTypes())
|
foreach (var type in asm.GetTypes())
|
||||||
{
|
{
|
||||||
var attributes = (ScriptAttribute[])type.GetCustomAttributes<ScriptAttribute>(true);
|
var attributes = (ScriptAttribute[])type.GetCustomAttributes<ScriptAttribute>();
|
||||||
if (attributes.Empty())
|
if (attributes.Empty())
|
||||||
{
|
{
|
||||||
var baseType = type.BaseType;
|
var baseType = type.BaseType;
|
||||||
while (baseType != null)
|
while (baseType != null)
|
||||||
{
|
{
|
||||||
if (baseType == typeof(ScriptObject))
|
if (baseType == typeof(ScriptObject))
|
||||||
|
{
|
||||||
Log.outWarn(LogFilter.Server, "Script {0} does not have ScriptAttribute", type.Name);
|
Log.outWarn(LogFilter.Server, "Script {0} does not have ScriptAttribute", type.Name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
baseType = baseType.BaseType;
|
baseType = baseType.BaseType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
var constructors = type.GetConstructors();
|
|
||||||
if (constructors.Length == 0)
|
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Scripts, "Type: {0} contains no Public Constructors. Can't load script.", type.Name);
|
var constructors = type.GetConstructors();
|
||||||
break;
|
if (constructors.Length == 0)
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var attribute in attributes)
|
|
||||||
{
|
|
||||||
if (!constructors.Any(p => p.GetParameters().Length == attribute.Args.Length))
|
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Scripts, "Type: {0} has ScriptAttribute that does not match paramter count: {1} Can't load script.", type.Name, attribute.Args.Length);
|
Log.outError(LogFilter.Scripts, "Type: {0} contains no Public Constructors. Can't load script.", type.Name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Activator.CreateInstance(type, attribute.Args);
|
|
||||||
|
foreach (var attribute in attributes)
|
||||||
|
{
|
||||||
|
if (!constructors.Any(p => p.GetParameters().Length == attribute.Args.Length))
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Scripts, "Type: {0} has ScriptAttribute that does not match paramter count: {1} Can't load script.", type.Name, attribute.Args.Length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Activator.CreateInstance(type, attribute.Args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,7 +409,6 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Anubarak
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Script]
|
|
||||||
class npc_anubarak_pet_template : ScriptedAI
|
class npc_anubarak_pet_template : ScriptedAI
|
||||||
{
|
{
|
||||||
public npc_anubarak_pet_template(Creature creature, bool isLarge) : base(creature)
|
public npc_anubarak_pet_template(Creature creature, bool isLarge) : base(creature)
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ namespace Scripts.Spells.Items
|
|||||||
public const uint StrengthOfTheTaunkaHero = 71561; // +700 Strength
|
public const uint StrengthOfTheTaunkaHero = 71561; // +700 Strength
|
||||||
|
|
||||||
//Defibrillate
|
//Defibrillate
|
||||||
public const uint GoblinJumperCablesFail = 8338;
|
public const int GoblinJumperCablesFail = 8338;
|
||||||
public const uint GoblinJumperCablesXlFail = 23055;
|
public const int GoblinJumperCablesXlFail = 23055;
|
||||||
|
|
||||||
//Desperatedefense
|
//Desperatedefense
|
||||||
public const uint DesperateRage = 33898;
|
public const uint DesperateRage = 33898;
|
||||||
@@ -1032,15 +1032,15 @@ namespace Scripts.Spells.Items
|
|||||||
// 8342 - Defibrillate (Goblin Jumper Cables) have 33% chance on success
|
// 8342 - Defibrillate (Goblin Jumper Cables) have 33% chance on success
|
||||||
// 22999 - Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
|
// 22999 - Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
|
||||||
// 54732 - Defibrillate (Gnomish Army Knife) have 67% chance on success
|
// 54732 - Defibrillate (Gnomish Army Knife) have 67% chance on success
|
||||||
[Script("spell_item_goblin_jumper_cables", 33u, SpellIds.GoblinJumperCablesFail)]
|
[Script("spell_item_goblin_jumper_cables", 33, SpellIds.GoblinJumperCablesFail)]
|
||||||
[Script("spell_item_goblin_jumper_cables_xl", 50u, SpellIds.GoblinJumperCablesXlFail)]
|
[Script("spell_item_goblin_jumper_cables_xl", 50, SpellIds.GoblinJumperCablesXlFail)]
|
||||||
[Script("spell_item_gnomish_army_knife", 67u)]
|
[Script("spell_item_gnomish_army_knife", 67, 0)]
|
||||||
class spell_item_defibrillate : SpellScriptLoader
|
class spell_item_defibrillate : SpellScriptLoader
|
||||||
{
|
{
|
||||||
public spell_item_defibrillate(string name, uint chance, uint failSpell = 0) : base(name)
|
public spell_item_defibrillate(string name, int chance, int failSpell) : base(name)
|
||||||
{
|
{
|
||||||
_chance = chance;
|
_chance = (uint)chance;
|
||||||
_failSpell = failSpell;
|
_failSpell = (uint)failSpell;
|
||||||
}
|
}
|
||||||
|
|
||||||
class spell_item_defibrillate_SpellScript : SpellScript
|
class spell_item_defibrillate_SpellScript : SpellScript
|
||||||
|
|||||||
Reference in New Issue
Block a user