int shield_check(Character *ch, Character *vict, int type, int w_type) {
int success = FALSE;
struct affected_type af;
int armor_rating = 0; //highest armor rating is 50
int lev = GET_LEVEL(vict);
int ded = (GET_POS(vict) <= POS_STUNNED);
int sht = is_short_wep(GET_EQ(ch, WEAR_WIELD));
global_dam = (ded? global_dam : global_dam/5);
if (!HERE(ch,vict))
return 0;
if (HERE(ch, vict) && is_short_wep(GET_EQ(ch, WEAR_WIELD)) && AFF_FLAGGED(vict, AFF_SHIELD_ICE) && !affected_by_spell(ch, SPELL_PROT_COLD)) {
if (!number(0, 5) && !AFF_FLAGGED(ch, AFF_FROZEN)) {
//SET_BIT_AR(AFF_FLAGS(vict), AFF_FROZEN);
act("You freeze as you touch $N's shield of ice.", FALSE, ch, 0 , vict, TO_CHAR);
act("$N is frozen as $E touches $N's shield of ice.", FALSE, ch, 0, vict, TO_NOTVICT);
act("$N is frozen as $E touches your shield of ice.", FALSE, ch, 0, vict, TO_VICT);
af.location = APPLY_SPEED;
af.expire = HOURS_TO_EXPIRE(1);
af.modifier = -2 * (GET_LEVEL(vict)+1);
af.bitvector = AFF_FROZEN;
af.type = SPELL_DG_AFFECT;
affect_to_char(ch, &af);
}
}
switch (type) {
case SHIELD_BLOCK:
armor_rating = MIN(40, (AFF_FLAGGED(vict, AFF_SHIELD_STATIC) ? 2*apply_ac(vict, WEAR_SHIELD) : apply_ac(vict, WEAR_SHIELD)));
success = (armor_rating ? (number(0, 100) < armor_rating) : 0);
if (success) {
if (IS_SPELL_ATK(w_type) || IS_SPELL_CAST(w_type)) {
act("$N deflects your magic with $S shield!", FALSE, ch, 0, vict, TO_CHAR);
act("You deflect $n's magic with your shield!", FALSE, ch, 0, vict, TO_VICT);
} else {
act("$N blocks your attack with $S shield!", FALSE, ch, 0, vict, TO_CHAR);
act("You block $n's attack with your shield!", FALSE, ch, 0, vict, TO_VICT);
}
}
break;
case SHIELD_REFLECT:
if (AFF_FLAGGED(vict, AFF_FIRE_SHIELD) && (GET_EQ(ch, WEAR_WIELD) && !sht) && (number(1, 81) < lev || ded)) {
act("$N scorches you with $S fire shield.", FALSE, ch, 0, vict, TO_CHAR);
act("You scorch $n with your fire shield.", FALSE, ch, 0, vict, TO_VICT);
return damage(vict, ch, global_dam, TYPE_UNDEFINED);
} else if (AFF_FLAGGED(vict, AFF_SHIELD_THORNS) && (GET_EQ(ch, WEAR_WIELD) && sht) && (number(1, 81) < lev || ded)) {
act("You are shredded by $N's whirling barrier of thorns!", FALSE, ch, 0, vict, TO_CHAR);
act("You shred $n with your whirling barrier of thorns!", FALSE, ch, 0, vict, TO_VICT);
return damage(vict, ch, global_dam, TYPE_UNDEFINED);
} else if (AFF_FLAGGED(vict, AFF_SHIELD_MIRROR) && (IS_SPELL_ATK(w_type) || IS_SPELL_CAST(w_type)) && (number(1, 81) < lev || ded)) {
act("$N's mirror shield reflects your magic back at you!", FALSE, ch, 0, vict, TO_CHAR);
act("You bounce $n's magic right back at $m!", FALSE, ch, 0, vict, TO_VICT);
return damage(vict, ch, global_dam, TYPE_UNDEFINED);
}
break;
case SHIELD_EVADE:
if (AFF_FLAGGED(vict, AFF_SHIELD_HOLY) && (GET_EQ(ch, WEAR_WIELD) && !sht) && (number(1, 101) < lev || ded)) {
act("A golden light moves $N out of your reach!", FALSE, ch, 0, vict, TO_CHAR);
act("A golden light moves you out of $n's reach!", FALSE, ch, 0, vict, TO_VICT);
success = TRUE;
}
break;
default:
break;
}
return success;
}
This is the code from the shield check.
global_dam = the damage that was taken by vict because of ch
So the damage you get attacked with is 20% of the damage you give to them at the moment.
But your damage reduction modifiers do affect how much of that 20% you end up actually taking.
I thought I would put the code up, because this is an interesting topic and if you would like to suggest a tweak on any of the parts of this, you are welcome.
If I can see a way that they would work with 4D, we will add them.