예제 #1
0
        private ScopeEntry GetWeaponScope(WeaponProfile weaponProfile, int strength)
        {
            if (weaponProfile == null)
            {
                return(null);
            }

            return(weaponProfile.scopeEntries.Where(x => x.strength == strength).FirstOrDefault());
        }
예제 #2
0
        private void HandleWeaponChange(WeaponProfile profile)
        {
            if (!weaponImage)
            {
                return;
            }

            weaponImage.sprite = profile.Icon;
        }
예제 #3
0
        public static WeaponProfile read(BinaryReader binaryReader)
        {
            WeaponProfile newObj = new WeaponProfile();

            newObj._damage_type            = binaryReader.ReadUInt32();
            newObj._weapon_time            = binaryReader.ReadUInt32();
            newObj._weapon_skill           = binaryReader.ReadUInt32();
            newObj._weapon_damage          = binaryReader.ReadUInt32();
            newObj._damage_variance        = binaryReader.ReadDouble();
            newObj._damage_mod             = binaryReader.ReadDouble();
            newObj._weapon_length          = binaryReader.ReadDouble();
            newObj._max_velocity           = binaryReader.ReadDouble();
            newObj._weapon_offense         = binaryReader.ReadDouble();
            newObj._max_velocity_estimated = binaryReader.ReadUInt32();
            return(newObj);
        }
예제 #4
0
        public static WeaponMask GetColorMask(WeaponProfile profile)
        {
            WeaponMask colorMask = 0;

            var weapon  = profile.Weapon;
            var wielder = profile.Wielder;

            // Enchant applies to all weapons
            if (profile.Enchantment_WeaponDefense > 0)
            {
                colorMask |= WeaponMask.MeleeDefense;
            }

            // Following enchants do not apply to caster weapons
            if (weapon.WeenieType != ACE.Entity.Enum.WeenieType.Caster)
            {
                // item enchanments are currently being cast on wielder
                if (profile.Enchantment_WeaponOffense > 0)
                {
                    colorMask |= WeaponMask.AttackSkill;
                }
                if (profile.Enchantment_WeaponTime < 0)
                {
                    colorMask |= WeaponMask.Speed;
                }
                if (profile.Enchantment_Damage > 0)
                {
                    colorMask |= WeaponMask.Damage;
                }
                if (profile.Enchantment_DamageVariance < 1.0f)
                {
                    colorMask |= WeaponMask.DamageVariance;
                }
                if (profile.Enchantment_DamageMod > 1.0f)
                {
                    colorMask |= WeaponMask.DamageMod;
                }
            }

            return(colorMask);
        }
예제 #5
0
파일: WeaponMask.cs 프로젝트: wmatuszak/ACE
        public static WeaponMask GetColorMask(WeaponProfile profile)
        {
            WeaponMask colorMask = 0;

            var weapon  = profile.Weapon;
            var wielder = profile.Wielder;

            // Enchant applies to all weapons
            if (profile.Enchantment_WeaponDefense > 0)
            {
                colorMask |= WeaponMask.MeleeDefense;
            }

            // Following enchants do not apply to caster weapons
            if (weapon.WeenieType != WeenieType.Caster && (weapon.WeenieType != WeenieType.Ammunition || PropertyManager.GetBool("show_ammo_buff").Item))
            {
                // item enchanments are currently being cast on wielder
                if (profile.Enchantment_WeaponOffense > 0)
                {
                    colorMask |= WeaponMask.AttackSkill;
                }
                if (profile.Enchantment_WeaponTime < 0)
                {
                    colorMask |= WeaponMask.Speed;
                }
                if (profile.Enchantment_Damage > 0)
                {
                    colorMask |= WeaponMask.Damage;
                }
                if (profile.Enchantment_DamageVariance < 1.0f)
                {
                    colorMask |= WeaponMask.DamageVariance;
                }
                if (profile.Enchantment_DamageMod > 0)
                {
                    colorMask |= WeaponMask.DamageMod;
                }
            }

            return(colorMask);
        }
예제 #6
0
        public static WeaponMask GetHighlightMask(WeaponProfile profile)
        {
            WeaponMask highlightMask = 0;

            var wielder = profile.Wielder;
            var weapon  = profile.Weapon;

            // Enchant applies to all weapons
            if (profile.Enchantment_WeaponDefense != 0)
            {
                highlightMask |= WeaponMask.MeleeDefense;
            }

            // Following enchants do not apply to caster weapons
            if (weapon.WeenieType != ACE.Entity.Enum.WeenieType.Caster)
            {
                if (profile.Enchantment_WeaponOffense != 0)
                {
                    highlightMask |= WeaponMask.AttackSkill;
                }
                if (profile.Enchantment_WeaponTime != 0)
                {
                    highlightMask |= WeaponMask.Speed;
                }
                if (profile.Enchantment_Damage != 0)
                {
                    highlightMask |= WeaponMask.Damage;
                }
                if (profile.Enchantment_DamageVariance != 1.0f)
                {
                    highlightMask |= WeaponMask.DamageVariance;
                }
                if (profile.Enchantment_DamageMod != 1.0f)
                {
                    highlightMask |= WeaponMask.DamageMod;
                }
            }

            return(highlightMask);
        }
예제 #7
0
        private void DisplayCurrentWeapon(WeaponProfile p, ScopeEntry s)
        {
            settings.isLoading = true;

            setStatus("Updating current weapon display");

            if (p == null)
            {
                labActiveWeapon.Text = "None";
                setStatus("No weapon found");
            }
            else
            {
                labActiveWeapon.Text = "" + p.name;
                setStatus("Weapon is now: " + p.name);
            }

            if (s == null)
            {
                labActiveScope.Text = "None";

                nudCompensationAmount.Value = 0;
                nudCompensationDelay.Value  = 0;
                nudFireRateDelay.Value      = 0;
                nudActivationDelay.Value    = 0;
            }
            else
            {
                labActiveScope.Text = "" + s.strength + "x";

                nudCompensationAmount.Value = s.compensationAmount;
                nudCompensationDelay.Value  = s.compensationDelay;
                nudFireRateDelay.Value      = s.fireDelay;
                nudActivationDelay.Value    = s.activationDelay;
            }

            settings.isLoading = false;
        }
예제 #8
0
        public static AppraisalProfile read(BinaryReader binaryReader)
        {
            AppraisalProfile newObj = new AppraisalProfile();

            newObj.header       = binaryReader.ReadUInt32();
            newObj.success_flag = binaryReader.ReadUInt32();
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_IntStats) != 0)
            {
                newObj._intStatsTable = PackableHashTable <STypeInt, int> .read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_Int64Stats) != 0)
            {
                newObj._int64StatsTable = PackableHashTable <STypeInt64, long> .read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_BoolStats) != 0)
            {
                newObj._boolStatsTable = PackableHashTable <STypeBool, int> .read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_FloatStats) != 0)
            {
                newObj._floatStatsTable = PackableHashTable <STypeFloat, double> .read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_StringStats) != 0)
            {
                newObj._strStatsTable = PackableHashTable <STypeString, PStringChar> .read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_DataIDStats) != 0)
            {
                newObj._didStatsTable = PackableHashTable <STypeDID, uint> .read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_SpellList) != 0)
            {
                newObj._spellsTable = PList <uint> .read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ArmorProfile) != 0)
            {
                newObj._armorProfileTable = ArmorProfile.read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_CreatureProfile) != 0)
            {
                newObj._creatureProfileTable = CreatureAppraisalProfile.read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_WeaponProfile) != 0)
            {
                newObj._weaponProfileTable = WeaponProfile.read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_HookProfile) != 0)
            {
                newObj._hookProfileTable = HookAppraisalProfile.read(binaryReader);
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ArmorEnchant) != 0)
            {
                newObj._armorEnchantment = binaryReader.ReadUInt32();
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_WeaponEnchant) != 0)
            {
                newObj._weaponEnchantment = binaryReader.ReadUInt32();
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ResistEnchant) != 0)
            {
                newObj._resistEnchantment = binaryReader.ReadUInt32();
            }
            if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ArmorLevels) != 0)
            {
                newObj._armorLevelsTable = ArmorLevels.read(binaryReader);
            }
            return(newObj);
        }
예제 #9
0
 public override void Pack(BinaryWriter writer)
 {
     writer.Write(ObjectID);
     writer.Write(Flags);
     writer.WriteBool32(Success);
     if ((Flags & 0x00000001) != 0)
     {
         IntStatsTable.Pack(writer);
     }
     if ((Flags & 0x00002000) != 0)
     {
         Int64StatsTable.Pack(writer);
     }
     if ((Flags & 0x00000002) != 0)
     {
         BoolStatsTable.Pack(writer);
     }
     if ((Flags & 0x00000004) != 0)
     {
         FloatStatsTable.Pack(writer);
     }
     if ((Flags & 0x00000008) != 0)
     {
         StrStatsTable.Pack(writer);
     }
     if ((Flags & 0x00001000) != 0)
     {
         DidStatsTable.Pack(writer);
     }
     if ((Flags & 0x00000010) != 0)
     {
         SpellBook.Pack(writer);
     }
     if ((Flags & 0x00000080) != 0)
     {
         ArmorProfile.Pack(writer);
     }
     if ((Flags & 0x00000100) != 0)
     {
         CreatureProfile.Pack(writer);
     }
     if ((Flags & 0x00000020) != 0)
     {
         WeaponProfile.Pack(writer);
     }
     if ((Flags & 0x00000040) != 0)
     {
         HookAppraisalProfile.Pack(writer);
     }
     if ((Flags & 0x00000200) != 0)
     {
         writer.Write((ushort)ProtHighlight);
         writer.Write((ushort)ProtColor);
     }
     if ((Flags & 0x00000800) != 0)
     {
         writer.Write((ushort)WeapHighlight);
         writer.Write((ushort)WeapColor);
     }
     if ((Flags & 0x00000400) != 0)
     {
         writer.Write((ushort)ResistHighlight);
         writer.Write((ushort)ResistColor);
     }
     if ((Flags & 0x00004000) != 0)
     {
         writer.Write(BaseArmorHead);
         writer.Write(BaseArmorChest);
         writer.Write(BaseArmorGroin);
         writer.Write(BaseArmorBicep);
         writer.Write(BaseArmorWrist);
         writer.Write(BaseArmorHand);
         writer.Write(BaseArmorThigh);
         writer.Write(BaseArmorShin);
         writer.Write(BaseArmorFoot);
     }
 }
예제 #10
0
 public override void Unpack(BinaryReader reader)
 {
     base.Unpack(reader);
     ObjectID = reader.ReadUInt32();
     Flags    = reader.ReadUInt32();
     Success  = reader.ReadBool32();
     if ((Flags & 0x00000001) != 0)
     {
         IntStatsTable.Unpack(reader);
     }
     if ((Flags & 0x00002000) != 0)
     {
         Int64StatsTable.Unpack(reader);
     }
     if ((Flags & 0x00000002) != 0)
     {
         BoolStatsTable.Unpack(reader);
     }
     if ((Flags & 0x00000004) != 0)
     {
         FloatStatsTable.Unpack(reader);
     }
     if ((Flags & 0x00000008) != 0)
     {
         StrStatsTable.Unpack(reader);
     }
     if ((Flags & 0x00001000) != 0)
     {
         DidStatsTable.Unpack(reader);
     }
     if ((Flags & 0x00000010) != 0)
     {
         SpellBook.Unpack(reader);
     }
     if ((Flags & 0x00000080) != 0)
     {
         ArmorProfile.Unpack(reader);
     }
     if ((Flags & 0x00000100) != 0)
     {
         CreatureProfile.Unpack(reader);
     }
     if ((Flags & 0x00000020) != 0)
     {
         WeaponProfile.Unpack(reader);
     }
     if ((Flags & 0x00000040) != 0)
     {
         HookAppraisalProfile.Unpack(reader);
     }
     if ((Flags & 0x00000200) != 0)
     {
         ProtHighlight = (ArmorHighlightMask)reader.ReadUInt16();
         ProtColor     = (ArmorHighlightMask)reader.ReadUInt16();
     }
     if ((Flags & 0x00000800) != 0)
     {
         WeapHighlight = (WeaponHighlightMask)reader.ReadUInt16();
         WeapColor     = (WeaponHighlightMask)reader.ReadUInt16();
     }
     if ((Flags & 0x00000400) != 0)
     {
         ResistHighlight = (ResistHighlightMask)reader.ReadUInt16();
         ResistColor     = (ResistHighlightMask)reader.ReadUInt16();
     }
     if ((Flags & 0x00004000) != 0)
     {
         BaseArmorHead  = reader.ReadUInt32();
         BaseArmorChest = reader.ReadUInt32();
         BaseArmorGroin = reader.ReadUInt32();
         BaseArmorBicep = reader.ReadUInt32();
         BaseArmorWrist = reader.ReadUInt32();
         BaseArmorHand  = reader.ReadUInt32();
         BaseArmorThigh = reader.ReadUInt32();
         BaseArmorShin  = reader.ReadUInt32();
         BaseArmorFoot  = reader.ReadUInt32();
     }
 }
예제 #11
0
        private void bgwMain_DoWork(object sender, DoWorkEventArgs e)
        {
            int startTime;

            int nextFireTime;

            PlayerWeapon[] playerWeapons = new PlayerWeapon[2] {
                new PlayerWeapon(), new PlayerWeapon()
            };



            startTime    = 0;
            nextFireTime = 0;

            runMode = RunMode.RUN;

            bool doingNade = false;

            bool slept = false;

            int nextWindowTime = Environment.TickCount;

            IntPtr lastForegroundWindow = IntPtr.Zero;

            bool isGameActive = false;

            float brightnessMinimum;


            Point scopeStart1 = new Point(1586, 115);
            Point scopeStart2 = new Point(1586, 345);

            Point start = new Point(890, 920);

            Size area = new Size(140, 45);

            Size scopeArea = new Size(48, 43);


            List <ScopeMask> scopeMasks;

            int currentWeaponGameIndex = 1;

            SpeechSynthesizer speaker = new SpeechSynthesizer();

            speaker.Volume = 100;

            brightnessMinimum = 0.80f;

            float scopeBrightnessMaximum = 0.15f;

            bool firedGun = false;


            int lastWeaponSlot    = 1,
                currentWeaponSlot = 1;

            List <string> singleFireWeapons = new List <string>(new string[] { "awm", "crossbow", "kar98k", "m24" });

            weaponMasks = new List <WeaponMask>();
            scopeMasks  = new List <ScopeMask>();



            // Load the scope masks into objects
            foreach (string s in Directory.GetFiles("input images\\raw\\menu scopes"))
            {
                ScopeMask mask;

                Bitmap bmp;


                bmp = new Bitmap(s);

                mask          = new ScopeMask();
                mask.filename = s.Split("\\").Last().Split(".").First();
                mask.points   = new List <MaskPoint>();

                for (int y = 0; y < bmp.Height; y++)
                {
                    for (int x = 0; x < bmp.Width; x += 10)
                    {
                        Color pixel = bmp.GetPixel(x, y);

                        if ((pixel.R == Color.Magenta.R && pixel.G == Color.Magenta.G && pixel.B == Color.Magenta.B) == false)
                        {
                            mask.points.Add(new MaskPoint(x, y, ((pixel.R + pixel.G + pixel.B) / 3.0f)));
                        }
                    }
                }

                mask.strength = int.Parse(mask.filename.Split(".").First().Split("-").First().Replace("x", ""));

                setStatus("Point count: " + mask.points.Count);

                bmp.Dispose();
                scopeMasks.Add(mask);
            }

            scopeMasks = scopeMasks.OrderBy(x => x.points.Count).ToList();

            scopeMasks.Reverse();



            // Load the gun masks into objects
            foreach (string s in Directory.GetFiles("input images\\raw\\menu guns"))
            {
                WeaponMask mask;

                Bitmap bmp;


                bmp = new Bitmap(s);


                mask          = new WeaponMask();
                mask.filename = s.Split("\\").Last().Split(".").First().ToLower();
                mask.points   = new List <MaskPoint>();

                for (int y = 0; y < bmp.Height; y += 1)
                {
                    for (int x = 0; x < bmp.Width; x++)
                    {
                        Color pixel = bmp.GetPixel(x, y);

                        if ((pixel.R == Color.Magenta.R && pixel.G == Color.Magenta.G && pixel.B == Color.Magenta.B) == false)
                        {
                            mask.points.Add(new MaskPoint(x, y, ((pixel.R + pixel.G + pixel.B) / 3.0f)));
                        }
                    }
                }

                mask.points.Sort((x, y) =>
                {
                    if (x.averagePixel == y.averagePixel)
                    {
                        return(0);
                    }
                    else if (x.averagePixel < y.averagePixel)
                    {
                        return(-1);
                    }
                    else
                    {
                        return(1);
                    }
                });

                mask.points.Reverse();

                List <MaskPoint> final = new List <MaskPoint>();

                for (int i = 0; i < mask.points.Count; i += mask.points.Count / 20)
                {
                    final.Add(mask.points[i]);
                }

                mask.points = final;

                setStatus("Weapon Point count: " + mask.points.Count);


                bmp.Dispose();
                weaponMasks.Add(mask);
            }

            weaponMasks = weaponMasks.OrderBy(x => x.points.Count).ToList();

            weaponMasks.Reverse();



            // Create the weapon profiles
            foreach (WeaponMask a in weaponMasks)
            {
                // If the profile doesn't exist yet
                if (weaponProfiles.Where(x => x.name == a.filename).FirstOrDefault() == null)
                {
                    WeaponProfile p = new WeaponProfile();

                    p.name = a.filename;

                    weaponProfiles.Add(p);
                }
            }

            // Add the scope profiles to each weapon
            foreach (WeaponProfile p in weaponProfiles)
            {
                foreach (ScopeMask s in scopeMasks)
                {
                    // If it doesn't have an entry for that scope strength, then create one
                    if (p.scopeEntries.Where(x => x.strength == s.strength).FirstOrDefault() == null)
                    {
                        ScopeEntry se = new ScopeEntry();

                        se.strength = s.strength;

                        p.scopeEntries.Add(se);
                    }
                }
            }



            Point ptGunMaskStart1 = new Point(1445, 158);
            Point ptGunMaskStart2 = new Point(1445, 388);

            Point ptScopeMaskStart1 = new Point(1585, 114);
            Point ptScopeMaskStart2 = new Point(1585, 344);

            List <string> screenshots;



            int lastScreenshotTime = 0;

            int nextCompensationTime = 0;

            bool requestingScreenshot = false;


            while (true)
            {
                try
                {
                    if ((GetAsyncKeyState(Keys.Up) & 1) == 1)
                    {
                        nudIndex--;

                        if (nudIndex < 0)
                        {
                            nudIndex = 0;
                        }

                        this.ActiveControl = null;


                        foreach (NumericUpDown a in nudOptions)
                        {
                            a.BackColor = SystemColors.Control;
                        }

                        nudOptions[nudIndex].BackColor = Color.LightGray;
                    }
                    else if ((GetAsyncKeyState(Keys.Down) & 1) == 1)
                    {
                        nudIndex++;

                        if (nudIndex > 3)
                        {
                            nudIndex = 3;
                        }

                        this.ActiveControl = null;

                        foreach (NumericUpDown a in nudOptions)
                        {
                            a.BackColor = SystemColors.Control;
                        }

                        nudOptions[nudIndex].BackColor = Color.LightGray;
                    }
                    else if ((GetAsyncKeyState(Keys.Left) & 1) == 1)
                    {
                        if (nudOptions[nudIndex].Value > nudOptions[nudIndex].Minimum)
                        {
                            if (GetAsyncKeyState(Keys.LShiftKey) != 0)
                            {
                                nudOptions[nudIndex].Value = Math.Max(0, nudOptions[nudIndex].Value - 100);
                            }
                            else
                            {
                                nudOptions[nudIndex].Value -= 1;
                            }
                        }
                    }
                    else if ((GetAsyncKeyState(Keys.Right) & 1) == 1)
                    {
                        if (nudOptions[nudIndex].Value < nudOptions[nudIndex].Maximum)
                        {
                            if (GetAsyncKeyState(Keys.LShiftKey) != 0)
                            {
                                nudOptions[nudIndex].Value = Math.Min(nudOptions[nudIndex].Maximum, nudOptions[nudIndex].Value + 100);
                            }
                            else
                            {
                                nudOptions[nudIndex].Value += 1;
                            }
                        }
                    }
                    else if ((GetAsyncKeyState(Keys.D1) & 1) == 1)
                    {
                        currentWeaponSlot = 0;

                        WeaponProfile p = weaponProfiles.Where(x => x.name == playerWeapons[currentWeaponSlot].name).FirstOrDefault();

                        ScopeEntry s = null;

                        if (p != null)
                        {
                            s = p.scopeEntries.Where(x => x.strength == playerWeapons[currentWeaponSlot].scopeStrength).FirstOrDefault();
                        }

                        DisplayCurrentWeapon(p, s);
                    }
                    else if ((GetAsyncKeyState(Keys.D2) & 1) == 1)
                    {
                        currentWeaponSlot = 1;

                        WeaponProfile p = weaponProfiles.Where(x => x.name == playerWeapons[currentWeaponSlot].name).FirstOrDefault();

                        ScopeEntry s = null;

                        if (p != null)
                        {
                            s = p.scopeEntries.Where(x => x.strength == playerWeapons[currentWeaponSlot].scopeStrength).FirstOrDefault();
                        }

                        DisplayCurrentWeapon(p, s);
                    }
                    else if ((GetAsyncKeyState(Keys.D5) & 1) == 1 || (GetAsyncKeyState(Keys.G) & 1) == 1)
                    {
                        currentWeaponSlot = 4;

                        DisplayCurrentWeapon(null, null);
                    }
                    else if ((GetAsyncKeyState(Keys.Tab) & 1) == 1)
                    {
                        AccurateSleep(0.3f);
                        requestingScreenshot = true;
                    }


                    if (Environment.TickCount > nextWindowTime)
                    {
                        isGameActive = IsGameActive();

                        nextWindowTime = Environment.TickCount + 2000;
                    }

                    if (isGameActive == true || skipWindowCheck == true)
                    {
                        if (requestingScreenshot == true)
                        {
                            if (Environment.TickCount - lastScreenshotTime > 1000)
                            {
                                setStatus("Taking screenshot");
                                keybd_event((int)Keys.F12, 0x9e, 0, UIntPtr.Zero);
                                Thread.Sleep(10);
                                keybd_event((int)Keys.F12, 0x9e, KEYEVENTF_KEYUP, UIntPtr.Zero);
                                Thread.Sleep(10);

                                requestingScreenshot = false;
                            }
                        }


                        // Process any screenshots in the folder
                        screenshots = Directory.GetFiles("input images\\screenshots").ToList();

                        if (screenshots.Count > 0)
                        {
                            DirectBitmap rawTest = null;

                            Thread.Sleep(25);

                            screenshots[0] = screenshots[screenshots.Count - 1];

                            setStatus("Screenshot found");

                            for (int i = 0; i < 100; i++)
                            {
                                try
                                {
                                    rawTest = new DirectBitmap(screenshots[0]);

                                    break;
                                }
                                catch (Exception x)
                                {
                                    x.ToString();
                                    Thread.Sleep(10);
                                }
                            }

                            if (rawTest != null)
                            {
                                if (IsScreenshotInTabMenu(rawTest) == true)
                                {
                                    // While the tab is open, keep screenshotting

                                    requestingScreenshot = true;

                                    WeaponProfile p;

                                    for (int i = 0; i < 2; i++)
                                    {
                                        p = null;

                                        setStatus("Checking slot: " + i);
                                        Point ptCurrentGunMaskStart,
                                              ptCurrentScopeMaskStart;

                                        if (i == 0)
                                        {
                                            ptCurrentGunMaskStart   = ptGunMaskStart1;
                                            ptCurrentScopeMaskStart = ptScopeMaskStart1;
                                        }
                                        else
                                        {
                                            ptCurrentGunMaskStart   = ptGunMaskStart2;
                                            ptCurrentScopeMaskStart = ptScopeMaskStart2;
                                        }


                                        //Image compare for a weapon match
                                        foreach (WeaponMask m in weaponMasks)
                                        {
                                            if (DoesMaskMatch(rawTest, ptCurrentGunMaskStart, m.points) == true)
                                            {
                                                p = WeaponMaskToProfile(m);

                                                int index = weaponMasks.IndexOf(m);

                                                weaponMasks.Insert(0, m);
                                                weaponMasks.RemoveAt(index + 1);

                                                break;
                                            }

                                            Thread.Sleep(1);
                                        }

                                        // if a weapon was matched
                                        if (p != null)
                                        {
                                            int  scopeStrength = 1;
                                            bool updateDisplay = false;

                                            setStatus("Matched: " + p.name);

                                            if (playerWeapons[i].name != p.name)
                                            {
                                                //Process.Start(screenshots[0]);
                                                playerWeapons[i].name = p.name;

                                                string name = playerWeapons[i].name;
                                                if (name == "pp-19 bizon")
                                                {
                                                    name = "P. P. Bizon";
                                                }
                                                else if (name == "sks")
                                                {
                                                    name = "S. K. S.";
                                                }
                                                else if (name == "aug")
                                                {
                                                    name = "A. U. G.";
                                                }
                                                else if (name == "awm")
                                                {
                                                    name = "A. W. M.";
                                                }
                                                else if (name == "slr")
                                                {
                                                    name = "S. L. R.";
                                                }
                                                else if (name == "ak47")
                                                {
                                                    name = "A. K. 47";
                                                }

                                                speaker.SpeakAsync(name + " " + (i == 0 ? "first" : "second") + " slot");
                                                updateDisplay = true;
                                            }

                                            foreach (ScopeMask s in scopeMasks)
                                            {
                                                if (DoesMaskMatch(rawTest, ptCurrentScopeMaskStart, s.points) == true)
                                                {
                                                    setStatus("Matched scope: " + s.strength);

                                                    scopeStrength = s.strength;


                                                    int index = scopeMasks.IndexOf(s);

                                                    scopeMasks.Insert(0, s);
                                                    scopeMasks.RemoveAt(index + 1);

                                                    if (cbBabyMode.Checked == true)
                                                    {
                                                        if (scopeStrength > 2)
                                                        {
                                                            scopeStrength = 2;
                                                        }
                                                    }

                                                    break;
                                                }

                                                Thread.Sleep(1);
                                            }

                                            if (playerWeapons[i].scopeStrength != scopeStrength)
                                            {
                                                playerWeapons[i].scopeStrength = scopeStrength;

                                                speaker.SpeakAsync(playerWeapons[i].scopeStrength + " X. " + (i == 0 ? "first" : "second") + " slot");
                                                updateDisplay = true;
                                            }

                                            if (updateDisplay == true)
                                            {
                                                WeaponProfile p2 = weaponProfiles.Where(x => x.name == playerWeapons[currentWeaponSlot].name).FirstOrDefault();

                                                ScopeEntry s2 = null;

                                                if (p2 != null)
                                                {
                                                    s2 = p2.scopeEntries.Where(x => x.strength == playerWeapons[currentWeaponSlot].scopeStrength).FirstOrDefault();
                                                }

                                                DisplayCurrentWeapon(p2, s2);
                                            }
                                        }
                                    }
                                }
                            }

                            if (rawTest != null)
                            {
                                rawTest.Dispose();
                            }

                            setStatus("Deleting screenshots");

                            foreach (string s in screenshots)
                            {
                                try
                                {
                                    File.Delete(s);
                                }
                                catch (Exception x)
                                {
                                    x.ToString();
                                }
                            }

                            setStatus("Finished deleting");
                        }



                        if ((GetAsyncKeyState(Keys.LButton) != 0) && GetAsyncKeyState(Keys.RButton) == 0 && doingNade == false)
                        {
                            keybd_event((int)'L', 0x9e, 0, UIntPtr.Zero);
                            doingNade = true;
                        }

                        // if its attempt to do a nade
                        if (doingNade == true)
                        {
                            if ((GetAsyncKeyState(Keys.LButton) == 0) && GetAsyncKeyState(Keys.RButton) == 0)
                            {
                                keybd_event((int)'L', 0x9e, KEYEVENTF_KEYUP, UIntPtr.Zero);
                                doingNade = false;
                            }
                        }

                        // If its attempting to spray or is simulating a spray
                        if (GetAsyncKeyState(Keys.LButton) != 0 && GetAsyncKeyState(Keys.RButton) != 0 && currentWeaponSlot < 2)
                        {
                            if (startTime == 0)
                            {
                                startTime = Environment.TickCount;
                            }

                            //If the fire button has been held long enough to activate compensation
                            if (Environment.TickCount - startTime > nudActivationDelay.Value)
                            {
                                WeaponProfile currentWeaponProfile;


                                currentWeaponProfile = weaponProfiles.Where(x => x.name == playerWeapons[currentWeaponSlot].name).FirstOrDefault();

                                // If there is a weapon selected
                                if (currentWeaponProfile != null)
                                {
                                    ScopeEntry currentScopeEntry;


                                    currentScopeEntry = currentWeaponProfile.scopeEntries.Where(x => x.strength == playerWeapons[currentWeaponSlot].scopeStrength).FirstOrDefault();

                                    // If there is a scope available
                                    if (currentScopeEntry != null)
                                    {
                                        if (Environment.TickCount >= nextCompensationTime)
                                        {
                                            mouse_event(MOUSEEVENTF_MOVE, 0, currentScopeEntry.compensationAmount, 0, UIntPtr.Zero);

                                            nextCompensationTime = Environment.TickCount + currentScopeEntry.compensationDelay;
                                        }


                                        if (Environment.TickCount >= nextFireTime)
                                        {
                                            keybd_event((int)'L', 0x9e, 0, UIntPtr.Zero);
                                            nextFireTime = Environment.TickCount + (int)currentScopeEntry.fireDelay;
                                            Thread.Sleep(25);
                                        }
                                        else
                                        {
                                            // Do not try to auto fire on a gun that cannot be autofired
                                            if (singleFireWeapons.IndexOf(currentWeaponProfile.name) == -1)
                                            {
                                                keybd_event((int)'L', 0x9e, KEYEVENTF_KEYUP, UIntPtr.Zero);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            // if it didn't shoot
                            if (startTime != 0 && nextFireTime == 0)
                            {
                                keybd_event((int)'L', 0x9e, 0, UIntPtr.Zero);
                                Thread.Sleep(25);
                                keybd_event((int)'L', 0x9e, KEYEVENTF_KEYUP, UIntPtr.Zero);
                            }
                            // If it did shoot, reset the fire key just in case
                            else if (nextFireTime != 0)
                            {
                                keybd_event((int)'L', 0x9e, KEYEVENTF_KEYUP, UIntPtr.Zero);
                            }

                            startTime    = 0;
                            nextFireTime = 0;
                        }
                    }
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.ToString());
                }

                Thread.Sleep(1);
            }
        }
예제 #12
0
파일: Gun.cs 프로젝트: Arghonot/Battlefront
 public void Initialize(WeaponProfile profile)
 {
     bulletVelocity = profile.bulletVelocity;
     loadingTime    = profile.loadingTime;
 }