Skip to content

Commit 8167efb

Browse files
committed
✨(wayzer/cmds/vote) 更新新的跳波算法
1 parent f7647cf commit 8167efb

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

scripts/wayzer/cmds/vote.kts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import mindustry.game.EventType.GameOverEvent
88
import wayzer.VoteService
99
import java.time.Instant
1010
import kotlin.math.ceil
11+
import kotlin.math.max
1112
import kotlin.random.Random
1213

1314
fun VoteService.register() {
@@ -41,22 +42,23 @@ fun VoteService.register() {
4142
val t = (arg.firstOrNull()?.toIntOrNull() ?: 10).coerceIn(1, 50)
4243
start(player!!, "跳波({t}波)".with("t" to t), supportSingle = true) {
4344
val startTime = Instant.now()
44-
var waitTime = 3
4545
repeat(t) {
46-
while (state.enemies > 300) {//延长等待时间
47-
if (waitTime > 60) return@start //等待超时
48-
delay(waitTime * 1000L)
49-
waitTime *= 2
50-
}
5146
if (lastResetTime > startTime) return@start //Have change map
52-
Core.app.post { logic.runWave() }
53-
delay(waitTime * 1000L)
47+
val before = state.enemies
48+
logic.runWave()
49+
while (spawner.isSpawning) delay(1000L)
50+
val after = state.enemies
51+
while (state.enemies > max(before, (after - before) * 3 / 10)) {
52+
delay(1000L)
53+
}
54+
delay(3000L)
5455
}
5556
}
5657
}
5758
addSubVote("清理本队建筑记录", "", "clear", "清理", "清理记录") {
5859
val team = player!!.team()
59-
start(player!!, "清理建筑记录({team.colorizeName}[yellow]队|需要2/5同意)".with("team" to team),
60+
start(
61+
player!!, "清理建筑记录({team.colorizeName}[yellow]队|需要2/5同意)".with("team" to team),
6062
canVote = { it.team() == team }, requireNum = { ceil(it * 0.4).toInt() }
6163
) {
6264
team.data().plans.clear()

0 commit comments

Comments
 (0)