[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Randomizing messages for a critical hit
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Randomizing messages for a critical hit

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


Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] top

Posted by Boborak   USA  (228 posts)  [Biography] 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. ;-)
[Go to top] top

Posted by Yourdrunkendad   (35 posts)  [Biography] 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"
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] 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.


3,473 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]