/*********************************************
tiao.c
挑眼 主动外功
只限纯门派弟子(没有叛过一次师的)
每一百级skills增加一秒
*********************************************/  
#include <ansi.h>
inherit SSERVER;

void finish(object who)
{
if ( !who )
        return;
who->delete("disable_type");
who->delete_temp("disabled");
who->reset_action();
message_vision(HIR"\n$N"HIR"眼前一亮，终于可以看清四周的情景了。\n\n"NOR,who);
return;
}

int perform(object me, object target)
{
int t;
mapping action,t_action;
string *limbs,limb,str,msg,w_name,tw_name,damage_type;
object weapon,t_weapon;
int ap,dp;
        
if ( !target ) target = offensive_target(me);

if ( !target
  || !target->is_character()
  || target->is_corpse()
  || target==me 
  || target->query("disable_type")=="<眼盲状态>" )
        return notify_fail("你要对谁施展这一招「火芒挑眼」？\n");
/*
if ( !wizardp(me) )
        return 0;
*/
if ( me->query("叛师/num") )
        return notify_fail(HIR"\n红孩儿在半空现出身来，怒喝一声′小爷的绝招岂是汝等三心二意之徒所能领悟？！′\n\n"NOR);
if ( me->query("family/family_name")!="火云洞" )
        return notify_fail(HIR"\n红孩儿在半空现出身来，怒喝一声′小爷的绝招只有火云洞门人才可以用！′\n\n"NOR);
if ( !me->is_fighting() )
        return notify_fail(HIR"\n红孩儿在半空现出身来，怒喝一声′小爷的绝招只能在战斗中使用！′\n\n"NOR);
if ( (int)me->query("max_force") < 1500 )
        return notify_fail("你的内力不够！\n");
if ( (int)me->query("force") < 1000 )
        return notify_fail("你的内力不足！\n");
if ( (int)me->query("sen") < 800 )
        return notify_fail("你的精神不足，没法子施用外功！\n");
if ( me->query_skill_mapped("force")!="huomoforce" )
        return notify_fail(HIR"\n红孩儿在半空现出身来，怒喝一声′小爷的绝招必须配合火魔心法才能使用！′\n\n"NOR);

t = me->query_skill("huoyun-qiang",1);
if ( t<250 )
        return notify_fail(HIR"\n红孩儿在半空现出身来，怒喝一声′你的火云枪法不够,不配使小爷的绝招！′\n\n"NOR);
if ( t<=300) t = 5; 
else if ( t<=400) t = 6; 
else if ( t<=500) t = 7; 
else if ( t<=600) t = 8; 
else if ( t<=700) t = 9; 
else if ( t<=800) t = 10; 
else if ( t<=900) t = 12; 
else t = 6+random(10); 

weapon = me->query_temp("weapon");          
if ( !weapon )
        w_name = ({"左","右","双"})[random(3)]+({"拳","掌","爪"})[random(3)];
else    w_name = weapon->name();

t_weapon = target->query_temp("weapon");
if ( !t_weapon )
        tw_name = ({"左","右","双"})[random(3)]+({"拳","掌","爪"})[random(3)];
else    tw_name = t_weapon->name();

limbs = target->query("limbs");
limb = limbs[random(sizeof(limbs))];

action = me->query("actions");

msg = "\n"+action["action"]+"。\n";
msg = replace_string(msg,"$w",w_name);
msg = replace_string(msg,"$l",limb);
msg = SDS_D->no_color_msg(msg);
msg = HIR+msg+NOR;
message_vision(msg,me,target);
msg = "";

ap = me->query("combat_exp")/1000000;
if ( ap<10 ) ap = 10;
dp = target->query("combat_exp")/1000000;
if ( dp<10 ) dp = 10;
if ( random(ap)>dp/2 || random(me->query("force")/100)<10 )
        {
        msg+= "$N$w上忽地火焰卷起，但见一道火芒夹着浓烟直朝$n面门卷去！\n";
        msg+= "$n但觉眼前一黑，一时间什么也看不清！！\n\n";
        msg = replace_string(msg,"$w",w_name);
        msg = replace_string(msg,"$l",limb);
        msg = SDS_D->no_color_msg(msg);
        msg = HIR+msg+HIR;
        message_vision(msg,me,target);
        target->set("disable_type","<眼盲状态>"); 
        target->set_temp("disabled_living",1); 
        target->set_temp("disabled", 1); 
        me->add("force",-100);
        call_out("finish",t,target);
        }
else    {
        t_action = target->query("actions");
        if ( stringp(t_action["parry_msg"]) )
                msg+= t_action["parry_msg"];
        else    msg+= SKILL_D(target->query_skill_mapped("dodge"))->query_dodge_msg(weapon);
         msg+= "\n";
        msg = msg = replace_string(msg,"$w",tw_name);
        msg = msg = replace_string(msg,"$l",limb);
        msg = SDS_D->no_color_msg(msg);
        msg = HIR+msg+NOR"\n";
        message_vision(msg,me,target);
        }
me->receive_damage("sen",200+random(300));
me->add("force",-500);
return 1;
}

