[wizs] 關於合體技

看板mud_sanc (Sanctuary - 聖殿)作者 (小太保)時間14年前 (2011/06/03 09:27), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
「如果是我的話」我會照底下的寫法,wiz 們可以參考處 理的「流程」,而程式碼倒是不一定要照這樣寫。 首先,兩個技能都有一個共通的函數:together_skill() 然後,A先發動技能,這時候,做底下判斷.. env=environment(me); obs=all_inventory(env); obs-=({me}); // 先把自己從 obs 扣掉 t=time(); foreach(ob in obs) { if(ob && ob->query_temp("already_xxx")>t) // 判斷到同房間某人已有施展 { ob->delete_temp("already_xxx"); // 先移除那個人的標記 ob->set_temp("time_record/next_together",n+t); // 加上再施展間隔判斷 me->set_temp("time_record/next_together",n+t); // 加上再施展間隔判斷 ob->add_temp("casting",2); // 加上 casting me->add_temp("casting",2); // 加上 casting 然後先執行該人發動合體技的敘述; // 例如A大喊:龍飛!! // 換B時就喊:鳳舞!! call_out("together_skill",1,me,ob,env); // 把 me 跟 ob 傳去 together_skill // 然後同房間的人會看到 A 跟 B 都喊完後 1 秒,才出現合體技能 break; // 終止迴圈 } } // 若程式跑到這裡代表房間還沒有其它人發動合體技 me->set_temp("already_xxx",m+time()); // 設定該合體技的有效作用時間 // 該時間 < time() 時就失效 然後執行該人發動合體技的敘述; // 例如A大喊:龍飛!! // 這時B看到A要發動合體技的請求訊息時,就可以在 m 秒內 // 決定要不要跟著也發動合體技 return 1; } // 一般會建議合體技寫成不需接目標的全體型技能比較方便 int together_skill(object me,object tar,object env) { // 底下是基本判斷 object env1,env2,ob; mixed obs; if(!env) return 1; if(!env1=environment(me)) return 1; if(!env2=environment(tar)) return 1; if(env1!=env2 || env1!=env || env2!=env) return 1; // 通過上面的判斷就可以發動 先執行合體技能訊息顯示; obs=me->query_attackers(); // 讀取自己的所有戰鬥對象 foreach(ob in obs) if(ob && !userp(ob) && living(ob)) // 限怪物 執行對該怪物的傷害; return 1; } 這裡有個問題,因為合體技是由 me 呼叫,因此如果上面的 函數裡頭有 tar->shut 的呼叫語法的話,它實際上呼叫的主 體就會是 me 而不是 tar。 這裡有一種折衷的做法,就是讓 me 跟 tar 在同一時間設定 special_attack.. mixed special_attack=({}); special_attack=(mixed)me->query_temp("special_attack"); special_attack+=({ 加上合體技的相關攻擊設定 }); me->set_temp("special_attack",special_attack); special_attack=(mixed)tar->query_temp("special_attack"); special_attack+=({ 加上合體技的相關攻擊設定 }); tar->set_temp("special_attack",special_attack); 而上面的缺點就是「它是必中技能」,對上某些怪物會無效果 Belldandy -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 115.81.183.99
文章代碼(AID): #1Dw3YT-k (mud_sanc)
文章代碼(AID): #1Dw3YT-k (mud_sanc)