Welcome to the Builder Academy

Question Parry and Dodge Fix

More
26 Nov 2017 02:02 - 26 Nov 2017 02:03 #7164 by WhiskyTest
Replied by WhiskyTest on topic Parry and Dodge Fix
Papaya Pete hasn't edited the original post so I would say it hasn't been updated.

With the fixes that were discussed it would look like this:
Code:
/* Decide whether this is a hit or a miss. * Victim asleep = hit, otherwise: * 1 = Automatic miss. * 2..19 = Checked vs. AC. * 20 = Automatic hit. */ if (diceroll == 20 || !AWAKE(victim)) dam = TRUE; else if (diceroll == 1) dam = FALSE; else dam = (calc_thaco - diceroll <= victim_ac); + /* Dodge and Parry Snippet */ + if (dam) { + if (!IS_NPC(victim) && GET_SKILL(victim, SKILL_PARRY) > 0) { + prob = rand_number(1, 101); + if (prob < GET_SKILL(victim, SKILL_PARRY)) { + chance = rand_number(1, 100); + if (chance <= 15) { + act("$N parries your attack!", FALSE, ch, NULL, victim, TO_CHAR); + act("You parry $n's attack!", FALSE, ch, NULL, victim, TO_VICT); + act("$N parries $n's attack!", FALSE, ch, NULL, victim, TO_NOTVICT); + dam = FALSE; + } + } + + if (GET_SKILL(victim, SKILL_PARRY) > 0) + chance = rand_number(1, 100); + else + chance = 0; + + if ((chance <= 10) && (GET_SKILL(victim, SKILL_PARRY) < 80) && (GET_SKILL(victim, SKILL_PARRY) > 0)) { + send_to_char(victim, "\tGYour parrying skill has gone up!\tn\r\n"); + GET_SKILL(victim, SKILL_PARRY) += 1; + } + } + else if (!IS_NPC(victim) && GET_SKILL(victim, SKILL_DODGE) > 0) { + prob = rand_number(1, 101); + if (prob < GET_SKILL(victim, SKILL_DODGE)) { + chance = rand_number(1, 100); + if (chance <= 15 ) { + act("$N dodges your attack!", FALSE, ch, NULL, victim, TO_CHAR); + act("You dodge $n's attack!", FALSE, ch, NULL, victim, TO_VICT); + act("$N dodges $n's attack!", FALSE, ch, NULL, victim, TO_NOTVICT); + dam = FALSE; + } + } + + if (GET_SKILL(victim, SKILL_DODGE) > 0) + chance = rand_number(1, 100); + else + chance = 0; + + if ((chance <= 10) && (GET_SKILL(victim, SKILL_DODGE) < 80) && (GET_SKILL(victim, SKILL_DODGE) > 0)) { + send_to_char(victim, "\tGYour dodging skill has gone up!\tn\r\n"); + GET_SKILL(victim, SKILL_DODGE) += 1; + } + } + } + /* End Dodge and Parry */ if (!dam) /* the attacker missed the victim */ damage(ch, victim, 0, type == SKILL_BACKSTAB ? SKILL_BACKSTAB : w_type); else {

This code also assumes you have added the two new skills SKILL_DODGE and SKILL_PARRY.

Other things:
You'd want to test the balance for the frequency of parry and dodge proccing - currently it has a 15% chance to proc provided the character makes their skill check.

Also doesn't check whether you need a weapon to parry.
Dodge will be tested even if parry was successful earlier.

But a great starting point I think.
Last edit: 26 Nov 2017 02:03 by WhiskyTest. Reason: spelling

Please Log in or Create an account to join the conversation.

More
23 May 2025 16:03 #10710 by zi
Replied by zi on topic Parry and Dodge Fix
I've searched for solid snippets but really just wound up cobbling my own together:
Code:
  else    dam = FALSE; /* Dodge Check */   if (dam) {     if (IS_NPC(victim)) {             /* check if a NPC dodges */       if (rand_number(1, 200) < GET_LEVEL(victim) * 2) { // looking at this again i should switch this and the below if           if (GET_POS(victim) > POS_SITTING) {       // should be at least standing or fighting to dodge           act("$N skillfully dodges your attack.", FALSE, ch, 0, victim, TO_CHAR);           act("$N skillfully dodges $n's attack.", FALSE, ch, 0, victim, TO_NOTVICT);           act("You dodge $n's attack.", FALSE, ch, 0, victim, TO_VICT); /* weird... keep for switched?*/           return;           }       }     } else {                          /* check if a player dodges */       if (rand_number(1, 399) <= GET_SKILL(victim, SKILL_DODGE) && // at 100% skill that's a 1 in 4 chance?         GET_POS(victim) > POS_SITTING && !PLR_FLAGGED(victim, PLR_KILLER)) {         act("$N skillfully dodges your attack.", FALSE, ch, 0, victim, TO_CHAR);         act("$N skillfully dodges $n's attack.", FALSE, ch, 0, victim, TO_NOTVICT);         act("You dodge $n's attack.", FALSE, ch, 0, victim, TO_VICT);         improve_skill(ch, SKILL_DODGE);         return;       }     }   }

The dam = FALSE seemed like a good idea but for me it was returning both the act text and the missed attack text (because damage was set to false and we normally interpert that as a miss) so I landed on a return to skip the missed attack call. Am I inviting trouble here?

I check to see if the victim is in fighting or standing position to realistically dodge.

I'm going to mess around with the numbers/logic, but that's the framework.

Please Log in or Create an account to join the conversation.

More
23 May 2025 21:13 #10711 by thomas
Replied by thomas on topic Parry and Dodge Fix
Looks good to me :) Nice work. Is there a special reason pkillers can't dodge?

Please Log in or Create an account to join the conversation.

More
24 May 2025 12:05 #10715 by zi
Replied by zi on topic Parry and Dodge Fix
i'm a no pk mud (unless opted in? that's late stage dev problems!) and players won't last long with the killer flag.

Please Log in or Create an account to join the conversation.

Time to create page: 0.216 seconds