[go: up one dir, main page]

Menu

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

Download this file

635 lines (526 with data), 15.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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
/*
IRE: Core Data structures
Version: 2.0, 29/2/00
*/
#ifndef __IRCORE
#define __IRCORE
#define IKV "0.99" // IRE Kernel Version
#include "types.h"
#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>
///////////////////////////////////////////////////////////////////////////
// Script Processing Data Structures //
///////////////////////////////////////////////////////////////////////////
// NPC Flags
#define STRIPNPC 0x7fffffff
#define IS_FEMALE 0x80000001
#define KNOW_NAME 0x80000002
#define IS_HERO 0x80000004
#define CANT_EAT 0x80000008
#define CANT_DRINK 0x80000008 // Synonymous with CANT_EAT
#define IS_CRITICAL 0x80000010
#define NOT_CLOSE_DOOR 0x80000020
#define NOT_CLOSE_DOORS 0x80000020
#define IS_SYMLINK 0x80000040
#define IS_BIOLOGICAL 0x80000080
#define IS_GUARD 0x80000100
#define IS_SPAWNED 0x80000200
#define NOT_OPEN_DOOR 0x80000400
#define NOT_OPEN_DOORS 0x80000400
#define IN_BED 0x80000800
#define NO_SCHEDULE 0x80001000
#define IS_OVERDUE 0x80002000
#define IS_WIELDED 0x80004000
/*
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;
char *readername; // Text, not a pointer or SaveID since since a book/npc may not exist from map to map
// And SaveIDs may not exist at this point.
struct NPC_RECORDING *next;
} NPC_RECORDING;
typedef struct CHAR_LABELS
{
char *rank;
char *race;
char *party;
char *location;
} CHAR_LABELS;
// Statistics
typedef struct STATS
{
VMINT hp;
VMINT dex;
VMINT str;
VMINT intel;
VMINT weight;
VMINT quantity;
VMINT armour;
VMINT tick; // Animation timer
VMUINT npcflags;
VMINT damage; // Damage (caused by a weapon)
VMINT radius;
OBJECTID owner;
VMINT karma; // Have you been a good little boy? (or girl)
VMINT bulk;
VMINT range;
VMINT speed;
VMINT level; // skill level
VMINT alignment;
} STATS;
// Temporary data for a game in progress
// Changing this may well break savegame compatability
#define USEDATA_VERSION 256 // 256 bytes, this must always be the size in bytes
#define USEDATA_SLOTS 20
#define USEDATA_POTIONS 10
#define USEDATA_ACTSTACK ACT_STACK
typedef struct USEDATA
{
VMINT user[USEDATA_SLOTS];
VMINT poison;
VMINT unconscious;
VMINT potion[USEDATA_POTIONS]; // space for 10 potions
VMINT dx,dy; // Used by the pathfinder
VMINT vigilante; // If this is set, you have a license to kill people
VMINT edecor; // Used by the Editor
VMINT counter; // Counter. Used by eggs or the pathfinder
VMINT experience; // Experience points
VMINT magic; // Magic points
VMINT archive; // Used when switching worlds
VMINT oldhp; // Previous hp, used internally
OBJECTID arcpocket; // Used when switching worlds
OBJECTID pathgoal; // For the long-range pathfinder
// Sub-Activities
VMINT actlist[USEDATA_ACTSTACK];
struct OBJECT *acttarget[USEDATA_ACTSTACK];
VMINT actptr,actlen;
VMINT 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;
VMINT thumbcol;
VMINT w,h;
VMUINT wxh;
VMINT x,y;
unsigned char flags;
VMINT 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;
VMINT frames;
VMUINT flags; // See SEQ_FLAGS
VMINT 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
VMINT hookfunc; // Optional script call
VMINT 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;
VMINT codelen;
VMINT size;
char hidden; // local function
char Class;
} PEM;
// Stored data lookup items
typedef struct DT_ITEM
{
char *ks;
long ki;
char *is;
VMINT ii;
} DT_ITEM;
typedef struct DATATABLE
{
char *name;
VMINT entries;
char keytype;
char listtype;
DT_ITEM *list;
} DATATABLE;
//////////////////////////////////////////////////////////////////
// Object Data Structures //
//////////////////////////////////////////////////////////////////
#define IS_ON 0x00000001
#define CAN_OPEN 0x00000002
#define IS_WINDOW 0x00000004
#define IS_SOLID 0x00000008
#define IS_FRAGILE 0x00000010
#define IS_TRIGGER 0x00000020
#define IS_INVISIBLE 0x00000040
#define IS_PARTY 0x00000080
#define IS_FIXED 0x00000100
#define IS_CONTAINER 0x00000200
#define IS_TRANSLUCENT 0x00000400
#define IS_LARGE 0x00000800
#define IS_SPIKEPROOF 0x00001000
#define CAN_WIELD 0x00002000
#define DID_STEPUPDATE 0x00004000
#define DID_SETSEQUENCE 0x00008000
#define DOES_BLOCKLIGHT 0x00010000
#define IS_TABLETOP 0x00020000
#define DID_INIT 0x00040000
#define DID_UPDATE 0x00080000
#define IS_PERSON 0x00100000
#define IS_HORRIBLE 0x00200000
#define IS_HORROR 0x00200000
#define IS_SHOCKING 0x00200000
#define IS_QUANTITY 0x00400000
#define IS_BOAT 0x00800000
#define IS_WATER 0x00800000
#define IS_SHADOW 0x01000000
#define IS_DECOR 0x02000000
#define IS_SYSTEM 0x04000000
#define IS_NPCFLAG 0x80000000 // RESERVED
#define IS_INVISSHADOW 0x01000040
/*
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
VMINT ucache;
char *suse; // This is a pointer to the string array, for PEscript
char talk[128]; // TALK to it
VMINT tcache;
char *stalk;
char kill[32]; // KILL/BREAK it
VMINT kcache;
char *skill;
char look[32]; // LOOK at it
VMINT lcache;
char *slook;
char stand[32]; // STAND on it
VMINT scache;
char *sstand;
char hurt[32]; // HURT/DAMAGE it
VMINT hcache;
char *shurt;
char init[32]; // Called when object first created
VMINT 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];
VMINT 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
VMINT wcache;
char *swield;
char attack[32]; // Attack with it
VMINT acache;
char *sattack;
char user1[32];
char *suser1;
char user2[32];
char *suser2;
char horror[32]; // NPC sees something truly awful
VMINT hrcache;
char *shorror;
char quantity[32]; // Quantity is changed
VMINT qcache;
char *squantity;
} FUNCS;
// Tiles
typedef struct TILE
{
char *name;
VMUINT flags;
SEQ_POOL *form; // Direct access to animation
char seqname[32]; // Name of animation (in editor)
VMINT sptr; // Animation counter
VMINT cost; // movement cost
VMINT sdir,tick; // animation info
VMINT sdx,sdy; // Scroll delta x,y
VMINT sx,sy; // scroll coordinates x,y
VMINT 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 active,ok,hour,minute;
char vrm[32];
VMINT 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;
VMUINT flags;
VMINT w,h,mw,mh;
VMINT x,y,z;
char *personalname;
SCHEDULE *schedule;
SEQ_POOL *form;
VMINT sptr,SPARE,sdir; // animation info
STATS *maxstats; // Statistics structure
STATS *stats; // Current stats
FUNCS *funcs; // VRM Function table
VMINT 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)
VMINT tag; // Tags are used for triggering things
VMINT 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
VMINT hotx,hoty; // attack hotspot
unsigned int save_id; // Assigned object number (during saving and loading)
VMINT 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
{
VMINT tile;
VMINT becomes;
} TL_DATA;
typedef struct TILELINK
{
char *name;
VMINT 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;
VMINT nt;
VMINT st;
VMINT et;
VMINT wt;
VMINT net;
VMINT nwt;
VMINT set;
VMINT swt;
} TILELINK;
typedef struct USERSTRING
{
VMINT 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