/* Armor 5.0, by XxMoNsTeRXM http://www.jazz2online.com/snippets/123/armor/ */ /*********************************************Armor Script*********************************************/ uint elapsedhealth = 0; uint armorLevel = 0; int defend = 0; const int Tab = 9; array armor = { "Rabbit Fur", "Leather", "Bronze", "Iron", "Your Armor" }; array armorDurabilityMax = { 999999999, 25, 60, 100, //maxDurability for your armor }; array armorDurability = { 999999999, 25, 60, 100, //mainDurability for your armor }; bool alreadyDefended = false; void onLevelBegin() { elapsedhealth = jjLocalPlayers[0].health; } bool inDefense = false; void onMain() { if (jjGameTicks % 140 == 0) { elapsedhealth = p.health; alreadyDefended = false; } if (elapsedhealth > p.health && p.health != 0 && p.health != 1) { if (!alreadyDefended) { defend = jjRandom() % 15 + 1; if (defend == 7) { p.health = p.health + 1; } else if (defend == 4) { if (armorLevel > 0) { p.health = p.health + 1; } } else if (defend == 12) { if (armorLevel > 0) { p.health = p.health + 1; } } else if (defend == 5) { if (armorLevel > 1) { p.health = p.health + 1; } } else if (defend == 15) { if (armorLevel > 2) { p.health = p.health + 1; } } else if (defend == 1) { if (armorLevel > 2) { p.health = p.health + 1; } } else if (defend == /*your defend number*/) { //Note: do not put the same number as another IF in here. if (armorLevel > /*...*/) { //You can understand this. If "armorLevel" is bigger than a certain level. <- p.health = p.health + 1; } } armorDurability[armorLevel] -= jjRandom() % 3 + 1; alreadyDefended = true; } } if (armorDurability[armorLevel] > armorDurabilityMax[armorLevel]) { armorDurability[armorLevel] = armorDurabilityMax[armorLevel]; } if (armorDurability[armorLevel] < 1) { armorLevel = 0; armorDurability[0] = 999999999; } } int defense; bool onDrawScore(jjPLAYER@ p, jjCANVAS@ canvas) { if (jjKey[Tab]) { canvas.drawString(jjSubscreenWidth - 420, jjSubscreenHeight - 300, "Armor Type: " + armor[armorLevel], STRING::SMALL, STRING::NORMAL); switch(armorLevel) { case 0: defense = 1; break; case 1: defense = 3; break; case 2: defense = 4; break; case 3: defense = 6; break; } canvas.drawString(jjSubscreenWidth - 420, jjSubscreenHeight - 280, "Defense: " + defense, STRING::SMALL, STRING::NORMAL); if (armorLevel != 0) { canvas.drawString(jjSubscreenWidth - 420, jjSubscreenHeight - 260, "Durability: " + armorDurability[armorLevel], STRING::SMALL, STRING::NORMAL); } else { canvas.drawString(jjSubscreenWidth - 420, jjSubscreenHeight - 260, "Durability: ^", STRING::SMALL, STRING::NORMAL); } } return true; } void onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ p, int force) { switch(obj.eventID) { case OBJECT::CHIPS: armorLevel = jjRandom() % 4; armorDurability[armorLevel] = armorDurabilityMax[armorLevel]; obj.scriptedCollisions = false; obj.behavior = BEHAVIOR::EXPLOSION2; obj.frameID = 0; jjSample(p.xPos, p.yPos, SOUND::COMMON_PICKUPW1, 30); jjAlert("Equipped " + armor[armorLevel] + " Armour!"); break; } } /*You can always add different methods to get a certain armor. I just put that if you collect chips it will equip a random armor.*/ /***************************************************************************************************************************************/