static void evalcommand(union node *cmd, int flags, struct backcmd *backcmd) { union node *argp; struct arglist arglist; struct arglist varlist; char **argv; int argc; char **envp; int varflag; int mode; int pip[2]; struct cmdentry cmdentry; struct job *jp; struct jmploc jmploc; struct jmploc *savehandler; char *savecmdname; struct shparam saveparam; struct localvar *savelocalvars; struct parsefile *savetopfile; volatile int e; char *lastarg; int realstatus; int do_clearcmdentry; const char *path = pathval(); int i; /* First expand the arguments. */ TRACE(("evalcommand(%p, %d) called\n", (void *)cmd, flags)); emptyarglist(&arglist); emptyarglist(&varlist); varflag = 1; jp = NULL; do_clearcmdentry = 0; oexitstatus = exitstatus; exitstatus = 0; /* Add one slot at the beginning for tryexec(). */ appendarglist(&arglist, nullstr); for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) { if (varflag && isassignment(argp->narg.text)) { expandarg(argp, varflag == 1 ? &varlist : &arglist, EXP_VARTILDE); continue; } else if (varflag == 1) varflag = isdeclarationcmd(&argp->narg) ? 2 : 0; expandarg(argp, &arglist, EXP_FULL | EXP_TILDE); } appendarglist(&arglist, nullstr); expredir(cmd->ncmd.redirect); argc = arglist.count - 2; argv = &arglist.args[1]; argv[argc] = NULL; lastarg = NULL; if (iflag && funcnest == 0 && argc > 0) lastarg = argv[argc - 1]; /* Print the command if xflag is set. */ if (xflag) xtracecommand(&varlist, argc, argv); /* Now locate the command. */ if (argc == 0) { /* Variable assignment(s) without command */ cmdentry.cmdtype = CMDBUILTIN; cmdentry.u.index = BLTINCMD; cmdentry.special = 0; } else { static const char PATH[] = "PATH="; int cmd_flags = 0, bltinonly = 0; /* * Modify the command lookup path, if a PATH= assignment * is present */ for (i = 0; i < varlist.count; i++) if (strncmp(varlist.args[i], PATH, sizeof(PATH) - 1) == 0) { path = varlist.args[i] + sizeof(PATH) - 1; /* * On `PATH=... command`, we need to make * sure that the command isn't using the * non-updated hash table of the outer PATH * setting and we need to make sure that * the hash table isn't filled with items * from the temporary setting. * * It would be better to forbit using and * updating the table while this command * runs, by the command finding mechanism * is heavily integrated with hash handling, * so we just delete the hash before and after * the command runs. Partly deleting like * changepatch() does doesn't seem worth the * bookinging effort, since most such runs add * directories in front of the new PATH. */ clearcmdentry(); do_clearcmdentry = 1; } for (;;) { if (bltinonly) { cmdentry.u.index = find_builtin(*argv, &cmdentry.special); if (cmdentry.u.index < 0) { cmdentry.u.index = BLTINCMD; argv--; argc++; break; } } else find_command(argv[0], &cmdentry, cmd_flags, path); /* implement the bltin and command builtins here */ if (cmdentry.cmdtype != CMDBUILTIN) break; if (cmdentry.u.index == BLTINCMD) { if (argc == 1) break; argv++; argc--; bltinonly = 1; } else if (cmdentry.u.index == COMMANDCMD) { if (argc == 1) break; if (!strcmp(argv[1], "-p")) { if (argc == 2) break; if (argv[2][0] == '-') { if (strcmp(argv[2], "--")) break; if (argc == 3) break; argv += 3; argc -= 3; } else { argv += 2; argc -= 2; } path = _PATH_STDPATH; clearcmdentry(); do_clearcmdentry = 1; } else if (!strcmp(argv[1], "--")) { if (argc == 2) break; argv += 2; argc -= 2; } else if (argv[1][0] == '-') break; else { argv++; argc--; } cmd_flags |= DO_NOFUNC; bltinonly = 0; } else break; } /* * Special builtins lose their special properties when * called via 'command'. */ if (cmd_flags & DO_NOFUNC) cmdentry.special = 0; } /* Fork off a child process if necessary. */ if (((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN) && ((flags & EV_EXIT) == 0 || have_traps())) || ((flags & EV_BACKCMD) != 0 && (cmdentry.cmdtype != CMDBUILTIN || !safe_builtin(cmdentry.u.index, argc, argv)))) { jp = makejob(cmd, 1); mode = FORK_FG; if (flags & EV_BACKCMD) { mode = FORK_NOJOB; if (pipe(pip) < 0) error("Pipe call failed: %s", strerror(errno)); } if (cmdentry.cmdtype == CMDNORMAL && cmd->ncmd.redirect == NULL && varlist.count == 0 && (mode == FORK_FG || mode == FORK_NOJOB) && !disvforkset() && !iflag && !mflag) { vforkexecshell(jp, argv, environment(), path, cmdentry.u.index, flags & EV_BACKCMD ? pip : NULL); goto parent; } if (forkshell(jp, cmd, mode) != 0) goto parent; /* at end of routine */ if (flags & EV_BACKCMD) { FORCEINTON; close(pip[0]); if (pip[1] != 1) { dup2(pip[1], 1); close(pip[1]); } flags &= ~EV_BACKCMD; } flags |= EV_EXIT; } /* This is the child process if a fork occurred. */ /* Execute the command. */ if (cmdentry.cmdtype == CMDFUNCTION) { #ifdef DEBUG trputs("Shell function: "); trargs(argv); #endif saveparam = shellparam; shellparam.malloc = 0; shellparam.reset = 1; shellparam.nparam = argc - 1; shellparam.p = argv + 1; shellparam.optp = NULL; shellparam.optnext = NULL; INTOFF; savelocalvars = localvars; localvars = NULL; reffunc(cmdentry.u.func); savehandler = handler; if (setjmp(jmploc.loc)) { freeparam(&shellparam); shellparam = saveparam; popredir(); unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; funcnest--; handler = savehandler; longjmp(handler->loc, 1); } handler = &jmploc; funcnest++; redirect(cmd->ncmd.redirect, REDIR_PUSH); INTON; for (i = 0; i < varlist.count; i++) mklocal(varlist.args[i]); exitstatus = oexitstatus; evaltree(getfuncnode(cmdentry.u.func), flags & (EV_TESTED | EV_EXIT)); INTOFF; unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; freeparam(&shellparam); shellparam = saveparam; handler = savehandler; funcnest--; popredir(); INTON; if (evalskip == SKIPRETURN) { evalskip = 0; skipcount = 0; } if (jp) exitshell(exitstatus); } else if (cmdentry.cmdtype == CMDBUILTIN) { #ifdef DEBUG trputs("builtin command: "); trargs(argv); #endif mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH; if (flags == EV_BACKCMD) { memout.nleft = 0; memout.nextc = memout.buf; memout.bufsize = 64; mode |= REDIR_BACKQ; } savecmdname = commandname; savetopfile = getcurrentfile(); cmdenviron = &varlist; e = -1; savehandler = handler; if (setjmp(jmploc.loc)) { e = exception; if (e == EXINT) exitstatus = SIGINT+128; else if (e != EXEXIT) exitstatus = 2; goto cmddone; } handler = &jmploc; redirect(cmd->ncmd.redirect, mode); outclearerror(out1); /* * If there is no command word, redirection errors should * not be fatal but assignment errors should. */ if (argc == 0) cmdentry.special = 1; listsetvar(cmdenviron, cmdentry.special ? 0 : VNOSET); if (argc > 0) bltinsetlocale(); commandname = argv[0]; argptr = argv + 1; nextopt_optptr = NULL; /* initialize nextopt */ builtin_flags = flags; exitstatus = (*builtinfunc[cmdentry.u.index])(argc, argv); flushall(); if (outiserror(out1)) { warning("write error on stdout"); if (exitstatus == 0 || exitstatus == 1) exitstatus = 2; } cmddone: if (argc > 0) bltinunsetlocale(); cmdenviron = NULL; out1 = &output; out2 = &errout; freestdout(); handler = savehandler; commandname = savecmdname; if (jp) exitshell(exitstatus); if (flags == EV_BACKCMD) { backcmd->buf = memout.buf; backcmd->nleft = memout.nextc - memout.buf; memout.buf = NULL; } if (cmdentry.u.index != EXECCMD) popredir(); if (e != -1) { if ((e != EXERROR && e != EXEXEC) || cmdentry.special) exraise(e); popfilesupto(savetopfile); if (flags != EV_BACKCMD) FORCEINTON; } } else { #ifdef DEBUG trputs("normal command: "); trargs(argv); #endif redirect(cmd->ncmd.redirect, 0); for (i = 0; i < varlist.count; i++) setvareq(varlist.args[i], VEXPORT|VSTACK); envp = environment(); shellexec(argv, envp, path, cmdentry.u.index); /*NOTREACHED*/ } goto out; parent: /* parent process gets here (if we forked) */ if (mode == FORK_FG) { /* argument to fork */ INTOFF; exitstatus = waitforjob(jp, &realstatus); INTON; if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) { evalskip = SKIPBREAK; skipcount = loopnest; } } else if (mode == FORK_NOJOB) { backcmd->fd = pip[0]; close(pip[1]); backcmd->jp = jp; } out: if (lastarg) setvar("_", lastarg, 0); if (do_clearcmdentry) clearcmdentry(); }
me->set("timer/pfm/hs_chunxin", time()); // + 200 force for everyone, self = +100 me->add_temp("pfm/free_perform",1); msg = HIG" 残雪斑驳,小草吐翠,柳絮轻扬,香山春信匆匆。$N纤指三扣,燕燕轻盈,莺莺 娇软,是耶非耶?是真是幻?曼妙的舞姿,伴着轻柔的歌声:笑江梅、雪里开迟。 香风轻度,翠叶柔枝。与玉郎摘,美人戴,总相宜。。。。\n"NOR; message_vision(msg, me); team1 = me->query_team(); if (!team1 || sizeof(team1)<2) team1 = ({ me }); team = filter_array(team1,(: present($1,environment($2)) :),me); num = sizeof(team); for (i=0; i<num; i++) { if (team[i]->query("force") < team[i]->query("max_force")*2) { if (team[i]->query("force") + cloud < team[i]->query("max_force") *2) team[i]->add("force",cloud); } else team[i]->set("force", team[i]->query("max_force")*2); team[i]->force_status_msg("force"); tell_object( team[i],YEL"生机渐盎,如春临大地,一股氤氲之气,缓缓流过你奇经八脉。\n"NOR); } buff = ([ "caster":me, "who": me,
int start() { this_object()->move("/d/citrin/rooms/shack1"); message("", "One of the many forest guardians enters.", environment(this_object())); call_out("a", 3); return 1; }
int tobe(object me,object target,object weapon, object room) { string msg; int hit_damage, damage, rate, stage, crit; if (!me) return 1; if(!target || environment(target)!=environment(me) || room!= environment(me)) { tell_object(me, WHT"真可惜,你要刺杀的目标溜走了。\n"NOR); return 1; } if (me->query_temp("last_damage_from") || me->query_temp("is_unconcious")) return 1; if(target->is_fighting(me) || target->query_max_hate()== me) { tell_object(me, "战斗中无法使用荆轲刺秦!\n"); return 1; } if (target->is_corpse()) { tell_object(me, "他已经没气啦!\n"); return 1; } if(!present(weapon,me) || weapon->query("equipped")!="wielded"){ tell_object(me, WHT"手软了?你怎么把武器收起来了? \n"NOR); return 1; } msg = YEL "\n$N跃身而起,手中"+weapon->query("name")+YEL"一转,带起阵阵风雷之声。\n$N手一抖," + weapon->query("name") + YEL"脱手飞出,如风卷黄沙呼啸着击向$n。 \n"NOR; message_vision(msg, me, target); weapon->move(environment(me)); rate = 80; stage = F_LEVEL->get_level(me->query("combat_exp")); if (stage >= 105 ) rate = 100; // 6.6 M else if (stage >=95) rate = 90; // 5.6 M // 150*3 + 100 = 550 // 485*3 + 100 = 1555; 1555*1.5= 2332 average // 150*3 + 100 = 550, 485*3 + 100 = 1555 // Players can reach skill cap @4.6M, so we use hard code to limit it // @4.6M 左右, 1088*1.5 = 1632 // 1321* 1.5 = 1982 dmg @ 5.6M+ // 1555* 1.5 = 2332 dmg @ 6.6M + hit_damage = 100 + me->query_skill("hammer") * 3* rate/100; hit_damage = hit_damage * (F_ABILITY->check_ability(me,"bolang2_add")*2 + 100)/100; // inherently 2% critical chance if (F_ABILITY->check_ability(me,"bolang1_add")+2 > random(100)) { hit_damage = hit_damage *2; crit = 1; } if (COMBAT_D->do_busy_attack(me, target, "assassin-hammer/bolangyiji","unarmed", 500, 10) || ANNIE_D->check_buff(me,"assassinate")) { damage = hit_damage + random(hit_damage); if (ANNIE_D->check_buff(me,"assassinate")) damage = hit_damage *2; damage = COMBAT_D->magic_modifier(me, target, "kee", damage); if (damage >= hit_damage *3/2) msg = HIR"只见" +weapon->query("name")+ HIR"带着一阵低啸和猛烈的劲风“轰”地击中了$n"HIR"的头部!\n"NOR; else msg = HIR"只见" +weapon->query("name")+ HIR"带着一阵低啸和猛烈的劲风“轰”地击中了$n"HIR"的胸口!\n"NOR; if (crit) msg = HBRED+HIW"只见" +weapon->query("name") + HBRED+HIW"带着一阵低啸和猛烈的劲风“轰”地击中了$n"HBRED+HIW"的眉心!\n"NOR; message_vision(msg, me, target); target->receive_damage("kee",damage, me); target->set("eff_kee",target->query("kee")); COMBAT_D->report_status(target); }else { msg = HIR"只见" +weapon->query("name")+ HIR"带着一阵劲风贴着$n"HIR"的脑袋飞过,只差几寸没有击中!\n"NOR; message_vision(msg, me, target); } target->kill_ob(me); me->kill_ob(target); me->stop_busy(); return 1; }
int curse(object me, object target) { int skill, i, mod, duration; int time; object* inv; if( me->query("class") != "wolfmount" ) { return notify_fail("只有狼山弟子才能使用『摄心咒』\n"); } skill = me->query_skill("wolf-curse", 1); if( (skill < 200 || me->query_skill("cursism", 1) < 200) && userp(me) || me->query_skill("summonwolf", 1) < 260 ) { return notify_fail("『摄心咒』需要200级天狼血咒和降头术,260级唤狼术!\n"); } // duration = 5mins. duration = me->query("timer/pfm/wm_mindcurse") + 300 - time(); if( duration > 0 ) { return notify_fail("『摄心咒』极耗元神,需要"+duration+"秒钟后才能再次运用。\n"); } if( !target ) { target = offensive_target(me); } if( !target || !target->is_character() || !me->is_fighting(target) ) { return notify_fail("『摄心咒』只能对战斗中的对手使用。\n"); } if( target->query_temp("mesmerize") || target->is_busy() ) { return notify_fail("对方已经在失魂落魄或忙乱中了,快抓紧时间进攻吧。\n"); } mod = COMBAT_D->can_busy(me, target, "wolf-curse"); if( !mod ) { return notify_fail(HIW"此人功力深湛,不会被此咒法摄魂的。\n"NOR); } if( userp(target) ) { time = 10; } else { time = 10 + F_ABILITY->check_ability(me, "3_shexin_add", 3) * 2; } // Mesmerize timer, 无论成败都出现 me->set("timer/pfm/wm_mindcurse", time()); target->set_temp("busy_timer/wolf-curse", time()); message_vision(HIB"\n$N突然发出沁人毛髓的啸叫,如同发狂的猛兽般欺身扑向$n!\n\n" NOR, me, target); // Quite high rate of success if( COMBAT_D->do_busy_attack(me, target, "wolf-curse/mindcurse", "step", 300, mod) ) { message("vision",HIR""+me->name()+HIR"的眼睛突然现出一片腥红之色,"+target->name()+HIR"的眼神与之一碰,当即呆立当场!\n"NOR, environment(me), ({target,me}));
int main (object me,string arg) { object can; mapping my; seteuid(getuid(me)); if (!arg) return help(me); if (!objectp(can=present(arg,me))&& !objectp(can=present(arg,environment(me)))) return help(me); my = can->query("液体"); // 可以在容器上头设定额外函数 if (can->query("液体/额外函数")) return 1; if( !can->query("液体/剩") ) { if (stringp(can->query("液体/名称"))) printf ("%s的%s已经被喝光了。\n",can->name(),can->query("液体/名称")); else printf ("%s是空的。\n",can->name()); return 1; } if (me->query("water") >= me->max_water_capacity()) { write ("你已经喝太多了,再也灌不下一滴水了。\n"); return 1; } can->add("液体/剩",-1); // 可以在容器上头设定饮用讯息 by ACKY if( !can->query("液体/饮用讯息") ) message_vision ("$N把嘴巴对着" + can->name() + ", 咕噜噜地喝了几口" + can->query("液体/名称") + "。\n",me); if (!intp(can->query("液体/止渴"))) me->add("water",10); else me->add("water",can->query("液体/止渴")); if ((int)me->query("water") > me->max_water_capacity()) me->set("water",me->max_water_capacity()); if (me->is_fighting()) me->start_busy(2); if (!can->query ("液体/剩")) { write ("你已经将" + can->name() + "里的" + can->query("液体/名称") + "喝得一滴也不剩了。\n"); return 1; } if (can->query("get_poison")) { write ("糟了 ! 水里有毒 !\n"); me->apply_condition (can->query("get_poison"),can->query("poison_power")); } switch(can->query("液体/种类")) { case "酒": me->apply_condition("drunk", (int)me->query_condition("drunk") + can->query("液体/酒精成份")); break; } return 1; }
string mapper(object who) { int tem, flg, i; object env, *livs; string descript, shady, tempo, nothin; env = environment(who); tem = 0; flg = 0; descript = sprintf("%-="+61+"s", env->query_long(0) + "\n"); sscanf(descript, "%s\n", tempo); tempo = nightshady(tempo); tempo += "%^GREEN%^|%^RESET%^ "; if (env->query_exit("northwest") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "[%^GREEN%^*%^RESET%^] "; else tempo += "[ ] "; flg = 0; } else tempo += " "; if (env->query_exit("north") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "[%^GREEN%^*%^RESET%^] "; else tempo += "[ ] "; flg = 0; } else tempo += " "; if (env->query_exit("northeast") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "[%^GREEN%^*%^RESET%^]\n"; else tempo += "[ ]\n"; flg = 0; } else tempo += "\n"; shady = tempo; sscanf(descript, "%*s\n%s\n", nothin); sscanf(descript, "%s\n", tempo); if (nothin == tempo){ tempo = ""; tem = 1; } else tempo = nothin; tempo = nightshady(tempo); tempo += "%^GREEN%^|%^RESET%^ "; if (env->query_exit("northwest") != "/d/standard/void") tempo += "\\ "; else tempo += " "; if (env->query_exit("north") != "/d/standard/void") tempo += "|"; else tempo += " "; if (env->query_exit("up") != "/d/standard/void") tempo += "+"; else tempo += " "; if (env->query_exit("northeast") != "/d/standard/void") tempo += "/\n"; else tempo += "\n"; shady += tempo; sscanf(descript, "%*s\n%*s\n%s\n", nothin); sscanf(descript, "%*s\n%s\n", tempo); if (nothin == tempo){ tempo = ""; tem = 1; } else tempo = nothin; if(tem) tempo = ""; tempo = nightshady(tempo); tempo += "%^GREEN%^|%^RESET%^ "; if (env->query_exit("west") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "[%^GREEN%^*%^RESET%^]-[%^RED%^X%^RESET%^]"; else tempo += "[ ]-[%^RED%^X%^RESET%^]"; flg = 0; } else tempo += " [%^RED%^X%^RESET%^]"; if (env->query_exit("east") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "-[%^GREEN%^*%^RESET%^]\n"; else tempo += "-[ ]\n"; flg = 0; } else tempo += "\n"; shady += tempo; sscanf(descript, "%*s\n%*s\n%*s\n%s\n", nothin); sscanf(descript, "%*s\n%*s\n%s\n", tempo); if (nothin == tempo){ tempo = ""; tem = 1; } else tempo = nothin; if(tem) tempo = ""; tempo = nightshady(tempo); tempo += "%^GREEN%^|%^RESET%^ "; if (env->query_exit("southwest") != "/d/standard/void") tempo += "/"; else tempo += " "; if (env->query_exit("down") != "/d/standard/void") tempo += "-"; else tempo += " "; if (env->query_exit("south") != "/d/standard/void") tempo += "| "; else tempo += " "; if (env->query_exit("southeast") != "/d/standard/void") tempo += "\\\n"; else tempo += "\n"; shady += tempo; sscanf(descript, "%*s\n%*s\n%*s\n%*s\n%s\n", nothin); sscanf(descript, "%*s\n%*s\n%*s\n%s\n", tempo); if (nothin == tempo){ tempo = ""; tem = 1; } else tempo = nothin; if(tem) tempo = ""; tempo = nightshady(tempo); tempo += "%^GREEN%^|%^RESET%^ "; if (env->query_exit("southwest") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "[%^GREEN%^*%^RESET%^] "; else tempo += "[ ] "; flg = 0; } else tempo += " "; if (env->query_exit("south") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "[%^GREEN%^*%^RESET%^] "; else tempo += "[ ] "; flg = 0; } else tempo += " "; if (env->query_exit("southeast") != "/d/standard/void") { livs = all_inventory(find_object(env->query_exit())); for(i=0;i<sizeof(livs);i++) if(living(livs[i])) flg = 1; if(flg) tempo += "[%^GREEN%^*%^RESET%^]\n"; else tempo += "[ ]\n"; flg = 0; } else tempo += "\n"; shady += tempo; sscanf(descript, "%*s\n%*s\n%*s\n%*s\n%*s\n%s", nothin); sscanf(descript, "%*s\n%*s\n%*s\n%*s\n%s\n", tempo); if (nothin == tempo){ tempo = ""; tem = 1; } else tempo = nothin; if(tem) tempo = ""; shady += tempo; return shady; }
/*! Get the origin of the trajectory. */ const StaBody* ScenarioLoiteringTrajectory::centralBody() const { return environment()->centralBody()->body(); }
void init() { object me = this_player(); if( wizardp(me) && getuid(me)!="qfy ") message("vision", me->name()+"走了过来。\n", environment(me), ({me}));
sta::StateVector ScenarioLoiteringTrajectory::computeInitialStateVector() const { return m_simulationParameters->initialStatePosition()->computeStateVector(environment()->centralBody()->body()); }
/*! Propagate a loitering trajectory, filling the lists of sampleTimes * and samples with the results of each step. Errors during propagation * are indicated by setting the error flag in the PropagationFeedback * object. * * The return value of propagate is the final state after propagation * is complete (i.e. the last entry in the samples list.) */ sta::StateVector ScenarioLoiteringTrajectory::propagate(PropagationFeedback& propFeedback, const sta::StateVector& initialState, QList<double>& sampleTimes, QList<sta::StateVector>& samples) { QTextStream out (stdout); double mu = centralBody()->mu(); const ScenarioExtendedTimeline* timeline = simulationParameters()->timeline(); // Creating the list of perturbations that will influence the propagation ScenarioSpaceVehicle* spacevehicle = dynamic_cast<ScenarioSpaceVehicle*>(this->parent()->parent()); ScenarioProperties* vehicleproperties = spacevehicle->properties(); QList<Perturbations*> perturbationsList = environment()->createListPerturbations(vehicleproperties); double timelineDuration = sta::daysToSecs(timeline->endTime() - timeline->startTime()); double dt = trajectoryPropagation()->timeStep(); if (dt == 0.0) { propFeedback.raiseError(QObject::tr("Time step is zero!")); return initialState; } // We don't output values at every integration step. Instead use the time step // from simulation parameters. The actual output step used will not necessarily // match the requested output step: the code below sets it to be an integer // multiple of the integration step. double requestedOutputTimeStep = simulationParameters()->timeline()->timeStep(); double outputTimeStep; unsigned int outputRate; if (requestedOutputTimeStep < dt) { outputRate = 1; outputTimeStep = dt; } else { outputRate = (unsigned int) floor(requestedOutputTimeStep / dt + 0.5); outputTimeStep = outputRate * dt; } if (timelineDuration / outputTimeStep > MAX_OUTPUT_STEPS) { propFeedback.raiseError(QObject::tr("Number of propagation steps exceeds %1. Try increasing the simulation time step.").arg(MAX_OUTPUT_STEPS)); return initialState; } // Calculate initial keplerian elements in case the propagator Two Body will be used sta::KeplerianElements foundKeplerianElements = cartesianTOorbital(mu, initialState); double sma = foundKeplerianElements.SemimajorAxis; double e = foundKeplerianElements.Eccentricity; double inclination = foundKeplerianElements.Inclination; double raan = foundKeplerianElements.AscendingNode; double argOfPeriapsis = foundKeplerianElements.ArgumentOfPeriapsis; double meanAnomaly = foundKeplerianElements.MeanAnomaly; double perigee = sma * (1-e); if (perigee<centralBody()->meanRadius()) { QMessageBox::warning(NULL, QObject::tr("The trajectory has been not propagated"), QObject::tr("The perigee distance is smaller than the main body radius.")); return initialState.zero(); } sta::StateVector stateVector = initialState; // deviation, reference, and q will be used only in Encke propagation sta::StateVector deviation(Vector3d::Zero(), Vector3d::Zero()); sta::StateVector reference = initialState; double q = 0.0; sampleTimes << timeline->startTime(); samples << stateVector; double time = timeline->startTime(); //mjd QFile ciccio("data/PerturbationsData.stae"); QTextStream cicciostream(&ciccio); ciccio.open(QIODevice::WriteOnly); unsigned int steps = 0; for (double t = dt; t < timelineDuration + dt; t += dt) { JulianDate jd = timeline->startTime() + sta::secsToDays(t); // Choosing the propagator and propagating the trajectory if (trajectoryPropagation()->propagator() == "TWO BODY") { double perigee=sma*(1-e); if (perigee<centralBody()->meanRadius()) { QMessageBox::warning(NULL, QObject::tr("The trajectory has been not propagated"), QObject::tr("The perigee distance is smaller than the main body radius.")); return stateVector.zero(); } double argOfPeriapsisUpdated = 0.0; double meanAnomalyUpdated = 0.0; double raanUpdated = 0.0; stateVector = propagateTWObody(mu, sma, e, inclination, argOfPeriapsis, raan, meanAnomaly, trajectoryPropagation()->timeStep(), raanUpdated, argOfPeriapsisUpdated, meanAnomalyUpdated); argOfPeriapsis = argOfPeriapsisUpdated; meanAnomaly = meanAnomalyUpdated; raan = raanUpdated; } else if (trajectoryPropagation()->propagator() == "COWELL") { stateVector = propagateCOWELL(mu, stateVector, trajectoryPropagation()->timeStep(), perturbationsList, time, trajectoryPropagation()->integrator(), propFeedback); } else if (trajectoryPropagation()->propagator() == "ENCKE") { deviation = propagateENCKE(mu, reference, trajectoryPropagation()->timeStep(),perturbationsList, time, stateVector, deviation, q, trajectoryPropagation()->integrator(), propFeedback); // PropagateTWObody is used to propagate the reference trajectory double argOfPeriapsisUpdated = 0.0; double meanAnomalyUpdated = 0.0; double raanUpdated = 0.0; reference = propagateTWObody(mu, sma, e, inclination, argOfPeriapsis, raan, meanAnomaly, trajectoryPropagation()->timeStep(), raanUpdated, argOfPeriapsisUpdated, meanAnomalyUpdated); argOfPeriapsis = argOfPeriapsisUpdated; meanAnomaly = meanAnomalyUpdated; raan = raanUpdated; // Calculating the perturbed trajectory stateVector = reference + deviation; q = deviation.position.dot(reference.position + 0.5 * deviation.position) / pow(reference.position.norm(), 2.0); // // Rectification of the reference trajectory, when the deviation is too large. // if (q > 0.01) // { // sta::KeplerianElements keplerian = cartesianTOorbital(mu, stateVector); // // sma = keplerian.SemimajorAxis; // e = keplerian.Eccentricity; // inclination = keplerian.Inclination; // argOfPeriapsis = keplerian.ArgumentOfPeriapsis; // raan = keplerian.AscendingNode; // meanAnomaly = keplerian.MeanAnomaly; // // q = 0; // reference = stateVector; // deviation = sta::StateVector(null, null); // } } else if (trajectoryPropagation()->propagator() == "GAUSS") { stateVector = propagateGAUSS(mu, stateVector, trajectoryPropagation()->timeStep(), perturbationsList, time, trajectoryPropagation()->integrator()); } KeplerianElements kep = cartesianTOorbital(mu, stateVector); cicciostream.setRealNumberPrecision(8); //cicciostream << kep.SemimajorAxis << " "; //cicciostream << kep.Eccentricity << " "; cicciostream << kep.Inclination << " "; //cicciostream << kep.ArgumentOfPeriapsis << " "; //cicciostream << kep.AscendingNode << " "; //cicciostream << kep.TrueAnomaly << " "; // //Treat the debris perturbation if selected by the user // foreach (Perturbations* perturbation, perturbationsList) // if (dynamic_cast<DebrisPerturbations*>(perturbation)) // { // DebrisPerturbations* debris = dynamic_cast<DebrisPerturbations*>(perturbation); // double gravityAcceleration = (-pow(initialState.position.norm(),-3.0) * mu * initialState.position).norm(); // double perturbedAcceleration = gravityAcceleration + debris->calculatePerturbingEffect(initialState, sta::daysToSecs(jd)); // } // Append a trajectory sample every outputRate integration steps (and // always at the last step.) if (steps % outputRate == 0 || t >= timelineDuration) { sampleTimes << jd; samples << stateVector; } ++steps; time += sta::secsToDays(dt); }; //out << "samples size: " << samples.size() << endl; return stateVector; }
void endCallback(object who) { if( who ) { send_messages("", "The %^BOLD%^CYAN%^magical shield%^RESET%^ around " "$agent_name shatters into nothingness.", who, 0, environment(who), 0); } }
tmp += words[i]; if( ob = present(tmp, this_player()) ) { if( i == maxi - 1 ) text = ""; else text = implode(words[i+1..], " "); break; } if( (env=environment(this_player())) && ob = present(tmp, env) ) { if( i == maxi - 1 ) text = ""; else text = implode(words[i+1..], " "); break; } tmp += " "; } } else text = ""; ob = (ob || environment(this_player())); if( text != "" ) { if( ob ) { tmp = (string)this_player()->GetCapName() + " reports praise in: " + identify(ob) + "\non " + ctime(time()) + "\n"; secondary = GetCreator(ob); } else tmp = (string)this_player()->GetCapName() + " reports praise on: " + ctime(time()) + ":\n"; log_file("praise", tmp + text + "\n\n"); if( secondary ) log_file("reports/" + secondary, tmp + text + "\n\n"); message("system", "Praise reported!!! Thank you!!!", this_player()); return 1; } rm( file = DIR_TMP "/" + (string)this_player()->GetKeyName() );
int main(object me, string arg) { object ob; mapping skill; int cost, my_skill; if(environment(me)->query("no_fight") || environment(me)->query("no_magic") ) return notify_fail("这里不是读书的地方。\n"); if( me->is_fighting() ) return notify_fail("你无法在战斗中专心下来研读新知!\n"); if (me->is_busy() || me->query_temp("pending/exercising")) return notify_fail("你现在正忙着呢。\n"); if(!arg || !objectp(ob = present(arg, me)) ) return notify_fail("你要读什么?\n"); if( !mapp(skill = ob->query("skill")) ) return notify_fail("你无法从这样东西学到任何东西。\n"); if( !me->query_skill("literate", 1) ) return notify_fail("你是个文盲,先学学读书识字(literate)吧。\n"); message("vision", me->name() + "正专心地研读" + ob->name() + "。\n", environment(me), me); my_skill=me->query_skill(skill["name"],1); if ( (string)SKILL_D(skill["name"])->type()=="martial" ) { if( my_skill*my_skill*my_skill/10>(int)me->query("combat_exp") || (int)me->query("combat_exp") < skill["exp_required"] ) { write("你的武学修为还没到这个境界,光读是没用的。\n"); return 1; } } else if ( (string)SKILL_D(skill["name"])->type()=="magic" ) { if( my_skill*my_skill*my_skill/10>(int)me->query("daoxing") || (int)me->query("daoxing") < skill["dx_required"] ) { write("你的道行还没到这个境界,光读是没用的。\n"); return 1; } } notify_fail("以你目前的能力,还没有办法学这个技能。\n"); if( !SKILL_D(skill["name"])->valid_learn(me) ) return 0; cost = skill["sen_cost"] + skill["sen_cost"] * (skill["difficulty"] - (int)me->query_int())/20; if (cost < 5) cost = 5; if( (int)me->query("sen") < cost ) { write("你现在过于疲倦,无法专心下来研读新知。\n"); return 1; } if( me->query_skill(skill["name"], 1) > skill["max_skill"] ) { write("你研读了一会儿,但是发现上面所说的对你而言都太浅了,没有学到任何东西。\n"); return 1; } me->receive_damage("sen", cost); if( !me->query_skill(skill["name"], 1) ) me->set_skill(skill["name"], 0); me->improve_skill(skill["name"], (int)me->query_skill("literate", 1)/5+1); write("你研读有关" + to_chinese(skill["name"]) + "的技巧,似乎有点心得。\n"); return 1; }
int main(object me, string arg) { object ob; mapping skill; int cost, intt, literate,repeat,i; string name; repeat=0; if( me->is_fighting() ) return notify_fail("你无法在战斗中专心下来研读新知!\n"); if(!arg) return notify_fail("你要读什么?\n"); if(sscanf(arg,"%d %s",repeat,name)==2) arg=name; if(!repeat) repeat=1; if(!arg || !objectp(ob = present(arg, me)) ) return notify_fail("你要读什么?\n"); if( !mapp(skill = ob->query("skill")) ) return notify_fail("这东西并不是武术秘籍, 你无法从它学到东西。\n"); if( !(literate=me->query_skill("literate", 1)) ) return notify_fail("你是个文盲,先学学读书识字(literate)吧。\n"); if ( (int)me->query("combat_exp") < skill["exp_required"] ) return notify_fail ("你的实战经验不足,再怎么读也没用。\n"); if( !SKILL_D(skill["name"])->valid_learn(me) ) return 0; //notify_fail("以你目前的能力,还没有办法学这个技能。\n"); // fix by Onion. // skill 里的 valid_learn() 都有写 notify_fail(), 应以 skill 的叙述就好。 if (ob->valid_learn(me)<0) return notify_fail ("据说你还不够格读此书哩!\n"); cost = skill["difficulty"] - (intt=(int)me->query("int")); if (cost < 0) cost = 0; cost = -literate/10+skill["sen_cost"] + skill["sen_cost"] * cost/20; if( cost < 0 ) cost = skill["sen_cost"]; if(me->query("class")=="scholar") cost=cost*2/3; for(i=0;i<repeat;i++) { if( (int)me->query("sen") < cost ) { write("你现在过于疲倦,无法专心下来研读新知。\n"); return 1; } if( me->query_skill(skill["name"], 1) > skill["max_skill"] ) return notify_fail ("你发现上面所说的对你而言都太浅了。\n"); me->receive_damage("sen", cost); if( !me->query_skill(skill["name"], 1) ) me->set_skill(skill["name"], 1); else { // Modify By chun 95/10/27 // 由literate的影响改为受int的影响 // wade fix in 1/4/1996, 改为混合 literate 与 悟性 两者 intt = intt/2; me->improve_skill(skill["name"], literate/10+random(intt)+5); if(me->query("class")=="scholar") me->improve_skill(skill["name"], literate/10+random(intt)+5); } message("vision", me->name() + "正专心地研读" + ob->name() + "。\n", environment(me), me); write("你研读有关" + to_chinese(skill["name"]) + "的技巧,似乎有点心得。\n"); } return 1; }
static void evalcommand(union node *cmd, int flags, struct backcmd *backcmd) { struct stackmark smark; union node *argp; struct arglist arglist; struct arglist varlist; char **argv; int argc; char **envp; int varflag; struct strlist *sp; int mode; int pip[2]; struct cmdentry cmdentry; struct job *jp; struct jmploc jmploc; struct jmploc *savehandler; char *savecmdname; struct shparam saveparam; struct localvar *savelocalvars; volatile int e; char *lastarg; int realstatus; int do_clearcmdentry; /* First expand the arguments. */ TRACE(("evalcommand(%p, %d) called\n", (void *)cmd, flags)); setstackmark(&smark); arglist.lastp = &arglist.list; varlist.lastp = &varlist.list; varflag = 1; do_clearcmdentry = 0; oexitstatus = exitstatus; exitstatus = 0; for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) { char *p = argp->narg.text; if (varflag && is_name(*p)) { do { p++; } while (is_in_name(*p)); if (*p == '=') { expandarg(argp, &varlist, EXP_VARTILDE); continue; } } expandarg(argp, &arglist, EXP_FULL | EXP_TILDE); varflag = 0; } *arglist.lastp = NULL; *varlist.lastp = NULL; expredir(cmd->ncmd.redirect); argc = 0; for (sp = arglist.list ; sp ; sp = sp->next) argc++; argv = stalloc(sizeof (char *) * (argc + 1)); for (sp = arglist.list ; sp ; sp = sp->next) { TRACE(("evalcommand arg: %s\n", sp->text)); *argv++ = sp->text; } *argv = NULL; lastarg = NULL; if (iflag && funcnest == 0 && argc > 0) lastarg = argv[-1]; argv -= argc; /* Print the command if xflag is set. */ if (xflag) { char sep = 0; const char *p; out2str(ps4val()); for (sp = varlist.list ; sp ; sp = sp->next) { if (sep != 0) outc(' ', &errout); p = sp->text; while (*p != '=' && *p != '\0') out2c(*p++); if (*p != '\0') { out2c(*p++); out2qstr(p); } sep = ' '; } for (sp = arglist.list ; sp ; sp = sp->next) { if (sep != 0) outc(' ', &errout); /* Disambiguate command looking like assignment. */ if (sp == arglist.list && strchr(sp->text, '=') != NULL && strchr(sp->text, '\'') == NULL) { out2c('\''); out2str(sp->text); out2c('\''); } else out2qstr(sp->text); sep = ' '; } outc('\n', &errout); flushout(&errout); } /* Now locate the command. */ if (argc == 0) { /* Variable assignment(s) without command */ cmdentry.cmdtype = CMDBUILTIN; cmdentry.u.index = BLTINCMD; cmdentry.special = 1; } else { static const char PATH[] = "PATH="; char *path = pathval(); /* * Modify the command lookup path, if a PATH= assignment * is present */ for (sp = varlist.list ; sp ; sp = sp->next) if (strncmp(sp->text, PATH, sizeof(PATH) - 1) == 0) { path = sp->text + sizeof(PATH) - 1; /* * On `PATH=... command`, we need to make * sure that the command isn't using the * non-updated hash table of the outer PATH * setting and we need to make sure that * the hash table isn't filled with items * from the temporary setting. * * It would be better to forbit using and * updating the table while this command * runs, by the command finding mechanism * is heavily integrated with hash handling, * so we just delete the hash before and after * the command runs. Partly deleting like * changepatch() does doesn't seem worth the * bookinging effort, since most such runs add * directories in front of the new PATH. */ clearcmdentry(0); do_clearcmdentry = 1; } find_command(argv[0], &cmdentry, 1, path); if (cmdentry.cmdtype == CMDUNKNOWN) { /* command not found */ exitstatus = 127; flushout(&errout); return; } /* implement the bltin builtin here */ if (cmdentry.cmdtype == CMDBUILTIN && cmdentry.u.index == BLTINCMD) { for (;;) { argv++; if (--argc == 0) break; if ((cmdentry.u.index = find_builtin(*argv, &cmdentry.special)) < 0) { outfmt(&errout, "%s: not found\n", *argv); exitstatus = 127; flushout(&errout); return; } if (cmdentry.u.index != BLTINCMD) break; } } } /* Fork off a child process if necessary. */ if (cmd->ncmd.backgnd || (cmdentry.cmdtype == CMDNORMAL && ((flags & EV_EXIT) == 0 || have_traps())) || ((flags & EV_BACKCMD) != 0 && (cmdentry.cmdtype != CMDBUILTIN || cmdentry.u.index == CDCMD || cmdentry.u.index == DOTCMD || cmdentry.u.index == EVALCMD)) || (cmdentry.cmdtype == CMDBUILTIN && cmdentry.u.index == COMMANDCMD)) { jp = makejob(cmd, 1); mode = cmd->ncmd.backgnd; if (flags & EV_BACKCMD) { mode = FORK_NOJOB; if (pipe(pip) < 0) error("Pipe call failed: %s", strerror(errno)); } if (forkshell(jp, cmd, mode) != 0) goto parent; /* at end of routine */ if (flags & EV_BACKCMD) { FORCEINTON; close(pip[0]); if (pip[1] != 1) { dup2(pip[1], 1); close(pip[1]); } } flags |= EV_EXIT; } /* This is the child process if a fork occurred. */ /* Execute the command. */ if (cmdentry.cmdtype == CMDFUNCTION) { #ifdef DEBUG trputs("Shell function: "); trargs(argv); #endif redirect(cmd->ncmd.redirect, REDIR_PUSH); saveparam = shellparam; shellparam.malloc = 0; shellparam.reset = 1; shellparam.nparam = argc - 1; shellparam.p = argv + 1; shellparam.optnext = NULL; INTOFF; savelocalvars = localvars; localvars = NULL; reffunc(cmdentry.u.func); INTON; savehandler = handler; if (setjmp(jmploc.loc)) { if (exception == EXSHELLPROC) freeparam(&saveparam); else { freeparam(&shellparam); shellparam = saveparam; } unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; handler = savehandler; longjmp(handler->loc, 1); } handler = &jmploc; for (sp = varlist.list ; sp ; sp = sp->next) mklocal(sp->text); funcnest++; exitstatus = oexitstatus; if (flags & EV_TESTED) evaltree(getfuncnode(cmdentry.u.func), EV_TESTED); else evaltree(getfuncnode(cmdentry.u.func), 0); funcnest--; INTOFF; unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; freeparam(&shellparam); shellparam = saveparam; handler = savehandler; popredir(); INTON; if (evalskip == SKIPFUNC) { evalskip = 0; skipcount = 0; } if (flags & EV_EXIT) exitshell(exitstatus); } else if (cmdentry.cmdtype == CMDBUILTIN) { #ifdef DEBUG trputs("builtin command: "); trargs(argv); #endif mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH; if (flags == EV_BACKCMD) { memout.nleft = 0; memout.nextc = memout.buf; memout.bufsize = 64; mode |= REDIR_BACKQ; } savecmdname = commandname; cmdenviron = varlist.list; e = -1; savehandler = handler; if (setjmp(jmploc.loc)) { e = exception; exitstatus = (e == EXINT)? SIGINT+128 : 2; goto cmddone; } handler = &jmploc; redirect(cmd->ncmd.redirect, mode); if (cmdentry.special) listsetvar(cmdenviron); commandname = argv[0]; argptr = argv + 1; nextopt_optptr = NULL; /* initialize nextopt */ builtin_flags = flags; exitstatus = (*builtinfunc[cmdentry.u.index])(argc, argv); flushall(); cmddone: cmdenviron = NULL; out1 = &output; out2 = &errout; freestdout(); if (e != EXSHELLPROC) { commandname = savecmdname; if (flags & EV_EXIT) { exitshell(exitstatus); } } handler = savehandler; if (e != -1) { if ((e != EXERROR && e != EXEXEC) || cmdentry.special) exraise(e); FORCEINTON; } if (cmdentry.u.index != EXECCMD) popredir(); if (flags == EV_BACKCMD) { backcmd->buf = memout.buf; backcmd->nleft = memout.nextc - memout.buf; memout.buf = NULL; } } else { #ifdef DEBUG trputs("normal command: "); trargs(argv); #endif clearredir(); redirect(cmd->ncmd.redirect, 0); for (sp = varlist.list ; sp ; sp = sp->next) setvareq(sp->text, VEXPORT|VSTACK); envp = environment(); shellexec(argv, envp, pathval(), cmdentry.u.index); /*NOTREACHED*/ } goto out; parent: /* parent process gets here (if we forked) */ if (mode == FORK_FG) { /* argument to fork */ INTOFF; exitstatus = waitforjob(jp, &realstatus); INTON; if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) { evalskip = SKIPBREAK; skipcount = loopnest; } } else if (mode == FORK_NOJOB) { backcmd->fd = pip[0]; close(pip[1]); backcmd->jp = jp; } out: if (lastarg) setvar("_", lastarg, 0); if (do_clearcmdentry) clearcmdentry(0); popstackmark(&smark); }
int weapon_hit(object ob) { if ( ob->query_guild() != "darksoul" ) { message("info", "%^BOLD%^%^BLACK%^Dark Souls Knife glows and a deep black mist begins to fill the room, as souls devour everything.\n", environment(ob)); return 10000; } return 1; }
int main(object me, string arg) { string from, item; object obj, *inv, env, obj2; int i, amount; if (!arg) return notify_fail("你要捡起什么东西?\n"); if (me->is_busy()) return notify_fail("你上一个动作还没有完成!\n"); if (sscanf(arg, "%s from %s", arg, from) == 2) { env = present(from, me); if (!env) env = present(from, environment(me)); if (!env) return notify_fail("你找不到 " + from + " 这样东西。\n"); if ((env->query("no_get_from") || living(env)) && (wiz_level(me) <= wiz_level(env))) return notify_fail("你的巫师等级必须比对方高,才能搜身。\n"); } else env = environment(me); if (sscanf(arg, "%d %s", amount, item) == 2) { if (!objectp(obj = present(item, env))) return notify_fail("这里没有这样东西。\n"); if (!obj->query_amount()) return notify_fail(obj->name() + "不能被分开拿走。\n"); if (amount < 1) return notify_fail("东西的个数至少是一个。\n"); if (amount > obj->query_amount()) return notify_fail("这里没有那麽多的" + obj->name() + "。\n"); else if(amount == (int)obj->query_amount()) return do_get(me, obj); else { obj2 = new(base_name(obj)); obj2->set_amount((int)obj->query_amount() - amount); obj->set_amount( amount ); do_get(me, obj); obj2->move(env); if (me->is_fighting()) me->start_busy(3); return 1; } } if (arg=="all") { if (me->is_fighting()) return notify_fail("你还在战斗中!只能一次拿一样。\n"); if (!env->query_max_encumbrance()) return notify_fail("那不是容器。\n"); if (env->is_tree()) return notify_fail("这是给新手活命用的,还是不要太贪心了吧n"); inv = all_inventory(env); if (!sizeof(inv)) { if (env->is_tree()) return notify_fail("树上什么也没有了。\n"); return notify_fail("那里面没有任何东西。\n"); } for (i = 0; i < sizeof(inv); i ++) { if (inv[i]->is_character() || inv[i]->query("no_get")) continue; do_get(me, inv[i]); } write("捡好了。\n"); return 1; } if (!objectp(obj = present(arg, env)) || living(obj)) return notify_fail("你附近没有这样东西。\n"); if (obj->query("no_get")) return notify_fail("这个东西拿不起来。\n"); return do_get(me, obj); }
int update_sex_status() { mapping my; string dodge, force, spells; int sex_per, update_flag, sex_affair; update_flag = 0; my = query_entire_dbase(); if (!mapp(my)) return 0; if (my["want"] > 0 && my["want"] > my["eff_want"]) { my["want"] -= 1; update_flag++; } if (my["enjoy"] > 0) { my["enjoy"] -= 1; update_flag++; } sex_per = my["per"] + query_temp("apply/personality"); dodge = query_skill_mapped("dodge"); force = query_skill_mapped("force"); spells = query_skill_mapped("spells"); sex_affair = 0; if (dodge) { sex_affair += SKILL_D(dodge)->query_sex_affair(); if (sex_affair == 0) ; else if (sex_affair < 0) { my["want"] += sex_affair; update_flag++; } else if (sex_affair > 0) { sex_per += sex_affair; } } if (force) { sex_affair += SKILL_D(force)->query_sex_affair(); if (sex_affair == 0) ; else if (sex_affair < 0) { my["want"] += sex_affair; update_flag++; } else if (sex_affair > 0) { sex_per += sex_affair; } } if (spells) { sex_affair += SKILL_D(spells)->query_sex_affair(); if (sex_affair == 0) ; else if (sex_affair < 0) { my["want"] += sex_affair; update_flag++; } else if (sex_affair > 0) { sex_per += sex_affair; } } sex_per += query_temp("apply/sex_personality"); if (sex_affair > 0) { object env = environment(); if (environment()) { object ob = first_inventory(environment()); while (ob) { if (living(ob)) { ob->add("want", sex_per); update_flag++; } ob = next_inventory(ob); } } } return update_flag; }
int cmd_heal(string str) { string whom, limb, clas; int amount, cost, healing, i, wisdom; object tp, ob; string * limbs; if (!spell()) { return 0; } if(!str) { notify_fail("Heal whom?\n"); return 0; } tp = this_player(); if(tp->query_busy()) { notify_fail("You are in the middle of something else.\n"); return 0; } if(!alignment_ok(this_player())) { notify_fail("You have betrayed the source of your powers.\n"); return 0; } if(this_player()->query_ghost()) return notify_fail("You cannot speak without a body.\n"); healing = (int)tp->query_skill("healing")/2; healing += (int)tp->query_level()/3; healing += (int)tp->query_skill("faith")/4; healing += tp->query_skill("belief")/4; healing += tp->query_stats("wisdom")/3; clas = (string)tp->query_subclass(); if(str == "me" || str == "myself") ob = tp; else ob = present(str, environment(tp)); if(!ob) { if(sscanf(str, "%s %s", whom, limb) != 2) { notify_fail("Heal whom?\n"); return 0; } if(whom == "me" || whom == "myself") ob = tp; else ob = present(whom, environment(tp)); } if(!ob) { notify_fail("Heal whom?\n"); return 0; } if(!limb) cost = healing/2; else if(limb == "all") cost = healing*3/4; else if(member_array(limb, (string *)ob->query_limbs()) == -1) { notify_fail("That limb is missing!\n"); return 0; } else cost = healing/3; if(ob != tp) cost = random(cost); if((int)tp->query_mp() < cost) { notify_fail("Too low on magic power.\n"); return 0; } tp->add_mp(-cost); amount = (healing); if(amount > 800) { log_file("hmmm", this_player()->query_name()+" healing "+ob->query_short()+" "+amount+"\n"); amount = 800; } this_player()->set_magic_round(1); if(tp == ob) tp->add_skill_points("healing", amount/3); else { tp->add_skill_points("healing", amount/2); tp->add_alignment(5+amount/5); tp->add_exp(amount/4); } if(!limb) { ob->add_hp(amount); } else if(limb == "all") { limbs = (string *)ob->query_limbs(); for(i=0; i<sizeof(limbs); i++) { ob->heal_limb(limbs[i], (amount/2)); } ob->add_hp(amount/2); } else { ob->heal_limb(limb, amount); ob->add_hp(amount/3); } send_messages(tp, ob, clas, limb); return 1; }
int main(object me, string arg) { object ob, old_rec; mapping family; int i; if( !arg ) return notify_fail("指令格式:recruit [cancel]|<对象>\n"); if( arg=="cancel" ) { old_rec = me->query_temp("pending/recruit"); if( !objectp(old_rec) ) return notify_fail("你现在并没有收录任何人为弟子的意思。\n"); write("你改变主意不想收" + old_rec->name() + "为弟子了。\n"); tell_object(old_rec, me->name() + "改变主意不想收你为弟子了。\n"); me->delete_temp("pending/recruit"); return 1; } if( !(ob = present(arg, environment(me))) ) return notify_fail("你想收谁作弟子?\n"); if( ob==me ) return notify_fail("收自己为弟子?好主意...不过没有用。\n"); if( ob->is_apprentice_of(me) ) { message_vision("$N拍拍$n的头,说道:「好徒儿!」\n", me, ob); return 1; } if( !me->query("family") ) return notify_fail("你并不属于任何门派,你必须先加入一个门派,或自己创一个才能收徒。\n"); if (!me->query("family/generation")) return notify_fail("你乃弃徒,先求哪一位本门师父将你重列门墙再说吧。\n"); if ( (ob->query("family")) && (me->query("family/family_name") != ob->query("family/family_name")) ) return notify_fail(ob->name()+"乃"+ob->query("family/family_name") +"弟子,未经其师尊同意就挖人家墙角不太好吧。\n\n"); if (me->query("family/master_id") == ob->query("id")) return notify_fail("开什么玩笑?人家是你师父,还有什么要从你这里学的?\n"); if ( userp(me) && userp(ob) && (wizardp(me) != wizardp(ob)) ) return notify_fail("巫师玩家之间不能有师徒关系。\n"); /* if( ob->query("family")){ if ((int)me->query("family/generation") >= (int)ob->query("family/generation")) return notify_fail("你只能收辈份比你低的同门派弟子为徒。\n"); } */ // If the target is willing to apprentice us already, we do it. if( (object)ob->query_temp("pending/apprentice") == me ) { if( !living(ob) ) { message_vision( "$N决定收$n为弟子。\n\n" "不过看样子$n显然没有办法行拜师之礼。\n\n", me, ob); return 1; } // follow modified by elon 09-10-95 to fix a bug in 1st time recruit if((ob->query("family")) && ( (string)me->query("family/family_name") != (string)ob->query("family/family_name") ) ) { message_vision( "$N决定投入$n门下!!\n\n" "$N跪了下来向$n恭恭敬敬地磕了四个响头,叫道:「师父!」\n\n", ob, me); ob->set("score", 0); ob->add("betrayer", 1); } else message_vision( "$N决定收$n为弟子。\n\n" "$n跪了下来向$N恭恭敬敬地磕了四个响头,叫道:「师父!」\n", me, ob); me->recruit_apprentice(ob); ob->delete_temp("pending/apprentice"); write("恭喜你新收了一名弟子!\n"); family = ob->query("family"); tell_object( ob, sprintf("恭喜您成为%s的第%s代弟子。\n", family["family_name"], chinese_number(family["generation"]) )); return 1; } else { old_rec = me->query_temp("pending/recruit"); if( ob==old_rec ) return notify_fail("你想收" + ob->name() + "为弟子,但是对方还没有答应。\n"); else if( objectp(old_rec) ) { write("你改变主意不想收" + old_rec->name() + "为弟子了。\n"); tell_object(old_rec, me->name() + "改变主意不想收你为弟子了。\n"); } me->set_temp("pending/recruit", ob ); message_vision("\n$N想要收$n为弟子。\n", me, ob); tell_object(ob, YEL "如果你愿意拜" + me->name() + "为师父,用 apprentice 指令。\n" NOR); return 1; } }
int cmd_heal(string str) { string whom, limb, clas; int amount, cost, healing, i, wisdom; object tp, ob; string * limbs; if (!spell()) { write("What?\n"); return 1; } if(!str) { notify_fail("Heal whom?\n"); return 0; } tp = this_player(); if(tp->query_casting()) { notify_fail("You are in the middle of another spell!\n"); return 0; } if(!alignment_ok(this_player())) { notify_fail("You have betrayed the source of your powers.\n"); return 0; } healing = (int)tp->query_skill("healing"); wisdom = (int)tp->query_stats("wisdom"); clas = (string)tp->query_subclass(); if(str == "me" || str == "myself") ob = tp; else ob = present(str, environment(tp)); if(!ob) { if(sscanf(str, "%s %s", whom, limb) != 2) { notify_fail("Correct syntax: <heal [who] [(limb)]\n"); return 0; } if(whom == "me" || whom == "myself") ob = tp; else ob = present(whom, environment(tp)); } if(!ob) { notify_fail("Heal whom?\n"); return 0; } if(!limb) cost = 22; else if(limb == "all") cost = 44; else if(member_array(limb, (string *)tp->query_limbs()) == -1) { notify_fail("You do not have a "+limb+".\n"); return 0; } else cost = 14; if(ob != tp) cost = random(cost); if((int)tp->query_mp() < cost) { notify_fail("Too low on magic power.\n"); tp->add_mp(-cost); return 0; } this_player()->set_magic_round(1); tp->add_mp(-cost); if(healing < 5) amount = 0; else amount = random(wisdom + (healing/10)); if(!amount) { write("You do not have the skill to do that."); return 1; } if(tp == ob) tp->add_skill_points("healing", amount); else { tp->add_skill_points("healing", amount * 2); tp->add_alignment(amount); tp->add_exp(random((amount/2)+2)); } if(!limb) { ob->add_hp(amount); send_messages(tp, ob, clas, 0); } else if(limb == "all") { limbs = (string *)ob->query_limbs(); for(i=0; i<sizeof(limbs); i++) { ob->heal_limb(limbs[i], (amount / 2)); } ob->add_hp(amount / 2); send_messages(tp, ob, clas, limb); } else { ob->heal_limb(limb, amount); send_messages(tp, ob, clas, limb); } return 1; }
message_vision(HIB"\n$N突然发出沁人毛髓的啸叫,如同发狂的猛兽般欺身扑向$n!\n\n" NOR, me, target); // Quite high rate of success if( COMBAT_D->do_busy_attack(me, target, "wolf-curse/mindcurse", "step", 300, mod) ) { message("vision",HIR""+me->name()+HIR"的眼睛突然现出一片腥红之色,"+target->name()+HIR"的眼神与之一碰,当即呆立当场!\n"NOR, environment(me), ({target,me})); tell_object(me, HIR"你的眼睛突然现出一片腥红之色,"+target->name()+HIR"的眼睛与之一碰,当即呆立当场!\n"NOR); tell_object(target, HIR""+me->name()+HIR"的眼瞳突然突然现出一片腥红之色,突然变成千百头狼从四面八方扑来, 你逃无可逃,避不可避,万念俱灰!\n"NOR); target->set_temp("mesmerize", time()); target->start_call_out((: call_other, __FILE__, "remove_effect", target :), time*2); target->start_busy(time); target->set_temp("condition_type", HIB" <失魂中> "NOR); me->remove_killer(target); me->add_rival(target); inv = all_inventory(environment(me)); for( i = 0; i < sizeof(inv); i++) { // It can't stop teammate's pet if( inv[i]->query("possessed") == me || inv[i]->team_member(me) ) { if( inv[i]->is_fighting(target) ) { inv[i]->remove_killer(target); inv[i]->add_rival(target); } } } return 1; } else { message_vision(HIC "$n见势不对,急忙后退,$N一扑落空,脚下不稳,向前冲出几步才站稳!\n" NOR, me, target); } me->perform_busy(1) ; return 1;
int main(object me, string arg) { mapping list, tlist; mixed *klist, *tlist2; object ob, ob1; string text,*tmp, id, spec; int loop; //Security check?? seteuid(geteuid(me)); if (arg) { sscanf (arg, "%s %s", spec, arg); if (arg == "-t" || arg == "-d") { spec = arg; arg = 0; } if (spec && spec != "-d" && spec != "-t") { arg = spec + " " + arg; spec = 0; } } if(!arg || arg == "") ob=me; else if (sscanf (arg, "%s in %s", arg, id) == 2) { ob1=present(id, environment(me)); if (!ob1) ob1 = present(id, me); if (!ob1) return notify_fail ("Data:本地无此生物: "+id+"\n"); if (!ob=present(arg, ob1)) return notify_fail ("Data:该生物身上无此物件: "+arg+"\n"); } else if (arg == "here") ob = environment(me); else { arg = lower_case(arg); ob = present(arg, environment(me)); if (!ob) ob = find_player(arg); if (!ob) ob = find_living(arg); if (!ob) ob = present(arg, me); if(!ob) return notify_fail("Data:无法找到此物件: "+arg+"。\n"); } list = (mapping)ob->query_entire_dbase(); tlist = (mapping)ob->query_entire_temp_dbase(); if( (!list || !mapp(list)) && (!tlist || !mapp(tlist))) return notify_fail("Data:此物件并没有任何的资料。\n"); if (sizeof(list)) { klist = keys(list); klist = sort_array(klist, "sort_keys", this_object()); } if (sizeof(tlist)) { tlist2 = keys(tlist); tlist2 = sort_array(tlist2, "sort_keys", this_object()); } if(!klist || !sizeof(klist)) return notify_fail("Data:此物件并没有储存任何资料。\n"); if (!spec || spec == "-d") { text = HIW"物件:" + base_name(ob) + ".c"NOR"\n"; for(loop=0; loop<sizeof(klist); loop++) { if(strlen(klist[loop]) > 7) text += klist[loop] + "\t: "; else text += klist[loop] + "\t\t: "; text +=sprintf("%O \n",list[ klist[loop] ]); } text += "\n"HIW"总共有 " + sizeof(klist) + " 个储存的资料。"NOR"\n\n"; } else text = ""; if (!spec || spec == "-t") { text += HIW"暂存资料:"NOR"\n\n"; for(loop=0; loop<sizeof(tlist2); loop++) { if(strlen(tlist2[loop]) > 7) text += tlist2[loop] + "\t: "; else text += tlist2[loop] + "\t\t: "; text +=sprintf("%O \n",tlist[ tlist2[loop] ]); } text += "\n"HIW"总共有 " + sizeof(tlist2) + " 个暂存的资料。"NOR"\n\n"; } me->start_more("", text, 0); return 1; }
int cmd_pay(string str) { int year; int mo; string month; string guild; int error; if( !this_player()->query_guild() ) return 0; if( this_player()->query_guild_position() != "leader" && this_player()->query_guild_position() != "main" ) { return 0; } if( !str || str != "dues" ) return notify_fail("Pay what?\n"); seteuid(UID_DAEMONSAVE); restore_object(SAVE_FILE); seteuid(getuid()); year = EVENTS_D->query_year(time()); mo = EVENTS_D->query_month(time()) - 1; month = MONTHS[mo]; guild = (string)(environment(this_player())->query_guild()); if( !sizeof(guild) ) return notify_fail("You must be in your treasury to do that.\n"); if( !payments ) payments = ([]); if( !payments[guild] ) payments[guild] = ([]); if( !payments[guild][year] ) payments[guild][year] = ([]); if( !payments[guild][year][mo] ) { error = TREASURY_D->withdraw(this_player()->query_name(), guild, DUES_AMOUNT, "gold"); switch( error ) { case INSF: return notify_fail("You need at least " + DUES_AMOUNT + " gold in your treasury.\n"); break; case NO_ACCOUNT: return notify_fail("Your guild doesn't have a treasury!\n"); break; case BAD_ACCESS: return notify_fail("You don't have access to the guild's " + "treasury!\n"); break; case TRANSACTION_OK: payments[guild][year][mo] = DUES_AMOUNT; message("info", "You have paid your dues for " + capitalize(month) + ".", this_player()); seteuid(UID_DAEMONSAVE); save_object(SAVE_FILE); seteuid(getuid()); TREASURY_D->update_summary( this_player()->query_original_guild(), "Guild dues", "gold", DUES_AMOUNT); environment(this_player())->do_scroll_write( capitalize(this_player()->query_name()) + " (dues)", WITHDRAW, DUES_AMOUNT, "gold"); return 1; break; default: /* Edit eventually to log the error */ return notify_fail("An error occured; please contact an " + "Admin.\n"); break; } } else { return notify_fail("Your dues have already been paid for this month.\n"); } // Should never get here, but just in case return 0; }
void do_drive_str(string str) { environment(this_body())->do_go_somewhere(str); }
int StubProcess::ConverseStub(int check) { TQCString line, tmp; while (1) { line = readLine(); if (line.isNull()) return -1; if (line == "tdesu_stub") { // This makes parsing a lot easier. enableLocalEcho(false); if (check) writeLine("stop"); else writeLine("ok"); } else if (line == "display") { writeLine(display()); } else if (line == "display_auth") { #ifdef Q_WS_X11 writeLine(displayAuth()); #else writeLine(""); #endif } else if (line == "dcopserver") { if (m_bDCOPForwarding) writeLine(dcopServer()); else writeLine("no"); } else if (line == "dcop_auth") { if (m_bDCOPForwarding) writeLine(dcopAuth()); else writeLine("no"); } else if (line == "ice_auth") { if (m_bDCOPForwarding) writeLine(iceAuth()); else writeLine("no"); } else if (line == "command") { writeLine(m_Command); } else if (line == "path") { TQCString path = getenv("PATH"); if (!path.isEmpty() && path[0] == ':') path = path.mid(1); if (m_User == "root") if (!path.isEmpty()) path = "/usr/local/sbin:/usr/sbin:/sbin:" + path; else if (strcmp(__TDE_BINDIR, "/usr/bin") == 0) { path = "/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin"; } else { path = "/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:" __TDE_BINDIR ":/usr/bin:/bin"; } writeLine(path); } else if (line == "user") { writeLine(m_User); } else if (line == "priority") { tmp.setNum(m_Priority); writeLine(tmp); } else if (line == "scheduler") { if (m_Scheduler == SchedRealtime) writeLine("realtime"); else writeLine("normal"); } else if (line == "xwindows_only") { if (m_bXOnly) writeLine("no"); else writeLine("yes"); } else if (line == "app_startup_id") { QCStringList env = environment(); TQCString tmp; for( QCStringList::ConstIterator it = env.begin(); it != env.end(); ++it ) { if( (*it).find( "DESKTOP_STARTUP_ID=" ) == 0 ) tmp = (*it).mid( strlen( "DESKTOP_STARTUP_ID=" )); } if( tmp.isEmpty()) tmp = "0"; writeLine(tmp); } else if (line == "app_start_pid") { // obsolete tmp.setNum(getpid()); writeLine(tmp); } else if (line == "environment") { // additional env vars QCStringList env = environment(); for( QCStringList::ConstIterator it = env.begin(); it != env.end(); ++it ) writeLine( *it ); writeLine( "" ); } else if (line == "end") { return 0; } else { kdWarning(900) << k_lineinfo << "Unknown request: -->" << line << "<--\n"; return 1; } } return 0; }
int main(object me, string arg) { object ob, old_rec; mapping family; int i; if( !arg ) return notify_fail("指令格式:recruit [cancel]|<对象>\n"); if( arg=="cancel" ) { old_rec = me->query_temp("pending/recruit"); if( !objectp(old_rec) ) return notify_fail("你现在并没有收录任何人为弟子的意思。\n"); write("你改变主意不想收" + old_rec->name() + "为弟子了。\n"); tell_object(old_rec, me->name() + "改变主意不想收你为弟子了。\n"); me->delete_temp("pending/recruit"); return 1; } if( !(ob = present(arg, environment(me))) ) return notify_fail("你想收谁作弟子?\n"); if( ob==me ) return notify_fail("收自己为弟子?好主意....不过没有用。\n"); if (userp(me)) if ( me->query("title") != "普通百姓" || me->query("combat_exp") < 20000 || me->query("age") < 18) return notify_fail("你似乎不够收徒的条件哦。。\n"); if( ob->is_apprentice_of(me) ) { message_vision("$N拍拍$n的头,说道:「好徒儿!」\n", me, ob); return 1; } /* if( !me->query("family") ) return notify_fail("你并不属於任何门派,你必须先加入一个门派,或自己创一个才能收徒。\n"); */ // If the target is willing to apprentice us already, we do it. if( (object)ob->query_temp("pending/apprentice") == me ) { if( !living(ob) ) { message_vision( "$N决定收$n为弟子。\n\n" "不过看样子$n显然没有办法行拜师之礼。\n\n", me, ob); return 1; } // follow modified by elon 09-10-95 to fix a bug in 1st time recruit if((ob->query("family")) && ( (string)me->query("family/family_name") != (string)ob->query("family/family_name") ) ) { message_vision( "$N决定背叛师门,改投入$n门下!!\n\n" "$N跪了下来向$n恭恭敬敬地磕了四个响头,叫道:「师父!」\n\n", ob, me); ob->set("score", 0); ob->add("betrayer", 1); } else message_vision( "$N决定收$n为弟子。\n\n" "$n跪了下来向$N恭恭敬敬地磕了四个响头,叫道:「师父!」\n", me, ob); me->recruit_apprentice(ob); ob->delete_temp("pending/apprentice"); write("恭喜你新收了一名弟子!\n"); family = ob->query("family"); tell_object( ob, sprintf("恭喜您成为%s的第%s代弟子。\n", family["family_name"], chinese_number(family["generation"]) )); return 1; } else { old_rec = me->query_temp("pending/recruit"); if( ob==old_rec ) return notify_fail("你想收" + ob->name() + "为弟子,但是对方还没有答应。\n"); else if( objectp(old_rec) ) { write("你改变主意不想收" + old_rec->name() + "为弟子了。\n"); tell_object(old_rec, me->name() + "改变主意不想收你为弟子了。\n"); } me->set_temp("pending/recruit", ob ); message_vision("\n$N想要收$n为弟子。\n", me, ob); tell_object(ob, YEL "如果你愿意拜" + me->name() + "为师父,用 apprentice 指令。\n" NOR); return 1; } }
void a() { this_object()->force_me("say You have killed the last protector " "of the forest. Soon the armies will raid.", environment(this_object())); call_out("b", 3); }
int wield() { object owner, old_weapon; mapping weapon_prop; string *apply, type; int flag; // Only character object can wear armors. if( !(owner = environment())->is_character() ) return 0; // If already wielded, just recognize it. if( query("equipped") ) return 1; // Check if we have "weapon_prop" defined. if( !mapp(weapon_prop = query("weapon_prop")) ) return notify_fail("你只能装备可当作武器的东西。\n"); flag = query("flag"); if( flag & TWO_HANDED ) { if( owner->query_temp("weapon") || owner->query_temp("secondary_weapon") || owner->query_temp("armor/shield") ) return notify_fail("你必须空出双手才能装备双手武器。\n"); owner->set_temp("weapon", this_object()); } else { // If we are are using any weapon? if( !(old_weapon = owner->query_temp("weapon")) ) owner->set_temp("weapon", this_object()); else // If we still have a free hand? if( !owner->query_temp("secondary_weapon") && !owner->query_temp("armor/shield") ) { // If we can wield this as secondary weapon? if(flag & SECONDARY) { owner->set_temp("secondary_weapon", this_object()); // If we can switch our old weapon to secondary weapon ? } else if( (int)old_weapon->query("flag") & SECONDARY ) { old_weapon->unequip(); owner->set_temp("weapon", this_object()); old_weapon->wield(); // We need unwield our old weapon before we can use this one. } else return notify_fail("你必须先放下你目前装备的武器。\n"); // We have both hands wearing something. } else return notify_fail("你必须空出一只手来使用武器。\n"); } apply = keys(weapon_prop); for(int i = 0; i<sizeof(apply); i++) owner->add_temp("apply/" + apply[i], weapon_prop[apply[i]]); owner->reset_action(); set("equipped", "wielded"); return 1; }