视频录制的比较早,目前已经转换为yarn
作为npm包管理工具,请自行将视频中的npm
改为yarn
Xavier 的 dota2 自定义游戏开发模板
node.js
,目前的要求是>16.0.0
scripts/addon.config.js
,将addon_name
修改为你的项目名称yarn install
安装依赖,他应该会自动 linkcontent
,game
文件夹到你的dota 2 beta/dota_addons
(如果碰到权限问题,请关闭代码编辑器后使用控制台来执行yarn
,或者重启一下电脑再试,如果碰到安装错误,可以尝试使用npmmirror镜像,或者直接执行yarn config set registry https://registry.npmmirror.com
再执行yarn install
)yarn dev
,开始你的开发yarn launch map_name
启动游戏并载入地图,或者使用yarn launch
只是启动工具而不载入地图,之后再在控制台使用指令载入地图。流程同新建项目,只不过在5后插入一个
.gitignore
,因为本项目默认不追踪 content/panorama/layout/
目录 和 game/scripts/vscripts/
目录的变更
*.d.ts
文件来提供类型声明,如果要使用 import
语句,请对lua脚本进行适当的修改,可以参考对 game/scripts/src/utils/timers.lua
的改造及他对应的 d.ts
文件webpack.dev.js
,主要是要删去 PanoramaManifestPlugin
部分,来自己编辑 custom_ui_manifest.xml
,更推荐的做法是将 传统 panorama 写法的代码放到 src 文件夹,之后使用 webpack 共同打包现代
的语言来进行开发,也就是typescript
,而不是用lua
和javascript
,等于可以少学一门语言。kv
文件,而无需掌握他们的结构。react
来开发UI可以更好地管理你的代码,而无需掌握xml
的写法。UI无法读取KV文件
,UI图片不会自动编译
等问题。content/panorama/src
与后端的game/scripts/src
文件夹分别用来写用户界面 react 源码和游戏逻辑的 ts 源代码game/scripts/npc
文件夹,同时在panorama和scripts文件夹生成与每个kv文件对应的json文件,这样你的ts代码可以很方便地获取kv数据addon.csv
变成 addon_*.txt
,(也可以把 addon_*.txt
变成 addon.csv
)yarn launch [[addon_name] map_name]
启动 dota2,两个参数为可选参数,如果提供了addon_name
那么会载入指定的 addon(默认该项目),提供了map_name
则会自动载入对应的地图名(若未提供 addon_name 则默认载入当前 addon)yarn dev
进入 dev 模式,将会执行将后端的ts代码编译成lua代码、使用webpack打包前端代码、同步KV到js,生成localization,Excel转KV等操作
,正常来说,每次开发你需要保持yarn dev的运行状态yarn prod
执行发布
操作,将会自动生成publish
文件夹并自动 link 到dota_addons/you_addon_name_publish
文件夹,之后你可以选择这个文件夹发布(可以在package.json -> dota_developer
中对发布进行一些设置)。
将 scripts/addon.config.js 里面的 encrypt_files
变量根据你的需要修改,哪些文件加密,哪些不加密(解密脚本,入口文件不能加密,客户端会使用到的技能和Modifier代码建议也不加密,不要尝试通过将密钥发送给客户端这样的操作来加密客户端脚本,因为别人可以通过读内存等等方法获取到密钥)
将该文件中的 encryptDedicatedServerKeyRelease
修改成你的图的 DedicatedServerKey
key的获取方法:不加密上传一次,去获取KEY,要注意,获取KEY的 version
参数应该和 decrypt.lua 中的保持一致,你也可以上传这个项目去批量获取一些key,之后根据需要使用某一个key
执行yarn prod
来完成测试加密流程(在加密范围内的代码有变更之后需要执行,一般是要确认新加的功能能否在加密后正常运行)
确认一切运行正确后,执行 yarn prod
来完成正式发布加密流程
执行yarn launch your_addon_name_publish
来启动加密后的图,之后执行上传操作(注意,这个时候本地的publish是不能正常运行的,因为密钥只有服务器上有,因此直接上传即可)
yarn api
生成与 scripts/server_api.json
(需要符合Swagger 3.0规范)的API一致的请求类,并储存于 game/scripts/src/server/services
,关于请求实现的细节,请查阅 game/scripts/src/server/core
文件夹dota 2 beta/content/dota_addons/your_addon_name
同步更新dota 2 beta/game/dota_addons/your_addon_name
同步更新panorama ts
和tstl
公用的声明,如custom_net_tables
等gulpfile.ts
来查看 gulp 的使用方法node.js, LuaForWindows , Python 等一系列环境的配置请自行使用搜索引擎完成,不赘述。
只推荐使用
steam
启动dota2的形式来完成modding,如果尚未安装,请点此下载
如果你在DOTA2自定义游戏制作过程中遇到了任何问题,可以到本项目的 Issues页面 提问,如果我知道的将会予以解答。
[]() Xavier's dota2 custom game development template (English translated with DeepL)
If you want to use this template, in addition to mastering the Valve's development tools, you need to additionally learn
typescript
, javascript
react
node.js
DOTA2 Typescript API
, you can check out node_modules/dota-lua-types
and node_modules/panorama-types
after you finish yarn
.game/scripts/npc
,addon.csv
to addon_*.txt
, (also you can convert them back to addon.csv
),content/panorama/src
and game/scripts/src
.gulpfile.ts
for more details.yarn launch [[addon_name] map_name]
launches dota2, all parameters are optional, if addon_name
is provided then the specified addon will be loaded (default to launch this project), if map_name
is provided then the corresponding map name will be loaded automatically (if addon_name is not provided then the current addon will be loaded by default)yarn dev
enter dev mode to compile the ts source code and watch the changes of the files.yarn prod
to run publish
operation, it will automatically generate publish
folder and automatically link to dota_addons/you_addon_name_publish
folder, then you can choose this folder to publish (you can set some settings for publishing in package.json -> dota_ developer
to make some settings for publishing).yarn compile
to compile the source contentsnode.js
, require above Node v14.10.1 ~~ because versions below is not tested ~~package.json
and change name
to your preferred nameyarn
to install the dependencies, it should automatically link content
,game
folder to your dota 2 beta/dota_addons/your_preferred_name
, (if you encounter permission problems, please try to restart)yarn dev
and start your developmentdota 2 beta/content/dota_addons/your_addon_name
dota 2 beta/game/dota_addons/your_addon_name
panorama
and typescript-to-lua
, like custom net tables
scripts/publish.js
issues