Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function int Dakka_PickupArmor(int whichArmor, int count)
- {
- int armor = DakkaKnownArmors[whichArmor][0];
- int armorMode = DakkaArmorValues[whichArmor][ARM_COMPAREMODE];
- int armorType = DakkaArmorValues[whichArmor][ARM_TYPE];
- int armorGive = DakkaArmorValues[whichArmor][ARM_PICKUPPOINTS];
- int armorMax = DakkaArmorValues[whichArmor][ARM_MAXPOINTS];
- int armorRatio = DakkaArmorValues[whichArmor][ARM_PROTECTION];
- if (armorGive == 0) { return 0; }
- int fromIndex = getCurrentArmorIndex();
- int fromPoints = CheckInventory("Armor");
- int fromArmor, fromRatio, fromScore;
- // If we don't know what armor he has, assume he has none since no other
- // assumption would be sensible.
- if (fromIndex == -1)
- {
- fromArmor = "";
- fromRatio = 0;
- fromScore = 0;
- }
- else
- {
- fromArmor = DakkaKnownArmors[fromIndex][0];
- fromRatio = DakkaArmorValues[fromIndex][ARM_PROTECTION];
- fromScore = dak_armorscore(fromRatio, fromPoints, armorMode);
- }
- int toPoints = min(fromPoints + (count * armorGive), armorMax);
- int toScore = dak_armorscore(toRatio, toPoints, armorMode);
- // If we don't actually gain anything from picking up this armor, abort.
- if (fromScore >= toScore) { return 0; }
- int endArmor;
- /*
- * If the player has no known armor at this point, we assume he has no armor.
- * The armor he will end up with is the armor being given, without question.
- *
- * If the player has known armor, and this pickup is considered a bonus,
- * the ending armor type is the current armor.
- *
- * Otherwise, since we've determined that we're gaining something from this
- * new armor, the end armor is the armor we're giving.
- */
- if (fromIndex == -1) { endArmor = armor; }
- else switch (armorType)
- {
- case ATYPE_BONUS: endArmor = fromArmor; break;
- default: endArmor = armor; break;
- }
- // We now know what armor value we're ending at, and what armor type it is.
- if (!strcmp(endArmor, fromArmor))
- {
- GiveInventory("Dakka_OneArmor", toPoints - fromPoints);
- }
- else
- {
- TakeInventory("BasicArmor", 0x7FFFFFFF);
- GiveInventory(endArmor, 1);
- int curArmor = CheckInventory("Armor");
- if (curArmor < endPoints)
- {
- GiveInventory("Dakka_OneArmor", endPoints - curArmor);
- }
- else
- {
- TakeInventory("BasicArmor", curArmor - endPoints);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment