[go: up one dir, main page]

Menu

[r7]: / engine / core.hpp  Maximize  Restore  History

Download this file

586 lines (484 with data), 13.1 kB

  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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
/*
IRE: Core Data structures
Version: 2.0, 29/2/00
*/
#ifndef __IRCORE
#define __IRCORE
#define IKV "0.94" // IRE Kernel Version
#define ACT_STACK 8 // Sub-Activity stack
#define RANDOM_TILE 0xffff // Appears as an eyesore
// SaveID values and manipulation constants
#define SAVEID_NONE 0
#define SAVEID_INVALID 0xffffffff
#define SAVEID_MAPMASK 0xfe000000
#define SAVEID_MAPBITS 7
#define SAVEID_IDMASK 0x01ffffff
#define SAVEID_IDBITS 25
#define CHAR_U 0 // Directions for the sequence cache in CHlist
#define CHAR_D 1
#define CHAR_L 2
#define CHAR_R 3
#define FP_DIAGONAL 1 // Pathfinder flags
#define FP_FINDROUTE 2
#define KILLROOF 1
#define KILLMAP 2
#define MAPSIG 0xf15e0005
#define MAX_W 8192
#define MAX_H 8192
#define MAX_MEMBERS 128
#define MAP_POS(x,y) (ytab[y]+(x))
#include <allegro.h>
#ifndef __VMTYPE
#define __VMTYPE
typedef union VMTYPE
{
void *ptr;
unsigned long ul;
unsigned long u32; // was int, but...
unsigned short u16;
unsigned char u8;
long l;
int i32;
short i16;
char i8;
} VMTYPE;
#endif
typedef union OBJECTID
{
struct OBJECT *objptr;
unsigned int saveid;
} OBJECTID;
///////////////////////////////////////////////////////////////////////////
// Script Processing Data Structures //
///////////////////////////////////////////////////////////////////////////
// NPC Flags
typedef struct NPC_FLAGS
{
unsigned int female :1; // Male or Female
unsigned int know_name :1; // Do I know you?
unsigned int is_hero :1; // Is this the hero?
unsigned int cant_eat :1; // Can it eat and drink? (Robots can't)
unsigned int critical :1; // Has gone critical
unsigned int no_shutdoor :1; // Won't shut doors after themselves
unsigned int symlink :1; // Owner is the NPC, not object (phones etc)
unsigned int biological :1; // Affected by poison etc
unsigned int guard :1; // Policeman
unsigned int spawned :1; // Dynamically created (and destroyed ;-)
unsigned int no_opendoor :1; // Can't open doors
unsigned int in_bed :1; // In bed
unsigned int ignoreschedule :1; // temporary monomania (e.g. for a plot event)
unsigned int scheduleoverdue :1; // overdue, go right to bed NOW
unsigned int spare :17;
} NPC_FLAGS;
typedef struct NPC_RECORDING
{
char *page;
struct OBJECT *player;
struct NPC_RECORDING *next;
} NPC_RECORDING;
typedef struct CHAR_LABELS
{
char *rank;
char *race;
char *party;
char *location;
} CHAR_LABELS;
// Statistics
typedef struct STATS
{
long hp;
long dex;
long str;
long intel;
long weight;
long quantity;
long armour;
long tick; // Animation timer
NPC_FLAGS npcflags;
long damage; // Damage (caused by a weapon)
long radius;
OBJECTID owner;
long karma; // Have you been a good little boy? (or girl)
long bulk;
long range;
long speed;
long level; // skill level
long alignment;
} STATS;
// Temporary data for a game in progress
// Changing this may well break savegame compatability
typedef struct USEDATA
{
long user[20];
long poison;
long unconscious;
long potion[10]; // space for 10 potions
long dx,dy; // Used by the pathfinder
long vigilante; // If this is set, you have a license to kill people
long edecor; // Used by the Editor
long counter; // Counter. Used by eggs or the pathfinder
long experience; // Experience points
long magic; // Magic points
long archive; // Used when switching worlds
long oldhp; // Previous hp, used internally
OBJECTID arcpocket; // Used when switching worlds
OBJECTID pathgoal; // For the long-range pathfinder
// Sub-Activities
long actlist[ACT_STACK];
struct OBJECT *acttarget[ACT_STACK];
long actptr,actlen;
long fx_func; // Special effects function number or 0
NPC_RECORDING *npctalk; // Used to record what you've said for continuity
NPC_RECORDING *lFlags; // Local Flags
} USEDATA;
// Archive states for objects as they move between worlds
enum
{
UARC_NORMAL,
UARC_ONCEONLY,
UARC_SYSPOCKET,
UARC_INPOCKET,
UARC_SYSLIST,
};
// A single sprite
typedef struct S_POOL
{
char *name;
char *fname;
RLE_SPRITE *image;
long thumbcol;
long w,h;
unsigned long wxh;
long x,y;
unsigned char flags;
long darkness;
} S_POOL;
// A single lightmap sprite
typedef struct L_POOL
{
char *fname;
BITMAP *image;
} L_POOL;
// A complete animation sequence
typedef struct SEQ_POOL
{
char *name;
S_POOL **seq;
long frames;
unsigned int flags; // See SEQ_FLAGS
long x,y;
unsigned char speed;
S_POOL *overlay; // This is always drawn on top of the sprite
// but it has no physical existence
struct SEQ_POOL *jumpto;// Sequence to jump to on exit if necessary
long hookfunc; // Optional script call
long translucency; // Translucency amount
} SEQ_POOL;
#define SEQFLAG_PINGPONG 0x00000001
#define SEQFLAG_LOOP 0x00000002
#define SEQFLAG_RANDOM 0x00000004
#define SEQFLAG_UNISYNC 0x00000005
#define SEQFLAG_ANIMCODE 0x00000007 // mask covering animation flags
#define SEQFLAG_STEPPED 0x00000010
#define SEQFLAG_JUMPTO 0x00000020
#define SEQFLAG_CHIMNEY 0x00000040
#define SEQFLAG_POSTOVERLAY 0x00000080
#define SEQFLAG_WALL 0x00000100
#define SEQFLAG_ASYNC 0x00000200
// Scripts
typedef struct PEM
{
char *name;
char *file;
char *code;
long codelen;
long size;
char hidden; // local function
char Class;
} PEM;
// Stored data lookup items
typedef struct DT_ITEM
{
char *ks;
long ki;
char *is;
long ii;
} DT_ITEM;
typedef struct DATATABLE
{
char *name;
long entries;
char keytype;
char listtype;
DT_ITEM *list;
} DATATABLE;
//////////////////////////////////////////////////////////////////
// Object Data Structures //
//////////////////////////////////////////////////////////////////
typedef struct S_FLAGS
{
unsigned int on :1; // active?
unsigned int willopen:1; // Is is always impassible?
unsigned int window:1; // Is it a window?
unsigned int solid:1; // Is it solid to people?
unsigned int fragile:1; // Will it break if you drop it?
unsigned int trigger:1; // Is it a trigger?
unsigned int invisible:1; // Will it only appear in the editor?
unsigned int party:1; // Is it a Party Member? (affects solidity)
unsigned int fixed:1; // Is is nailed to the ground (can't move)
unsigned int container:1; // Is is a container?
unsigned int translucent:1; // Is it translucent?
unsigned int large :1; // Object bigger than 1 tile
unsigned int spikeproof:1; // Isn't hurt by objects below
unsigned int wield :1; // Can it be wielded?
unsigned int stepupdated :1;// Was just updated (used by stepping code)
unsigned int setsequence :1; // Has setsequence just been used?
unsigned int blocklight :1; // Does it blocklight?
unsigned int tabletop :1; // Can you drop things on it even if it's solid?
unsigned int didinit :1; // Have we done the INIT function?
unsigned int didupdate :1; // Have we moved just now (prevent runaway)?
unsigned int person :1; // Is a person
unsigned int horror :1; // Will the very sight of it affect NPCs
unsigned int quantity :1; // Can it be a pile of things?
unsigned int watery :1; // Can it go on water (or is it a water tile?)
unsigned int shadow :1; // Is it just a dark patch?
unsigned int decor :1; // Is it a decoration?
unsigned int system :1; // Hidden from the player (markers, triggers)?
unsigned int spare :6;
} S_FLAGS;
typedef struct FUNCS // This is called when you...
{
char use[32]; // USE it
long ucache;
char *suse; // This is a pointer to the string array, for PEscript
char talk[128]; // TALK to it
long tcache;
char *stalk;
char kill[32]; // KILL/BREAK it
long kcache;
char *skill;
char look[32]; // LOOK at it
long lcache;
char *slook;
char stand[32]; // STAND on it
long scache;
char *sstand;
char hurt[32]; // HURT/DAMAGE it
long hcache;
char *shurt;
char init[32]; // Called when object first created
long icache;
char *sinit;
// The ?cache number succeeding each entry is the index in the array of VRMs
// to the one that will be called, and is used for optimisation.
char contains[8][32];
long contents;
// Up to 8 objects can be put in the object when it's first created
char resurrect[32]; // Object it becomes when resurrected
char *sresurrect;
char wield[32]; // Called when object is wielded/removed
long wcache;
char *swield;
char attack[32]; // Attack with it
long acache;
char *sattack;
char user1[32];
char *suser1;
char user2[32];
char *suser2;
char horror[32]; // NPC sees something truly awful
long hrcache;
char *shorror;
char quantity[32]; // Quantity is changed
long qcache;
char *squantity;
} FUNCS;
// Tiles
typedef struct TILE
{
char *name;
S_FLAGS flags;
SEQ_POOL *form; // Direct access to animation
char seqname[32]; // Name of animation (in editor)
long sptr; // Animation counter
long cost; // movement cost
long sdir,tick; // animation info
long sdx,sdy; // Scroll delta x,y
long sx,sy; // scroll coordinates x,y
long standfunc; // Function to be called if stood
char *desc; // description
SEQ_POOL **alternate;// Alternate tiles (for blanked corners) or NULL
} TILE;
// AI objects
typedef struct SCHEDULE
{
char ok,hour,minute;
char vrm[32];
long call;
OBJECTID target;
} SCHEDULE;
typedef struct WIELD
{
struct OBJECT *head;
struct OBJECT *neck;
struct OBJECT *body;
struct OBJECT *legs;
struct OBJECT *feet;
struct OBJECT *arms;
struct OBJECT *l_hand;
struct OBJECT *r_hand;
struct OBJECT *l_finger;
struct OBJECT *r_finger;
struct OBJECT *spare1;
struct OBJECT *spare2;
struct OBJECT *spare3;
struct OBJECT *spare4;
} WIELD;
enum {
WIELD_HEAD,
WIELD_NECK,
WIELD_BODY,
WIELD_LEGS,
WIELD_FEET,
WIELD_ARMS,
WIELD_LHAND,
WIELD_RHAND,
WIELD_LFINGER,
WIELD_RFINGER,
WIELD_SPARE1,
WIELD_SPARE2,
WIELD_SPARE3,
WIELD_SPARE4,
WIELDMAX};
// Moving object entity
typedef struct OBJECT
{
char *name;
S_FLAGS flags;
long w,h,mw,mh;
long x,y,z;
char *personalname;
SCHEDULE *schedule;
SEQ_POOL *form;
long sptr,SPARE,sdir; // animation info
STATS *maxstats; // Statistics structure
STATS *stats; // Current stats
FUNCS *funcs; // VRM Function table
long curdir;
short dir[4]; // u,d,l,r
char *desc; // Examine Description
char *shortdesc; // Short Description
OBJECTID target; // Current target object (behaviour goal, if any)
long tag; // Tags are used for triggering things
long activity; // Current activity VRM
struct USEDATA *user; // User data for a game in progress
unsigned char hblock[4]; // xywh
unsigned char vblock[4]; // xywh
unsigned char harea[4]; // xywh
unsigned char varea[4]; // xywh
long hotx,hoty; // attack hotspot
unsigned int save_id; // Assigned object number (during saving and loading)
long light; // Light it casts
CHAR_LABELS *labels; // Tags and labels for the object that don't change.
OBJECTID enemy;
//struct OBJECT **wield; // Christ, Joe, what were you thinking!?
struct WIELD *wield;
OBJECTID pocket;
struct OBJECT *next;
OBJECTID parent;
} OBJECT;
typedef struct OBJREGS
{
OBJECT *player;
OBJECT *current;
OBJECT *me;
OBJECT *victim;
} OBJREGS;
#define BLK_X 0
#define BLK_Y 1
#define BLK_W 2
#define BLK_H 3
// World structure
typedef struct WORLD
{
unsigned int sig; // Signature
int w,h;
unsigned short *physmap; // Physical world
OBJECT *object; // Linked list of objects
unsigned char *roof; // Rooftop
OBJECT **objmap; // Object Map
unsigned char *light; // Static Lighting
unsigned char *lightst;
int con_n,con_s,con_e,con_w;// map connections
int *temp[25];
} WORLD;
typedef struct OBJLIST
{
OBJECT *ptr;
struct OBJLIST *next;
} OBJLIST;
typedef struct PEVM
{
OBJECT *reg[4]; // Local object registers
char *name; // Name of function (for debugging)
char *file; // Filename of function (for debugging)
VMTYPE *code; // code and data
int size; // length of code and data
int codelen; // length of code and data
VMTYPE *ip; // instruction pointer
struct PEVM *next; // for use as a linked-list (vmstack etc)
} PEVM;
// Tile Linker for automatic map structure generation
typedef struct TL_DATA
{
long tile;
long becomes;
} TL_DATA;
typedef struct TILELINK
{
char *name;
long tile;
TL_DATA *n;
TL_DATA *s;
TL_DATA *e;
TL_DATA *w;
TL_DATA *ne;
TL_DATA *nw;
TL_DATA *se;
TL_DATA *sw;
long nt;
long st;
long et;
long wt;
long net;
long nwt;
long set;
long swt;
} TILELINK;
typedef struct USERSTRING
{
long len;
char *ptr;
} USERSTRING;
// Externals
extern OBJLIST *MasterList;
#ifdef __cplusplus
extern "C"
{
#endif
extern int gamewinsize;
extern BITMAP *gamewin;
extern BITMAP *roofwin;
extern int VSW; // Tiles
extern int VSH;
extern int VSA;
extern int VSMIDX;
extern int VSMIDY;
extern int VSW32; // Pixels
extern int VSH32;
extern int VSA32;
extern char imgcachedir[];
#ifdef __cplusplus
}
#endif
#endif