Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Critical Hit

Critical Hit

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Rayze   (9 posts)  Bio
Date Thu 01 May 2003 02:13 PM (UTC)

Amended on Thu 01 May 2003 02:15 PM (UTC) by Rayze

Message
Alright, I downloaded Josh Jenk's critical strike snippet from kyndig, it works fine... except that it just says theres a critical strike and doesn't do any damage at all.
Help on how to add the damage would be greatly appreciated, thanks. Heres the code.

in fight.c
/*
* Critical Hit Snippet
* By Josh Jenks [ Haelyn ]
*/
if ( diceroll == 19 )
{
act( AT_FIRE, "You critically hit $N!", ch, NULL, victim, TO_CHAR );
act( AT_FIRE, "$n critically hits you!", ch, NULL, victim, TO_VICT );
act( AT_FIRE, "$n critically hits $N!", ch, NULL, victim, TO_NOTVICT );
dam = dam*2;
}

Thanks Again,

Rayze
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #1 on Sat 03 May 2003 01:27 AM (UTC)
Message
Where exactly in fight.c is this located? Posting the 5 lines or so above your added snippet should help us find where you're at. It's likely that your code is simply in the wrong place in the function. Too 'high' would have it doubling 0, too 'low' would have it doubling damage after it was already delt.
Top

Posted by Rayze   (9 posts)  Bio
Date Reply #2 on Sat 03 May 2003 01:25 PM (UTC)
Message
/*
* Hit.
* Calc damage.
*/
/*
* Hit.
* Calc damage.
*/

if ( !wield ) /* bare hand dice formula fixed by Thoric */
dam = number_range( ch->barenumdie, ch->baresizedie * ch->barenumdie );
else
dam = number_range( wield->value[1], wield->value[2] );


Right after that.

Rayze
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #3 on Mon 04 Aug 2003 04:01 AM (UTC)
Message
I used the same snippet from the same site, put it in the same place in fight.c, but i get this error when i recompile it. Can anyone help me out?

fight.c: In function 'one_hit" :
fight.c 4265: parse error at end of input
make[1]: *** [o/fight.o] Error 1
make: *** [all] Error 2

Did he mess up something or have I somehow messed up.
I'm compiling with Cygwin in Windows XP

Help would be mucho appreciated.


Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #4 on Mon 04 Aug 2003 06:42 AM (UTC)
Message
Ok I'm an idiot I had an obvious typo jammed in there that I didn't noticed but it's installed now. However I have the same problem with it not doing any damage at all.

I tried changing the line dam = dam*2;
To dam = 2 * dam;

Because I think that is the right command, however it still doesn't work.

Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #5 on Mon 04 Aug 2003 08:18 AM (UTC)

Amended on Mon 04 Aug 2003 08:19 AM (UTC) by Nick Gammon

Message
For a start, all these are the same:

dam = dam * 2;
dam = 2 * dam;
dam *= 2;


The code looks OK, however maybe it got modified later? For instance, maybe this changed it back ...


    else
        dam = ris_damage( victim, dam, RIS_NONMAGIC );


I would put in some displays to see what is happening. eg.

printf ("At point 1 dam = %i\n", dam);

...

printf ("At point 2 dam = %i\n", dam);


Then see whether the calculation was made, and if so, where it was changed.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #6 on Mon 04 Aug 2003 10:00 AM (UTC)
Message
I really appreciate the help man, but I'm a coding newbie if it wasn't obvious by this point :P
Where do I put those commands you posted?
And how do the provide me the information I want?

Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #7 on Mon 04 Aug 2003 06:50 PM (UTC)
Message
Alright, take a look at mine and try it instead of that one, since this is the one that I use (I run SWR though).


  /*
   * Critical Hit -- Add onto by randomizing the critical hit and damage...
   *  By: Josh Jenks [Haelyn]...snippet for SMAUG 1.4a
   *  Added in and changed by Odis
   */
    if ( diceroll >= 19 )
    {
        int place;
        place = number_range( 1, 4 );

        if ( place == 1 )
        {
        act( AT_FIRE, "You hit $N's hand!", ch, NULL, victim, TO_CHAR  );
        act( AT_FIRE, "$n hits your hand!", ch, NULL, victim, TO_VICT );
        act( AT_FIRE, "$n hits $N's!", ch, NULL, victim, TO_NOTVICT );
        dam *= 1.5;
        }

        else if ( place == 2 )
        {
        act( AT_FIRE, "You critically hit $N in the chest!", ch, NULL, victim, TO_CHAR  );
        act( AT_FIRE, "$n critically hits you in the chest!", ch, NULL, victim, TO_VICT );
        act( AT_FIRE, "$n critically hits $N in the chest!", ch, NULL, victim, TO_NOTVICT );
        dam *= 2;
        }

        else if ( place == 3 )
        {
        act( AT_FIRE, "You bash $N's head!", ch, NULL, victim, TO_CHAR  );
        act( AT_FIRE, "$n bashes your head!", ch, NULL, victim, TO_VICT );
        act( AT_FIRE, "$n bashes $N's head!", ch, NULL, victim, TO_NOTVICT );
        dam *= 3;
        }

        else if( place == 4 )
        {
        act( AT_FIRE, "You mutilate $N's groin!", ch, NULL, victim, TO_CHAR  );
        act( AT_FIRE, "$n mutilates you in the groin!", ch, NULL, victim, TO_VICT );
        act( AT_FIRE, "$n mutilates $N's groin!", ch, NULL, victim, TO_NOTVICT );
        dam *= 2;
        }
    }



Thats the one that I have and it works for me, so you might try it. Just a suggestion. I don't really know why he made it just 19's only, I changed it to 19-20. Good luck.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #8 on Mon 04 Aug 2003 07:21 PM (UTC)
Message
Thanks alot man, but what file did you put it in and where?

I'm going to try jamming it in fight.c where the other one went. Hope it works

*Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"

Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #9 on Mon 04 Aug 2003 08:12 PM (UTC)
Message
Ok I've been testing this out for 20 minutes or so with a couple char's on my mud :Steve & Carl that I made to for this purpose, here's what I've found:

When it returns the "Steve mutilates you in the groin! or chest/head/hand" Value alone, there is no damage dealt at all, as you can see here.

<1397hp 100m 255mv>
Steve critically hits you in the chest!
The Cunning of Gravoc succors your learning.
Your slash barely scratches Steve.
The Cunning of Gravoc succors your learning.

<1397hp 100m 254mv>
Your slash scratches Steve.

However, when that message of a critical hit is sent *AND* a regular attack is landed it appears to double or triple the damage accordingly as is shown here:


<1451hp 100m 251mv>
Steve's slash barely scratches you. <-6 damage received

<1445hp 100m 249mv> <-8 damage received
Steve's slash barely scratches you.
Your slash barely scratches Steve.

<1437hp 100m 248mv>
You are thirsty.

<1442hp 100m 256mv> <-7 damage received
Steve's slash barely scratches you.

<1435hp 100m 255mv> <-20 damage received
Steve mutilates you in the groin! Attack Landed
Steve's slash scratches you. &
Critical Message
<1415hp 100m 254mv>
Steve drinks deeply from the flow of mystical water.

The occurrence of a critical hit attack occurring in the same round as a regular attack was much less frequent than a critical hit message with no attack and no damage.
I hope this clears things up a bit for anyone who is interested. I can only assume that the snippet is not rolling a 20 side die once for a critical hit but rolling a 20 side die twice, once to determine if a critical hit is made ie roll =19 and then again to see if you land a hit but I'm not sure if this roll is against the die again ie must =19 to hit, or using your thac0 and thac32. Anyways, whatever it is I have absolutely no idea how to fix it, but I hope someone out there does.


Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #10 on Mon 04 Aug 2003 08:15 PM (UTC)
Message
ahh that last part came out mangled here it is again


<1435hp 100m 255mv>
Steve mutilates you in the groin!
Steve's slash scratches you.

<1415hp 100m 254mv>
Steve drinks deeply from the flow of mystical water.

^
|
20 damage dealt when regular hit and critical message appear together, compared to the 5, 7 , and 8, damage of the other 3 attacks, which were consisent the ones before and after, all in the 4 - 9 damage range.

Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


27,732 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.