Subversion Repositories eduke32

Rev

Rev 4956 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1677 terminx 1
//-------------------------------------------------------------------------
2
/*
3
Copyright (C) 2010 EDuke32 developers and contributors
4
 
5
This file is part of EDuke32.
6
 
7
EDuke32 is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License version 2
9
as published by the Free Software Foundation.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 
15
See the GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
4541 hendricks2 19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
1677 terminx 20
*/
21
//-------------------------------------------------------------------------
22
 
4747 terminx 23
#ifndef actors_h_
24
#define actors_h_
1677 terminx 25
 
2854 helixhorne 26
#include "player.h"
27
 
4766 hendricks2 28
#ifdef __cplusplus
29
extern "C" {
30
#endif
31
 
1677 terminx 32
#define MAXSLEEPDIST        16384
33
#define SLEEPTIME           1536
34
#define ZOFFSET             (1<<8)
35
 
3679 helixhorne 36
#define ACTOR_MAXFALLINGZVEL 6144
37
#define ACTOR_ONWATER_ADDZ (24<<8)
38
 
3225 helixhorne 39
// KEEPINSYNC lunatic/con_lang.lua
1677 terminx 40
#define STAT_DEFAULT        0
41
#define STAT_ACTOR          1
42
#define STAT_ZOMBIEACTOR    2
43
#define STAT_EFFECTOR       3
44
#define STAT_PROJECTILE     4
45
#define STAT_MISC           5
46
#define STAT_STANDABLE      6
47
#define STAT_LOCATOR        7
48
#define STAT_ACTIVATOR      8
49
#define STAT_TRANSPORT      9
50
#define STAT_PLAYER         10
51
#define STAT_FX             11
52
#define STAT_FALLER         12
53
#define STAT_DUMMYPLAYER    13
2646 helixhorne 54
#define STAT_LIGHT          14
3443 terminx 55
#define STAT_NETALLOC       MAXSTATUS-1
1677 terminx 56
 
2724 helixhorne 57
 
1677 terminx 58
// Defines the motion characteristics of an actor
59
enum amoveflags_t {
60
    face_player         = 1,
61
    geth                = 2,
62
    getv                = 4,
63
    random_angle        = 8,
64
    face_player_slow    = 16,
65
    spin                = 32,
66
    face_player_smart   = 64,
67
    fleeenemy           = 128,
4378 helixhorne 68
    jumptoplayer_only   = 256,
69
    jumptoplayer_bits   = 257,  // NOTE: two bits set!
1677 terminx 70
    seekplayer          = 512,
71
    furthestdir         = 1024,
72
    dodgebullet         = 4096
73
};
74
 
75
// Defines for 'useractor' keyword
76
enum uactortypes_t {
77
    notenemy,
78
    enemy,
79
    enemystayput
80
};
81
 
3920 helixhorne 82
// These macros are there to give names to the t_data[]/T*/vm.g_t[] indices
83
// when used with actors. Greppability of source code is certainly a virtue.
3922 helixhorne 84
#define AC_COUNT(t) ((t)[0])  /* the actor's count */
3920 helixhorne 85
/* The ID of the actor's current move. In C-CON, the bytecode offset to the
86
 * move composite: */
3922 helixhorne 87
#define AC_MOVE_ID(t) ((t)[1])
88
#define AC_ACTION_COUNT(t) ((t)[2])  /* the actor's action count */
89
#define AC_CURFRAME(t) ((t)[3])  /* the actor's current frame offset */
3920 helixhorne 90
/* The ID of the actor's current action. In C-CON, the bytecode offset to the
91
 * action composite: */
3922 helixhorne 92
#define AC_ACTION_ID(t) ((t)[4])
93
#define AC_AI_ID(t) ((t)[5])  /* the ID of the actor's current ai */
2864 helixhorne 94
 
95
#ifdef LUNATIC
96
struct action {
3916 helixhorne 97
    // These members MUST be in this exact order because FFI cdata of this type
98
    // can be initialized by passing a table with numeric indices (con.action).
2864 helixhorne 99
    int16_t startframe, numframes;
100
    int16_t viewtype, incval, delay;
101
};
102
 
103
struct move {
3916 helixhorne 104
    // These members MUST be in this exact order.
2864 helixhorne 105
    int16_t hvel, vvel;
106
};
3315 helixhorne 107
 
3458 helixhorne 108
#pragma pack(push,1)
3315 helixhorne 109
typedef struct { int32_t id; struct move mv; } con_move_t;
110
typedef struct { int32_t id; struct action ac; } con_action_t;
3458 helixhorne 111
#pragma pack(pop)
2864 helixhorne 112
#endif
113
 
1677 terminx 114
typedef struct {
115
    int32_t workslike, cstat; // 8b
116
    int32_t hitradius, range, flashcolor; // 12b
117
    int16_t spawns, sound, isound, vel; // 8b
118
    int16_t decal, trail, tnum, drop; // 8b
119
    int16_t offset, bounces, bsound; // 6b
120
    int16_t toffset; // 2b
121
    int16_t extra, extra_rand; // 4b
122
    int8_t sxrepeat, syrepeat, txrepeat, tyrepeat; // 4b
123
    int8_t shade, xrepeat, yrepeat, pal; // 4b
3053 terminx 124
    int8_t movecnt; // 1b
1677 terminx 125
    uint8_t clipdist; // 1b
3866 helixhorne 126
    int8_t filler[2]; // 2b
127
    int32_t userdata; // 4b
1677 terminx 128
} projectile_t;
129
 
3922 helixhorne 130
// Select an actor's actiontics and movflags locations depending on
131
// whether we compile the Lunatic build.
132
// <spr>: sprite pointer
133
// <a>: actor_t pointer
134
#ifdef LUNATIC
135
# define AC_ACTIONTICS(spr, a) ((a)->actiontics)
136
# define AC_MOVFLAGS(spr, a) ((a)->movflags)
137
#else
138
# define AC_ACTIONTICS(spr, a) ((spr)->lotag)
139
# define AC_MOVFLAGS(spr, a) ((spr)->hitag)
140
#endif
141
 
3261 helixhorne 142
// (+ 40 16 16 4 8 6 8 6 4 20)
1677 terminx 143
typedef struct {
2185 helixhorne 144
    int32_t t_data[10];  // 40b sometimes used to hold offsets to con code
2864 helixhorne 145
 
146
#ifdef LUNATIC
3261 helixhorne 147
    // total: 16b
2864 helixhorne 148
    struct move mv;
149
    struct action ac;
3922 helixhorne 150
    // Gets incremented by TICSPERFRAME on each A_Execute() call:
151
    uint16_t actiontics;
2724 helixhorne 152
#endif
2451 helixhorne 153
 
3314 helixhorne 154
    int32_t flags; //4b
155
    vec3_t bpos; //12b
1677 terminx 156
    int32_t floorz,ceilingz,lastvx,lastvy; //16b
157
    int32_t lasttransport; //4b
158
 
3261 helixhorne 159
    int16_t picnum,ang,extra,owner; //8b
160
    int16_t movflag,tempang,timetosleep; //6b
161
 
3922 helixhorne 162
    int16_t actorstayput, dispicnum;
163
#if !defined LUNATIC
3921 helixhorne 164
    // NOTE: shootzvel is not used any more.
3922 helixhorne 165
    int16_t shootzvel_;
166
#else
167
    // Movement flags, sprite[i].hitag in C-CON:
168
    uint16_t movflags;
169
#endif
170
    int16_t cgg;
171
 
3082 terminx 172
    int16_t lightId, lightcount, lightmaxrange; //6b
1677 terminx 173
#ifdef POLYMER
174
    _prlight *lightptr; //4b/8b
175
#else
176
    void *lightptr;
177
#endif
178
 
2207 helixhorne 179
// pad struct to 128 bytes
180
#if !defined UINTPTR_MAX
181
# error Need UINTPTR_MAX define to select between 32- and 64-bit structs
182
#endif
183
#if UINTPTR_MAX == 0xffffffff
184
    /* 32-bit */
3920 helixhorne 185
# if !defined LUNATIC
3116 hendricks2 186
    int8_t filler[20];
2724 helixhorne 187
# else
3116 hendricks2 188
    int8_t filler[4];
2724 helixhorne 189
# endif
2185 helixhorne 190
#else
2207 helixhorne 191
    /* 64-bit */
3920 helixhorne 192
# if !defined LUNATIC
3116 hendricks2 193
    int8_t filler[16];
2724 helixhorne 194
# else
195
    /* no padding */
2185 helixhorne 196
#endif
2724 helixhorne 197
#endif
1677 terminx 198
} actor_t;
199
 
3968 helixhorne 200
#pragma pack(push,1)
1677 terminx 201
// this struct needs to match the beginning of actor_t above
202
typedef struct {
2185 helixhorne 203
    int32_t t_data[10];  // 40b sometimes used to hold offsets to con code
2864 helixhorne 204
 
205
#ifdef LUNATIC
206
    struct move mv;
207
    struct action ac;
3922 helixhorne 208
    uint16_t actiontics;
2724 helixhorne 209
#endif
1677 terminx 210
 
3314 helixhorne 211
    int32_t flags; //4b
212
    vec3_t bpos; //12b
3082 terminx 213
    int32_t floorz,ceilingz,lastvx,lastvy; //16b
214
    int32_t lasttransport; //4b
215
 
3261 helixhorne 216
    int16_t picnum,ang,extra,owner; //8b
217
    int16_t movflag,tempang,timetosleep; // 6b
218
 
3922 helixhorne 219
    int16_t actorstayput, dispicnum;
220
#if !defined LUNATIC
221
    int16_t shootzvel_;
222
#else
223
    uint16_t movflags;
224
#endif
225
    int16_t cgg;
3082 terminx 226
 
3270 terminx 227
    spritetype sprite;
228
    int16_t netIndex;
229
 
1677 terminx 230
} netactor_t;
3458 helixhorne 231
#pragma pack(pop)
3102 terminx 232
 
233
typedef struct {
3456 helixhorne 234
#if !defined LUNATIC
3102 terminx 235
    intptr_t *execPtr; // pointer to CON script for this tile, formerly actorscrptr
236
    intptr_t *loadPtr; // pointer to load time CON script, formerly actorLoadEventScrPtr or something
3456 helixhorne 237
#endif
3102 terminx 238
    uint32_t flags;    // formerly SpriteFlags, ActorType
239
 
3458 helixhorne 240
    int32_t cacherange; // formerly SpriteCache
3102 terminx 241
 
3151 helixhorne 242
    // todo: make this a pointer and allocate at runtime
3102 terminx 243
    projectile_t defproj;
244
} tiledata_t;
245
 
1677 terminx 246
 
3225 helixhorne 247
// KEEPINSYNC lunatic/con_lang.lua
1677 terminx 248
enum sflags_t {
4351 helixhorne 249
    SFLAG_SHADOW           = 0x00000001,
250
    SFLAG_NVG              = 0x00000002,
251
    SFLAG_NOSHADE          = 0x00000004,
252
    SFLAG_PROJECTILE       = 0x00000008,
253
    SFLAG_DECAL            = 0x00000010,
254
    SFLAG_BADGUY           = 0x00000020,
255
    SFLAG_NOPAL            = 0x00000040,
256
    SFLAG_NOEVENTCODE      = 0x00000080,
257
    SFLAG_NOLIGHT          = 0x00000100,
258
    SFLAG_USEACTIVATOR     = 0x00000200,
259
    SFLAG_NULL             = 0x00000400, // null sprite in multiplayer
260
    SFLAG_NOCLIP           = 0x00000800, // clipmove it with cliptype 0
261
    SFLAG_NOFLOORSHADOW    = 0x00001000, // for temp. internal use, per-tile flag not checked
262
    SFLAG_SMOOTHMOVE       = 0x00002000,
263
    SFLAG_NOTELEPORT       = 0x00004000,
264
    SFLAG_BADGUYSTAYPUT    = 0x00008000,
265
    SFLAG_CACHE            = 0x00010000,
3316 helixhorne 266
    // rotation-fixed wrt a pivot point to prevent position diverging due to
267
    // roundoff error accumulation:
4351 helixhorne 268
    SFLAG_ROTFIXED         = 0x00020000,
269
    SFLAG_HARDCODED_BADGUY = 0x00040000,
270
    SFLAG_DIDNOSE7WATER    = 0x00080000, // used temporarily
4371 helixhorne 271
    SFLAG_NODAMAGEPUSH     = 0x00100000,
4956 helixhorne 272
    SFLAG_NOWATERDIP       = 0x00200000,
1677 terminx 273
};
274
 
3743 helixhorne 275
// Custom projectiles "workslike" flags.
276
// XXX: Currently not predefined from CON.
1677 terminx 277
enum pflags_t {
278
    PROJECTILE_HITSCAN             = 0x00000001,
279
    PROJECTILE_RPG                 = 0x00000002,
280
    PROJECTILE_BOUNCESOFFWALLS     = 0x00000004,
281
    PROJECTILE_BOUNCESOFFMIRRORS   = 0x00000008,
282
    PROJECTILE_KNEE                = 0x00000010,
283
    PROJECTILE_WATERBUBBLES        = 0x00000020,
284
    PROJECTILE_TIMED               = 0x00000040,
285
    PROJECTILE_BOUNCESOFFSPRITES   = 0x00000080,
286
    PROJECTILE_SPIT                = 0x00000100,
287
    PROJECTILE_COOLEXPLOSION1      = 0x00000200,
288
    PROJECTILE_BLOOD               = 0x00000400,
289
    PROJECTILE_LOSESVELOCITY       = 0x00000800,
290
    PROJECTILE_NOAIM               = 0x00001000,
291
    PROJECTILE_RANDDECALSIZE       = 0x00002000,
292
    PROJECTILE_EXPLODEONTIMER      = 0x00004000,
293
    PROJECTILE_RPG_IMPACT          = 0x00008000,
294
    PROJECTILE_RADIUS_PICNUM       = 0x00010000,
295
    PROJECTILE_ACCURATE_AUTOAIM    = 0x00020000,
296
    PROJECTILE_FORCEIMPACT         = 0x00040000,
297
    PROJECTILE_REALCLIPDIST        = 0x00080000,
298
    PROJECTILE_ACCURATE            = 0x00100000,
3992 terminx 299
    PROJECTILE_TYPE_MASK           = PROJECTILE_HITSCAN|PROJECTILE_RPG|PROJECTILE_KNEE|PROJECTILE_BLOOD,
1677 terminx 300
};
301
 
3102 terminx 302
extern tiledata_t       g_tile[MAXTILES];
1677 terminx 303
extern actor_t          actor[MAXSPRITES];
304
extern int32_t          block_deletesprite;
305
extern int32_t          g_noEnemies;
306
extern int32_t          otherp;
307
extern int32_t          ticrandomseed;
308
extern intptr_t         *g_parsingActorPtr;
309
extern projectile_t     SpriteProjectile[MAXSPRITES];
310
 
2864 helixhorne 311
 
312
 
1677 terminx 313
void                A_AddToDeleteQueue(int32_t i);
314
int32_t             A_CheckSwitchTile(int32_t i);
315
void                A_DeleteSprite(int32_t s);
316
void                A_DoGuts(int32_t sp,int32_t gtype,int32_t n);
317
void                A_DoGutsDir(int32_t sp,int32_t gtype,int32_t n);
318
int32_t             A_IncurDamage(int32_t sn);
319
void                A_MoveCyclers(void);
320
void                A_MoveDummyPlayers(void);
321
void                A_PlayAlertSound(int32_t i);
322
void                A_RadiusDamage(int32_t i,int32_t r,int32_t hp1,int32_t hp2,int32_t hp3,int32_t hp4);
323
void                A_SpawnMultiple(int32_t sp,int32_t pic,int32_t n);
324
 
325
void                G_AddGameLight(int32_t radius,int32_t srcsprite,int32_t zoffset,int32_t range,int32_t color,int32_t priority);
2853 helixhorne 326
void                G_ClearCameraView(DukePlayer_t *ps);
1677 terminx 327
void                G_DoInterpolations(int32_t smoothratio);
328
void                G_MoveWorld(void);
5067 terminx 329
int32_t             G_SetInterpolation(int32_t * const posptr);
330
void                G_StopInterpolation(int32_t * const posptr);
1677 terminx 331
 
1926 helixhorne 332
// PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly
4745 terminx 333
void                Sect_ToggleInterpolation(int sectnum, int doset);
334
FORCE_INLINE void   Sect_ClearInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 0); }
335
FORCE_INLINE void   Sect_SetInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 1); }
1677 terminx 336
 
4766 hendricks2 337
#ifdef LUNATIC
338
int32_t G_ToggleWallInterpolation(int32_t w, int32_t doset);
339
#endif
340
 
341
#ifdef __cplusplus
342
}
343
#endif
344
 
3116 hendricks2 345
#include "actors_inline.h"
346
 
1677 terminx 347
#endif