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 ➜ Randomizing messages for a critical hit

Randomizing messages for a critical hit

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


Posted by Nick Cash   USA  (626 posts)  Bio
Date Fri 11 Apr 2003 10:58 PM (UTC)
Message
Alright, I was sitting here, at my computer trying to figure out the best way to do this. So I thought, why not post on the forum, they're always helpful. Anyways, perhaps some of you will share your insights on this.

For my mud I added in the basic critical hit that doubles the damage. It was in a snippet found at kyndig.com. Anyways, it just says You critically hit them!, so I wanted to expand it a bit.

So are questions:
I want it to display different messages, for example instead of always hitting them in the chest, it could randomize it and it could hit them in the head and do more damage, or hit them in the foot and only do 1.5x damage instead of double..how would I do that?
Should I just use the rand() function?
If I use rand(), how do I assign the number it generates to a variable that can then be combared in strings?

Any and all help, ideas, suggestions, comments are welcome and will be much appreciated.

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

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #1 on Sat 12 Apr 2003 04:10 AM (UTC)
Message
Here's how I'd do it.

switch(number_range(1,5))
{
case 1:
sprintf(buf, "You hit 'em in the head!");
dmg *= 2;
break;
case 2:
sprintf(buf, "You smashed their face!");
dmg *= 2.5;
break;
case 3:
sprintf(buf, "You hit 'em in the chest!");
dmg *= 1.5;
break;
case 4:
sprintf(buf, "You hit 'em in the groin!");
dmg *= 1.5;
break;
case 5:
sprintf(buf, "You missed and hit their foot!");
dmg *= 0.5;
break;
}

This should help you out. I'm not sure how the code you're using is set up. So if you can't quite figure out what you should do with this code, post the 'critical hit' part you have now, and I'll update this. ;-)
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #2 on Mon 04 Aug 2003 06:56 AM (UTC)
Message
I don't know about him but I'd love the help, I have the same snippet, downloaded from the same spot but there's a problem with it. It says "you critically hit blah blah or they critically hit you, but it doesn't actually do any damage, none at all. Here's the snippet:


1.) Open fight.c
2.) Find the following code:
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] );
And directly after that paste :

/*
* 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;
}
If you know how to make it actually do the damage it's supposed to that would be great, and if you feel like telling me how to incorporated your system for chest/head/face/feet hits as well, I would love you forever :P

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 #3 on Mon 04 Aug 2003 06:56 PM (UTC)
Message
See the other message about the critical hit snippet.

~Nick Cash
http://www.nick-cash.com
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.


13,512 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.