>I have in my mud types of damage, very similar to elemental stuff: fire, >cold, electricity, poison, and just general damage. I have it >bit-vectored, so damage could be both fire and electric, or cold and >poisoned, or something like that. Problem comes around when I come to my >resist _blank_ damage and _blank_ immunity code. If an attack has >multiple qualities to it, but one damage call, how would I reduce a >portion of the damage? >If I am not making sense, let's say I'm in a fight against someone with a >flaming sword. The item "flaming sword" has both bits for fire and >general damage, and has a 3d8 damage roll. But I have fire resistance at >75%; currently, the resistance code will--upon a successfull roll--reduce >damage from a total 3d8 roll, even though some of the damage is due to the >hard steel hitting my head, which fire resistance has nothing to do with! The easiest solution (though not the best ;) is to just declare that non-general damage does a constant percentage of the damage in all cases. So, 75% of the damage from a hit with a flaming sword is fire damage, 25% general. And, 75% of damage from the Vampiric Sword of Blood Sucking is from the energy drain and 25% is general damage. Etc. Then, apply your resistance to that percentage, and if they have immunity, just completely subtract that percentage from the total damage. pseudo-code: /* d = damage */ if (RESIST_FIRE(vict) && IS_SET(wielded(ch), WEAPON_FIRE)) { d = ((d * (.75 / NUM_SPECIALS(wielded(ch)) * (1 - RESIST_VALUE(vict))) + (d * .25) } Then you need the corresponding macros, of which the only interesting ones are NUM_SPECIALS, which figures out how many special attack types the weapon has (usually 1) and RESIST_VALUE, which is the amount of damage negated by the resistance (100% in the case of IMMUNE_xxx). The NUM_SPECIALS lets you have more than one special type on a weapon, say, a Negative Material Plane Mace, which does cold damage and energy drain damage, then splits that 75% non-general damage in half for each. So, the cold damage = 37.5% of the total damage, and the energy drain = 37.5% as well. This shouldn't be too difficult to imp, although it is fairly simplistic. If these weapons have their own flag in the obj file (like an E flag, but sets the special attack type) you could add an extra field to the flag that is a percentage of the total damage that that special attack does on each hit. Then use that percentage instead of a constant. Shouldn't be too much more work. +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST