AddUsedItems() public static method

public static AddUsedItems ( Hunt hunt, Dictionary usedItems ) : void
hunt Hunt
usedItems Dictionary
return void
Ejemplo n.º 1
0
        public static void UpdateUsedItems()
        {
            // Update the used items based on the equipment currently equiped
            // Update used ammunition
            // First, check the currently equipped ammunition (if any) and how much ammunition is equipped
            int  newCount     = MemoryReader.AmmunitionCount;
            int  ammunitionID = MemoryReader.AmmunitionType;
            Item item         = StorageManager.getItemFromTibiaID(ammunitionID);

            if (newCount > 0)
            {
                //if there is any ammunition equipped, and the current ammunition count is smaller than the previous ammunition count
                //AND the same ammunition type is equipped; then ammunition has been fired
                if (newCount < ammunitionCount && item != null && currentAmmunition == item)
                {
                    // add the used ammunition to the used items of the current hunt
                    int waste = ammunitionCount - newCount;
                    HuntManager.AddUsedItems(HuntManager.activeHunt, currentAmmunition, waste);
                }
                currentAmmunition = item;
                ammunitionCount   = newCount;
            }
            // do the same for the weapon slot, for throwing weapons/spears
            newCount = MemoryReader.WeaponCount;
            int  weaponID = MemoryReader.WeaponType;
            Item weapon   = StorageManager.getItemFromTibiaID(weaponID);

            if (newCount > 0)
            {
                if (newCount < weaponCount && weapon != null && currentWeapon == weapon)
                {
                    int waste = weaponCount - newCount;
                    HuntManager.AddUsedItems(HuntManager.activeHunt, currentWeapon, waste);
                }
                currentWeapon = weapon;
                weaponCount   = newCount;
            }
        }
Ejemplo n.º 2
0
        public static ParseMemoryResults ParseLogResults(ReadMemoryResults res)
        {
            if (res == null)
            {
                return(null);
            }
            ParseMemoryResults o = new ParseMemoryResults();

            // first we add the new parsed damage logs to the totalDamageResults
            o.newDamage = GlobalDataManager.UpdateDamageInformation(res.damageDealt);
            // now that we have updated the damage results, fill in the DPS meter, we use damage from the last 15 minutes for this
            List <string> times = TimestampManager.getLatestTimes(15);

            GlobalDataManager.GenerateDamageResults(o.damagePerSecond, times);

            // similar to damage, we keep a totalExperienceResults list
            // first update it with the new information
            int newExperience = GlobalDataManager.UpdateExperience(res.exp);

            // now compute the experience per hour
            // we use the same formula Tibia itself does so we get the same value
            // this formula is basically, take the experience in the last 15 minutes and multiply it by 4
            o.expPerHour = GlobalDataManager.GetExperiencePerHour();

            // Parse event messages
            foreach (Tuple <Event, string> newEvent in GlobalDataManager.UpdateEventInformation(res.eventMessages))
            {
                o.newEventMessages.Add(newEvent);
            }

            // Update the look information
            foreach (string newLook in GlobalDataManager.UpdateLookInformation(res.lookMessages))
            {
                o.newLooks.Add(newLook);
            }

            // Update death information
            o.death = GlobalDataManager.UpdateDeaths(res.deaths);

            // now parse any new commands given by users
            foreach (string newCommand in GlobalDataManager.UpdateCommands(res.commands))
            {
                o.newCommands.Add(newCommand);
            }

            // check new urls
            GlobalDataManager.UpdateURLs(res.urls);


            HuntManager.AddUsedItems(HuntManager.activeHunt, res.usingMessages);
            Parser.ParseLootMessages(HuntManager.activeHunt, res.itemDrops, o.newItems, true, true);
            HuntManager.activeHunt.totalExp += newExperience;

            readWatch.Stop();
            if (newExperience == 0)
            {
                if (ticksSinceExperience < 120)
                {
                    ticksSinceExperience += readWatch.Elapsed.TotalSeconds;
                }
            }
            else
            {
                ticksSinceExperience = 0;
            }
            if (ticksSinceExperience < 120)
            {
                HuntManager.activeHunt.totalTime += readWatch.Elapsed.TotalSeconds;
            }
            readWatch.Restart();
            HuntManager.SaveHunts();
            return(o);
        }