//sample function for creating new armor public void ExpandArmor() { Armor platinumBracelet = new Armor(12, FF1Text.TextToBytes("Plat"), ArmorIcon.BRACELET, 1, 42, 0, 0); platinumBracelet.setClassUsability((ushort)( EquipPermission.BlackBelt | EquipPermission.BlackMage | EquipPermission.BlackWizard | EquipPermission.Fighter | EquipPermission.Knight | EquipPermission.Master | EquipPermission.Ninja | EquipPermission.RedMage | EquipPermission.RedWizard | EquipPermission.Thief | EquipPermission.WhiteMage | EquipPermission.WhiteWizard)); platinumBracelet.writeArmorMemory(this); }
public void RandomArmorBonus(MT19337 rng, int min, int max) { //get base stats Armor currentArmor; for (int i = 0; i < ArmorCount; i++) { currentArmor = new Armor(i, this); int bonus = rng.Between(min, max); if (bonus != 0) { //body armor(indexes 0 - 15) +2/-2 +2/-2 weight //shield(indexes 16 - 24) +1/-1 +1/-1 weight //helm(indexes 25 - 31) +1/-1 +1/-1 weight //hand(indexes 32 - 39) +1/-1 +1/-1 weight int armorTypeAbsorbBonus = i < 16 ? 2 : 1; int armorTypeWeightBonus = i < 16 ? 2 : 1; //adjust stats //clamp minimums to 0 weight, and 1 absorb currentArmor.Weight = (byte)Math.Max(0, currentArmor.Weight - (armorTypeWeightBonus * bonus)); currentArmor.Absorb = (byte)Math.Max(1, currentArmor.Absorb + (armorTypeAbsorbBonus * bonus)); //change last two non icon characters to -/+bonus string bonusString = string.Format((bonus > 0) ? "+{0}" : "{0}", bonus.ToString()); byte[] bonusBytes = FF1Text.TextToBytes(bonusString); int iconIndex = currentArmor.NameBytes[6] > 200 && currentArmor.NameBytes[6] != 255 ? 5 : 6; for (int j = 0; j < bonusBytes.Length - 1; j++) { currentArmor.NameBytes[iconIndex - j] = bonusBytes[bonusBytes.Length - 2 - j]; } currentArmor.writeArmorMemory(this); } } }