📄 ai.bas
字号:
Attribute VB_Name = "AI"
Private Type CompAI
Active As Boolean
PlayerIndex As Integer
Difficulty As Integer
End Type
Global ComputerPlayers(10) As CompAI
Global MaxComputerPlayers As Integer
Public Sub GenerateComputerPlayer(Difficulty, PlayerIndex)
MaxComputerPlayers = MaxComputerPlayers + 1
CompNum = MaxComputerPlayers
ComputerPlayers(CompNum).Active = True
ComputerPlayers(CompNum).Difficulty = Difficulty
ComputerPlayers(CompNum).PlayerIndex = PlayerIndex
End Sub
Public Sub DestroyComputerPlayers()
For I = 1 To MaxComputerPlayers
ComputerPlayers(I).Active = False
Next I
End Sub
Public Sub RunComputerPlayers()
For I = 1 To MaxComputerPlayers
If ComputerPlayers(I).Active = True Then
Call RunIntelligence(I)
End If
Next I
End Sub
Public Static Sub RunIntelligence(CompNumber)
MyPlayerIndex = ComputerPlayers(CompNumber).PlayerIndex
Objectsavailable = 0
For I = 1 To ObjectsActive
If Objects(I).Side <> MyPlayerIndex Then
If Objects(I).Active = True Then
Objectsavailable = Objectsavailable + 1
End If
End If
Next I
For I = 1 To ObjectsActive
If ObjModels(Objects(I).ModelIndex).BehaviorType = BEHAVIORMODE_TANK Then
If Objects(I).Side = MyPlayerIndex Then
If Objects(I).Objective.Goal = GOAL_NOTHING Then
For i2 = 1 To ObjectsActive
If Objects(i2).Side <> MyPlayerIndex Then
If Objects(i2).Active = True Then
If ObjModels(Objects(i2).ModelIndex).Abilities(ABILITY_HITTABLE) = True Then
If Int(Objectsavailable * Rnd) = 1 Then Call Entities.ObjectCommand_AttackObject(I, i2, Objects(i2).MapPosition.X, Objects(i2).MapPosition.Y)
End If
End If
End If
Next i2
End If
End If
End If
Next I
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -