作者laechan (小太保)
看板mud_sanc
標題Re: [wizs]問題請教(十九)
時間Sat Sep 22 17:20:12 2007
※ 引述《amosdeus (幽素)》之銘言:
: 請問要怎樣把自己本身跟設定不能打的mob排除在外呢?
: 如果刪掉
: if(obs[i]=ppl) continue;
: if(obs[i]->query("no_attack")) continue;
: 就會攻擊,但是加上這兩行就不會攻擊。
: 目錄:/u/p/plain/pic_trans/wp/claymore.c
: int process_circle(string str)
: {
: 略
: ob=this_player()->query_current_attacker();
: 略
這個函數有點問題, 建議用..
mixed obs;
obs=this_player()->query_attackers();
把所有的 attackers 讀進一個陣列裡頭.
: obs=all_inventory(environment(ob));
: 略
: for(i=0;i<sizeof(obs);i++)
: {
: if(obs[i]=ppl) continue;
: if(obs[i]->query("no_attack")) continue;
: obs[i]->add("hp",-dam);
: if(obs[i]->query("hp")<0) obs[i]->die();
: }
: remove();
: return 1;
: }
: 以上
: 謝謝
: Plain@Sanc
上面改成底下較好
object ppl=this_player(),ob;
mixed obs=all_inventory(environment(ppl));
obs-=({ppl}); // 這裡就先把自己減掉了
foreach(ob in obs)
{
if(ob->query("no_attack")) continue;
ob->add("hp",-dam);
if(ob->query("hp")<0) ob->die();
}
是 == 不是 = ( 你上面那個 if(obs[i]=ppl) )
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.114.165.198