Hì, rmxp có thể làm game online, đây là khẳng định chắc chắn Nhưng mỗi cái có lẽ nó hơi yếu để làm chiện này. Tui hi vọng chúng ta có thể kiểm chứng ^^ Topic này được lập ra để mời những ai có hứng thú với 1 online game làm bằng rmxp, tui xin chỉ đích danh khách mới : Crystal (PTGV - hông bít ổng ở đây có nick gì nữa) và Fanha99 và những người khác :p Chúng ta thử làm việc open hết đê mọi người cùng đóng góp ý kiến coi ^^ tui có 1 demo của 1 nhóm trước đây từng làm, mai sẽ up lên, ngoài ra có vụ equip rồi, mọi người thử xem sao ?
@VoDich : Cho tui link đi Dưới đây là 1 project được 1 nhóm làm hồi 2005, những hình như stop rùi. Còn cái visual equip (project1) là project thử nghiệm về cách equip trang bị, xài cho hệ thống online (by rataime)
Các scripts trích từ project trên: 1.Socket: Mã: #============================================================================== # ■ Socket #------------------------------------------------------------------------------ # Creates and manages sockets. #------------------------------------------------------------------------------ # Goldenaura3 -- April/10/2005 # The socket class is nearing completion. It still needs a few minor # additions. One of the main ones is the ability to enter hostnames # instead of strictly IP addresses. #------------------------------------------------------------------------------ # Here's a quick sample of the socket class's usage. # # Example: # # Creates a new socket object. AF_INET is our address family. You don't # # need to worry about that right now. SOCK_STREAM is the type of # # connection we're making. Stream based connections are kinda like opening # # files. You're able to read and write from/to them as you please. The # # other I'd like to mention is SOCK_DGRAM. This type is message based. It # # is also connectionless. But, to make up for that, it is less reliable. # socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) # # # Attempts to connect to 123.581.321.345 on port 80. # socket.connect("123.581.321.345", 80) # # # If this is a valid host then let's send something to him. # socket.send("This is just a test!") # # # Let's see if we get a response. 4096 is our buffer size. In other words, # # we won't recieve anything larger than 4096 bits. # print socket.recv(4096) # # # Lastly, we'll close the socket. # socket.close # # That's it! That's all that's involved in establishing connections. # # I'm currently working on a handbook that will go into a bit more detail, but # this should give you some of the basics of using the socket class. # #============================================================================== class Socket #-------------------------------------------------------------------------- # ● Constants #-------------------------------------------------------------------------- AF_UNSPEC = 0 AF_UNIX = 1 AF_INET = 2 AF_IPX = 6 AF_APPLETALK = 16 SOCK_STREAM = 1 SOCK_DGRAM = 2 SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 #-------------------------------------------------------------------------- # ● Creates a new socket. #-------------------------------------------------------------------------- # Example: # socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) #-------------------------------------------------------------------------- def initialize(af, type, proto) @sock = Win32API.new("wsock32", "socket", "lll", "l").call(af, type, proto) @connected = false end #-------------------------------------------------------------------------- # ● Connects the socket to the given location. #-------------------------------------------------------------------------- # Example: # socket.connect("10.67.1.21", 23) #-------------------------------------------------------------------------- def connect(addr, port, af = AF_INET) addr = addr.split(".") sockaddr = [af, port, addr[0].to_i, addr[1].to_i, addr[2].to_i, addr[3].to_i, ""].pack("snC4a8") if Win32API.new("wsock32", "connect", "ppi", "l").call(@sock, sockaddr, sockaddr.length) == 0 @connected = true return end raise "Server could not be accessed.\r\nPlease retry in a few minutes." end #-------------------------------------------------------------------------- # ● Closes a socket. #-------------------------------------------------------------------------- # Example: # socket.connect("10.67.1.21", 23) rescue(socket.close) #-------------------------------------------------------------------------- def close Win32API.new("wsock32", "closesocket", "p", "l").call(@sock) end #-------------------------------------------------------------------------- # ● Recieves incoming data. #-------------------------------------------------------------------------- # Example: # print socket.recv(4096) #-------------------------------------------------------------------------- def recv(len, flags = 0) buf = " " * len Win32API.new("wsock32", "recv", "ppii", "l").call(@sock, buf, len, flags) raise "Disconnected from server.\r\nPlease retry in a few minutes." if buf.strip == "" return buf.strip end #-------------------------------------------------------------------------- # ● Sends data. #-------------------------------------------------------------------------- # Example: # socket.send("This is a test!", 0) #-------------------------------------------------------------------------- def send(data, flags = 0) Win32API.new("wsock32", "send", "ppii", "l").call(@sock, data, data.length, flags) end #-------------------------------------------------------------------------- # ● Checks to see if the socket is connected. #-------------------------------------------------------------------------- # Example: # if socket.connected? # @sprite_connected.visible = true # end #-------------------------------------------------------------------------- def connected? return @connected end #-------------------------------------------------------------------------- # ● Checks to see if data is ready for reading. #-------------------------------------------------------------------------- # Example: # if socket.ready? # print socket.recv(32) # end #-------------------------------------------------------------------------- def ready? fd = [1, @sock].pack("ll") ts = [0, 0].pack("ll") return Win32API.new("wsock32", "select", "ipppp", "l").call(1, fd, 0, 0, ts) == 1 ? true : false end end 2.Network: Mã: #============================================================================== # ■ Socket #------------------------------------------------------------------------------ # Creates and manages sockets. #------------------------------------------------------------------------------ # Goldenaura3 -- April/10/2005 # The socket class is nearing completion. It still needs a few minor # additions. One of the main ones is the ability to enter hostnames # instead of strictly IP addresses. #------------------------------------------------------------------------------ # Here's a quick sample of the socket class's usage. # # Example: # # Creates a new socket object. AF_INET is our address family. You don't # # need to worry about that right now. SOCK_STREAM is the type of # # connection we're making. Stream based connections are kinda like opening # # files. You're able to read and write from/to them as you please. The # # other I'd like to mention is SOCK_DGRAM. This type is message based. It # # is also connectionless. But, to make up for that, it is less reliable. # socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) # # # Attempts to connect to 123.581.321.345 on port 80. # socket.connect("123.581.321.345", 80) # # # If this is a valid host then let's send something to him. # socket.send("This is just a test!") # # # Let's see if we get a response. 4096 is our buffer size. In other words, # # we won't recieve anything larger than 4096 bits. # print socket.recv(4096) # # # Lastly, we'll close the socket. # socket.close # # That's it! That's all that's involved in establishing connections. # # I'm currently working on a handbook that will go into a bit more detail, but # this should give you some of the basics of using the socket class. # #============================================================================== class Socket #-------------------------------------------------------------------------- # ● Constants #-------------------------------------------------------------------------- AF_UNSPEC = 0 AF_UNIX = 1 AF_INET = 2 AF_IPX = 6 AF_APPLETALK = 16 SOCK_STREAM = 1 SOCK_DGRAM = 2 SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 #-------------------------------------------------------------------------- # ● Creates a new socket. #-------------------------------------------------------------------------- # Example: # socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) #-------------------------------------------------------------------------- def initialize(af, type, proto) @sock = Win32API.new("wsock32", "socket", "lll", "l").call(af, type, proto) @connected = false end #-------------------------------------------------------------------------- # ● Connects the socket to the given location. #-------------------------------------------------------------------------- # Example: # socket.connect("10.67.1.21", 23) #-------------------------------------------------------------------------- def connect(addr, port, af = AF_INET) addr = addr.split(".") sockaddr = [af, port, addr[0].to_i, addr[1].to_i, addr[2].to_i, addr[3].to_i, ""].pack("snC4a8") if Win32API.new("wsock32", "connect", "ppi", "l").call(@sock, sockaddr, sockaddr.length) == 0 @connected = true return end raise "Server could not be accessed.\r\nPlease retry in a few minutes." end #-------------------------------------------------------------------------- # ● Closes a socket. #-------------------------------------------------------------------------- # Example: # socket.connect("10.67.1.21", 23) rescue(socket.close) #-------------------------------------------------------------------------- def close Win32API.new("wsock32", "closesocket", "p", "l").call(@sock) end #-------------------------------------------------------------------------- # ● Recieves incoming data. #-------------------------------------------------------------------------- # Example: # print socket.recv(4096) #-------------------------------------------------------------------------- def recv(len, flags = 0) buf = " " * len Win32API.new("wsock32", "recv", "ppii", "l").call(@sock, buf, len, flags) raise "Disconnected from server.\r\nPlease retry in a few minutes." if buf.strip == "" return buf.strip end #-------------------------------------------------------------------------- # ● Sends data. #-------------------------------------------------------------------------- # Example: # socket.send("This is a test!", 0) #-------------------------------------------------------------------------- def send(data, flags = 0) Win32API.new("wsock32", "send", "ppii", "l").call(@sock, data, data.length, flags) end #-------------------------------------------------------------------------- # ● Checks to see if the socket is connected. #-------------------------------------------------------------------------- # Example: # if socket.connected? # @sprite_connected.visible = true # end #-------------------------------------------------------------------------- def connected? return @connected end #-------------------------------------------------------------------------- # ● Checks to see if data is ready for reading. #-------------------------------------------------------------------------- # Example: # if socket.ready? # print socket.recv(32) # end #-------------------------------------------------------------------------- def ready? fd = [1, @sock].pack("ll") ts = [0, 0].pack("ll") return Win32API.new("wsock32", "select", "ipppp", "l").call(1, fd, 0, 0, ts) == 1 ? true : false end end 3. GamePlayer2 (chèn 1 scripts mới xuống dưới GamePlayer) Mã: #============================================================================== # ■ Game_Character (分割定義 3) #------------------------------------------------------------------------------ # キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event # クラスのスーパークラスとして使用されます。 #============================================================================== class Game_Player < Game_Character attr_reader :move_speed #-------------------------------------------------------------------------- # ● 下に移動 # turn_enabled : その場での向き変更を許可するフラグ #-------------------------------------------------------------------------- def move_down(turn_enabled = true) # 下を向く if turn_enabled turn_down end # 通行可能な場合 if passable?(@x, @y, 2) # 下を向く turn_down # 座標を更新 @y += 1 # 歩数増加 increase_steps # 通行不可能な場合 else # 接触イベントの起動判定 check_event_trigger_touch(@x, @y+1) end # Sends network data. $network.send_player_data end #-------------------------------------------------------------------------- # ● 左に移動 # turn_enabled : その場での向き変更を許可するフラグ #-------------------------------------------------------------------------- def move_left(turn_enabled = true) # 左を向く if turn_enabled turn_left end # 通行可能な場合 if passable?(@x, @y, 4) # 左を向く turn_left # 座標を更新 @x -= 1 # 歩数増加 increase_steps # 通行不可能な場合 else # 接触イベントの起動判定 check_event_trigger_touch(@x-1, @y) end # Sends network data. $network.send_player_data end #-------------------------------------------------------------------------- # ● 右に移動 # turn_enabled : その場での向き変更を許可するフラグ #-------------------------------------------------------------------------- def move_right(turn_enabled = true) # 右を向く if turn_enabled turn_right end # 通行可能な場合 if passable?(@x, @y, 6) # 右を向く turn_right # 座標を更新 @x += 1 # 歩数増加 increase_steps # 通行不可能な場合 else # 接触イベントの起動判定 check_event_trigger_touch(@x+1, @y) end # Sends network data. $network.send_player_data end #-------------------------------------------------------------------------- # ● 上に移動 # turn_enabled : その場での向き変更を許可するフラグ #-------------------------------------------------------------------------- def move_up(turn_enabled = true) # 上を向く if turn_enabled turn_up end # 通行可能な場合 if passable?(@x, @y, 8) # 上を向く turn_up # 座標を更新 @y -= 1 # 歩数増加 increase_steps # 通行不可能な場合 else # 接触イベントの起動判定 check_event_trigger_touch(@x, @y-1) end # Sends network data. $network.send_player_data end end 4. Gametemp2 (chèn 1 scripts mới xuống dưới Gametemp) Mã: #============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ # セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ● Attributes #-------------------------------------------------------------------------- attr_accessor :spriteset_refresh attr_accessor :chat_refresh attr_accessor :chat_log #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias netplay_initialize initialize def initialize netplay_initialize @spriteset_refresh = false @chat_refresh = false @chat_log = [] end end 5. GameNetPlayer Mã: #============================================================================== # ■ Game_NetPlayer #------------------------------------------------------------------------------ # Handles a network player's data. #============================================================================== class Game_NetPlayer < Game_Character #-------------------------------------------------------------------------- # ● Class Variables #-------------------------------------------------------------------------- attr_reader :map_id attr_reader :name attr_reader :level #-------------------------------------------------------------------------- # ● Initializes a network player. #-------------------------------------------------------------------------- def initialize super @map_id = 0 @name = "" @level = 0 end #-------------------------------------------------------------------------- # ● Refreshes network player. #-------------------------------------------------------------------------- def refresh(data) eval(data) @transparent = (not $game_map.map_id == @map_id) end end
6. SpritesetMap2 (chèn 1 scripts mới xuống dưới scripts Spriteset map) Mã: #============================================================================== # ■ Spriteset_Map #------------------------------------------------------------------------------ # マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは # Scene_Map クラスの内部で使用されます。 #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias netplay_initialize initialize def initialize @network_sprites = [] refresh netplay_initialize end #-------------------------------------------------------------------------- # ● Refreshes the spriteset. #-------------------------------------------------------------------------- def refresh @network_sprites.clear for c in $network.players.values @network_sprites.push(Sprite_NetCharacter.new(@viewport1, c)) end $game_temp.spriteset_refresh = false end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias netplay_dispose dispose def dispose for sprite in @network_sprites sprite.dispose end netplay_dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias netplay_update update def update refresh if $game_temp.spriteset_refresh for s in @network_sprites s.update end netplay_update end end 7. Interpreter (chèn 1 scripts mới xuống dưới mấy cái Interpreter cũ) Mã: #============================================================================== # ■ Interpreter #------------------------------------------------------------------------------ # イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ # スや Game_Event クラスの内部で使用されます。 #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ● Switches #-------------------------------------------------------------------------- def command_121 # 一括操作のためにループ for i in @parameters[0] .. @parameters[1] # スイッチを変更 $game_switches[i] = (@parameters[2] == 0) $network.socket.send("SYSTEM:<$game_switches[#{i}] = #{@parameters[2] == 0}>\r\n") if i > 1000 end # マップをリフレッシュ $game_map.need_refresh = true # 継続 return true end #-------------------------------------------------------------------------- # ● Variables #-------------------------------------------------------------------------- def command_122 # 値を初期化 value = 0 # オペランドで分岐 case @parameters[3] when 0 # 定数 value = @parameters[4] when 1 # 変数 value = $game_variables[@parameters[4]] when 2 # 乱数 value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1) when 3 # アイテム value = $game_party.item_number(@parameters[4]) when 4 # アクター actor = $game_actors[@parameters[4]] if actor != nil case @parameters[5] when 0 # レベル value = actor.level when 1 # EXP value = actor.exp when 2 # HP value = actor.hp when 3 # SP value = actor.sp when 4 # MaxHP value = actor.maxhp when 5 # MaxSP value = actor.maxsp when 6 # 腕力 value = actor.str when 7 # 器用さ value = actor.dex when 8 # 素早さ value = actor.agi when 9 # 魔力 value = actor.int when 10 # 攻撃力 value = actor.atk when 11 # 物理防御 value = actor.pdef when 12 # 魔法防御 value = actor.mdef when 13 # 回避修正 value = actor.eva end end when 5 # エネミー enemy = $game_troop.enemies[@parameters[4]] if enemy != nil case @parameters[5] when 0 # HP value = enemy.hp when 1 # SP value = enemy.sp when 2 # MaxHP value = enemy.maxhp when 3 # MaxSP value = enemy.maxsp when 4 # 腕力 value = enemy.str when 5 # 器用さ value = enemy.dex when 6 # 素早さ value = enemy.agi when 7 # 魔力 value = enemy.int when 8 # 攻撃力 value = enemy.atk when 9 # 物理防御 value = enemy.pdef when 10 # 魔法防御 value = enemy.mdef when 11 # 回避修正 value = enemy.eva end end when 6 # キャラクター character = get_character(@parameters[4]) if character != nil case @parameters[5] when 0 # X 座標 value = character.x when 1 # Y 座標 value = character.y when 2 # 向き value = character.direction when 3 # 画面 X 座標 value = character.screen_x when 4 # 画面 Y 座標 value = character.screen_y when 5 # 地形タグ value = character.terrain_tag end end when 7 # その他 case @parameters[4] when 0 # マップ ID value = $game_map.map_id when 1 # パーティ人数 value = $game_party.actors.size when 2 # ゴールド value = $game_party.gold when 3 # 歩数 value = $game_party.steps when 4 # プレイ時間 value = Graphics.frame_count / Graphics.frame_rate when 5 # タイマー value = $game_system.timer / Graphics.frame_rate when 6 # セーブ回数 value = $game_system.save_count end end # 一括操作のためにループ for i in @parameters[0] .. @parameters[1] # 操作で分岐 case @parameters[2] when 0 # 代入 $game_variables[i] = value when 1 # 加算 $game_variables[i] += value when 2 # 減算 $game_variables[i] -= value when 3 # 乗算 $game_variables[i] *= value when 4 # 除算 if value != 0 $game_variables[i] /= value end when 5 # 剰余 if value != 0 $game_variables[i] %= value end end # 上限チェック if $game_variables[i] > 99999999 $game_variables[i] = 99999999 end # 下限チェック if $game_variables[i] < -99999999 $game_variables[i] = -99999999 end $network.socket.send("SYSTEM:<$game_variables[#{i}] = #{$game_variables[i]}>") if i > 1000 end # マップをリフレッシュ $game_map.need_refresh = true # 継続 return true end #-------------------------------------------------------------------------- # ● Self-Switches #-------------------------------------------------------------------------- def command_123 # イベント ID が有効の場合 if @event_id > 0 # セルフスイッチのキーを作成 key = [$game_map.map_id, @event_id, @parameters[0]] # セルフスイッチを変更 $game_self_switches[key] = (@parameters[1] == 0) end # マップをリフレッシュ $game_map.need_refresh = true # 継続 return true end end 8. SpriteNetCharacter : Mã: #============================================================================== # ■ Sprite_NetCharacter #------------------------------------------------------------------------------ # キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを # 監視し、スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_NetCharacter < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :character # キャラクター #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # character : キャラクター (Game_Character) #-------------------------------------------------------------------------- def initialize(viewport, character = nil) super(viewport) self.bitmap = Bitmap.new(1, 1) @name_sprite = Sprite.new @name_sprite.bitmap = Bitmap.new(120, 32) @name_sprite.bitmap.font.size = 22 @character = character update end #-------------------------------------------------------------------------- # ● Disposes sprite. #-------------------------------------------------------------------------- def dispose @name_sprite.bitmap.dispose @name_sprite.dispose super end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # タイル ID、ファイル名、色相のどれかが現在のものと異なる場合 if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue # タイル ID とファイル名、色相を記憶 @tile_id = @character.tile_id @character_name = @character.character_name @character_hue = @character.character_hue # タイル ID が有効な値の場合 if @tile_id >= 384 self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id, @character.character_hue) self.src_rect.set(0, 0, 32, 32) self.ox = 16 self.oy = 32 # タイル ID が無効な値の場合 else self.bitmap = RPG::Cache.character(@character.character_name, @character.character_hue) @cw = bitmap.width / 4 @ch = bitmap.height / 4 self.ox = @cw / 2 self.oy = @ch end end # 可視状態を設定 self.visible = (not @character.transparent) # グラフィックがキャラクターの場合 if @tile_id == 0 # 転送元の矩形を設定 sx = @character.pattern * @cw sy = (@character.direction - 2) / 2 * @ch self.src_rect.set(sx, sy, @cw, @ch) end # スプライトの座標を設定 self.x = @character.screen_x self.y = @character.screen_y self.z = @character.screen_z(@ch) # 不透明度、合成方法、茂み深さを設定 self.opacity = @character.opacity self.blend_type = @character.blend_type self.bush_depth = @character.bush_depth # アニメーション if @character.animation_id != 0 animation = $data_animations[@character.animation_id] animation(animation, true) @character.animation_id = 0 end @name_sprite.bitmap.clear @name_sprite.bitmap.draw_text(0, 0, 120, 32, @character.name, 1) @name_sprite.x = self.x - 60 @name_sprite.y = self.y - 80 @name_sprite.z = self.z @name_sprite.visible = self.visible end end 9. Scene Map 2 (chèn 1 script mới xuống dưới Scene Map) Mã: #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ # マップ画面の処理を行うクラスです。 #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● Initializes map. #-------------------------------------------------------------------------- def initialize $game_temp.spriteset_refresh end #-------------------------------------------------------------------------- # ● Updates map. #-------------------------------------------------------------------------- def update # ループ loop do # マップ、インタプリタ、プレイヤーの順に更新 # (この更新順序は、イベントを実行する条件が満たされているときに # プレイヤーに一瞬移動する機会を与えないなどの理由で重要) $game_map.update $game_system.map_interpreter.update $game_player.update # システム (タイマー)、画面を更新 $game_system.update $game_screen.update # Updates network. $network.update # プレイヤーの場所移動中でなければループを中断 unless $game_temp.player_transferring break end # 場所移動を実行 transfer_player # トランジション処理中の場合、ループを中断 if $game_temp.transition_processing break end end # スプライトセットを更新 @spriteset.update # メッセージウィンドウを更新 @message_window.update # ゲームオーバーの場合 if $game_temp.gameover # ゲームオーバー画面に切り替え $scene = Scene_Gameover.new return end # タイトル画面に戻す場合 if $game_temp.to_title # タイトル画面に切り替え $scene = Scene_Title.new return end # トランジション処理中の場合 if $game_temp.transition_processing # トランジション処理中フラグをクリア $game_temp.transition_processing = false # トランジション実行 if $game_temp.transition_name == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $game_temp.transition_name) end end # メッセージウィンドウ表示中の場合 if $game_temp.message_window_showing return end # エンカウント カウントが 0 で、エンカウントリストが空ではない場合 if $game_player.encounter_count == 0 and $game_map.encounter_list != [] # イベント実行中かエンカウント禁止中でなければ unless $game_system.map_interpreter.running? or $game_system.encounter_disabled # トループを決定 n = rand($game_map.encounter_list.size) troop_id = $game_map.encounter_list[n] # トループが有効なら if $data_troops[troop_id] != nil # バトル呼び出しフラグをセット $game_temp.battle_calling = true $game_temp.battle_troop_id = troop_id $game_temp.battle_can_escape = true $game_temp.battle_can_lose = false $game_temp.battle_proc = nil end end end # B ボタンが押された場合 if Input.trigger?(Input::B) # イベント実行中かメニュー禁止中でなければ unless $game_system.map_interpreter.running? or $game_system.menu_disabled # メニュー呼び出しフラグと SE 演奏フラグをセット $game_temp.menu_calling = true $game_temp.menu_beep = true end end # F5: Opens chat scene. if Input.trigger?(Input::F5) $scene = Scene_Chat.new end # プレイヤーの移動中ではない場合 unless $game_player.moving? # 各種画面の呼び出しを実行 if $game_temp.battle_calling call_battle elsif $game_temp.shop_calling call_shop elsif $game_temp.name_calling call_name elsif $game_temp.menu_calling call_menu elsif $game_temp.save_calling call_save elsif $game_temp.debug_calling call_debug end end end end 10. Scene Players: Mã: #============================================================================== # ■ Scene_Players #------------------------------------------------------------------------------ # Displays a list of all the connected players. #============================================================================== class Scene_Players #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main @spriteset = Spriteset_Map.new # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # メッセージウィンドウを解放 @spriteset.dispose # タイトル画面に切り替え中の場合 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # Updates network. $network.update @spriteset.update @chat_window.update @input_window.update if Input.getkey(27) $scene = Scene_Map.new end end end 12. WindowPlayers: Mã: #============================================================================== # ■ Window_Players #------------------------------------------------------------------------------ # Displays player list. #============================================================================== class Window_Players < Window_Base #-------------------------------------------------------------------------- # ● Initializes chat window. #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 480) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 16 self.opacity = 160 refresh end #-------------------------------------------------------------------------- # ● Refreshes chat window. #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0..$game_temp.chat_log.size - 1 self.contents.draw_text(0, i * 16 - 8, 640, 32, $game_temp.chat_log[i]) end $game_temp.chat_refresh = false end #-------------------------------------------------------------------------- # ● Updates chat window. #-------------------------------------------------------------------------- def update refresh if $game_temp.chat_refresh super end end
12. SceneChat: Mã: #============================================================================== # ■ Scene_Chat #------------------------------------------------------------------------------ # Creates a global chat session. #============================================================================== class Scene_Chat #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main @spriteset = Spriteset_Map.new @chat_window = Window_Chat.new @input_window = Window_ChatInput.new # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # メッセージウィンドウを解放 @spriteset.dispose @chat_window.dispose @input_window.dispose # タイトル画面に切り替え中の場合 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # Updates network. $network.update @spriteset.update @chat_window.update @input_window.update if Input.getkey(27) $scene = Scene_Map.new end end end 13. WindowChat: Mã: #============================================================================== # ■ Window_Chat #------------------------------------------------------------------------------ # Displays chat messages. #============================================================================== class Window_Chat < Window_Base #-------------------------------------------------------------------------- # ● Initializes chat window. #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 432) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 16 self.opacity = 160 refresh end #-------------------------------------------------------------------------- # ● Refreshes chat window. #-------------------------------------------------------------------------- def refresh $game_temp.chat_log.delete_at(0) while $game_temp.chat_log.size > 25 self.contents.clear for i in 0..$game_temp.chat_log.size - 1 self.contents.draw_text(0, i * 16 - 8, 640, 32, $game_temp.chat_log[i]) end $game_temp.chat_refresh = false end #-------------------------------------------------------------------------- # ● Updates chat window. #-------------------------------------------------------------------------- def update refresh if $game_temp.chat_refresh super end end 14. WindowChatInput: Mã: #============================================================================== # ■ Window_ChatInput Originally created by: Cybersam #------------------------------------------------------------------------------ # Based on the Full-Keyboard Input script created by Cybersam. #============================================================================== class Window_ChatInput < Window_Base #-------------------------------------------------------------------------- # ● Initializes chat input window. #-------------------------------------------------------------------------- def initialize super(0, 432, 640, 48) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 16 self.opacity = 160 @text = [] refresh end #-------------------------------------------------------------------------- # ● Refreshes chat input window. #-------------------------------------------------------------------------- def refresh @log = @text.to_s self.contents.clear self.contents.draw_text(0, -16, 620, 48, @text.to_s + "_") end #-------------------------------------------------------------------------- # ● Refreshes chat input window. #-------------------------------------------------------------------------- def add(char) if @text.size >= 80 $game_system.se_play($data_system.buzzer_se) else @text.push(char.to_s) refresh end end #-------------------------------------------------------------------------- # ● Updates input chat window. #-------------------------------------------------------------------------- def update # Sends chat message. if Input.getkey(13) if @text.size == 0 $game_system.se_play($data_system.buzzer_se) else $network.socket.send("CHAT:<#{$game_party.actors[0].name}) #{@text.to_s}>\r\n") @text.clear refresh end end # Removes last entry in test. if Input.getkey(8) if @text.size == 0 $game_system.se_play($data_system.buzzer_se) else @text.delete_at(-1) refresh end end # Adds a pressed key. if Input.getstate(16) add("A") if Input.getkey(65) add("B") if Input.getkey(66) add("C") if Input.getkey(67) add("D") if Input.getkey(68) add("E") if Input.getkey(69) add("F") if Input.getkey(70) add("G") if Input.getkey(71) add("H") if Input.getkey(72) add("I") if Input.getkey(73) add("J") if Input.getkey(74) add("K") if Input.getkey(75) add("L") if Input.getkey(76) add("M") if Input.getkey(77) add("N") if Input.getkey(78) add("O") if Input.getkey(79) add("P") if Input.getkey(80) add("Q") if Input.getkey(81) add("R") if Input.getkey(82) add("S") if Input.getkey(83) add("T") if Input.getkey(84) add("U") if Input.getkey(85) add("V") if Input.getkey(86) add("W") if Input.getkey(87) add("X") if Input.getkey(88) add("Y") if Input.getkey(89) add("Z") if Input.getkey(90) add(")") if Input.getkey(48) add("!") if Input.getkey(49) add("@") if Input.getkey(50) add("#") if Input.getkey(51) add("$") if Input.getkey(52) add("%") if Input.getkey(53) add("^") if Input.getkey(54) add("&") if Input.getkey(55) add("*") if Input.getkey(56) add("(") if Input.getkey(57) add(":") if Input.getkey(186) add("+") if Input.getkey(187) add("<") if Input.getkey(188) add("_") if Input.getkey(189) add(">") if Input.getkey(190) add("?") if Input.getkey(191) add("{") if Input.getkey(219) add("|") if Input.getkey(220) add("}") if Input.getkey(221) add("\"") if Input.getkey(222) else add("a") if Input.getkey(65) add("b") if Input.getkey(66) add("c") if Input.getkey(67) add("d") if Input.getkey(68) add("e") if Input.getkey(69) add("f") if Input.getkey(70) add("g") if Input.getkey(71) add("h") if Input.getkey(72) add("i") if Input.getkey(73) add("j") if Input.getkey(74) add("k") if Input.getkey(75) add("l") if Input.getkey(76) add("m") if Input.getkey(77) add("n") if Input.getkey(78) add("o") if Input.getkey(79) add("p") if Input.getkey(80) add("q") if Input.getkey(81) add("r") if Input.getkey(82) add("s") if Input.getkey(83) add("t") if Input.getkey(84) add("u") if Input.getkey(85) add("v") if Input.getkey(86) add("w") if Input.getkey(87) add("x") if Input.getkey(88) add("y") if Input.getkey(89) add("z") if Input.getkey(90) add("0") if Input.getkey(48) add("1") if Input.getkey(49) add("2") if Input.getkey(50) add("3") if Input.getkey(51) add("4") if Input.getkey(52) add("5") if Input.getkey(53) add("6") if Input.getkey(54) add("7") if Input.getkey(55) add("8") if Input.getkey(56) add("9") if Input.getkey(57) add(";") if Input.getkey(186) add("=") if Input.getkey(187) add(",") if Input.getkey(188) add("-") if Input.getkey(189) add(".") if Input.getkey(190) add("/") if Input.getkey(191) add("[") if Input.getkey(219) add("\\") if Input.getkey(220) add("]") if Input.getkey(221) add("'") if Input.getkey(222) end add(" ") if Input.getkey(32) add("*") if Input.getkey(106) add("+") if Input.getkey(107) add("-") if Input.getkey(109) add("/") if Input.getkey(111) end end
15. AntiLag: Mã: #====================================== # ■ Anti Event Lag Script #====================================== # By: Near Fantastica # Date: 12.06.05 # Version: 3 #====================================== #====================================== # ■ Game_Map #====================================== class Game_Map #-------------------------------------------------------------------------- def in_range?(object) screne_x = $game_map.display_x screne_x -= 256 screne_y = $game_map.display_y screne_y -= 256 screne_width = $game_map.display_x screne_width += 2816 screne_height = $game_map.display_y screne_height += 2176 return false if object.real_x <= screne_x-32 return false if object.real_x >= screne_width+32 return false if object.real_y <= screne_y-32 return false if object.real_y >= screne_height+32 return true end #-------------------------------------------------------------------------- def update if $game_map.need_refresh refresh end if @scroll_rest > 0 distance = 2 ** @scroll_speed case @scroll_direction when 2 scroll_down(distance) when 4 scroll_left(distance) when 6 scroll_right(distance) when 8 scroll_up(distance) end @scroll_rest -= distance end for event in @events.values if in_range?(event) or event.trigger == 3 or event.trigger == 4 event.update end end for common_event in @common_events.values common_event.update end @fog_ox -= @fog_sx / 8.0 @fog_oy -= @fog_sy / 8.0 if @fog_tone_duration >= 1 d = @fog_tone_duration target = @fog_tone_target @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d @fog_tone_duration -= 1 end if @fog_opacity_duration >= 1 d = @fog_opacity_duration @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d @fog_opacity_duration -= 1 end end end #====================================== # ■ Spriteset_Map #====================================== class Spriteset_Map #-------------------------------------------------------------------------- def in_range?(object) screne_x = $game_map.display_x screne_x -= 256 screne_y = $game_map.display_y screne_y -= 256 screne_width = $game_map.display_x screne_width += 2816 screne_height = $game_map.display_y screne_height += 2176 return false if object.real_x <= screne_x return false if object.real_x >= screne_width return false if object.real_y <= screne_y return false if object.real_y >= screne_height return true end #-------------------------------------------------------------------------- def update if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue @panorama_name = $game_map.panorama_name @panorama_hue = $game_map.panorama_hue if @panorama.bitmap != nil @panorama.bitmap.dispose @panorama.bitmap = nil end if @panorama_name != "" @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue) end Graphics.frame_reset end if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue @fog_name = $game_map.fog_name @fog_hue = $game_map.fog_hue if @fog.bitmap != nil @fog.bitmap.dispose @fog.bitmap = nil end if @fog_name != "" @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue) end Graphics.frame_reset end @tilemap.ox = $game_map.display_x / 4 @tilemap.oy = $game_map.display_y / 4 @tilemap.update @panorama.ox = $game_map.display_x / 8 @panorama.oy = $game_map.display_y / 8 @fog.zoom_x = $game_map.fog_zoom / 100.0 @fog.zoom_y = $game_map.fog_zoom / 100.0 @fog.opacity = $game_map.fog_opacity @fog.blend_type = $game_map.fog_blend_type @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy @fog.tone = $game_map.fog_tone i=0 for sprite in @character_sprites if sprite.character.is_a?(Game_Event) if in_range?(sprite.character) or sprite.character.trigger == 3 or sprite.character.trigger == 4 sprite.update i+=1 end else sprite.update i+=1 end end #p i @weather.type = $game_screen.weather_type @weather.max = $game_screen.weather_max @weather.ox = $game_map.display_x / 4 @weather.oy = $game_map.display_y / 4 @weather.update for sprite in @picture_sprites sprite.update end @timer_sprite.update @viewport1.tone = $game_screen.tone @viewport1.ox = $game_screen.shake @viewport3.color = $game_screen.flash_color @viewport1.update @viewport3.update end end 16. Visual Equipment: Mã: #============================================================================== # ■ Visual_Equipment # Written by Rataime # # Edit below # # Note : If you have a custom Window_SaveFile, check the one at the end of the script, # add the added lines to yours, and delete the whole Window_SaveFile class here #============================================================================== def equip_update(light=false) $visual_equipment=Array.new $visual_equipment[0]=light for i in 0..3 $visual_equipment[i+1]=[] end #=================================================== # ● EDIT HERE ! #=================================================== #If weapon n°33 is equiped, add the charset tpl_helmet_1.png (I don't have a weapon charset ><) #add_weapon_sprite(33,"tpl_helmet_1") #If weapon n°6 is equiped, add the charset tpl_helmet_1.png add_armor_sprite(6,"tpl_helmet_1") add_armor_sprite(7,"tpl_helmet_2") add_armor_sprite(20,"tpl_armor_white") add_armor_sprite(15,"tpl_armor_blue") add_armor_sprite(21,"tpl_armor_cape") #=================================================== # ▼ Visual_equip functions #=================================================== RPG::Cache.clear @game_party = $game_party @game_party = $game_party2 if $visual_equipment[0] for i in 0...@game_party.actors.size for img in $visual_equipment[i+1] bitmap = RPG::Cache.character(@game_party.actors[i].character_name, @game_party.actors[i].character_hue) if img!=true and img!=false add_equip(bitmap,img,i) end end end end def add_equip(sprite,to_add,character) @game_party = $game_party @game_party = $game_party2 if $visual_equipment[0] bmp = Sprite.new bmp.visible =false bmp.bitmap = RPG::Cache.character(to_add,@game_party.actors[character].character_hue) color = bmp.bitmap.get_pixel(0, 0) x=sprite.width y=sprite.height if $visual_equipment[0] x=x/4 y=y/4 end for i in 0..x for j in 0..y color_get=bmp.bitmap.get_pixel(i, j) if color_get!=color sprite.set_pixel(i, j ,color_get) end end end bmp=nil end def add_weapon_sprite(id,sprite) @game_party = $game_party @game_party = $game_party2 if $visual_equipment[0] for i in 0...@game_party.actors.size if @game_party.actors[i].weapon_id==id $visual_equipment[i+1].push(sprite) end end end def add_armor_sprite(id,sprite) @game_party = $game_party @game_party = $game_party2 if $visual_equipment[0] for i in 0...@game_party.actors.size if @game_party.actors[i].armor1_id==id or @game_party.actors[i].armor2_id==id or @game_party.actors[i].armor3_id==id or @game_party.actors[i].armor4_id==id $visual_equipment[i+1].push(sprite) end end end #=================================================== # ▼ CLASS Scene_Equip edit #=================================================== class Scene_Equip alias visual_update_right update_right def update_right if Input.trigger?(Input::B) equip_update $game_system.se_play($data_system.cancel_se) $scene = Scene_Menu.new(2) return end visual_update_right end end class Interpreter alias visual_command_319 command_319 def command_319 actor = $game_actors[@parameters[0]] if actor != nil actor.equip(@parameters[1], @parameters[2]) end equip_update return true end end class Game_Character attr_accessor :character_hue end class Game_Actor < Game_Battler alias visual_setup setup def setup(actor_id) visual_setup(actor_id) @character_hue = (@character_hue+1)%256 end end class Scene_Load alias visual_read_save_data read_save_data alias visual_on_cancel on_cancel def on_cancel equip_update visual_on_cancel end def read_save_data(file) visual_read_save_data(file) equip_update end end class Scene_Save alias visual_on_decision on_decision alias visual_on_cancel on_cancel def on_cancel equip_update visual_on_cancel end def on_decision(file) equip_update visual_on_decision(file) end end class Scene_Title alias visual_command_new_game command_new_game def command_new_game visual_command_new_game equip_update end end class Window_SaveFile < Window_Base def initialize(file_index, filename) super(0, 64 + file_index % 4 * 104, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize @file_index = file_index @filename = "Save#{@file_index + 1}.rxdata" @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") @time_stamp = file.mtime @characters = Marshal.load(file) @frame_count = Marshal.load(file) @game_system = Marshal.load(file) @game_switches = Marshal.load(file) @game_variables = Marshal.load(file) @self_variables = Marshal.load(file)#added @game_screen = Marshal.load(file)#added @game_actors = Marshal.load(file)#added $game_party2=@game_party= Marshal.load(file)#added @total_sec = @frame_count / Graphics.frame_rate file.close end equip_update(true)#added refresh @selected = false end end Graphics cho equipment:
Tường chả có ai thèm quan tâm T__T Mau mà có fanha ở đây. Bác nghĩ sao, vụ này có thể thực hiện được không ?
Quan tâm chứ , vụ này hay hết xảy , bác có thể làm 1 Demo lên đây dc ko vậy ? Cho anh em xem xét qua đi , nghe hấp dẫn qué