示例#1
0
        public void EndEmergencyRepairEffects()
        {
            m_EmergencyRepairTimer = null;
            m_Hits = m_PreRepairHits;
            m_PreRepairHits = 0;
            ComputeDamage();

            SendMessageToAllOnBoard(1116765);  //The emergency repairs have given out!
        }
示例#2
0
        public void TryRepairs(Mobile from)
        {
			if(from == null || from.Backpack == null)
				return;
				
			Container pack = from.Backpack;
            Container hold = m_GalleonHold;
            Container secure = SecureContainer;

            double wood = 0;
            double cloth = 0;

            for(int i = 0; i < WoodTypes.Length; i++)
            {
                Type type = WoodTypes[i];
                if (pack != null) wood += pack.GetAmount(type);
                if (hold != null) wood += hold.GetAmount(type);
                if (secure != null) wood += secure.GetAmount(type);
            }

            for (int i = 0; i < ClothTypes.Length; i++)
            {
                Type type = ClothTypes[i];
                if (pack != null) cloth += pack.GetAmount(type);
                if (hold != null) cloth += hold.GetAmount(type);
                if (secure != null) cloth += secure.GetAmount(type);
            }

			//Now, how much do they need for 100% repair
			double woodNeeded = WoodPer * (100.0 - Durability);
			double clothNeeded = ClothPer * (100.0 - Durability);
			
			//Apply skill bonus
			woodNeeded -= ((double)from.Skills[SkillName.Carpentry].Value / 200.0) * woodNeeded;
			clothNeeded -= ((double)from.Skills[SkillName.Tailoring].Value / 200.0) * clothNeeded;
			
			//get 10% of needed repairs
			double minWood = woodNeeded / 10;
			double minCloth = clothNeeded / 10;
			
			if(wood < minWood || cloth < minCloth)
			{
                from.SendLocalizedMessage(1116593, String.Format("{0}\t{1}", ((int)minCloth).ToString(), ((int)minWood).ToString())); //You need a minimum of ~1_CLOTH~ yards of cloth and ~2_WOOD~ pieces of lumber to effect repairs to this ship.
				return;
			}
			
			double percWood, percCloth, woodUsed, clothUsed;
			
			if(wood >= woodNeeded)
			{
				woodUsed = woodNeeded;
				percWood = 100;
            }
			else
			{
				woodUsed = wood;
				percWood = (wood / woodNeeded) * 100;
			}
				
			if(cloth >= clothNeeded)
			{
				clothUsed = clothNeeded;
				percCloth = 100;
			}
			else
			{
				clothUsed = cloth;
				percCloth = (cloth / clothNeeded) * 100;
			}

            if (clothUsed > woodUsed)
            {
                clothUsed = woodUsed;
                percCloth = percWood;
            }
            else if (woodUsed > clothUsed)
            {
                woodUsed = clothUsed;
                percWood = percCloth;
            }
			
			//Average out percentage
			double totalPerc = (percWood + percCloth) / 2;
            double toConsume = 0;
            double woodTemp = woodUsed;
            double clothTemp = clothUsed;

            #region Consume
            for (int i = 0; i < WoodTypes.Length; i++)
            {
                Type type = WoodTypes[i];

                if (woodUsed <= 0)
                    break;

                if (pack != null && woodUsed > 0 && pack.GetAmount(type) > 0)
                {
                    toConsume = Math.Min(woodUsed, pack.GetAmount(type));
                    pack.ConsumeTotal(type, (int)toConsume);
                    woodUsed -= toConsume;
                }
                if (hold != null && woodUsed > 0 && hold.GetAmount(type) > 0)
                {
                    toConsume = Math.Min(woodUsed, hold.GetAmount(type));
                    hold.ConsumeTotal(type, (int)toConsume);
                    woodUsed -= toConsume;
                }
                if (secure != null && woodUsed > 0 && secure.GetAmount(type) > 0)
                {
                    toConsume = Math.Min(woodUsed, secure.GetAmount(type));
                    secure.ConsumeTotal(type, (int)toConsume);
                    woodUsed -= toConsume;
                }
            }

            for (int i = 0; i < ClothTypes.Length; i++)
            {
                Type type = ClothTypes[i];

                if (clothUsed <= 0)
                    break;

                if (pack != null && clothUsed > 0 && pack.GetAmount(type) > 0)
                {
                    toConsume = Math.Min(clothUsed, pack.GetAmount(type));
                    pack.ConsumeTotal(type, (int)toConsume);
                    clothUsed -= toConsume;
                }
                if (hold != null && clothUsed > 0 && hold.GetAmount(type) > 0)
                {
                    toConsume = Math.Min(clothUsed, hold.GetAmount(type));
                    hold.ConsumeTotal(type, (int)toConsume);
                    clothUsed -= toConsume;
                }
                if (secure != null && clothUsed > 0 && secure.GetAmount(type) > 0)
                {
                    toConsume = Math.Min(clothUsed, secure.GetAmount(type));
                    secure.ConsumeTotal(type, (int)toConsume);
                    clothUsed -= toConsume;
                }
            }
            #endregion

            m_Hits += (int)((MaxHits - m_Hits) * (totalPerc / 100));
			if(m_Hits > MaxHits) m_Hits = MaxHits;
			ComputeDamage();
			
			totalPerc += Durability;

			if(totalPerc > 100) 
                totalPerc = 100;

            if (m_EmergencyRepairTimer != null)
            {
                m_EmergencyRepairTimer.Stop();
                m_EmergencyRepairTimer = null;
            }
		
            string args = String.Format("{0}\t{1}\t{2}", ((int)clothTemp).ToString(), ((int)woodTemp).ToString(), ((int)totalPerc).ToString());
            from.SendLocalizedMessage(1116598, args); //You effect permanent repairs using ~1_CLOTH~ yards of cloth and ~2_WOOD~ pieces of lumber. The ship is now ~3_DMGPCT~% repaired.
        }
示例#3
0
        public bool TryEmergencyRepair(Mobile from)
        {
            if (from == null || from.Backpack == null)
                return false;

            int clothNeeded = EmergencyRepairClothCost;
            int woodNeeded = EmergencyRepairWoodCost;
            Container pack = from.Backpack;
            Container hold = m_GalleonHold;
            TimeSpan ts = EmergencyRepairSpan;

            int wood1 = pack.GetAmount(typeof(Board));
            int wood2 = pack.GetAmount(typeof(Log));
            int wood3 = 0; int wood4 = 0;

            int cloth1 = pack.GetAmount(typeof(Cloth));
            int cloth2 = pack.GetAmount(typeof(UncutCloth));
            int cloth3 = 0; int cloth4 = 0;

            if (hold != null)
            {
                wood3 = hold.GetAmount(typeof(Board));
                wood4 = hold.GetAmount(typeof(Log));
                cloth3 = hold.GetAmount(typeof(Cloth));
                cloth4 = hold.GetAmount(typeof(UncutCloth));
            }

            int totalWood = wood1 + wood2 + wood3 + wood4;
            int totalCloth = cloth1 + cloth2 + cloth3 + cloth4;

            if (totalWood >= woodNeeded && totalCloth >= clothNeeded)
            {
                int toConsume = 0;

                if (woodNeeded > 0 && wood1 > 0)
                {
                    toConsume = Math.Min(woodNeeded, wood1);
                    pack.ConsumeTotal(typeof(Board), toConsume);
                    woodNeeded -= toConsume;
                }
                if (woodNeeded > 0 && wood2 > 0)
                {
                    toConsume = Math.Min(woodNeeded, wood2);
                    pack.ConsumeTotal(typeof(Log), toConsume);
                    woodNeeded -= toConsume;
                }
                if (hold != null && woodNeeded > 0 && wood3 > 0)
                {
                    toConsume = Math.Min(woodNeeded, wood3);
                    hold.ConsumeTotal(typeof(Board), toConsume);
                    woodNeeded -= toConsume;
                }
                if (hold != null && woodNeeded > 0 && wood4 > 0)
                {
                    toConsume = Math.Min(woodNeeded, wood4);
                    hold.ConsumeTotal(typeof(Log), toConsume);
                }
                if (clothNeeded > 0 && cloth1 > 0)
                {
                    toConsume = Math.Min(clothNeeded, cloth1);
                    pack.ConsumeTotal(typeof(Cloth), toConsume);
                    clothNeeded -= toConsume;
                }
                if (clothNeeded > 0 && cloth2 > 0)
                {
                    toConsume = Math.Min(clothNeeded, cloth2);
                    pack.ConsumeTotal(typeof(UncutCloth), toConsume);
                    clothNeeded -= toConsume;
                }
                if (hold != null && clothNeeded > 0 && cloth3 > 0)
                {
                    toConsume = Math.Min(clothNeeded, cloth3);
                    hold.ConsumeTotal(typeof(Cloth), toConsume);
                    clothNeeded -= toConsume;
                }
                if (hold != null && clothNeeded > 0 && cloth4 > 0)
                {
                    toConsume = Math.Min(clothNeeded, cloth4);
                    hold.ConsumeTotal(typeof(UncutCloth), toConsume);
                }

                from.SendLocalizedMessage(1116592, ts.TotalMinutes.ToString()); //Your ship is underway with emergency repairs holding for an estimated ~1_TIME~ more minutes.
                m_PreRepairHits = m_Hits;
                m_Hits = (int)(MaxHits * .40);
                m_EmergencyRepairTimer = new EmergencyRepairDamageTimer(this, ts);
                ComputeDamage();
                return true;
            }
            return false;
        }