寫一個teleport的指令模擬,本來要改自gps這個內容的寫法
但整合不起來...amem
以下是程式內容.....
------------------------------------------------------
inherit OBJECT;
void create()
{
seteuid(getuid(this_object()));
set("short","傳送模擬器");
set("long",@LONG
傳送teleport
LONG) ;
set("id",({"machine"}));
set("mass",1);
set("unit","顆");
}
void init()
{
add_action("teleport","teleport");
}
int move_env(object env)
{
write("你使用了傳送能力傳送到這裡來了!!\n");
this_player()->move_to(env);
return 1;
}
int map_function(string env_name,int max,string dir,int len)//max最大長度
{
object env;
mapping exits;
if(catch(env=find_object_or_load(env_name))) return notify_fail("傳送錯誤!!
\n");
if( random(max)<len || !exits=env->query("exits"))//沒有出口時不再繼續,長度越
長越難傳送
{
move_env(env);
return 1;
}
if(random(10) && env_name=exits[dir]) //九成選你所選的方向傳送
{
map_function(env_name,max,dir,len+1);
return 1;
}
map_function(values(exits)[random(sizeof(exits))],max,dir,len+1);
return 1;
}
int teleport(string str)
{
object ob,ppl=this_player(),env;
if(!str||str=="") return notify_fail(@J
指令
teleport [玩家A]:傳送到[玩家A]附近(可能差幾格)
teleport [怪物B]:傳送到[玩家A]附近(可能差幾格)
teleport [方向]:傳送往所選的方向n格(n從1~20,不可控制)
J);
if(ob=find_player(str))
{
if(!env=environment(ob)) return notify_fail("你要傳送的玩家處在虛空中哦!!
\n");
if(ppl->query_temp("time_record/teleport")>time())
return notify_fail("你要休息一下才能傳送哦!!\n");
ppl->set_temp("time_record/teleport",time()+30);
map_function(base_name(env),3,"none",0);
return 1;
}
if(ob=find_living(str))
{
if(!env=environment(ob)) return notify_fail("你要傳送的怪物處在虛空中哦!!
\n");
if(ppl->query_temp("time_record/teleport")>time())
return notify_fail("你要休息一下才能傳送哦!!\n");
ppl->set_temp("time_record/teleport",time()+30);
map_function(base_name(env),3,"none",0);
return 1;
}
if(!env=environment(ppl)) return notify_fail("你處在虛空中哦!!\n");
if(ppl->query_temp("time_record/teleport")>time())
return notify_fail("你要休息一下才能傳送哦!!\n");
ppl->set_temp("time_record/teleport",time()+30);
map_function(base_name(env),20,str,0);
return 1;
}
---------------------------------------------------------------
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.129.142.183