Parry and Dodge Fix

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
4 years 7 months ago #4526 by Papaya Pete
Parry and Dodge Fix was created by Papaya Pete
I have to apologize ahead of time; I didn't test this before trying it out. Once I did, I found that Parry and Dodge were not working properly. Anyways, I put the skill checks in fight.c in the wrong spots; here is where they (hopefully) should go. I've tested this, and it seems to work just fine.
if (diceroll == 20 || !AWAKE(victim))
    dam = TRUE;
  else if (diceroll == 1)
    dam = FALSE;
  else
    dam = (calc_thaco - diceroll <= victim_ac);

+  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) {
+                      send_to_char(ch, "%s parries your blow!\r\n", GET_NAME(victim));
+                      send_to_char(victim, "You parry %s's attack!\r\n", GET_NAME(ch));
+                      dam = FALSE;
+              }
+          }
+          if (GET_SKILL(ch, SKILL_PARRY) > 0) chance = rand_number(1, 100); else chance = 0;
+          if ((chance <= 10) && (GET_SKILL(ch, SKILL_PARRY) < 80) && (GET_SKILL(ch, SKILL_PARRY) > 0)) {
+            send_to_char(ch, "\tGYour parrying skill has gone up!\tn\r\n");
+            GET_SKILL(ch, 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) {
+                    send_to_char(ch, "%s dodges your attack!\r\n", GET_NAME(victim));
+                    send_to_char(victim, "You dodge %s's attack!\r\n", GET_NAME(ch));
+                    dam = FALSE;
+            }
+          }
+          if (GET_SKILL(ch, SKILL_DODGE) > 0) chance = rand_number(1, 100); else chance = 0;
+          if ((chance <= 10) && (GET_SKILL(ch, SKILL_DODGE) < 80) && (GET_SKILL(ch, SKILL_DODGE) > 0)) {
+            send_to_char(ch, "\tGYour dodging skill has gone up!\tn\r\n");
+            GET_SKILL(ch, SKILL_DODGE) += 1;
+          }
+        }
+  }

  if (!dam)
    /* the attacker missed the victim */
    damage(ch, victim, 0, type == SKILL_BACKSTAB ? SKILL_BACKSTAB : w_type);
     else {

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

More
4 years 5 months ago #4665 by RussBrown
Replied by RussBrown on topic Parry and Dodge Fix
FYI. The above code actually improves the attacker's dodge and parry skills. You should be checking victim instead of ch in those sections.
The following user(s) said Thank You: Papaya Pete

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

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
4 years 4 months ago #4724 by Papaya Pete
Replied by Papaya Pete on topic Parry and Dodge Fix
I think I actually found that bug (and forgot to post it), but will definitely double-check. Thanks for the heads up!

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

More
2 years 3 months ago - 2 years 3 months ago #5749 by JTP
Replied by JTP on topic Parry and Dodge Fix
Hmm i tested this short code, one little snag

there is no message showing room that someone parried.
Last edit: 2 years 3 months ago by JTP.

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

More
2 years 3 months ago #5750 by thomas
Replied by thomas on topic Parry and Dodge Fix
That is correct. The code only sends that to the two engaged chars. I suggest you add an act() call near the send_to_char calls if you wish it to also send to others. Search the code for examples of such act() calls.

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

More
7 months 3 weeks ago #7161 by Sascha
Replied by Sascha on topic Parry and Dodge Fix
Question - With something like this, where a "fix" is posted, and then someone later in the thread posts a fix or correction to the fix, is the original post updated? And is the original post in a condition where it works, or are other steps missing? I would love to put in dodge and parry as skills in my game and this is the only reference that comes up in the search function. I'm a newbie coder and looking at this in pieces to ascertain if it's good to go as is (or not) is beyond my confidence level, so any assistance is appreciated. Thanks so much!

Dovie'andi se tovya sagain. After the Breaking MUD, now in beta testing...

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

More
7 months 3 weeks ago - 7 months 3 weeks ago #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:
 /* 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: 7 months 3 weeks ago by WhiskyTest. Reason: spelling

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

Time to create page: 1.731 seconds