本文整理汇总了C++中environment函数的典型用法代码示例。如果您正苦于以下问题:C++ environment函数的具体用法?C++ environment怎么用?C++ environment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了environment函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: evalcommand
//.........这里部分代码省略.........
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;
开发者ID:FrauBSD,项目名称:FrauBSD,代码行数:67,代码来源:eval.c
示例2: time
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,
开发者ID:huangleon,项目名称:fy2005,代码行数:31,代码来源:chunxin.c
示例3: start
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;
}
开发者ID:ehershey,项目名称:pd,代码行数:6,代码来源:guardian.c
示例4: tobe
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;
}
开发者ID:huangleon,项目名称:fy2005,代码行数:92,代码来源:jingkeciqin.c
示例5: curse
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}));
开发者ID:huangleon,项目名称:fy2005,代码行数:45,代码来源:mindcurse.c
示例6: main
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;
}
开发者ID:szhowardhuang,项目名称:fs2,代码行数:66,代码来源:drink.c
示例7: environment
/*! Get the origin of the trajectory.
*/
const StaBody*
ScenarioLoiteringTrajectory::centralBody() const
{
return environment()->centralBody()->body();
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:7,代码来源:scenarioloitering.cpp
示例8: init
void init()
{
object me = this_player();
if( wizardp(me) && getuid(me)!="qfy ")
message("vision", me->name()+"走了过来。\n", environment(me), ({me}));
开发者ID:heypnus,项目名称:xkx2001,代码行数:6,代码来源:workroom.c
示例9:
sta::StateVector
ScenarioLoiteringTrajectory::computeInitialStateVector() const
{
return m_simulationParameters->initialStatePosition()->computeStateVector(environment()->centralBody()->body());
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:5,代码来源:scenarioloitering.cpp
示例10: out
/*! 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
//.........这里部分代码省略.........
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:101,代码来源:scenarioloitering.cpp
示例11: endCallback
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);
}
}
开发者ID:arylwen,项目名称:terebi,代码行数:6,代码来源:buffer.c
示例12: implode
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() );
开发者ID:arylwen,项目名称:terebi,代码行数:31,代码来源:praise.c
示例13: main
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;
}
开发者ID:gongfuPanada,项目名称:xyj2006,代码行数:69,代码来源:study.c
示例14: evalcommand
//.........这里部分代码省略.........
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);
}
开发者ID:grayshadow212,项目名称:usr.src,代码行数:101,代码来源:eval.c
示例15: main
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);
}
开发者ID:aricxu,项目名称:xkx100,代码行数:86,代码来源:get.c
示例16: update_sex_status
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;
}
开发者ID:wingkit,项目名称:xyj-ali,代码行数:79,代码来源:sex.c
示例17: cmd_heal
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;
}
开发者ID:ehershey,项目名称:pd,代码行数:86,代码来源:_heal.c
示例18: main
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;
}
}
开发者ID:gongfuPanada,项目名称:mhxy2002,代码行数:97,代码来源:recruit.c
示例19: cmd_heal
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;
}
开发者ID:ehershey,项目名称:pd,代 |
请发表评论