private void handleHarvest(PlayerCharacter pc, IncommingMessage msg)
        {
            if (pc.LoginState == PlayerCharacterLoginState.LoginSuccesfull)
            {
                HarvestIncommingMessage msgHarvest = (HarvestIncommingMessage)msg;

                switch (pc.LocationCurrentMap.Name)
                {
                    case ("calindor_startmap.elm"):
                        {
                            switch (msgHarvest.TargetObjectID)
                            {
                                case(138):
                                case (139):
                                    {

                                        ActionDescriptor actDesc = new HarvestActionDescriptor(2000, 1000);
                                        actDesc.AddExperienceDescriptor(new ExperienceDescriptor(EntitySkillType.HarvestingPlants, 3, 15));
                                        HarvestableResourceDescriptor rscDef =
                                            new HarvestableResourceDescriptor(
                                            ItemDefinitionCache.GetItemDefinitionByID(2), actDesc , 1);
                                        pc.HarvestStart(rscDef);
                                        break;
                                    }
                                case (274):
                                    {
                                        ActionDescriptor actDesc = new HarvestActionDescriptor(3000, 1000);
                                        actDesc.AddExperienceDescriptor(new ExperienceDescriptor(EntitySkillType.HarvestingPlants, 10, 25));
                                        HarvestableResourceDescriptor rscDef =
                                            new HarvestableResourceDescriptor(
                                            ItemDefinitionCache.GetItemDefinitionByID(3), actDesc, 1);
                                        pc.HarvestStart(rscDef);
                                        break;
                                    }
                                case (194):
                                    {
                                        ActionDescriptor actDesc = new HarvestActionDescriptor(3000, 1000);
                                        actDesc.AddExperienceDescriptor(new ExperienceDescriptor(EntitySkillType.HarvestingPlants, 10, 25));
                                        HarvestableResourceDescriptor rscDef =
                                            new HarvestableResourceDescriptor(
                                            ItemDefinitionCache.GetItemDefinitionByID(3), actDesc, 2);
                                        pc.HarvestStart(rscDef);
                                        break;
                                    }
                                case (276):
                                    {
                                        ActionDescriptor actDesc = new HarvestActionDescriptor(3000, 1000);
                                        actDesc.AddExperienceDescriptor(new ExperienceDescriptor(EntitySkillType.HarvestingPlants, 8, 20));
                                        HarvestableResourceDescriptor rscDef =
                                            new HarvestableResourceDescriptor(
                                            ItemDefinitionCache.GetItemDefinitionByID(7), actDesc, 1);
                                        pc.HarvestStart(rscDef);
                                        break;
                                    }
                            }
                            break;
                        }
                }
            }
        }
Exemplo n.º 2
0
        public void HarvestStart(HarvestableResourceDescriptor rscDef)
        {
            HarvestTimeBasedAction harvest =
                new HarvestTimeBasedAction(this, rscDef);
            harvest.Activate();

            RawTextOutgoingMessage msgRawText =
                (RawTextOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.RAW_TEXT);
            msgRawText.Channel = PredefinedChannel.CHAT_LOCAL;
            msgRawText.Color = PredefinedColor.Blue1;
            msgRawText.Text = "You started harvesting " + rscDef.HarvestedItem.Name;

            // Add success rate comment
            double successRate = HarvestGetSuccessRate(rscDef);
            if (successRate < 0.5)
            {
                if (successRate < 0.25)
                {
                    msgRawText.Text += " and you feel you will need a lot of luck.";
                }
                else
                {
                    msgRawText.Text += " and you feel you will need some luck.";
                }
            }
            else
                msgRawText.Text += " and you feel confident about it.";

            PutMessageIntoMyQueue(msgRawText);
        }
Exemplo n.º 3
0
 public void HarvestItemHarvested(HarvestableResourceDescriptor rscDef)
 {
     Item itm = new Item(rscDef.HarvestedItem);
     itm.Quantity = rscDef.QuantityPerHarvest;
     InventoryUpdateItem(itm);
     SkillsAwardExperience(rscDef.PerformedAction);
 }
Exemplo n.º 4
0
        public double HarvestGetSuccessRate(HarvestableResourceDescriptor rscDef)
        {
            double _return = 0.0;
            int skillsUsed = 0;
            double skillSuccessRate = 0.0;

            ActionDescriptor actDef = rscDef.PerformedAction;
            foreach (ExperienceDescriptor xpDesc in actDef.ExperienceDescriptors)
            {
                skillsUsed++;
                int levelDiff = skills.GetCurrentLevelDifference(xpDesc.Skill, xpDesc.BaseLevel);

                if (levelDiff < 0)
                    skillSuccessRate = (10.0 + levelDiff) * 0.05; // Linear
                else
                    skillSuccessRate = (20.0 + levelDiff) * 0.025; // Linear

                _return += skillSuccessRate;
            }

            _return /= skillsUsed;

            if (_return < 0.001)
                _return = 0.001; // Always a chance for lucky success 1/1000
            if (_return > 0.995)
                _return = 0.995; // Always a chance for failure 5/1000

            return _return;
        }
Exemplo n.º 5
0
        public uint HarvestGetActionTime(HarvestableResourceDescriptor rscDef)
        {
            ActionDescriptor actDef = rscDef.PerformedAction;

            int _return = 0;
            int skillsUsed = 0;
            int skillTime = 0;

            foreach (ExperienceDescriptor xpDesc in actDef.ExperienceDescriptors)
            {
                skillsUsed++;
                int levelDiff = skills.GetCurrentLevelDifference(xpDesc.Skill, xpDesc.BaseLevel);

                if (levelDiff < 0)
                    skillTime = (int)((-levelDiff) * (actDef.BaseTime / 10)); // Linear
                else
                    skillTime = (int)((-levelDiff) * (actDef.BaseTime / 20)); // Linear

                _return += (int)(actDef.BaseTime + skillTime);
            }

            _return /= skillsUsed;

            if (_return < actDef.MinTime)
                _return = (int)actDef.MinTime; // Can't work faster than min time

            if (_return < 0)
                return 0;
            else
                return (uint)_return;
        }