Rough Mobs Revamped

Rough Mobs Revamped

2M Downloads

[Feature Request] randomly set complete armor set

0xebjc opened this issue ยท 2 comments

commented

Something that would be nice to have, even if the probability is set low for armor prices it would be nice if this random change might set a complete armor set, so entities don't always have just one or two pieces, and the only way for them to get a complete set is set it so pretty much ever spawn has most or all sets of armor. Here's the code I came up with to make this work:

In EquipHelper just above 'public void equipEntity:

		public boolean getChance(int chanceDenominator) {
			if (chanceDenominator <= 0) {
				return false;
			}
			return Math.random() <= (float)1/(float)chanceDenominator;
		}

And then in the equipEntity function:

			// If chance passes, then equip entity with complete set of armor
			boolean completeArmorSet = getChance(chancePerPiece);

			for (int i = 0; i < pools.length; i++) 
			{
				EquipmentPool pool = pools[i];
				EntityEquipmentSlot slot = EntityEquipmentSlot.values()[i];
				
				int rnd = i <= 1 ? chancePerWeapon : chancePerPiece;
				if (getChance(rnd) || (completeArmorSet && i > 1))
				{
					ItemStack stack = pool.getRandom(entity, enchChance, enchMultiplier);
					
					if (stack != null) 
					{
						entity.setItemStackToSlot(slot, stack);
						entity.setDropChance(slot, dropChance);
					}
				}
			}
commented

Nice. Great idea. I'll add it when I get a chance, and credit it to you.

commented

Added in 2.2.9