Cornwallis
Member
- Joined
- Jan 3, 2010
- Messages
- 480
- Reaction score
- 16
Hello, I want to make a condition to absorb damage -- and absorb less damage, but I don't know where all I should be looking.
I'm thinking I should edit this to check if the condition is true, and if so then add it to the absorbPercent, which would be simple, and I know I have to add it in condition.cpp,
player.cpp:
So far I've come up with this but I don't know how to get the param for the percent:
I'm thinking I should edit this to check if the condition is true, and if so then add it to the absorbPercent, which would be simple, and I know I have to add it in condition.cpp,
player.cpp:
HTML:
BlockType_t Player::blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
bool checkDefense /* = false*/, bool checkArmor /* = false*/, bool field /* = false*/)
{
BlockType_t blockType = Creature::blockHit(attacker, combatType, damage, checkDefense, checkArmor, field);
if (attacker) {
sendCreatureSquare(attacker, SQ_COLOR_BLACK);
}
if (blockType != BLOCK_NONE) {
return blockType;
}
if (damage > 0) {
for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) {
if (!isItemAbilityEnabled(static_cast<slots_t>(slot))) {
continue;
}
Item* item = inventory[slot];
if (!item) {
continue;
}
const ItemType& it = Item::items[item->getID()];
if (it.abilities) {
const int16_t& absorbPercent = it.abilities->absorbPercent[combatTypeToIndex(combatType)];
if (absorbPercent != 0) {
damage -= std::ceil(damage * (absorbPercent / 100.));
uint16_t charges = item->getCharges();
if (charges != 0) {
g_game.transformItem(item, item->getID(), charges - 1);
}
}
if (field) {
const int16_t& fieldAbsorbPercent = it.abilities->fieldAbsorbPercent[combatTypeToIndex(combatType)];
if (fieldAbsorbPercent != 0) {
damage -= std::ceil(damage * (fieldAbsorbPercent / 100.));
uint16_t charges = item->getCharges();
if (charges != 0) {
g_game.transformItem(item, item->getID(), charges - 1);
}
}
}
}
}
if (damage <= 0) {
damage = 0;
blockType = BLOCK_ARMOR;
}
}
return blockType;
}
So far I've come up with this but I don't know how to get the param for the percent:
HTML:
Condition* condition = getCondition(CONDITION_ABSORBPERCENT, CONDITIONID_DEFAULT);
if (condition) {
absorbPercent +=
Last edited: