Zanthoris' Reroll Snippet


Installation Instructions
-------------------------
1. In character.h at the end of the public section of class CCharacter look for these lines:

    void		EndColorStack ()
				{ m_ColorStack.RemoveAll (); m_Flags.ClrBit (0); }

   and after it add these lines:

    int		GetNumRolls() { return m_NumRolls; }	   // Added by Zanthoris for reroll
    void	AddNumRolls(short h) { m_NumRolls += h; }  // command - 11/21/2000

   then at the end of the private section of the class look for:

    int				m_MobPactnum;		// Used by MOBprogram

   and after it add:

    int				m_NumRolls;         // Added by Zanthoris for reroll
                                                    // command - 11/21/2000

2. In smaug.h look for the following line:

   #define MAX_VROOMS			64

   and add the following line:

   #define MAX_ROLLS			8  // Note - Eight is what I use, you can change it to
                                           // whatever you want to use as your reroll limit
   Also in smaug.h search for:

   DECLARE_DO_FUN(do_report); 

   and below that line add:

   DECLARE_DO_FUN(do_reroll);

3. In player.cpp add the following code:

  void do_reroll(CCharacter *ch, char *argument)
  {
     char buf[MAX_STRING_LENGTH];
     int RollsLeft;

     if (ch->IsNpc())
        return;

     if (ch->GetNumRolls() >= MAX_ROLLS)
     {
        sprintf(buf,"You can only reroll your stats %d times.\n\r", MAX_ROLLS);
		ch->SendText(buf);
        return;
     }
     CRaceData	&Ra = *RaceTable.GetRaceData (ch->GetRace());
     ch->SendText("So, you want to change your stats do you?  Very well!\n\r");
     ch->AddNumRolls(1);
     RollsLeft = MAX_ROLLS - ch->GetNumRolls();
     ch->perm_str = number_range(8, 20);
     ch->perm_int = number_range(8, 20);
     ch->perm_wis = number_range(8, 20);
     ch->perm_dex = number_range(8, 20);
     ch->perm_con = number_range(8, 20);
     ch->perm_cha = number_range(8, 20);
     ch->perm_lck = number_range(8, 20);

     ch->perm_str += Ra.str_plus;
     ch->perm_int += Ra.int_plus;
     ch->perm_wis += Ra.wis_plus;
     ch->perm_dex += Ra.dex_plus;
     ch->perm_con += Ra.con_plus;
     ch->perm_cha += Ra.cha_plus;
     ch->perm_lck += Ra.lck_plus;
     ch->SendText("Your stats have been rerolled, here are your new stats!\n\r");
     sprintf(buf, "%s %d\n\r", "Str: ", ch->perm_str);
     ch->SendText(buf);
     sprintf(buf, "%s %d\n\r", "Int: ", ch->perm_int);
     ch->SendText(buf);
     sprintf(buf, "%s %d\n\r", "Wis: ", ch->perm_wis);
     ch->SendText(buf);
     sprintf(buf, "%s %d\n\r", "Dex: ", ch->perm_dex);
     ch->SendText(buf);
     sprintf(buf, "%s %d\n\r", "Con: ", ch->perm_con);
     ch->SendText(buf);
     sprintf(buf, "%s %d\n\r", "Cha: ", ch->perm_cha);
     ch->SendText(buf);
     sprintf(buf, "%s %d\n\r", "Lck:", ch->perm_lck);
     ch->SendText(buf);
	 sprintf(buf, "%s %d %s\n\r", "You have", RollsLeft, "rerolls left, use them wisely!");
     ch->SendText(buf);
	 return;
  }

4. In skills.cpp search for:

   if (!str_cmp (name, "do_report"))		return do_report;

   and below that line add:

   if (!str_cmp( name, "do_reroll"))       return do_reroll;

   also in skills.c search for:

   if (skill == do_report)			return "do_report";

   and below that line add:

   if (skill == do_reroll)         return "do_reroll";

5.   Rebuild all, then build SmaugWiz.exe

  Thats all there to the coding, now start up your MUD and add the reroll command:

  cedit reroll create
  cedit reroll level 1
  cedit reroll position 0
  cedit reroll log 1
  cedit save

This is my first attempt at a SmaugWiz snippet that isn't ported from an existing smaug
snippet.  It allows characters to reroll their stats up to a certain pre-set number of
times.  This number is set in smaug.h as a const making it easy to adjust at any time.
I chose not to put a level limit on this command, I saw no need for it. I can't imagine why a higher level player would ever want to reroll their stats, especially on my MUD where
they can train stats.  But if they do want to who am I to tell them no? :)

  
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

This snippet was written for and tested on SmaugWiz version 2.01, I cannot guarantee that
it will work in previous versions without some modification (though I expect it will).  If
you have problems with this snippet let me know!

-=Zanthoris=-

zanthoris@hotmail.com
telnet:\\zanthoris.dhs.org:4000
http:\\zanthoris.home.dhs.org