combatd.old
来自「C实现的MUD,对大家基本入门网络游戏很有帮助!」· OLD 代码 · 共 792 行 · 第 1/3 页
OLD
792 行
{
me->set_temp("action_flag",1);
do_attack(me, victim, me->query_temp("weapon"), TYPE_QUICK);
me->set_temp("action_flag",0);
}
// Else, see if we are brave enough to make an aggressive action.
} else if( random( (int)me->query_dex() ) > random( (int)victim->query_dex() )) {
me->set_temp("guarding", 0);
if( !victim->is_fighting(me) ) victim->fight_ob(me);
do_attack(me, victim, me->query_temp("weapon"), TYPE_REGULAR);
if( me->is_fighting(victim) && victim->is_fighting(me))
if( (!objectp(me->query_temp("weapon"))
&& sizeof(me->query_skill_prepare()) > 1)
|| ( objectp(me->query_temp("weapon"))
&&(me->query_temp("weapon"))->query("skill_type") == "sword"
&& me->query_skill("pixie-jian", 1) >= 60
&& me->query_skill_mapped("sword") == "pixie-jian") )
{
me->set_temp("action_flag",1);
do_attack(me, victim, me->query_temp("weapon"), TYPE_REGULAR);
me->set_temp("action_flag",0);
}
// Else, we just start guarding.
} else if( !me->query_temp("guarding") ) {
me->set_temp("guarding", 1);
message_vision( guard_msg[random(sizeof(guard_msg))], me, victim);
return;
} else return;
}
// auto_fight()
//
// This function is to start an automatically fight. Currently this is
// used in "aggressive", "vendetta", "hatred", "berserk" fight.
//
void auto_fight(object me, object obj, string type)
{
// Don't let NPC autofight NPC.
if( !userp(me) && !userp(obj) ) return;
// Because most of the cases that we cannot start a fight cannot be checked
// before we really call the kill_ob(), so we just make sure we have no
// aggressive callout wating here.
if( me->query_temp("looking_for_trouble") ) return;
me->set_temp("looking_for_trouble", 1);
// This call_out gives victim a chance to slip trough the fierce guys.
call_out( "start_" + type, 0, me, obj);
}
void start_berserk(object me, object obj)
{
int shen;
if( !me || !obj ) return; // Are we still exist( not becoming a corpse )?
me->set_temp("looking_for_trouble", 0);
if( me->is_fighting(obj) // Are we busy fighting?
|| !living(me) // Are we capable for a fight?
|| environment(me)!=environment(obj) // Are we still in the same room?
|| environment(me)->query("no_fight") // Are we in a peace room?
) return;
shen = 0 - (int)me->query("shen");
message_vision("$N用一种异样的眼神扫视著在场的每一个人。\n", me);
if( !userp(me) || (int)me->query("neili") > (random(shen) + shen)/10 ) return;
if( shen > (int)me->query("score")
&& !wizardp(obj) ) {
message_vision("$N对著$n喝道:" + RANK_D->query_self_rude(me)
+ "看你实在很不顺眼,去死吧。\n", me, obj);
me->kill_ob(obj);
} else {
message_vision("$N对著$n喝道:喂!" + RANK_D->query_rude(obj)
+ "," + RANK_D->query_self_rude(me) + "正想找人打架,陪我玩两手吧!\n",
me, obj);
me->fight_ob(obj);
}
}
void start_hatred(object me, object obj)
{
if( !me || !obj ) return; // Are we still exist( not becoming a corpse )?
me->set_temp("looking_for_trouble", 0);
if( me->is_fighting(obj) // Are we busy fighting?
|| !living(me) // Are we capable for a fight?
|| environment(me)!=environment(obj) // Are we still in the same room?
|| environment(me)->query("no_fight") // Are we in a peace room?
) return;
if( me->query_temp("owner") == obj->query("id") // be trained
|| obj->query_temp("owner") == me->query("id") // be trained
) return;
// We found our hatred! Charge!
message_vision( catch_hunt_msg[random(sizeof(catch_hunt_msg))], me, obj);
me->kill_ob(obj);
}
void start_vendetta(object me, object obj)
{
if( !me || !obj ) return; // Are we still exist( not becoming a corpse )?
me->set_temp("looking_for_trouble", 0);
if( me->is_fighting(obj) // Are we busy fighting?
|| !living(me) // Are we capable for a fight?
|| environment(me)!=environment(obj) // Are we still in the same room?
|| environment(me)->query("no_fight") // Are we in a peace room?
) return;
// We found our vendetta opponent! Charge!
me->kill_ob(obj);
}
void start_aggressive(object me, object obj)
{
if( !me || !obj ) return; // Are we still exist( not becoming a corpse )?
me->set_temp("looking_for_trouble", 0);
if( me->is_fighting(obj) // Are we busy fighting?
|| !living(me) // Are we capable for a fight?
|| environment(me)!=environment(obj) // Are we still in the same room?
|| environment(me)->query("no_fight") // Are we in a peace room?
) return;
// We got a nice victim! Kill him/her/it!!!
me->kill_ob(obj);
}
// This function is to announce the special events of the combat.
// This should be moved to another daemon in the future.
void announce(object ob, string event)
{
switch(event) {
case "dead":
message_vision(NOR"\n$N扑在地上挣扎了几下,腿一伸,口中喷出几口"HIR"鲜血"NOR",死了!\n\n" NOR, ob);
break;
case "unconcious":
message_vision("\n$N脚下一个不稳,跌在地上一动也不动了。\n\n", ob);
break;
case "revive":
message_vision("\n$N慢慢睁开眼睛,清醒了过来。\n\n", ob);
break;
}
}
void winner_reward(object killer, object victim)
{
killer->defeated_enemy(victim);
}
void killer_reward(object killer, object victim)
{
int bls;
string vmark;
string temp;
string msg="莫名其妙地死了。";
mapping quest, actions;
int exp, pot, score, bonus,factor;
int student_num;
// Call the mudlib killer apply.
killer->killed_enemy(victim);
if( userp(victim) ) {
killer->add("PKS", 1);
victim->clear_condition();
// Give the death penalty to the dying user.
/* if (victim->query("family/master_id") == "feng qingyang")
{
victim->delete("family");
victim->set("class","");
victim->set("title","普通百姓");
victim->set("feng_dietime",victim->query("mud_age"));
temp = read_file("/data/FENG", 1, 1);
student_num = atoi(temp);
student_num--;
if(student_num == 0)
temp = "0";
else if(student_num == 1)
temp = "1";
else if(student_num == 2)
temp = "2";
write_file("/data/FENG", temp, 1);
}*/ victim->add("shen", -(int)victim->query("shen") / 10);
if (victim->query("max_neili")>2)
{
victim->add("max_neili", -2);
}
victim->add("combat_exp", -(int)victim->query("combat_exp") / 50);
victim->delete("vendetta");
if( victim->query("thief") )
victim->set("thief", (int)victim->query("thief") / 2);
if( (int)victim->query("potential") > (int)victim->query("learned_points"))
victim->add("potential",
((int)victim->query("learned_points") - (int)victim->query("potential"))/2 );
//victim->skill_death_penalty();
victim->save();
bls = 10;
if(objectp(killer))
{
msg="被 "+killer->short(1);
actions = killer->query("actions");
switch(actions["damage_type"]) {
case "擦伤":
case "割伤":
msg+="砍死了。";
break;
case "反弹伤":
msg+="震死了。";
break;
case "刺伤":
msg+="刺死了。";
break;
case "瘀伤":
msg+="击死了。";
break;
case "内伤":
msg+="震死了。";
break;
default:
msg+="杀死了。";
}
}
CHANNEL_D->do_channel(this_object(), "rumor",
sprintf("%s"+msg, victim->short(1)));
write_file("/log/static/KILLRECORD",sprintf("%s 杀死了 %s on %s\n", killer->name(1),victim->name(1), ctime(time()) ));
} else {
killer->add("MKS", 1);
bls = 1;
}
if (userp(killer) && killer->query("combat_exp") < victim->query("combat_exp"))
killer->add("shen", -(int)victim->query("shen") / 10);
if( stringp(vmark = victim->query("vendetta_mark")) )
killer->add("vendetta/" + vmark, 1);
// 下面是杀人任务
if (userp(victim))
{
return;
}
if( interactive(killer) && (quest = killer->query("quest"))
&& ( (int)killer->query("task_time") >= time())
&&(quest["quest"]==victim->query("name")))
{
tell_object(killer,"恭喜你!你又完成了一项任务!\n");
exp = quest["exp_bonus"]/2 + random(quest["exp_bonus"]/2);
pot = quest["pot_bonus"]/2 + random(quest["pot_bonus"]/2);
score = quest["score"]/2 + random(quest["score"]/2);
factor=victim->query("quest_factor");
if (factor)
{
exp=exp*factor/10;
pot=pot*factor/10;
score=score*factor/10;
}
bonus = (int) killer->query("combat_exp");
bonus += exp;
killer->set("combat_exp", bonus);
bonus = (int) killer->query("potential");
bonus = bonus - (int) killer->query("learned_points");
bonus = bonus + pot;
if( bonus > 10000) bonus = 10000;
bonus += (int)killer->query("learned_points");
killer->set("potential", bonus );
bonus = (int)killer->query("shen");
if(bonus >= 0)
bonus += score;
else
bonus -= score;
killer->set("shen", bonus);
killer->add("score",score);
tell_object(killer,HIW"你被奖励了:" +
chinese_number(exp) + "点实战经验,"+
chinese_number(pot) + "点潜能," +
chinese_number(score)+"点江湖阅历。\n" NOR);
killer->set("quest", 0 );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?