示例#1
0
/* fitness runs a simulation and stores its resulting score in a variable libSRES then accesses
	parameters:
		parameters: the parameters provided by libSRES
		score: a pointer to store the score the simulation received
		constraints: parameter constraints (not used but required by libSRES's code structure)
	returns: nothing
	notes:
		This function is called by libSRES for every population member every generation.
	todo:
*/
void fitness (double* parameters, double* score, double* constraints) {
	parameters[0] = (int)parameters[0];
	parameters[1] = (int)parameters[1];
	if (parameters[0] > parameters[1]) {
		int temp = parameters[0];
		parameters[0] = parameters[1];
		parameters[1] = temp;
	}
	*score = simulate_set(parameters);
}
示例#2
0
int perform(object me, object target)
{
        string msg,temp,temp1;
        int extra,num,num1;
        int myexp,yourexp, exp_bonus,cond;
        object weapon,shadow,hisweapon,newweapon;
        
        extra = me->query_skill("xinyue-dagger",1);
        exp_bonus = (me->query("combat_exp")-3000000)/3000*extra/1000;
        if (exp_bonus> extra) exp_bonus=extra;
        
        if(me->query("class")!="wolfmount")
        return notify_fail("只有狼山弟子才能使出「斗转星移」的绝技。\n");
        
        if ( extra < 106) return notify_fail("你的[新月斩]还不够纯熟!\n");
        if( !target ) target = offensive_target(me);
        if( !target
        ||      !target->is_character()
        ||      !me->is_fighting(target) )
                return notify_fail("[斗转星移]只能对战斗中的对手使用。\n");
        weapon = me->query_temp("weapon");
        myexp=me->query("combat_exp");
        yourexp=target->query("combat_exp");
        
        msg = HIR "$N一声长啸:"NOR+"      "+HIC"斗"NOR+"      "+HIY"转"NOR+
        "      "+HIW"星"NOR+"      "+HIB"移"NOR+"\n"; 
        message_vision(msg,me);
        
        if ((myexp*3/4+random(myexp*4)>yourexp)&& !target->query_temp("is_unconcious")) {
                
                msg= MAG"\n$N仿佛置身于一个极大的漩涡中,攻出的招式竟然反击回来!\n\n"NOR;
                message_vision(msg,target);
                        
                seteuid(getuid());
           if (!userp(target)) {
                        sscanf(file_name(target),"%s#%d",temp,num);
                        shadow=new(temp);
                        
                        }
                else    {
                        shadow=new("/d/fy/npc/shadefigure");
                        shadow->changeshape(target);            
                        if(hisweapon=target->query_temp("weapon"))      {
                                sscanf(file_name(hisweapon),"%s#%d",temp1,num1);
                                newweapon=new(temp1);
                                newweapon->move(shadow);
                                newweapon->wield();
                        }
                }       
                shadow->set("owner",me);
                shadow->set("possessed",me);
                shadow->move(environment(me));
                if (!target->query_temp("weapon"))
                if (newweapon=shadow->query_temp("weapon"))
                        newweapon->unequip();   
                shadow->add_killer(target->query("id"));
                
                
                simulate_set(target,shadow);
                shadow->add_temp("apply/attack", extra/2);
                message_vision(HIC "    斗\n" NOR,me);
                COMBAT_D->do_attack(shadow,target,msg);
                if (target->query_temp("damaged_during_attack"))
                                        target->set_temp("last_damage_from",me);
                
                message_vision(YEL "            转\n" NOR,me);
                simulate_set(target,shadow);
                COMBAT_D->do_attack(shadow,target,msg);
                if (target->query_temp("damaged_during_attack"))
                                        target->set_temp("last_damage_from",me);
                
                message_vision(HIW "                    星\n" NOR,me);
                simulate_set(target,shadow);
                COMBAT_D->do_attack(shadow,target,msg);
           if (target->query_temp("damaged_during_attack"))
                                        target->set_temp("last_damage_from",me);
                
                message_vision(HIB "                              移\n" NOR,me);
                simulate_set(target,shadow);
                COMBAT_D->do_attack(shadow,target,msg);
                if (target->query_temp("damaged_during_attack"))
                                        target->set_temp("last_damage_from",me);
                
                shadow->add_temp("apply/attack", -extra/2);
                if (me->is_killing(target->query("id"))) cond=1;
                destruct(shadow);
        }