java解析魔兽争霸3录像_《魔兽争霸》的录像,为什么长达半小时的录像大小只有几百 KB?...
相信你提出這個問題是以為魔獸的錄像文件是份視頻,所以才提出了"為什么它只有幾百KB"這樣的問題,事實上這份文件不是一份視頻文件,它實際上是一份自定義格式的文件具體格式和內容可以參考下面的內容。
我在GitHub找到的一份非官方發布魔獸3錄像格式的文件描述,作者通過逆向工程和自己游戲的經驗得出,里面非常詳盡地描述了一個錄像文件的格式和內容包括哪些東西,幫助你了解;
錄像原理簡而言之:魔獸客戶端就是一個播放器,錄像就是輸入內容,播放器根據輸入播放輸出,其中的格式就是自己根據需求定義。
1.文件格式目錄:
文件的目錄大致包含以下內容,首先錄像文件頭包含了版本信息。雖然看到了這個版本的定義,但是對錄像文件的數據沒有做版本控制,這也是為什么播放錄像的時候,如果客戶端版本不對,就無法播放的問題。擴展一下,其實這個問題可以在定制錄像文件的時候,針對不同部分的數據做特別的版本控制,以此達到兼容的問題,至少可以做到向下兼容。
===============================================================================
Table of Content 錄像文件描述文件目錄摘錄
===============================================================================
1.0 Introduction
2.0 [Header]
2.1 [SubHeader] for header version 0
2.2 [SubHeader] for header version 1
2.3 Version information
2.4 WarCraft III The Frozen Throne beta replay information
3.0 [Data block header]
4.0 [Decompressed data]
4.1 [PlayerRecord] 玩家記錄
4.2 [GameName] 游戲名稱
4.3 [EncodedString] 加密字符串
4.4 [GameSettings] 游戲設置
4.5 [Map&CreatorName] 地圖角色
4.6 [PlayerCount] 玩家數量
4.7 [GameType] 游戲類型
4.8 [LanguageID] 語言ID
4.9 [PlayerList] 玩家列表
4.10 [GameStartRecord]
4.11 [SlotRecord] 得分記錄
4.12 [RandomSeed] 隨機種子
5.0 [ReplayData]
6.0 General notes
6.1 Notes on official Blizzard Replays
7.0 Credits
8.0 Document revision history
===============================================================================5.0 [ReplayData]
===============================================================================
在上面的ReplayData中,包含了錄像所有的時間片數據,被細分為多個區塊Block,每個塊的數據或固定大小,或不固定,數據的都是以一個字節代表blockID,用以標識要跳過某些固定的內容,以實現錄像跳過等功能。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x1F - TimeSlot block 時間片數據 [ n+3 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 word - n = number of bytes that follow 記錄時間片數據長度
1 word - time increment (milliseconds) 時間增長量(ms)
about 250 ms in http://battle.net 戰網250毫秒
about 100 ms in LAN and single player局域網100毫秒
n-2 byte - CommandData block(s) (not present if n=2) 輸入命令數據塊
For every player which has executed an action during this time slot there is
at least one 'Command data block'.
CommandData block:
1 byte - PlayerID
1 word - Action block length
n byte - Action block(s) (see file 'w3g_actions.txt' for details)
這里有兩個重要的概念
1.TimeSlot Block"時間片數據塊",魔獸客戶端播放錄像就是嚴格按照時間片進行解析播放,時間片數據中主要記錄了數據長度和該時間片內游戲中所有對象發生的動作序列,可以參考下面的動作描述文件內容。
2.CommandData Block,“命令數據塊”包括玩家的ID, 對應的動作序列長度和動作數據。
例如:
DD 00 0D 00 - use ability: cripple (UD Necromancer) [12-44-ID-ClickX/Y-TargetID]
這條記錄就描述了此刻時間片內發生的事件,亡靈的巫師使用了殘廢,點擊坐標(X,Y),對象的ID是誰誰誰醬紫,然后魔獸客戶端內部定義一套播放的接口,根據輸入的數據進行播放就能完成播放了。
ReplayData中主要數據是一下內容:===============================================================================
WarCraft III Replay action format description content 動作描述文件目錄摘錄
===============================================================================
1.0 Introduction
1.1 Standardized APMs
2.0 Action ID's
3.0 AbilityFlags
4.0 ItemID's
4.1 Stringencoded ItemID's
4.2 Numeric ItemID's
5.0 ObjectID's
6.0 Click Coordinates
7.0 General notes
8.0 Notes on older Patches
9.0 Credits
10.0 Document revision history
里面就記錄一些描述游戲世界中對象的動作數據:
eg:
Following is a list of alphanumeric ID's found so far:
03 00 0D 00 - rightclick
04 00 0D 00 - stop
08 00 0D 00 - cancel (train, research)
0C 00 0D 00 - set rally point
0F 00 0D 00 - attack
10 00 0D 00 - attack ground (e.g. Orc Catapult)
12 00 0D 00 - move unit
16 00 0D 00 - patrol
19 00 0D 00 - hold position
- - - - - -
21 00 0D 00 - give away item (from inventory to unit or ground)
- - - - - -
22 00 0D 00 - swap item place 7 (slot of item to swap with!)
23 00 0D 00 - swap item place 8
24 00 0D 00 - swap item place 4
25 00 0D 00 - swap item place 5
2.格式讀取說明
這里以PlayerRecord說明一下里面的具體錄像格式,按照二進制的方式讀取的
其中offest代表流的偏移,size/type代表讀取的數據大小,這樣就能精準的定位到具體的數據了。
4.1 [PlayerRecord]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
offset | size/type | Description
-------+-----------+-----------------------------------------------------------
0x0000 | 1 byte | RecordID:
| | 0x00 for game host
| | 0x16 for additional players (see 4.9)
0x0001 | 1 byte | PlayerID
0x0002 | n bytes | PlayerName (null terminated string)
n+2 | 1 byte | size of additional data:
| | 0x01 = custom
| | 0x08 = ladder
BTW:
回答一下,頂樓的問題:
“掉落表怎么做,實際掉落生成方式怎么設計”
其實掉落就是實現一個權重概率的問題,游戲設計策劃人員會配置一個掉落庫,包括掉落的物品ID,掉落權重,然后在怪物配置里面去綁定掉落的信息,魔獸里面的怪物都是一個野怪會掉落不同的物品,這是一對多的關系,然后實現權重就可以了,權重也是偽隨機,就是說如果記錄下了隨機種子,那隨機結果就是唯一且確定的,所以錄像中一定會保留所有產生的隨機種子,這樣所有游戲隨機的結果也就被記錄下來了。
趕腳劍圣錄像中的臺詞是不是都是都一樣呢?For the burning Blade!
總結
以上是生活随笔為你收集整理的java解析魔兽争霸3录像_《魔兽争霸》的录像,为什么长达半小时的录像大小只有几百 KB?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Trace View
- 下一篇: 常用css样式大全以及css属性代码大全