Re: [wizs]問題請教(十九)
看板mud_sanc (Sanctuary - 聖殿)作者laechan (小太保)時間18年前 (2007/09/22 17:20)推噓0(0推 0噓 0→)留言0則, 0人參與討論串2/2 (看更多)
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
mud_sanc 近期熱門文章
PTT遊戲區 即時熱門文章
12
19