//天地无用

#include <ansi.h>
#include <skill.h>
#include <weapon.h>
#include <combat.h>


void remove_effect(object me, int a_amount, int d_amount);

inherit F_SSERVER;
int perform(object me, object target)
{
	object weapon;
	int skill,i;
	string msg;
        for(i=1;i<3+random(2);i++)
   {

	if( !target ) target = offensive_target(me);

	if( !target
	||	!target->is_character()
	||	!me->is_fighting(target) )
		return notify_fail("天地无用只能对战斗中的对手使用。\n");

	if (!objectp(weapon = me->query_temp("weapon"))
		|| (string)weapon->query("skill_type") != "sword")
			return notify_fail("你使用的武器不对。\n");

	if( (int)me->query_skill("huashan-jianfa", 1) < 80 )
		return notify_fail("你的归魂剑法不够娴熟，不会使用「天地无用」。\n");

	
	if( (int)me->query("neili") < 300  ) 
		return notify_fail("你的内力不够。\n");

	if( (int)me->query_temp("begin") ) 
		return notify_fail("你已经在运功中了。\n");

	msg = YEL"$N双手握起"NOR + weapon->name() + YEL"，剑芒暴长，刹那间天昏地暗，飞沙走石，$w从一片迷茫之中\n神奇般的突出，直刺$w的$l"NOR;
	message_vision(msg, me, target);

	skill = (int)me->query_skill("guihun-jian",1);
	me->add_temp("apply/attack", skill/2);
	me->add_temp("apply/dodge", -skill/8);
	me->set_temp("begin", 1);

	me->start_call_out( (: call_other, __FILE__, "remove_effect", me, skill/2, skill/2 :), 2);

	me->add("neili", -80);
     }

	return 1;
}

void remove_effect(object me, int a_amount, int d_amount)
{
	me->add_temp("apply/attack", - a_amount);
	me->add_temp("apply/dodge", d_amount);
	me->delete_temp("begin");
	me->start_busy(2);
}
