dice_roll.txt
snippets · 8.8 KB · 2010-03-30
Dice roll by Silence Tyire: rolls a pair of dice and gives a hit/damage roll bonus based on the result.
Download « Back to the snippets list
/***
Coder: --Silence Tyire
How it works: Rolls a pair of dice and gives the character a hr/dr buffer
based off of what the number was rolled on each die.
It displays the the die numbers to the char and prevents
them from rolling multiple times to have an outrageous
hr/dr buff.
I always thought that thief's/assassins/rogues/whatever your MU* calls them
should have their own hr/dr buffer, so I wrote this simple skill:
***/
/***
I put this in fight.c, but I'm sure it'll work in any file.
***/
void do_dice_roll(CHAR_DATA *ch, char *argument)
{
AFFECT_DATA af;
if(IS_AFFECTED2(ch, AFF2_DICED))
{
stc("You must wait to roll again.", ch);
return;
}
/***Hitroll***/
switch(number_range(0,5))
{
case (0):
stc("{cYou roll a {W[{D1{W]{x ", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_HITROLL;
af.modifier = 5 + (ch->perm_stat[STAT_DEX] / 6);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his first dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (1):
stc("{cYou roll a {W[{D2{W]{x ", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_HITROLL;
af.modifier = 10 + (ch->perm_stat[STAT_DEX] / 5);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his first dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (2):
stc("{cYou roll a {W[{D3{W]{x ", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_HITROLL;
af.modifier = 15 + (ch->perm_stat[STAT_DEX] / 4);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his first dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (3):
stc("{cYou roll a {W[{D4{W]{x ", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_HITROLL;
af.modifier = 20 + (ch->perm_stat[STAT_DEX] / 3);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his first dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (4):
stc("{cYou roll a {W[{D5{W]{x ", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_HITROLL;
af.modifier = 25 + (ch->perm_stat[STAT_DEX] / 2);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his first dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (5):
stc("{cYou roll a {W[{D6{W]{x ", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_HITROLL;
af.modifier = 30 + (ch->perm_stat[STAT_DEX] / 1);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his first dice.", NULL, NULL, NULL, TO_ROOM);
break;
}
/***Damroll***/
switch(number_range(0,5))
{
case (0):
stc("{cand a {W[{D1{W]{x\n\r", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_DAMROLL;
af.modifier = 5 + (ch->perm_stat[STAT_STR] / 6);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his second dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (1):
stc("{cand a {W[{D2{W]{x\n\r", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_DAMROLL;
af.modifier = 10 + (ch->perm_stat[STAT_STR] / 5);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his second dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (2):
stc("{cand a {W[{D3{W]{x\n\r", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_DAMROLL;
af.modifier = 15 + (ch->perm_stat[STAT_STR] / 4);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his second dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (3):
stc("{cand a {W[{D4{W]{x\n\r", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_DAMROLL;
af.modifier = 20 + (ch->perm_stat[STAT_STR] / 3);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his second dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (4):
stc("{cand a {W[{D5{W]{x\n\r", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_DAMROLL;
af.modifier = 25 + (ch->perm_stat[STAT_STR] / 2);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his second dice.", NULL, NULL, NULL, TO_ROOM);
break;
case (5):
stc("{cand a {W[{D6{W]{x\n\r", ch);
af.where = TO_AFFECTS2;
af.type = gsn_dice_roll;
af.level = ch->level;
af.duration = 30;
af.location = APPLY_DAMROLL;
af.modifier = 30 + (ch->perm_stat[STAT_STR] / 1);
af.bitvector = AFF2_DICED;
affect_to_char (ch, &af);
act ("$n rolls his second dice.", NULL, NULL, NULL, TO_ROOM);
break;
}
return;
}
/***
in merc.h define the aff_diced and set the gsn. I don't have the unlimited bits code so mine is defined as an aff2
***/
#define AFF2_DICED (G)
/***
With the other gsn_defines (mine is under the gsn_third_attack)
***/
extern sh_int gsn_dice_roll;
/***
in const.c set the skill
I have 5 classes, be sure to set or remove the class gains according
to how your mud is set.
***/
{
"dice roll", {-1, -1, 13, -1, -1}, { 0, 0, 4, 0, 0},
spell_null, TAR_IGNORE, POS_STANDING,
&gsn_dice_roll, SLOT (0), 0, 24,
"dice roll", "!dice roll", ""},
/***
in db.c define the gsn again (mine is below gsn_third_attack)
***/
sh_int gsn_dice_roll;
/***
in handler.c under 'char *affect_bit_name (int vector)'
define the aff2_diced
***/
if (vector & AFF2_DICED)
strcat (buf, " dice_roll");
/***
in tables.c set the flag type for dice_roll under
'const struct flag_type affect_flags[] '
***/
{"dice_roll", G, TRUE},
/***
Make sure you have it defined in interp.c and interp.h
run a clean compile, and you have a new hr/dr buffer
***/