[wizs] 關於地圖產生器
看板mud_sanc (Sanctuary - 聖殿)作者laechan (小太保)時間15年前 (2010/08/09 13:28)推噓2(2推 0噓 0→)留言2則, 2人參與討論串1/2 (看更多)
belldandy 離開前寫了這個東西的原案。
大抵上同一個區域的定義是「同一個目錄」,這樣就可以用
get_dir 來叫出一個有限制範圍的 mixed rooms,令 rooms
是全域變數。
接著假定一個全域 mapping 為 area_map,以及一個處理房
間的函數 check_room ...
主函數()
{
string here_base_name,paths,files,room_file;
int i,j;
// 讀出所在地的 base_name
here_base_name=base_name(environment(this_player()));
paths=get_path(here_base_name); // 讀出目錄
files=get_file(here_base_name); // 讀出檔名 (這兩個函數是假定的)
rooms=get_dir(paths);
j=sizeof(rooms);
for(i=0;i<j;i++)
{
files=rooms[i];
if(strsrch(files,".c")>0)
{
files=substr(files,".c","");
rooms[i]=paths+files;
}
}
files=get_file(here_base_name); // 讀出檔名 get_path 跟 get_file 都是假定函數
check_room(paths,files,0,0);
}
check_room(string paths,string files,int a,int b)
{
mixed exits;
object room;
string room_file,tmp;
if(!catch(room=find_object_or_load(paths+files)))
{
room_file=base_name(room);
if(member_array(room_file,keys(area_map))==-1)
{
if(room->query("exits"))
{
exits=keys((mapping)room->query("exits"));
// 處理該房間的 area_map;
area_map[room_file]=process_area_map(exits,a,b);
foreach(tmp in exits)
{
if(member_array(room->query("exits/"+tmp),rooms)!=-1)
{
switch(tmp)
{
if(!area_map[tmp])
check_room(paths,get_file(tmp),a,b,
}
}
}
}
}
}
modify_area_map();
}
我想這個應該是可行的,下午我會在我自己的電腦寫寫看,
它的核心有四個..
一、遞迴寫法
二、area_map 的資料格式
三、process_area_map 函數
四、modify_area_map 函數
不過依照 gps 的情況來看,這個程式我應該不會放在聖殿,
而是會放在我的電腦裡。若程式寫好了,我會貼出其執行結
果,當做建構論文模型前的 coding 暖身。
Laechan
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.3.82
推
08/09 13:57, , 1F
08/09 13:57, 1F
推
08/09 19:51, , 2F
08/09 19:51, 2F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
2
2
mud_sanc 近期熱門文章
PTT遊戲區 即時熱門文章
51
111
47
79
6
15
4
12