/*
Spell Surging for Spell Casters.. EG: Mages

   I've seen surge code in action for many years while playing (Unnamed Mud).
   But it wasn't until I came across the basic system written by Martin for
   Daleken Mud. Daleken's surge just allowed an off and on setting where as
   on (Unnamed Mud), You can choose to surge between 1 - 5 levels. (Not mud Levels)

   Basicly, this is meant for higher level spell casters and helps them to solo
   a bit easier in a sense, however, if a mob is rather tough, a mage surging at
   level 5 may kill the mobile in one cast, but the cast will take all of thier
   mana so they have to regen. I have tried to balance this surge code to be very
   simular to the mana cost and damage done as compared to my mage on (Unnamed Mud).

Example output from my codebase to give ideas.. (Surge can be given to Mages at Level 25 or so)

- This is based on a Level 7 Elf Mage (test char), casting chill touch which costs 15 mana.

-----------------------
96/96hp 174/174m 188/188mv> look
The Main Street ( City )
[Exits: north east south west]
The main street, to the north is the weapon shop and to the south is the
Guild of Swordsmen.  To the east you leave town and to the west the street
leads to the market square.
(Aggressive) Beastly Fido is here.

96/96hp 174/174m 188/188mv> surge 5
You will now attempt to surge your spells at level 5.

96/96hp 174/174m 188/188mv> c chill fido
Your eyes glow red for an instant!
You chilling touch the beastly fido with terminal brutality!
the beastly fido is DEAD!!
You receive 61 experience points.
You get 14 gold coins from corpse of the beastly fido.

96/96hp 24/174m 188/188mv>
-----------------------
Chill Touch without surge costs 15 mana..
Chill Touch with surge level 5 costs 150 mana.

This was put together in about 5 minutes and tested for only about 10 before I
uploaded here at MudBytes.com.. If you have any ideas for improvement, let me
know..

Chris, 
cbunting99@gmail.com

And yes.. when you rely on surge 5 to kill mobiles and you get... You lost your concentration.
Your DEAD!

 */

// GENERAL DEFINES.. (My files are dif than stock)

// DB.C?
int gsn_surge;


// INTERP.C
{"surge", do_surge, POS_FIGHTING, 0, LOG_NORMAL, 1},


// INTERP.H
DECLARE_DO_FUN (do_surge);


// MERC.H UNDER struct pc_data
int spell_surge;


//MERC.H with the rest of the externs
extern int gsn_surge;


// CONST.C (Change this to fit your setup)
  {				/* 2 */
   "surge", {},
   spell_null, TAR_CHAR_OFFENSIVE, POS_FIGHTING,
   &gsn_surge, 50, 25,
   "", "!surge!"},


// SAVE.C in, void fwrite_char (Mine is below Wiznet)
fprintf (fp, "Surge        %d\n", ch->pcdata->spell_surge);


// SAVE.C in, bool load_char_obj (Mine is below security for OLC, condition ect..)
ch->pcdata->spell_surge = 0;


// SAVE.C in, void fread_char (Under CASE S')
KEY ("Surge", ch->pcdata->spell_surge, fread_number (fp));


// MAGIC.C (Where ever you want this)
void do_surge (CHAR_DATA * ch, char *argument)
{
    char buf[MAX_STRING_LENGTH];

    if (IS_NPC (ch))
        return;

    if (ch->class != CLASS_MAGE)
    {
        send_to_char ("You know nothing of surging.\n\r", ch);
        return;
    }

    if (argument[0] == '\0' || !is_number (argument))
    {
        if (ch->pcdata->spell_surge == 0)
            send_to_char ("Syntax: Surge <level> (1/2/3/4/5) 0 = off\n\r", ch);
        else
            sprintf (buf, "You currently surge your spells at level %d.\n\r", ch->pcdata->spell_surge);
        send_to_char (buf, ch);
        return;
    }

    ch->pcdata->spell_surge = atoi (argument);

    if (ch->pcdata->spell_surge < 0 || ch->pcdata->spell_surge > 5)
    {
        send_to_char ("Level must be 0 (off) or 1 to 5.\n\r", ch);
        return;
    }

    if (ch->pcdata->spell_surge == 0)
        send_to_char ("{gYou are no longer surging your spells.{x\n\r", ch);
    else
        sprintf (buf, "{gYou will now attempt to surge your spells at level %d.\n\r{x", ch->pcdata->spell_surge);
    send_to_char (buf, ch);
    return;
}

// MAGIC.C (In do_cast under the mana calculations just below, 
// you can't concentrate enough and just above Locate Targets )

  
  /* We only want to suck mana for offensive / damaging spells.. Not c armor, c enchant ect..
     Even I kept forgetting to surge 0 before casting non offensive spells.. This fixes that.
   */
  if (!IS_NPC (ch) && ch->pcdata->spell_surge > 0 && skill_table[sn].target == TAR_CHAR_OFFENSIVE)
  {
    switch (ch->pcdata->spell_surge)
    {
    default:
      mana = mana;
      break;
    case 1:
      mana *= 2;
      break;
    case 2:
      mana *= 4;
      break;
    case 3:
      mana *= 6;
      break;
    case 4:
      mana *= 8;
      break;
    case 5:
      mana *= 10;
      break;
    }
  }

// FIGHT.C (Right under the comment for Damage modifiers, Add)

  /*
   * Damage modifiers.
   */

  /* Surge damage bonus based on casters setting. (Mages only during Testing) */
   if (!IS_NPC (ch) && ch->pcdata->spell_surge > 0)
  {
    switch (ch->pcdata->spell_surge)
    {
    default:
      dam = dam; 
	  break;
    case 1:
      dam *= 1.5;
      break;
    case 2:
      dam *= 2;
      break;
    case 3:
      dam *= 3;
      break;
    case 4:
      dam *= 4;
      break;
    case 5:
      dam *= 5;
      break;
    }
  }