/
area/city/
area/crypts/
area/guilds/
area/psuedowild/
area/religion/
data/documents/MPDocs/
data/html/
data/mobprogs/
data/quest/
data/world/
data/world/_utilities/
data/world/images/
design/html/
notes/
player/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "interp.h"
#include "magic.h"
#include "balance.h"

extern char *target_name;

            /*****************************************\
            *       First Circle Spells              *
            \*****************************************/
/*
 * Spell Name:         Magic Missile
 * Base Mana Cost:     5
 * Damage:             1-5 + 1-3 per level   
 */ 
void spell_1_magic_missile (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    
    dam = number_range(1, 5);
    
    for (i = 0; i < level; i++)
        dam += number_range(1, 3);
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_OTHER, TRUE, TRUE);
}

/*
Spell Name:         Wizard's Fire
Base Mana Cost:     20
Damage:             5-10 + 2-4 per level
Effect:             Fire Effect
*/
void spell_1_wizard_fire (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    
    dam = number_range(5, 10);
    
    for (i = 0; i < level; i++)
        dam += number_range(2, 4);
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_FIRE, TRUE, TRUE);
    fire_effect((CHAR_DATA *) vo, level, 1, TARGET_CHAR);
}

/*
Spell Name:         Wizard's Frost
Base Mana Cost:     20
Damage:             6-8 + 3 per level
Effect:             Frost Effect
*/
void spell_1_wizard_frost (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    
    dam = number_range(6, 8);
    
    for (i = 0; i < level; i++)
        dam += 3;
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_COLD, TRUE, TRUE);
    cold_effect((CHAR_DATA *) vo, level, 1, TARGET_CHAR);
}

/*
Spell Name:         Wizard's Spark
Base Mana Cost:     20
Damage:             1-15 + 1-5 per level
Effect:             Lightning Effect
*/
void spell_1_wizard_spark (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    
    dam = number_range(1, 15);
    
    for (i = 0; i < level; i++)
        dam += number_range(1, 5);
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_LIGHTNING, TRUE, TRUE);
    shock_effect((CHAR_DATA *) vo, level, 1, TARGET_CHAR);
}

/*
Spell Name:         Continual Light
Base Mana Cost:     20
Duration:           infinate
Effect:             Creates a light
*/
void spell_1_continual_light (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    OBJ_DATA *light;

    light = create_object (get_obj_index (OBJ_VNUM_LIGHT_BALL), 0);
    obj_to_char (light, ch);
    act ("$n twiddles $s thumbs and $p appears.", ch, light, NULL, TO_ROOM);
    act ("You twiddle your thumbs and $p appears.", ch, light, NULL, TO_CHAR);
    return;
}
/*
Spell Name:         Mend
Base Mana Cost:     10
Damage:             1-4
Effect:             Heals victim's health by Damage
*/
void spell_1_mend (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    int heal;

    heal = dice (1, 4);
    heal_char(victim, heal, TRUE);
    update_pos (victim);
    send_to_char ("You feel better!\n\r", victim);
    if (ch != victim)
        send_to_char ("Ok.\n\r", ch);
    return;
}

/*
Spell Name:         orcish strength
Base Mana Cost:     20
Damage:             2
Effect:             Increases victims strength by Damage
*/
void spell_1_orc_strength (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You are already as strong as you can get!\n\r", ch);
        else
            act ("$N can't get any stronger.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where = TO_AFFECTS;
    af.type = sn;
    af.level = level;
    af.duration = level;
    af.location = APPLY_STR;
    af.modifier = 2;
    af.bitvector = 0;
    affect_to_char (victim, &af);
    send_to_char ("Your muscles surge with orcish power!\n\r", victim);
    act ("$n's muscles surge with orcish power.", victim, NULL, NULL,
         TO_ROOM);
    return;
}
/*
Spell Name:         Lesser Invisibility
Base Mana Cost:     20
Duration:           10 + level
Effect:             Grants Invis for duration
*/
void spell_1_lesser_invis (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You are already invisible!\n\r", ch);
        else
            act ("$N is already invisible.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 10 + level;
    af.location     = APPLY_NONE;
    af.modifier     = 0;
    af.bitvector    = AFF_INVISIBLE;
    affect_to_char (victim, &af);
    send_to_char ("You fade out of existence slightly.\n\r", victim);
    return;
}


/******************************************************************************

            Second Circle Spells

*******************************************************************************/
/*
Spell Name:         Shock
Base Mana Cost:     45
Damage:             1-50 + 1-10 per level
Effect:             Lightning Effect
*/
void spell_2_shock (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    
    dam = number_range(1, 50);
    
    for (i = 0; i < level; i++)
        dam += number_range(1, 10);
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_LIGHTNING, TRUE, TRUE);
    shock_effect((CHAR_DATA *) vo, level, 1, TARGET_CHAR);
}


/*
Spell Name:         Leech Strength
Base Mana Cost:     50
Damage:             2 + 1 per level / 2(Strength)
Duration:           2 + level
Effect:             Gives Caster strength of Damage
*/
void spell_2_leech_strength (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;
    int mod;

    if (is_affected (victim, sn) && is_affected (ch, sn))
    {
        if (victim == ch)
            send_to_char ("You cannot leech any more strength!\n\r", ch);
        else
            act ("$N cannot be leeched.", ch, NULL, victim, TO_CHAR);
        return;
    }

    mod             = 2 + (level / 2);
    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 2 + level;
    af.location     = APPLY_STR;
    af.modifier     = mod;
    af.bitvector    = 0;
    affect_to_char (ch, &af);
    
    mod             = -2 - (level / 2);
    af.modifier     = mod;
    affect_to_char (victim, &af);
    
    send_to_char ("Your muscles surge with your leeched stength!\n\r", victim);
    act ("$n's muscles surge leeched strength.", victim, NULL, NULL, TO_ROOM);
    act ("$n's muscles surge, while yours weaken.", victim, NULL, NULL, TO_VICT);
    return;
}
/*
Spell Name:         Shield
Base Mana Cost:     60
Damage:             3 + (level / 10)
Duration:           20 + level
Effect:             Applies AC
*/
void spell_2_shield (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You are already shielded from harm.\n\r", ch);
        else
            act ("$N is already protected by a shield.", ch, NULL, victim,
                 TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 20 + level;
    af.location     = APPLY_AC;
    af.modifier     = 2 + (level / 10);
    af.bitvector    = 0;
    affect_to_char (victim, &af);
    act ("$n is surrounded by a force shield.", victim, NULL, NULL, TO_ROOM);
    send_to_char ("You are surrounded by a force shield.\n\r", victim);
    return;
}

/*
Spell Name:         Protection from Evil
Base Mana Cost:     50
Duration            50 + level * 2
Effect:             Damage Reduction from evil
*/
void spell_2_prot_evil (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You are already protected from evil.\n\r", ch);
        else
            act ("$N is already protected from evil.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 50 + (level * 2);
    af.location     = 0;
    af.modifier     = 0;
    af.bitvector    = AFF_PROTECT_EVIL;
    affect_to_char (victim, &af);
    
    act ("$n is protected from evil.", victim, NULL, NULL, TO_ROOM);
    send_to_char ("You are protected from evil.\n\r", victim);
    return;
}

/*
Spell Name:         Protection from Good
Base Mana Cost:     50
Duration            50 + level * 2
Effect:             Damage Reduction from Good
*/
void spell_2_prot_good (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You are already protected from good.\n\r", ch);
        else
            act ("$N is already protected from good.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 50 + (level * 2);
    af.location     = 0;
    af.modifier     = 0;
    af.bitvector    = AFF_PROTECT_GOOD;
    affect_to_char (victim, &af);
    
    act ("$n is protected from good.", victim, NULL, NULL, TO_ROOM);
    send_to_char ("You are protected from good.\n\r", victim);
    return;
}

/*
Spell Name:         Detect Hidden
Base Mana Cost:     40
Duration            50 + level * 2
Effect:             Grants detection of Hidden things
*/
void spell_2_detect_hidden (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You can already see hidden creatures.\n\r", ch);
        else
            act ("$N can already see hidden creatures.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 50 + (level * 2);
    af.location     = 0;
    af.modifier     = 0;
    af.bitvector    = AFF_DETECT_HIDDEN;
    affect_to_char (victim, &af);
    
    act ("$n's eyes shift slightly.", victim, NULL, NULL, TO_ROOM);
    send_to_char ("You eyes shift slightly.\n\r", victim);
    return;
}

/*
Spell Name:         Detect Invis
Base Mana Cost:     40
Duration            50 + level * 2
Effect:             Grants detection of Invis Things
*/
void spell_2_detect_invis (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You can already see invisible creatures.\n\r", ch);
        else
            act ("$N can already see invisible creatures.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 50 + (level * 2);
    af.location     = 0;
    af.modifier     = 0;
    af.bitvector    = AFF_DETECT_INVIS;
    affect_to_char (victim, &af);
    
    act ("$n's eyes phase slightly.", victim, NULL, NULL, TO_ROOM);
    send_to_char ("You eyes phase slightly.\n\r", victim);
    return;
}

/*
Spell Name:         Flight
Base Mana Cost:     45
Duration:           20 + level
Effect:             Grants Fly for Duration
*/
void spell_2_flight (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You can already fly!\n\r", ch);
        else
            act ("$N doesn't need your assistance to fly.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 20 + level;
    af.location     = 0;
    af.modifier     = 0;
    af.bitvector    = AFF_FLYING;
    affect_to_char (victim, &af);
    
    act ("$n's feet rise off the ground.", victim, NULL, NULL, TO_ROOM);
    send_to_char ("You feet rise off the ground.\n\r", victim);
    return;
}


/******************************************************************************

            Third Circle Spells

*******************************************************************************/

/*
Spell Name:         Wizard's Fireball
Base Mana Cost:     125
Damage:             30-60 + 10-15 per level
Effect:             fire_effect/room
*/
void spell_3_wiz_fireball (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    dam = number_range(30, 60);
    
    for (i = 0; i < level; i++)
        dam += number_range(10, 15);
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_FIRE, TRUE, TRUE);
    fire_effect((CHAR_DATA *) vo, level, 1, TARGET_CHAR);
}

/*
Spell Name:         Ice Bolt
Base Mana Cost:     110
Damage:             20-30 + 5-10 per level
Effect:             cold effect
*/
void spell_3_ice_bolt (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    dam = number_range(20, 30);
    
    for (i = 0; i < level; i++)
        dam += number_range(5, 10);
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_COLD, TRUE, TRUE);
    cold_effect((CHAR_DATA *) vo, level, 1, TARGET_CHAR);
}


/*
Spell Name:         Lightning
Base Mana Cost:     120
Damage:             1-100 + 1-20 per level
Effect:             Lightning Effect
*/
void spell_3_lightning (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    int dam, i;
    dam = number_range(1, 100);
    
    for (i = 0; i < level; i++)
        dam += number_range(1, 20);
    
    damage (ch, (CHAR_DATA *) vo, dam, sn, DAM_LIGHTNING, TRUE, TRUE);
    shock_effect((CHAR_DATA *) vo, level, 1, TARGET_CHAR);
}

/*
Spell Name:         Wizard's Eye
Base Mana Cost:     100
Effect:             'see' the room the victim is in.
*/
void spell_3_wizard_eye (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    ROOM_INDEX_DATA *original;
    CHAR_DATA *wch;
    CHAR_DATA *victim;

    if (!(victim = get_char_world (ch, target_name)) || victim == ch || !victim->in_room)
    {
        send_to_char ("You have failed.\n", ch);
        return;
    }
    original = ch->in_room;
    char_from_room (ch);
    char_to_room (ch, victim->in_room);
    do_look (ch, "auto");
    /*
     * See if 'ch' still exists before continuing!
     * Handles 'c 'wizard eye' XXXX quit' case.
     */
    for (wch = char_list; wch; wch = wch->next)
    {
        if (wch == ch)
        {
            char_from_room (ch);
            char_to_room (ch, original);
            break;
        }
    }

    return;
}

/*
Spell Name:         Haste
Base Mana Cost:     105
Duration:           25 + level
Effect:             Grants Haste for Duration
*/
void spell_3_haste (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    AFFECT_DATA af;

    if (is_affected (victim, sn))
    {
        if (victim == ch)
            send_to_char ("You are already hasted!\n\r", ch);
        else
            act ("$N is already hasted.", ch, NULL, victim, TO_CHAR);
        return;
    }

    af.where        = TO_AFFECTS;
    af.type         = sn;
    af.level        = level;
    af.duration     = 25 + level;
    af.location     = APPLY_NONE;
    af.modifier     = 0;
    af.bitvector    = AFF_HASTE;
    affect_to_char (victim, &af);
    send_to_char ("You body speeds up.\n\r", victim);
    return;
}