Exemplo n.º 1
0
    //Čia nurodysim, kaip bus skaičiuojami mūsų Antriniai atributai
    private void setupModifiers()
    {
        ModAttribute mod;
        ModifiedStat modStat;

        //HP = 60 + 3 * vitality
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Hit_Points);
        modStat.baseValue = 60;
        mod = new ModAttribute(AttrNames.Vitality, 3);
        modStat.addModifyingAttribute(mod);
        //TP = 5 + 1 * Technique
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Technique_Points);
        modStat.baseValue = 5;
        mod = new ModAttribute(AttrNames.Technique, 1);
        modStat.addModifyingAttribute(mod);
        //Defense = 10 + dexterity * 1
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Defense);
        modStat.baseValue = 10;
        mod = new ModAttribute(AttrNames.Dexterity, 1);
        modStat.addModifyingAttribute(mod);
        //Melee attack = 30 + Strength * 0.5 + Dexterity * 0.5;
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Melee_Attack);
        modStat.baseValue = 30;
        mod = new ModAttribute(AttrNames.Strength, 0.5f);
        modStat.addModifyingAttribute(mod);
        mod = new ModAttribute(AttrNames.Dexterity, 0.5f);
        modStat.addModifyingAttribute(mod);
        //Ranged attack = 10 + Dexterity * 2;
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Ranged_Attack);
        modStat.baseValue = 10;
        mod = new ModAttribute(AttrNames.Dexterity, 2);
        modStat.addModifyingAttribute(mod);
        //Damage resistance = 20 + Vitality * 0.5;
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Damage_Resistance);
        modStat.baseValue = 20;
        mod = new ModAttribute(AttrNames.Vitality, 0.5f);
        modStat.addModifyingAttribute(mod);
        //Magic resistance = 10 + soulpower * 1 + vitality * 0.5;
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Magic_Resistance);
        modStat.baseValue = 10;
        mod = new ModAttribute(AttrNames.Soulpower, 1);
        modStat.addModifyingAttribute(mod);
        mod = new ModAttribute(AttrNames.Vitality, 0.5f);
        modStat.addModifyingAttribute(mod);
        //Movement speed = 4 + dexterity * 0.04;
        modStat           = getSecondaryAttr((int)SecondaryAttrNames.Movement_Speed);
        modStat.baseValue = 4;
        mod = new ModAttribute(AttrNames.Dexterity, 0.04f);
        modStat.addModifyingAttribute(mod);
    }
Exemplo n.º 2
0
	public void addModifyingAttribute(ModAttribute modAttribute)
	{
        modifyingAttributes.Add(modAttribute);
	}
Exemplo n.º 3
0
 public void addModifyingAttributes(ModAttribute[] modAttributes)
 {
     modifyingAttributes.AddRange(modAttributes);
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            IPatcher patcher;
            // TODO: Check which mods have already been installed, only install new ones
            // TODO: If this is the first time patching, backup the assembly in a "pristine" folder.
            // TODO: Corollary to first: maintain list of mods and patches, add this to the assembly for later reading.

            String targetAssembly   = args.Length > 0 ? args[0] : Path.Combine(DEFAULT_ASSEMBLY_DIR, "Assembly-CSharp.dll");
            String pristineLocation = targetAssembly.Replace(".dll", "-pristine.dll");
            String outputLocation   = targetAssembly;

            if (File.Exists(pristineLocation))
            {
                Console.WriteLine("Found pristine DLL at {0}, using this as patching base.", pristineLocation);
                targetAssembly = pristineLocation;
            }
            else
            {
                Console.WriteLine("Making backup of current {0} at {1}....", targetAssembly, pristineLocation);
                try
                {
                    File.Copy(targetAssembly, pristineLocation);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to make backup of {0} at {1}!", targetAssembly, pristineLocation);
                    Console.WriteLine(e);
                    return;
                }
            }
            try
            {
                patcher = CecilPatcher.Create(targetAssembly);
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to read input assembly {0}: {1}", targetAssembly, e);
                return;
            }
            IEnumerable <string> modDlls =
                Directory.EnumerateFileSystemEntries(DEFAULT_MODS_DIR, "*.dll", SearchOption.AllDirectories);

            foreach (String modDll in modDlls)
            {
                Assembly assembly;
                try
                {
                    // TODO: use reflection only context to avoid overhead of loading assembly transitive deps.
                    // Requires converting all GetCustomAttribute to CustomAttributeData.GetCustomAttributes.
                    assembly = Assembly.LoadFrom(modDll);
                    assembly.GetTypes();
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Exception while attempting to load assembly [{0}]", modDll);
                    Console.WriteLine(exception);
                    continue;
                }
                ModAttribute modAttr = Attribute.GetCustomAttribute(assembly, typeof(ModAttribute)) as ModAttribute;
                if (modAttr == null)
                {
                    Console.WriteLine("Assembly {0} had no Mod attribute", assembly);
                    return;
                }
                Console.WriteLine("Processing data for mod {0}:", modAttr.ToString());
                ICollection <PatchDescriptor> patchesForMod = ProcessAssembly(assembly);
                // TODO: Verify PatchDescriptors locally (make sure method signatures match)
                // and globally (no conflicting patches).
                // TODO: Populate dictionary of <String, Patches> or make a list of "ModDescriptor" objects.
                foreach (var patch in patchesForMod)
                {
                    Console.WriteLine(
                        "Adding patch for method {0} in type {1}.",
                        patch.patchAttribute.method,
                        patch.patchAttribute.type);
                    try
                    {
                        patcher.AddPatch(patch);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Failed to add patch! Exception: {0}", e);
                    }
                }
            }
            using (var outputStream = new FileStream(outputLocation, FileMode.OpenOrCreate, FileAccess.Write))
            {
                patcher.WritePatchedAssembly(outputStream);
            }
        }
Exemplo n.º 5
0
 public void addModifyingAttribute(ModAttribute modAttribute)
 {
     modifyingAttributes.Add(modAttribute);
 }
Exemplo n.º 6
0
	//Čia nurodysim, kaip bus skaičiuojami mūsų Antriniai atributai
	private void setupModifiers()
	{
        ModAttribute mod;
        ModifiedStat modStat;
        //HP = 60 + 3 * vitality
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Hit_Points);
        modStat.baseValue = 60;
        mod = new ModAttribute(AttrNames.Vitality, 3);
        modStat.addModifyingAttribute(mod);
        //TP = 5 + 1 * Technique
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Technique_Points);
        modStat.baseValue = 5;
        mod = new ModAttribute(AttrNames.Technique, 1);
        modStat.addModifyingAttribute(mod);
        //Defense = 10 + dexterity * 1
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Defense);
        modStat.baseValue = 10;
        mod = new ModAttribute(AttrNames.Dexterity, 1);
        modStat.addModifyingAttribute(mod);
        //Melee attack = 30 + Strength * 0.5 + Dexterity * 0.5;
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Melee_Attack);
        modStat.baseValue = 30;
        mod = new ModAttribute(AttrNames.Strength, 0.5f);
        modStat.addModifyingAttribute(mod);
        mod = new ModAttribute(AttrNames.Dexterity, 0.5f);
        modStat.addModifyingAttribute(mod);
        //Ranged attack = 10 + Dexterity * 2;
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Ranged_Attack);
        modStat.baseValue = 10;
        mod = new ModAttribute(AttrNames.Dexterity, 2);
        modStat.addModifyingAttribute(mod);
        //Damage resistance = 20 + Vitality * 0.5;
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Damage_Resistance);
        modStat.baseValue = 20;
        mod = new ModAttribute(AttrNames.Vitality, 0.5f);
        modStat.addModifyingAttribute(mod);
        //Magic resistance = 10 + soulpower * 1 + vitality * 0.5;
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Magic_Resistance);
        modStat.baseValue = 10;
        mod = new ModAttribute(AttrNames.Soulpower, 1);
        modStat.addModifyingAttribute(mod);
        mod = new ModAttribute(AttrNames.Vitality, 0.5f);
        modStat.addModifyingAttribute(mod);
        //Movement speed = 4 + dexterity * 0.04;
        modStat = getSecondaryAttr((int)SecondaryAttrNames.Movement_Speed);
        modStat.baseValue = 4;
        mod = new ModAttribute(AttrNames.Dexterity, 0.04f);
        modStat.addModifyingAttribute(mod);
	}