-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot_ai.pas
131 lines (104 loc) · 3.45 KB
/
bot_ai.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
BOT.DLL for Need For Kill
(c) 3d[Power]
http://www.3dpower.org
unit: bot_ai
purpose: general bot ai unit
}
unit bot_ai;
interface
uses Sysutils, bot_register, bot_defs, math, bot_util;
// ============================
procedure EVENT_BeginGame;
procedure EVENT_ResetGame;
procedure EVENT_MapChanged;
procedure EVENT_DMGReceived(TargetDXID, AttackerDXID:Word; dmg : word);
procedure EVENT_ChatReceived(DXID:Word; Text : shortstring);
procedure MAIN_Loop;
function BotVersion : shortstring;
// ============================
implementation
// îòâåòèòü íôê.åõå íàñ÷åò âåðñèè.
function BotVersion : shortstring;
begin
result := '';
// result := '^3bot.dll: Running "sample bot" v0.0.0';
end;
// ================
// Íà÷àëî ïàðòèè
// ================
procedure EVENT_BeginGame;
begin
// load waypoints here...
// addmessage(GetSystemVariable ('mapcrc32'));
end;
// ================
// Âûçûâàåòñÿ ïðè map restart, è ïîñëå EVENT_BeginGame
// ================
procedure EVENT_ResetGame;
begin
// reset bot ai here..
end;
// ================
// Âûçûâàåòñÿ ïðè ñìåíå êàðòû.
// ================
procedure EVENT_MapChanged;
begin
// reload bot ai here.. similar to EVENT_BeginGame
end;
// ================
// Ïîëó÷åíèå ïîâðåæäåíèÿ èãðîêîì ñ DXID = TargetDXID, àòàêóþùèé AttackerDXID
// ================
procedure EVENT_DMGReceived(TargetDXID, AttackerDXID:Word; dmg : word);
begin
// öèêëîì ìîæíî íàéòè êîìó áûëî íàíåñåíî ïîâðåæäåíèå, íåçàáûâàéòå ïðîâåðÿòü players[i] <> nil .
// Åñëè AttackerDXID=0 òî ïîâðåæäåíèå áûëî íàíåñåíî íå èãðîêîì. (ëàâîé íàïðèìåð).
end;
// =================
// Êòî-òî ïîñëàë ÷àò
// =================
procedure EVENT_ChatReceived(DXID:Word; Text : shortstring);
begin
// ó÷òèòå, ÷òî íå íóæíî ðåàãèðîâàòü áîòó íà ÷àò, êîòîðûé ïîñëàë îí ñàì.
end;
// ================
// ===================
procedure BOT_NEWTHINK (i:byte);
begin
{ players[i].ThinkTime := 50+random(100);
players[i].currentkeys := 0;
if random(2)=0 then
players[i].currentkeys := players[i].currentkeys + BKEY_MOVERIGHT else
players[i].currentkeys := players[i].currentkeys + BKEY_MOVELEFT;
if random(4)>0 then
players[i].currentkeys := players[i].currentkeys + BKEY_MOVEUP else
players[i].currentkeys := players[i].currentkeys + BKEY_MOVEDOWN;
if random(4)>0 then
players[i].currentkeys := players[i].currentkeys + BKEY_FIRE;
if random(2)>0 then
players[i].fangle := random(360);
SetWeapon(players[i].dxid, random(8));
// if random(10)=0 then SendBotChat (players[i].dxid,':)',false);}
end;
// ====================
// Îáðàáîòêà AI
// ====================
procedure BOT_AI_PROCESS(I:byte);
begin
{ if players[i].ThinkTime = 0 then BOT_NEWTHINK(i) else dec(players[i].ThinkTime);
// general bot ai here.
SetAngle(players[i].dxid, trunc(players[i].fangle));
Setkeys(players[i].dxid, players[i].currentkeys);}
end;
// ====================
// Âûçûâàåòñÿ 50 ðàç â ñåêóíäó èç nfk.exe
// Ó÷òèòå ÷òî ýòà ïðîöåäóðà ÍÅ âûçâàåòñÿ åñëè íà êàðòå íåòó íèîäíîãî áîòà.
// ====================
procedure MAIN_Loop;
var i : byte;
begin
// for i := 0 to 7 do if players[i] <> nil then if players[i].bot then
// BOT_AI_PROCESS(i);
end;
begin
end.