?? magic.c
字號:
}
return;
}
void spell_dispel_magic( int sn, int level, CHAR_DATA *ch, void *vo )
{
send_to_char( "Sorry but this spell has been disabled.\n\r", ch );
return;
}
void spell_dispel_evil( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if ( !IS_NPC(ch) && IS_EVIL(ch) )
victim = ch;
if ( IS_GOOD(victim) )
{
act( "God protects $N.", ch, NULL, victim, TO_ROOM );
return;
}
if ( IS_NEUTRAL(victim) )
{
act( "$N does not seem to be affected.", ch, NULL, victim, TO_CHAR );
return;
}
dam = dice( level, 4 );
if ( saves_spell( level, victim ) )
dam /= 2;
damage( ch, victim, dam, sn );
return;
}
void spell_earthquake( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
send_to_char( "The earth trembles beneath your feet!\n\r", ch );
act( "$n makes the earth tremble and shiver.", ch, NULL, NULL, TO_ROOM );
for ( vch = char_list; vch != NULL; vch = vch_next )
{
vch_next = vch->next;
if ( vch->in_room == NULL )
continue;
if ( vch->in_room == ch->in_room )
{
if ( vch != ch && ( IS_NPC(ch) ? !IS_NPC(vch) : IS_NPC(vch) ) )
damage( ch, vch, level + dice(2, 8), sn );
continue;
}
if ( vch->in_room->area == ch->in_room->area )
send_to_char( "The earth trembles and shivers.\n\r", vch );
}
return;
}
void spell_enchant_weapon( int sn, int level, CHAR_DATA *ch, void *vo )
{
OBJ_DATA *obj = (OBJ_DATA *) vo;
AFFECT_DATA *paf;
if ( obj->item_type != ITEM_WEAPON
|| IS_OBJ_STAT(obj, ITEM_MAGIC)
|| obj->affected != NULL )
return;
if ( affect_free == NULL )
{
paf = alloc_perm( sizeof(*paf) );
}
else
{
paf = affect_free;
affect_free = affect_free->next;
}
paf->type = sn;
paf->duration = -1;
paf->location = APPLY_HITROLL;
paf->modifier = level / 5;
paf->bitvector = 0;
paf->next = obj->affected;
obj->affected = paf;
if ( affect_free == NULL )
{
paf = alloc_perm( sizeof(*paf) );
}
else
{
paf = affect_free;
affect_free = affect_free->next;
}
paf->type = -1;
paf->duration = -1;
paf->location = APPLY_DAMROLL;
paf->modifier = level / 10;
paf->bitvector = 0;
paf->next = obj->affected;
obj->affected = paf;
obj->level = number_fuzzy( ch->level - 5 );
if ( IS_GOOD(ch) )
{
SET_BIT(obj->extra_flags, ITEM_ANTI_EVIL);
act( "$p glows blue.", ch, obj, NULL, TO_CHAR );
}
else if ( IS_EVIL(ch) )
{
SET_BIT(obj->extra_flags, ITEM_ANTI_GOOD);
act( "$p glows red.", ch, obj, NULL, TO_CHAR );
}
else
{
SET_BIT(obj->extra_flags, ITEM_ANTI_EVIL);
SET_BIT(obj->extra_flags, ITEM_ANTI_GOOD);
act( "$p glows yellow.", ch, obj, NULL, TO_CHAR );
}
send_to_char( "Ok.\n\r", ch );
return;
}
/* "make purse", { 37, 37, 37, 37 },
spell_make_purse, TAR_OBJ_INV, POS_STANDING,
NULL, SLOT(50), 100, 24,
"", "!Make Purse!"*/
void spell_make_purse( int sn, int level, CHAR_DATA *ch, void *vo )
{
static char *headers[] = { "corpse of the ", "corpse of The ",
"corpse of an ", "corpse of An ",
"corpse of a ", "corpse of A ",
"corpse of " }; // (This one must be last)
OBJ_DATA *obj = (OBJ_DATA *) vo;
char buf[MAX_STRING_LENGTH];
int i;
if ( obj->item_type != ITEM_CORPSE_NPC && obj->item_type != ITEM_CORPSE_PC)
return;
for (i = 0; i < 7; i++)
{
int len = strlen(headers[i]);
if ( memcmp(obj->short_descr, headers[i], len) == 0 )
{
sprintf( buf, "purse %s", obj->short_descr+len );
free_string( obj->name );
obj->name = str_dup(buf);
sprintf( buf, "A purse of fine %s hide catches your eye. ",
obj->short_descr+len );
free_string( obj->description );
obj->description = str_dup( buf );
sprintf( buf, "purse made from %s hide", obj->short_descr+len );
free_string( obj->short_descr );
obj->short_descr = str_dup( buf );
break;
}
}
obj->item_type = ITEM_CONTAINER;
obj->wear_flags = ITEM_HOLD|ITEM_TAKE;
obj->timer = 0;
obj->weight = 5;
obj->level = level/3;
obj->cost = level * 50;
obj->value[0] = level * 10; /* Weight capacity */
obj->value[1] = 1; /* Closeable */
obj->value[2] = -1; /* No key needed */
obj->pIndexData = get_obj_index( 5660 ); /* So it's not a corpse */
act( "Your new $p looks pretty snazzy.", ch, obj, NULL, TO_CHAR );
act( "$n's new $p looks pretty snazzy.", ch, obj, NULL, TO_ROOM );
send_to_char( "Ok.\n\r", ch );
return;
}
/*
* Drain XP, MANA, HP.
* Caster gains HP.
*/
void spell_energy_drain( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if ( saves_spell( level, victim ) )
return;
ch->alignment = UMAX(-1000, ch->alignment - 200);
if ( victim->level <= 2 )
{
dam = ch->hit + 1;
}
else
{
gain_exp( victim, 0 - number_range( level / 2, 3 * level / 2 ) );
victim->mana /= 2;
victim->move /= 2;
dam = dice(1, level);
ch->hit += dam;
}
damage( ch, victim, dam, sn );
return;
}
void spell_fireball( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
static const sh_int dam_each[] =
{
0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 30, 35, 40, 45, 50, 55,
60, 65, 70, 75, 80, 82, 84, 86, 88, 90,
92, 94, 96, 98, 100, 102, 104, 106, 108, 110,
112, 114, 116, 118, 120, 122, 124, 126, 128, 130
};
int dam;
level = UMIN(level, sizeof(dam_each)/sizeof(dam_each[0]) - 1);
level = UMAX(0, level);
dam = number_range( dam_each[level] / 2, dam_each[level] * 2 );
if ( saves_spell( level, victim ) )
dam /= 2;
damage( ch, victim, dam, sn );
return;
}
void spell_flamestrike( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
dam = dice(6, level);
if ( saves_spell( level, victim ) )
dam /= 2;
damage( ch, victim, dam, sn );
return;
}
void spell_faerie_fire( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_FAERIE_FIRE) )
return;
af.type = sn;
af.duration = level;
af.location = APPLY_AC;
af.modifier = 2 * level;
af.bitvector = AFF_FAERIE_FIRE;
affect_to_char( victim, &af );
send_to_char( "You are surrounded by a pink outline.\n\r", victim );
act( "$n is surrounded by a pink outline.", victim, NULL, NULL, TO_ROOM );
return;
}
void spell_faerie_fog( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *ich;
act( "$n conjures a cloud of purple smoke.", ch, NULL, NULL, TO_ROOM );
send_to_char( "You conjure a cloud of purple smoke.\n\r", ch );
for ( ich = ch->in_room->people; ich != NULL; ich = ich->next_in_room )
{
if ( !IS_NPC(ich) && IS_SET(ich->act, PLR_WIZINVIS) )
continue;
if ( ich == ch || saves_spell( level, ich ) )
continue;
affect_strip ( ich, gsn_invis );
affect_strip ( ich, gsn_mass_invis );
affect_strip ( ich, gsn_sneak );
REMOVE_BIT ( ich->affected_by, AFF_HIDE );
REMOVE_BIT ( ich->affected_by, AFF_INVISIBLE );
REMOVE_BIT ( ich->affected_by, AFF_SNEAK );
act( "$n is revealed!", ich, NULL, NULL, TO_ROOM );
send_to_char( "You are revealed!\n\r", ich );
}
return;
}
void spell_fly( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_FLYING) )
return;
af.type = sn;
af.duration = level + 3;
af.location = 0;
af.modifier = 0;
af.bitvector = AFF_FLYING;
affect_to_char( victim, &af );
send_to_char( "Your feet rise off the ground.\n\r", victim );
act( "$n's feet rise off the ground.", victim, NULL, NULL, TO_ROOM );
return;
}
void spell_gate( int sn, int level, CHAR_DATA *ch, void *vo )
{
char_to_room( create_mobile( get_mob_index(MOB_VNUM_VAMPIRE) ),
ch->in_room );
return;
}
/*
* Spell for mega1.are from Glop/Erkenbrand.
*/
void spell_general_purpose( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
dam = number_range( 25, 100 );
if ( saves_spell( level, victim ) )
dam /= 2;
damage( ch, victim, dam, sn );
return;
}
void spell_giant_strength( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( is_affected( victim, sn ) )
return;
af.type = sn;
af.duration = level;
af.location = APPLY_STR;
af.modifier = 1 + (level >= 18) + (level >= 25);
af.bitvector = 0;
affect_to_char( victim, &af );
send_to_char( "You feel stronger.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_harm( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
dam = UMAX( 20, victim->hit - dice(1,4) );
if ( saves_spell( level, victim ) )
dam = UMIN( 50, dam / 4 );
dam = UMIN( 100, dam );
damage( ch, victim, dam, sn );
return;
}
void spell_heal( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
victim->hit = UMIN( victim->hit + 100, victim->max_hit );
update_pos( victim );
send_to_char( "A warm feeling fills your body.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
/*
* Spell for mega1.are from Glop/Erkenbrand.
*/
void spell_high_explosive( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
dam = number_range( 30, 120 );
if ( saves_spell( level, victim ) )
dam /= 2;
damage( ch, victim, dam, sn );
return;
}
void spell_identify( int sn, int level, CHAR_DATA *ch, void *vo )
{
OBJ_DATA *obj = (OBJ_DATA *) vo;
char buf[MAX_STRING_LENGTH];
AFFECT_DATA *paf;
sprintf( buf,
"Object '%s' is type %s, extra flags %s.\n\rWeight is %d, value is %d, level is %d.\n\r",
item_type_name( obj ),
extra_bit_name( obj->extra_flags ),
obj->weight,
obj->cost,
obj->level
);
send_to_char( buf, ch );
switch ( obj->item_type )
{
case ITEM_SCROLL:
case ITEM_POTION:
case ITEM_PILL: // @@@
sprintf( buf, "Level %d spells of:", obj->value[0] );
send_to_char( buf, ch );
if ( obj->value[1] >= 0 && obj->value[1] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[1]].name, ch );
send_to_char( "'", ch );
}
if ( obj->value[2] >= 0 && obj->value[2] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[2]].name, ch );
send_to_char( "'", ch );
}
if ( obj->value[3] >= 0 && obj->value[3] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[3]].name, ch );
send_to_char( "'", ch );
}
send_to_char( ".\n\r", ch );
break;
case ITEM_WAND:
case ITEM_STAFF:
sprintf( buf, "Has %d(%d) charges of level %d",
obj->value[1], obj->value[2], obj->value[0] );
send_to_char( buf, ch );
if ( obj->value[3] >= 0 && obj->value[3] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[3]].name, ch );
send_to_char( "'", ch );
}
send_to_char( ".\n\r", ch );
break;
case ITEM_WEAPON:
sprintf( buf, "Damage is %d to %d (average %d).\n\r",
obj->value[1], obj->value[2],
( obj->value[1] + obj->value[2] ) / 2 );
send_to_char( buf, ch );
break;
case ITEM_ARMOR:
sprintf( buf, "Armor class is %d.\n\r", obj->value[0] );
send_to_char( buf, ch );
break;
}
for ( paf = obj->pIndexData->affected; paf != NULL; paf = paf->next )
{
if ( paf->location != APPLY_NONE && paf->modifier != 0 )
{
sprintf( buf, "Affects %s by %d.\n\r",
affect_loc_name( paf->location ), paf->modifier );
send_to_char( buf, ch );
}
}
for ( paf = obj->affected; paf != NULL; paf = paf->next )
if ( paf->location != APPLY_NONE && paf->modifier != 0 )
{
sprintf( buf, "Affects %s by %d.\n\r",
affect_loc_name( paf->location ), paf->modifier );
send_to_char( buf, ch );