Transistor 發表於 2017-3-19 23:57:06

[開發中]NPC亂跑

被打會亂跑~跨海域城鎮

開發中 還未詳細debug大家幫忙測試測試:L

寫在battle.cgi

把原始code

# Sub Battle #

        } else {
                &add_record("襲擊$uname!<br>獲得[奪取:$get_s、擊沉:$sink_s、資金:$get_money G、財寶:$rob_item]<br>被害[奪取:$uget_s、擊沉:$usink_s]");
                &add_record("受到$name襲擊!<br>被害[奪取:$get_s、擊沉:$sink_s、資金:$get_money G、財寶:$rob_item]<br>獲得[奪取:$uget_s、擊沉:$usink_s]",1)
        }
        &into_ind; &into_uind;
        &set_me;
        &set_u;
        &play
}

改成這個


        } else {
                &add_record("襲擊$uname!<br>獲得[奪取:$get_s、擊沉:$sink_s、資金:$get_money G、財寶:$rob_item]<br>被害[奪取:$uget_s、擊沉:$usink_s]");
                &add_record("受到$name襲擊!<br>被害[奪取:$get_s、擊沉:$sink_s、資金:$get_money G、財寶:$rob_item]<br>獲得[奪取:$uget_s、擊沉:$usink_s]",1)
        }
       
        #NPC Test
        if($uid == 00002){                                #change uid to NPC's id
       
        my $des_area = int(1001 + rand(9));
        my $area_file = new Nfile("$datadir/$des_area\.dat",'read');
        my @test_arealine = $area_file->read;
       
        my @area_array;
       
        foreach (@test_arealine) {
                ($test_move_num) = split(/<>/,$_);
                push (@area_array,$test_move_num);
        }
       
        my $area_index = int(rand(scalar(@area_array)));
        my $des_port = $area_array[$area_index];

        $uarea = "$des_area";
        $uport = "$des_port";
       
        }
       
       
        &into_ind; &into_uind;
        &set_me;
        &set_u;
        &play



Transistor 發表於 2017-3-20 00:16:22

補充~

如果只想在特定海域內移動

把這行

my $des_area = int(1001 + rand(9));

改成這個

my $des_area = $uarea;

這樣就好了^^

teng 發表於 2017-3-20 15:08:33

這寫法不錯, 應該是不會有Bug的

teng 發表於 2017-3-21 18:30:19

台中人2000 發表於 2017-3-21 18:01 static/image/common/back.gif
問目前的玩家一個問題喔,現在遊戲中的NPC是自己生出來的還是之前就有的?

我看程式裡面沒有相關的設定?


{:3_77:} 那個不是你開出來的嗎?
是突然出現的0.0

j85040370 發表於 2017-3-21 20:00:39

大家都以為是台中人你開出來的耶......@@

dog29329584 發表於 2017-3-27 18:34:51

這個程式編碼有漏洞,750艘會維持不變。要嘛改成17艘或是750艘會慢慢遞減

Transistor 發表於 2017-3-27 19:28:11

dog29329584 發表於 2017-3-27 18:34 static/image/common/back.gif
這個程式編碼有漏洞,750艘會維持不變。要嘛改成17艘或是750艘會慢慢遞減

能貼一下戰報嗎?
理論上這個程式不會動到船隻設定

看有沒有少寫into_uind這個函式

teng 發表於 2017-3-27 20:06:50

我建議分兩隻NPC, 一隻是船的, 一隻是財寶的:L

teng 發表於 2017-3-28 10:22:46

台中人2000 發表於 2017-3-28 10:20 static/image/common/back.gif
戰報?
這是甚麼



台中人大大請問你設定自動重新 重生的時間設定幾天了?
現在變成750條線= = 無限重新了, 這樣第一是很傷服務器, 會加大流量

第二玩家會變的超超超超級難取得寶物和船隻

teng 發表於 2017-3-28 10:27:53

teng 發表於 2017-3-28 10:22 static/image/common/back.gif
台中人大大請問你設定自動重新 重生的時間設定幾天了?
現在變成750條線= = 無限重新了, 這樣第一是很傷 ...

750 條船~ 不是線
頁: [1]
查看完整版本: [開發中]NPC亂跑