📄 special.c
字号:
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include <ctype.h> // @@@ Needed for spec_cast_from_list
/*
* The following special functions are available for mobiles.
*/
DECLARE_SPEC_FUN( spec_breath_any );
DECLARE_SPEC_FUN( spec_breath_acid );
DECLARE_SPEC_FUN( spec_breath_fire );
DECLARE_SPEC_FUN( spec_breath_frost );
DECLARE_SPEC_FUN( spec_breath_gas );
DECLARE_SPEC_FUN( spec_breath_lightning );
DECLARE_SPEC_FUN( spec_cast_adept );
DECLARE_SPEC_FUN( spec_cast_cleric );
DECLARE_SPEC_FUN( spec_cast_judge );
DECLARE_SPEC_FUN( spec_cast_mage );
DECLARE_SPEC_FUN( spec_cast_undead );
DECLARE_SPEC_FUN( spec_executioner );
DECLARE_SPEC_FUN( spec_fido );
DECLARE_SPEC_FUN( spec_guard );
DECLARE_SPEC_FUN( spec_janitor );
DECLARE_SPEC_FUN( spec_mayor );
DECLARE_SPEC_FUN( spec_poison );
DECLARE_SPEC_FUN( spec_thief );
DECLARE_SPEC_FUN( spec_cast_psionicist );
DECLARE_SPEC_FUN( spec_animated_dead ); // @@@
DECLARE_SPEC_FUN( spec_taxidermist ); // @@@
DECLARE_SPEC_FUN( spec_capn_swing ); // @@@
DECLARE_SPEC_FUN( spec_snake_charm ); // @@@
DECLARE_SPEC_FUN( spec_hunger );
DECLARE_SPEC_FUN( spec_cast_from_list ); // @@@ ###
DECLARE_SPEC_FUN( spec_shopkeeper ); // @@@
DECLARE_SPEC_FUN( spec_obj_bribe ); // @@@
DECLARE_SPEC_FUN( spec_agg_no_object ); // @@@
DECLARE_SPEC_FUN( spec_follow_mob ); // @@@
DECLARE_SPEC_FUN( spec_generator ); // @@@
DECLARE_SPEC_FUN( spec_defend_vs_agg ); // @@@
DECLARE_SPEC_FUN( spec_agg_if_object ); // @@@
DECLARE_SPEC_FUN( spec_circuit ); // @@@
DECLARE_SPEC_FUN( spec_hatred ); // @@@
/*
* Given a name, return the appropriate spec fun.
*/
SPEC_FUN *spec_lookup( const char *name )
{
if ( !str_cmp( name, "spec_breath_any" ) ) return spec_breath_any;
if ( !str_cmp( name, "spec_breath_acid" ) ) return spec_breath_acid;
if ( !str_cmp( name, "spec_breath_fire" ) ) return spec_breath_fire;
if ( !str_cmp( name, "spec_breath_frost" ) ) return spec_breath_frost;
if ( !str_cmp( name, "spec_breath_gas" ) ) return spec_breath_gas;
if ( !str_cmp( name, "spec_breath_lightning" ) ) return
spec_breath_lightning;
if ( !str_cmp( name, "spec_cast_adept" ) ) return spec_cast_adept;
if ( !str_cmp( name, "spec_cast_cleric" ) ) return spec_cast_cleric;
if ( !str_cmp( name, "spec_cast_judge" ) ) return spec_cast_judge;
if ( !str_cmp( name, "spec_cast_mage" ) ) return spec_cast_mage;
if ( !str_cmp( name, "spec_cast_undead" ) ) return spec_cast_undead;
if ( !str_cmp( name, "spec_executioner" ) ) return spec_executioner;
if ( !str_cmp( name, "spec_fido" ) ) return spec_fido;
if ( !str_cmp( name, "spec_guard" ) ) return spec_guard;
if ( !str_cmp( name, "spec_janitor" ) ) return spec_janitor;
if ( !str_cmp( name, "spec_mayor" ) ) return spec_mayor;
if ( !str_cmp( name, "spec_poison" ) ) return spec_poison;
if ( !str_cmp( name, "spec_cast_psionicist" ) ) return
spec_cast_psionicist;
if ( !str_cmp( name, "spec_thief" ) ) return spec_thief;
if ( !str_cmp( name, "spec_taxidermist" ) ) return spec_taxidermist; // @@@
if ( !str_cmp( name, "spec_animated_dead" ) ) return spec_animated_dead;
if ( !str_cmp( name, "spec_capn_swing" ) ) return spec_capn_swing; // @@@
if ( !str_cmp( name, "spec_snake_charm" ) ) return spec_snake_charm; // @@@
if ( !str_cmp( name, "spec_hunger" ) ) return spec_hunger; // @@
if ( !str_cmp( name, "spec_cast_from_list" )) return spec_cast_from_list; // @@@ ###
if ( !str_cmp( name, "spec_shopkeeper" )) return spec_shopkeeper; // @@@ ###
if ( !str_cmp( name, "spec_obj_bribe" )) return spec_obj_bribe; // @@@ ###
if ( !str_cmp( name, "spec_agg_no_object" )) return spec_agg_no_object; // @@@ ###
if ( !str_cmp( name, "spec_follow_mob" )) return spec_follow_mob; // @@@
if ( !str_cmp( name, "spec_generator" )) return spec_generator; // @@@
if ( !str_cmp( name, "spec_defend_vs_agg" )) return spec_defend_vs_agg; // @@@
if ( !str_cmp( name, "spec_agg_if_object" )) return spec_agg_if_object; // @@@
if ( !str_cmp( name, "spec_circuit" )) return spec_circuit; // @@@
if ( !str_cmp( name, "spec_hatred" )) return spec_hatred; // @@@
return 0;
}
/*
* Core procedure for dragons.
*/
bool dragon( CHAR_DATA *ch, char *spell_name )
{
CHAR_DATA *victim;
CHAR_DATA *v_next;
int sn;
if ( ch->position != POS_FIGHTING )
return FALSE;
for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
{
v_next = victim->next_in_room;
if ( victim->fighting == ch && number_bits( 2 ) == 0 )
break;
}
if ( victim == NULL )
return FALSE;
if ( ( sn = skill_lookup( spell_name ) ) < 0 )
return FALSE;
(*skill_table[sn].spell_fun) ( sn, ch->level, ch, victim );
return TRUE;
}
/*
* Special procedures for mobiles.
*/
bool spec_breath_any( CHAR_DATA *ch )
{
if ( ch->position != POS_FIGHTING )
return FALSE;
switch ( number_bits( 3 ) )
{
case 0: return spec_breath_fire ( ch );
case 1:
case 2: return spec_breath_lightning ( ch );
case 3: return spec_breath_gas ( ch );
case 4: return spec_breath_acid ( ch );
case 5:
case 6:
case 7: return spec_breath_frost ( ch );
}
return FALSE;
}
bool spec_breath_acid( CHAR_DATA *ch )
{
return dragon( ch, "acid breath" );
}
bool spec_breath_fire( CHAR_DATA *ch )
{
return dragon( ch, "fire breath" );
}
bool spec_breath_frost( CHAR_DATA *ch )
{
return dragon( ch, "frost breath" );
}
bool spec_breath_gas( CHAR_DATA *ch )
{
int sn;
if ( ch->position != POS_FIGHTING )
return FALSE;
if ( ( sn = skill_lookup( "gas breath" ) ) < 0 )
return FALSE;
(*skill_table[sn].spell_fun) ( sn, ch->level, ch, NULL );
return TRUE;
}
bool spec_breath_lightning( CHAR_DATA *ch )
{
return dragon( ch, "lightning breath" );
}
bool spec_cast_adept( CHAR_DATA *ch )
{
CHAR_DATA *victim;
CHAR_DATA *v_next;
if ( !IS_AWAKE(ch) )
return FALSE;
for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
{
v_next = victim->next_in_room;
if ( victim != ch && can_see( ch, victim ) && number_bits( 1 ) == 0 )
break;
}
if ( victim == NULL )
return FALSE;
switch ( number_bits( 3 ) )
{
case 0:
act( "$n utters the word 'tehctah'.", ch, NULL, NULL, TO_ROOM );
spell_armor( skill_lookup( "armor" ), ch->level, ch, victim );
return TRUE;
case 1:
act( "$n utters the word 'nhak'.", ch, NULL, NULL, TO_ROOM );
spell_bless( skill_lookup( "bless" ), ch->level, ch, victim );
return TRUE;
case 2:
act( "$n utters the word 'yeruf'.", ch, NULL, NULL, TO_ROOM );
spell_cure_blindness( skill_lookup( "cure blindness" ),
ch->level, ch, victim );
return TRUE;
case 3:
act( "$n utters the word 'garf'.", ch, NULL, NULL, TO_ROOM );
spell_cure_light( skill_lookup( "cure light" ),
ch->level, ch, victim );
return TRUE;
case 4:
act( "$n utters the words 'rozar'.", ch, NULL, NULL, TO_ROOM );
spell_cure_poison( skill_lookup( "cure poison" ),
ch->level, ch, victim );
return TRUE;
case 5:
act( "$n utters the words 'nadroj'.", ch, NULL, NULL, TO_ROOM );
spell_refresh( skill_lookup( "refresh" ), ch->level, ch, victim );
return TRUE;
}
return FALSE;
}
bool spec_cast_cleric( CHAR_DATA *ch )
{
CHAR_DATA *victim;
CHAR_DATA *v_next;
char *spell;
int sn;
if ( ch->position != POS_FIGHTING )
return FALSE;
for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
{
v_next = victim->next_in_room;
if ( victim->fighting == ch && number_bits( 2 ) == 0 )
break;
}
if ( victim == NULL )
return FALSE;
for ( ;; )
{
int min_level;
switch ( number_bits( 4 ) )
{
case 0: min_level = 0; spell = "blindness"; break;
case 1: min_level = 3; spell = "cause serious"; break;
case 2: min_level = 7; spell = "earthquake"; break;
case 3: min_level = 9; spell = "cause critical"; break;
case 4: min_level = 10; spell = "dispel evil"; break;
case 5: min_level = 12; spell = "curse"; break;
case 6: min_level = 12; spell = "change sex"; break;
case 7: min_level = 13; spell = "flamestrike"; break;
case 8:
case 9:
case 10: min_level = 15; spell = "harm"; break;
default: min_level = 16; spell = "dispel magic"; break;
}
if ( ch->level >= min_level )
break;
}
if ( ( sn = skill_lookup( spell ) ) < 0 )
return FALSE;
(*skill_table[sn].spell_fun) ( sn, ch->level, ch, victim );
return TRUE;
}
bool spec_cast_judge( CHAR_DATA *ch )
{
CHAR_DATA *victim;
CHAR_DATA *v_next;
char *spell;
int sn;
if ( ch->position != POS_FIGHTING )
return FALSE;
for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
{
v_next = victim->next_in_room;
if ( victim->fighting == ch && number_bits( 2 ) == 0 )
break;
}
if ( victim == NULL )
return FALSE;
spell = "high explosive";
if ( ( sn = skill_lookup( spell ) ) < 0 )
return FALSE;
(*skill_table[sn].spell_fun) ( sn, ch->level, ch, victim );
return TRUE;
}
bool spec_cast_mage( CHAR_DATA *ch )
{
CHAR_DATA *victim;
CHAR_DATA *v_next;
char *spell;
int sn;
if ( ch->position != POS_FIGHTING )
return FALSE;
for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
{
v_next = victim->next_in_room;
if ( victim->fighting == ch && number_bits( 2 ) == 0 )
break;
}
if ( victim == NULL )
return FALSE;
for ( ;; )
{
int min_level;
switch ( number_bits( 4 ) )
{
case 0: min_level = 0; spell = "blindness"; break;
case 1: min_level = 3; spell = "chill touch"; break;
case 2: min_level = 7; spell = "weaken"; break;
case 3: min_level = 8; spell = "teleport"; break;
case 4: min_level = 11; spell = "colour spray"; break;
case 5: min_level = 12; spell = "change sex"; break;
case 6: min_level = 13; spell = "energy drain"; break;
case 7:
case 8:
case 9: min_level = 15; spell = "fireball"; break;
default: min_level = 20; spell = "acid blast"; break;
}
if ( ch->level >= min_level )
break;
}
if ( ( sn = skill_lookup( spell ) ) < 0 )
return FALSE;
(*skill_table[sn].spell_fun) ( sn, ch->level, ch, victim );
return TRUE;
}
bool spec_cast_undead( CHAR_DATA *ch )
{
CHAR_DATA *victim;
CHAR_DATA *v_next;
char *spell;
int sn;
if ( ch->position != POS_FIGHTING )
return FALSE;
for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
{
v_next = victim->next_in_room;
if ( victim->fighting == ch && number_bits( 2 ) == 0 )
break;
}
if ( victim == NULL )
return FALSE;
for ( ;; )
{
int min_level;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -