-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI_UTILS.CPP
315 lines (290 loc) · 8.28 KB
/
AI_UTILS.CPP
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/* ========================================================================
Copyright (c) 1990,1996 Synergistic Software
All Rights Reserved
========================================================================
Filename: AI_UTILS.C
Author: Greg Hightower
========================================================================
Contains the following general functions:
AICheckLine - checks for intersection/collision against the blockmap
AIOpenScript - open/close a script file (toggles)
AIDropPoint - Place the current Univeral coords in the AIScript file
Contains the following internal functions:
======================================================================== */
/* ------------------------------------------------------------------------
Includes
------------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "system.h"
#include "engine.h"
//remove when AICheckLine is moved back to engine
#include "engint.h"
#include "ai_utils.h"
#include "athing.hxx"
#include "player.hxx"
#include "scnmgr.hxx"
#include "scene.hxx"
#include "sound.hxx"
//#ifdef _WINDOWS
//#ifdef OLD_SOUND
//#include "winsys\sndutil.h"
//#endif
//#endif
/* ------------------------------------------------------------------------
Defines and Compile Flags
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Macros
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Prototypes
------------------------------------------------------------------------ */
SHORT TestWorldBit(
LONG X,
LONG Y,
LONG W
);
/* ------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------ */
FILE *hAIScriptFile = NULL;
/* ========================================================================
Function - AIOpenScript
Description - open/close a script file (toggles)
Returns - void
======================================================================== */
void AIOpenScript( LONG)
{
static BOOL open = FALSE;
if(open)
FileClose( hAIScriptFile );
else
hAIScriptFile = FileOpen( "script.txt", "w" );
open = !open;
}
/* ========================================================================
Function - AIDropPoint
Description - Place the current Univeral coords in the AIScript file
Returns - void
======================================================================== */
void AIDropPoint( LONG )
{
fprintf( hAIScriptFile, "%ld %ld %ld %ld\n",
PLAYER_INT_VAL(player.x), PLAYER_INT_VAL(player.y), player.h, player.a );
}
/* ========================================================================
Function - pfVoiceInq
Description - make a voice inquiry
Returns -
======================================================================== */
void pfVoiceInq( LONG
#ifdef _WINDOWS
#ifdef OLD_SOUND
type
#endif
#endif
)
{
#ifdef _WINDOWS
#ifdef OLD_SOUND
SHORT i = fERROR;
// GEH replace this later
if (type == DOG)
{
i = (SHORT) (43 + random(6));
}
else
if (type == OLD_WOMAN ||
type == HIGH_PRIESTESS ||
type == PEASANT_WOMAN_1 ||
type == PEASANT_WOMAN_2 ||
type == SERVANT_WOMAN ||
type == WENCH ||
type == WIZARD_FEMALE_1 ||
type == WIZARD_FEMALE_2 ||
type == LORD_FEMALE_1 ||
type == LORD_FEMALE_2 ||
type == LORD_FEMALE_3
)
{
i = (SHORT) (SND_AVATAR_FEMALE_INQUIRY_YOUNG + random(SND_AVATAR_FEMALE_INQUIRY_YOUNG_LAST));
}
else
if (type == ARCHER ||
type == LIGHT_CAVALRY ||
type == ELITE_INFANTRY ||
type == INFANTRY ||
type == IRREGULAR ||
type == KNIGHT ||
type == LEVY ||
type == OFFICER ||
type == PIKEMAN ||
type == SCOUT ||
type == DWARF_ARCHER ||
type == DWARF_INFANTRY ||
type == DWARF_OFFICER ||
type == ELF_ARCHER ||
type == ELF_CAVALRY ||
type == ELF_OFFICER ||
type == MERC_ARCHER ||
type == MERC_CAVALRY ||
type == MERC_INFANTRY ||
type == MERC_IRREGULAR ||
type == MERC_OFFICER ||
type == MERC_PIKEMAN ||
type == AMBASSADOR ||
type == COUNSELOR ||
type == CHIEF ||
type == GENERAL_1 ||
type == GENERAL_2 ||
type == GUARD ||
type == LIEUTENANT ||
type == MERCHANT ||
type == TRADER ||
type == OLD_MAN ||
type == HIGH_PRIEST ||
type == MONK ||
type == PEASANT_MAN_1 ||
type == PEASANT_MAN_2 ||
type == RANGER ||
type == ROGUE ||
type == ROYAL_GUARD ||
type == SERVANT_MAN ||
type == SHOP_KEEPER_1 ||
type == SHOP_KEEPER_2 ||
type == SMITH ||
type == WARRIOR ||
type == WIZARD_MALE_1 ||
type == WIZARD_MALE_2 ||
type == LORD_MALE_1 ||
type == LORD_MALE_2 ||
type == LORD_MALE_3 ||
type == DWARF_LORD ||
type == DWARF_GUARD ||
type == ELF_GUARD
)
{
i = (SHORT) (SND_AVATAR_INQUIRY_MATURE + (random(3)*3) + (type % 3));
}
if (i != fERROR)
{
PlayWave(i, FALSE);
}
#endif
#endif
}
/* ========================================================================
Function - pfVoiceResp
Description - make a voice acknowledgement
Returns -
======================================================================== */
void pfVoiceResp( LONG
#ifdef _WINDOWS
#ifdef OLD_SOUND
type
#endif
#endif
)
{
#ifdef _WINDOWS
#ifdef OLD_SOUND
SHORT i = fERROR;
// GEH replace this later
if (type == DOG)
{
i = (SHORT) (43 + random(6));
}
else
if (type == OLD_WOMAN ||
type == HIGH_PRIESTESS ||
type == PEASANT_WOMAN_1 ||
type == PEASANT_WOMAN_2 ||
type == SERVANT_WOMAN ||
type == WENCH ||
type == WIZARD_FEMALE_1 ||
type == WIZARD_FEMALE_2 ||
type == LORD_FEMALE_1 ||
type == LORD_FEMALE_2 ||
type == LORD_FEMALE_3
)
{
i = (SHORT) (64 + random(3));
}
else
if (type == ARCHER ||
type == LIGHT_CAVALRY ||
type == ELITE_INFANTRY ||
type == INFANTRY ||
type == IRREGULAR ||
type == KNIGHT ||
type == LEVY ||
type == OFFICER ||
type == PIKEMAN ||
type == SCOUT ||
type == DWARF_ARCHER ||
type == DWARF_INFANTRY ||
type == DWARF_OFFICER ||
type == ELF_ARCHER ||
type == ELF_CAVALRY ||
type == ELF_OFFICER ||
type == MERC_ARCHER ||
type == MERC_CAVALRY ||
type == MERC_INFANTRY ||
type == MERC_IRREGULAR ||
type == MERC_OFFICER ||
type == MERC_PIKEMAN ||
type == AMBASSADOR ||
type == COUNSELOR ||
type == CHIEF ||
type == GENERAL_1 ||
type == GENERAL_2 ||
type == GUARD ||
type == LIEUTENANT ||
type == MERCHANT ||
type == TRADER ||
type == OLD_MAN ||
type == HIGH_PRIEST ||
type == MONK ||
type == PEASANT_MAN_1 ||
type == PEASANT_MAN_2 ||
type == RANGER ||
type == ROGUE ||
type == ROYAL_GUARD ||
type == SERVANT_MAN ||
type == SHOP_KEEPER_1 ||
type == SHOP_KEEPER_2 ||
type == SMITH ||
type == WARRIOR ||
type == WIZARD_MALE_1 ||
type == WIZARD_MALE_2 ||
type == LORD_MALE_1 ||
type == LORD_MALE_2 ||
type == LORD_MALE_3 ||
type == DWARF_LORD ||
type == DWARF_GUARD ||
type == ELF_GUARD
)
{
i = (SHORT)( 2 + 9 + (random(3) * 3) + (type % 3));
}
if (i != fERROR)
{
// SndCueWave((BIRTHRT_SND) i, FALSE, NULL,NULL);
// PlayWave(i, FALSE);
}
#endif
#endif
}
/* ========================================================================
Function - pfCommandOnHide
Description - on closing of command popup
Returns -
======================================================================== */
void pfCommandOnHide(void)
{
PTR_SCENE pCurrentScene = (PTR_SCENE) BLKPTR(SCENE_MGR::hCurrentScene);
pCurrentScene->mfSetSceneState(SCENE_AI::PLAY);
}