eGameX

 找回密碼
 立即註冊
搜索
查看: 522|回復: 1

小修改 Transistor 的Npc重生

[複製鏈接]
發表於 2017-3-28 13:29:13 | 顯示全部樓層 |閱讀模式
這次不把npcupdata放在sea.cgi

直接放在
battle.cgi

  1. sub enemy {
  2.         &get_all_users;
  3.         &form_table('up','100%',1);
  4.         &reload;
  5.         print qq|襲擊  |;
  6.         &submit_button;
  7.         print qq|</td></tr><tr><td align=left>\n|;
  8.         foreach (@alllines) {
  9.                 ($uid,$uname,$usex,$uarea,$uport,$utactics) = (split(/<>/))[0,1,3,15,16,18];
  10.                 if ( ((($port != $uport) || !$port) && ($port || $uport || ($area != $uarea))) || $id == $uid) { next }
  11.                 $checked = !$first ? ' checked' : '';
  12.                 $surrender = $utactics == 3 ? ' 白旗' : '';
  13.                 $first =1;
  14.                 $sex_img = $usex ? $wmn_img : $man_img;
  15.                 $on_click = qq|onClick="return opWin('$listcgi?mode=uprofile&uid=$uid','win6')"|;
  16.                 print qq|<input type=radio name=uid value="$uid"$checked>\n|;
  17.                 print qq|<img src="$img/$sex_img"><a href="$listcgi?mode=uprofile&uid=$uid" $on_click target=_blank>$uname</a>$surrender<br>\n|;
  18.         }
  19.         if (!$sex_img) { print qq|附近沒有發現其他艦隊...| }
  20.         print qq|<input type=hidden name=mode value="battle">\n|;
  21.         &id_ps;
  22.         &form_table('down');
  23.         &b_lift;
  24. }
複製代碼
以下加上
  1. #NPC#
  2. sub NPC_update{
  3.         my  @NPC_uid = ("00002");        # NPC ID
  4.         my  $NPCdir  = 'npcdir';         # NPC帳戶資料存放目錄(※可更改 不可與usrdir相同)
  5.        
  6.            foreach (@NPC_uid) {
  7.              my  $NPC_load_file = new Nfile("$NPCdir\/$_\.dat",'read');
  8.              my  @npc_ilines = $NPC_load_file->read;
  9.                if (!@npc_ilines) { &error("NPC資料讀取錯誤"); }
  10.                if ($npc_ilines[0] eq "Read Error") {&msg("<font color="#FF0000">NPC檔案不存在!</font>");return;}

  11.              my  $NPC_save_file = new Nfile("$usrdir\/$_\.dat",'save');
  12.              my  @npc_update = $NPC_save_file->read;

  13.              if (!@npc_update) { &error("NPC資料讀取錯誤"); }
  14.              if ($npc_update[0] eq "Read Error") {&msg("<font color="#FF0000">NPC檔案不存在!</font>");return;}

  15.              $NPC_save_file->write(@npc_ilines);

  16.         }

  17. }
複製代碼
========================
  1. sub battle {
  2. .........



  3.         &into_ind; &into_uind;
  4.         &set_me;
  5.         &set_u;

  6. 改成

  7. [code]
  8. #if($Npcship_total < 50 ){ #判斷如果小於50條船重新

  9.         if ($uship_line =~ /武藏/) {  #判斷全部船中 如果如果沒有武藏...
  10.         }else { #如果沒有武藏...
  11.            &NPC_update; #重生Npc

  12.                         #$ship[0][4]; = 中間那條船  
  13.                         #$ship[2][4]; = 中間左邊那條船
  14.                         #$ship[1][4]; = 中間右邊那條船
  15.         }
  16.      
  17.         &play;
  18. }
複製代碼
這如果NPC一條武藏也沒有了, 就會重生

至於重生後的NPC 會否出現新船名 還在研究中

//---------------------------------------------------------
  1.                 if($uid == '00002'){
  2.                         $uship[0][4] ='測試改船名';
  3.                         $action = '';
  4.                         &set_u;
  5.                 }
複製代碼
這方法是失敗的


發表於 2017-3-28 23:04:22 | 顯示全部樓層
自動產生日期


  1.         #下面整個if會自動幫NPC補船
  2.        
  3.         if($#uship < 16) {



  4.                 &get_date(time);
  5.        
  6.                 my @NPC_ship = ("ship.gif<>1500<>1000<>8<>大和",               
  7.             "te.png<>2000<>500<>7.5<>武藏$year-$month",);
  8.                
  9.                 my $ship_type = 1;        #0代表NPC_ship第一艘船  1代表第二艘
  10.        
  11.                 my ($shipimg,$shipquan,$shiphp,$shipvec,$shipname) = split(/<>/,$NPC_ship[$ship_type]);

  12.        
  13.                 push(@uship_ind , "$shipimg,$shipquan,$shiphp,$shipvec,$shipname");
  14.         }


複製代碼
回復 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

小黑屋|Archiver|排行榜|eGameX

GMT+8, 2024-4-20 02:49 , Processed in 0.029838 second(s), 6 queries , Gzip On, APCu On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表