Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
phpdts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nemo Ma
phpdts
Commits
b955be6b
Commit
b955be6b
authored
Feb 07, 2026
by
Nemo Ma
Committed by
GitHub
Feb 07, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #220 from amarillonmc/codex/create-bot-control-system-in-bothost-v6c6nq
fix: 死亡 BOT 自动退场并按概率补位,避免 bothost 超时空转
parents
66c4558d
12bfdf09
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
5 deletions
+37
-5
bot/revbotservice.php
bot/revbotservice.php
+21
-2
bothost/README.md
bothost/README.md
+3
-1
bothost/config.example.json
bothost/config.example.json
+4
-2
bothost/main.py
bothost/main.py
+9
-0
No files found.
bot/revbotservice.php
View file @
b955be6b
...
...
@@ -11,6 +11,10 @@ require_once $gameRoot.'include/common.inc.php';
require_once
GAME_ROOT
.
'./include/game.func.php'
;
require_once
GAME_ROOT
.
'./bot/revbot.func.php'
;
$bot_respawn_chance
=
isset
(
$_GET
[
'respawn_chance'
])
?
(
int
)
$_GET
[
'respawn_chance'
]
:
35
;
if
(
$bot_respawn_chance
<
0
)
$bot_respawn_chance
=
0
;
if
(
$bot_respawn_chance
>
100
)
$bot_respawn_chance
=
100
;
# 注意:因为进程锁的存在,运行bot脚本时必须确保游戏处于未开始状态
# 否则请先中止游戏,并手动清空lock目录下所有文件,然后确保游戏正处于未开始状态下运行脚本
...
...
@@ -77,14 +81,29 @@ while($id)
{
$flag
=
bot_acts
(
$id
);
if
(
$flag
==
0
)
{
unset
(
$gamevars
[
'botid'
][
array_search
(
$id
,
$gamevars
[
'botid'
])]);
$index
=
array_search
(
$id
,
$gamevars
[
'botid'
]);
if
(
$index
!==
false
)
unset
(
$gamevars
[
'botid'
][
$index
]);
$roll
=
mt_rand
(
1
,
100
);
if
(
$gamestate
>
10
&&
$bot_respawn_chance
>
0
&&
$roll
<=
$bot_respawn_chance
)
{
$gamevars
[
'botplayer'
]
=
isset
(
$gamevars
[
'botplayer'
])
?
(
int
)
$gamevars
[
'botplayer'
]
+
1
:
1
;
echo
"BOT:
{
$id
}
已死亡;已加入重生队列。roll=
{
$roll
}
, chance=
{
$bot_respawn_chance
}
\n
"
;
}
else
{
echo
"BOT:
{
$id
}
已死亡;不加入重生队列。roll=
{
$roll
}
, chance=
{
$bot_respawn_chance
}
\n
"
;
}
save_gameinfo
();
save_combatinfo
();
if
(
empty
(
$gamevars
[
'botid'
]))
break
;
ob_end_flush
();
break
;
}
echo
"
\n
BOT:
{
$id
}
行动完成
\n
"
;
ob_end_flush
();
}
else
{
echo
"BOT:
{
$id
}
不在活动队列,进程退出。
\n
"
;
ob_end_flush
();
break
;
}
sleep
(
1
);
}
else
...
...
bothost/README.md
View file @
b955be6b
...
...
@@ -42,7 +42,7 @@ python bothost/main.py -c bothost/config.json
-
`disable_env_proxy`
:是否禁用环境变量中的 HTTP/HTTPS 代理(默认 true,建议保持)。
-
`insecure_skip_tls_verify`
:是否跳过 TLS 证书校验(默认 false,仅测试环境临时使用)。
-
`headers`
:额外请求头。
-
`query`
:附加查询参数。
-
`query`
:附加查询参数。
可加入
`respawn_chance`
(0-100)控制 BOT 死亡后的随机补位概率。
## 注意事项
...
...
@@ -58,3 +58,5 @@ python bothost/main.py -c bothost/config.json
-
若出现证书错误,可先确认站点证书链;仅在临时测试中可设
`insecure_skip_tls_verify=true`
。
-
若
`last_error`
中包含
`include(...common.inc.php): failed to open stream`
等报错,通常是目标站
`bot/revbotservice.php`
在 Web 环境下工作目录不正确;本仓库已修复为基于脚本目录计算 GAME_ROOT。
-
当目标端输出“已死亡;已加入重生队列 / 不加入重生队列”时,bothost 会将该 worker 标记为
`bot_dead_queued`
/
`bot_dead_retired`
,并等待连接退出后自动重连。
bothost/config.example.json
View file @
b955be6b
...
...
@@ -11,9 +11,11 @@
"disable_env_proxy"
:
true
,
"insecure_skip_tls_verify"
:
false
,
"headers"
:
{
"User-Agent"
:
"bothost/0.
2
"
"User-Agent"
:
"bothost/0.
3
"
},
"query"
:
{}
"query"
:
{
"respawn_chance"
:
"35"
}
}
]
}
bothost/main.py
View file @
b955be6b
...
...
@@ -178,6 +178,15 @@ class BotHost:
state
.
status
=
"running"
if
"等待中"
in
line
:
state
.
status
=
"waiting_lock"
if
"已死亡;已加入重生队列"
in
line
:
state
.
status
=
"bot_dead_queued"
state
.
bot_id
=
None
if
"已死亡;不加入重生队列"
in
line
:
state
.
status
=
"bot_dead_retired"
state
.
bot_id
=
None
if
"不在活动队列,进程退出"
in
line
:
state
.
status
=
"bot_retired"
state
.
bot_id
=
None
low
=
line
.
lower
()
if
"fatal error"
in
low
or
"warning:"
in
low
or
"uncaught error"
in
low
:
state
.
last_error
=
line
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment