2021-04-28 22:56:36 +00:00
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2020-2021 Christoph Oelckers
This file is part of Raze.
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
aint with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
( not much left of the original code, though... ;) )
*/
//-------------------------------------------------------------------------
2021-04-22 16:52:39 +00:00
// contains all global Duke definitions
struct Duke native
{
enum ESpecialMusic
{
MUS_INTRO = 0,
MUS_BRIEFING = 1,
MUS_LOADING = 2,
};
2021-12-30 09:30:21 +00:00
2021-04-22 16:52:39 +00:00
enum EPalette
{
BASEPAL = 0,
WATERPAL,
SLIMEPAL,
TITLEPAL,
DREALMSPAL,
ENDINGPAL, // 5
ANIMPAL, // not used anymore. The anim code now generates true color textures.
DRUGPAL,
BASEPALCOUNT
};
2021-05-15 12:27:32 +00:00
enum dukeinvicon_t
{
ICON_NONE, // 0
ICON_FIRSTAID,
ICON_STEROIDS,
ICON_HOLODUKE,
ICON_JETPACK,
ICON_HEATS, // 5
ICON_SCUBA,
ICON_BOOTS,
ICON_MAX
};
2022-02-20 23:19:26 +00:00
enum EClipMask
{
CLIPMASK0 = (1 << 16) + 1,
CLIPMASK1 = (256 << 16) + 64
}
2021-05-15 12:27:32 +00:00
2022-12-08 23:44:48 +00:00
enum ETexFlags
2022-11-19 11:54:50 +00:00
{
2022-11-29 12:06:42 +00:00
TFLAG_WALLSWITCH = 1 << 0,
TFLAG_ADULT = 1 << 1,
2022-12-08 23:44:48 +00:00
TFLAG_CLEARINVENTORY = 1 << 2, // really dumb Duke stuff...
TFLAG_DOORWALL = 1 << 3,
TFLAG_BLOCKDOOR = 1 << 4,
TFLAG_NOBLOODSPLAT = 1 << 5,
TFLAG_NOCIRCLEREFLECT = 1 << 6,
2022-12-23 16:55:28 +00:00
TFLAG_SEASICKWALL = 1 << 7,
TFLAG_FORCEFIELD = 1 << 8,
TFLAG_ANIMFORCEFIELD = 1 << 9,
TFLAG_ANIMSCREEN = 1 << 10,
TFLAG_ANIMSCREENNOISE = 1 << 11,
2022-12-08 23:44:48 +00:00
};
enum ETexSurfaces
{
TSURF_NONE = 0,
TSURF_ELECTRIC = 1,
TSURF_SLIME = 2,
TSURF_OUTERSPACE = 3,
TSURF_MUDDY = 4,
TSURF_PURPLELAVA = 5, // very special kind of terrain type.
TSURF_SCROLLSKY = 6,
TSURF_THUNDERSKY = 7,
TSURF_PLASMA = 8,
TSURF_MAGMA = 9,
2022-12-09 07:28:55 +00:00
TSURF_METALDUCTS = 10,
TSURF_OIL = 11,
TSURF_DEEPMUD = 12, // also affects motorcycle
TSURF_SPECIALWATER = 13,
2022-11-19 11:54:50 +00:00
};
2022-11-20 07:10:15 +00:00
enum ESoundFlags
{
SF_LOOP = 1,
SF_MSFX = 2,
SF_TALK = 4,
SF_ADULT = 8,
SF_GLOBAL = 16,
SF_ONEINST_INTERNAL = 32,
SF_DTAG = 128,
};
2022-11-27 22:36:39 +00:00
enum ESyncBits
{
SB_FIRST_WEAPON_BIT = 1 << 0,
SB_ITEM_BIT_1 = 1 << 4,
SB_ITEM_BIT_2 = 1 << 5,
SB_ITEM_BIT_3 = 1 << 6,
SB_ITEM_BIT_4 = 1 << 7,
SB_ITEM_BIT_5 = 1 << 8,
SB_ITEM_BIT_6 = 1 << 9,
SB_ITEM_BIT_7 = 1 << 10,
SB_INVPREV = 1 << 11,
SB_INVNEXT = 1 << 12,
SB_INVUSE = 1 << 13,
SB_CENTERVIEW = 1 << 14,
SB_TURNAROUND = 1 << 15,
SB_HOLSTER = 1 << 16,
SB_OPEN = 1 << 17,
SB_AIMMODE = 1 << 18,
SB_QUICK_KICK = 1 << 19,
SB_ESCAPE = 1 << 20,
SB_AIM_UP = 1 << 21,
SB_AIM_DOWN = 1 << 22,
SB_LOOK_LEFT = 1 << 23,
SB_LOOK_RIGHT = 1 << 24,
2023-04-10 17:46:05 +00:00
SB_LOOK_UP = SB_AIM_UP|SB_CENTERVIEW,
SB_LOOK_DOWN = SB_AIM_DOWN|SB_CENTERVIEW,
SB_CROUCH = 1 << 25,
SB_CROUCH_LOCK = 1 << 26,
2022-11-27 22:36:39 +00:00
SB_RUN = 1 << 27,
SB_JUMP = 1 << 28,
2023-04-10 17:46:05 +00:00
SB_FIRE = 1 << 29,
SB_ALTFIRE = 1 << 30,
2022-11-27 22:36:39 +00:00
SB_WEAPONMASK_BITS = (15u * SB_FIRST_WEAPON_BIT), // Weapons take up 4 bits
SB_ITEMUSE_BITS = (127u * SB_ITEM_BIT_1),
2023-04-16 07:15:17 +00:00
SB_BUTTON_MASK = SB_ALTFIRE|SB_FIRE|SB_CROUCH|SB_JUMP|SB_LOOK_UP|SB_LOOK_DOWN|SB_AIM_UP|SB_AIM_DOWN|SB_LOOK_LEFT|SB_LOOK_RIGHT|SB_QUICK_KICK, // all input from buttons (i.e. active while held)
SB_INTERFACE_MASK = (SB_INVPREV|SB_INVNEXT|SB_INVUSE|SB_CENTERVIEW|SB_TURNAROUND|SB_HOLSTER|SB_OPEN|SB_ESCAPE), // all input from CCMDs
2022-11-27 22:36:39 +00:00
SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS | SB_ITEMUSE_BITS | SB_INTERFACE_MASK),
SB_ALL = ~0u
};
2022-11-30 18:39:06 +00:00
const SLEEPTIME = 1536;
2022-11-19 11:54:50 +00:00
2021-04-22 16:52:39 +00:00
native static void PlaySpecialMusic(int which);
2022-11-24 20:27:08 +00:00
native static int PlaySound(Sound num, int channel = CHAN_AUTO, int flags = 0, float vol =0.8f);
native static void StopSound(Sound num);
native static bool CheckSoundPlaying(Sound num);
2021-05-15 12:27:32 +00:00
native static DukePlayer GetViewPlayer();
2022-11-28 17:57:50 +00:00
native static DukePlayer GetLocalPlayer();
2021-05-15 12:27:32 +00:00
native static int MaxAmmoAmount(int weap);
2022-02-20 23:19:26 +00:00
native static DukePlayer checkcursectnums(sectortype sect);
2022-11-19 11:54:50 +00:00
native static int global_random();
2022-11-24 20:27:08 +00:00
native static int GetSoundFlags(Sound snd);
2022-11-20 10:58:19 +00:00
native static int badguyID(int id);
2022-12-02 15:26:31 +00:00
native static void updatepindisplay(int tag, int pinmask);
2022-12-03 12:57:54 +00:00
native static bool StartCommentary(int tag, DukeActor act);
native static void StopCommentary();
2022-12-11 23:58:04 +00:00
static native int getPlayerIndex(DukePlayer p);
2022-12-12 08:25:41 +00:00
static native void setlastvisinc(int amount);
2022-12-23 07:55:13 +00:00
static native bool isaccessswitch(TextureID tex);
2022-12-23 16:55:28 +00:00
static native bool isshootableswitch(TextureID tex);
2022-12-28 21:46:13 +00:00
static native bool CheckSprite(class<DukeActor> tex);
static native bool setnextmap(bool checksecret);
2022-11-27 20:00:22 +00:00
static int rnd(int val)
{
return (random(0, 255) >= (255 - (val)));
}
2021-12-30 09:30:21 +00:00
2021-04-23 10:24:42 +00:00
static void PlayBonusMusic()
{
2021-05-22 00:15:49 +00:00
if (System.MusicEnabled())
2022-11-24 20:27:08 +00:00
PlaySound("BONUSMUSIC", CHAN_AUTO, CHANF_UI);
2021-04-23 10:24:42 +00:00
}
2021-12-30 09:30:21 +00:00
2021-04-23 08:07:02 +00:00
//==========================================================================
//
// wrappers around DrawText to allow easier reuse of the old code.
// The vertical displacements are to have the same positioning as with the original code.
//
//==========================================================================
2021-12-30 09:30:21 +00:00
2021-04-23 08:07:02 +00:00
static void BigText(double x, double y, String text, int align = -1, double alpha = 1.)
{
2021-05-31 09:51:02 +00:00
let myfont = Raze.PickBigFont();
2021-04-23 08:07:02 +00:00
if (!Raze.isRR())
{
2021-05-31 09:51:02 +00:00
if (align != -1) x -= myfont.StringWidth(text) * (align == 0 ? 0.5 : 1);
Screen.DrawText(myfont, Font.CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Alpha, alpha);
2021-04-23 08:07:02 +00:00
}
else
{
2023-01-14 09:37:07 +00:00
if (align != -1) x -= myfont.StringWidth(text) * (align == 0 ? 0.175 : 0.35);
Screen.DrawText(myfont, Font.CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 0.35, DTA_ScaleY, 0.35, DTA_Alpha, alpha);
2021-04-23 08:07:02 +00:00
}
}
static void GameText(double x, double y, String t, int shade, int align = -1, int trans = 0)
{
2021-05-31 09:51:02 +00:00
let myfont = Raze.PickSmallFont();
2021-04-23 08:07:02 +00:00
int fsmode = FSMode_Fit320x200;
if (Raze.isRR())
{
x *= 2;
y *= 2;
fsmode = FSMode_Fit640x400;
}
2021-05-31 09:51:02 +00:00
if (align != -1) x -= myfont.StringWidth(t) * (align == 0 ? 0.5 : 1);
Screen.DrawText(myfont, Font.CR_NATIVEPAL, x, y + 2, t, DTA_FullscreenScale, fsmode, DTA_TranslationIndex, Translation.MakeID(Translation_Remap, trans), DTA_Color, Raze.shadeToLight(shade));
2021-04-23 08:07:02 +00:00
}
2022-12-11 23:58:04 +00:00
2021-04-22 16:52:39 +00:00
}
2021-04-22 17:59:45 +00:00
2022-11-17 17:38:25 +00:00
struct DukePlayer native
2021-05-15 12:27:32 +00:00
{
2022-11-12 20:55:14 +00:00
/*
2021-05-15 12:27:32 +00:00
// player's horizon and angle structs.
PlayerHorizon horizon;
PlayerAngle angle;
uint16_t frags[MAXPLAYERS];
*/
2022-12-28 21:46:13 +00:00
native vector3 vel;
2021-05-15 12:27:32 +00:00
native bool gotweapon[DukeWpn.MAX_WEAPONS];
// Palette management uses indices into the engine's palette table now.
native color pals;
// this was a global variable originally.
2022-11-12 20:55:14 +00:00
native Vector2 fric;
2021-05-15 12:27:32 +00:00
// weapon drawer variables and their interpolation counterparts.
native int weapon_sway;
native int oweapon_sway;
native int16 weapon_pos, kickback_pic, random_club_frame;
native int16 oweapon_pos, okickback_pic, orandom_club_frame;
native uint8 hard_landing;
native uint8 ohard_landing;
// Store current psectlotag as determined in processinput() for use with scaling angle aiming.
native int16 psectlotag;
2022-11-27 20:00:22 +00:00
native Vector2 loogie[64];
2021-12-30 11:47:19 +00:00
native int numloogs, loogcnt;
2021-05-15 12:27:32 +00:00
native int invdisptime;
2022-08-30 20:25:07 +00:00
native double pyoff, opyoff;
2022-02-04 16:49:48 +00:00
native int last_pissed_time;
native double truefz, truecz;
2021-05-15 12:27:32 +00:00
native int player_par, visibility;
native int bobcounter;
native int randomflamex, crack_time;
2021-11-06 21:45:02 +00:00
native int aim_mode, ftt;
2021-05-15 12:27:32 +00:00
2021-11-17 23:08:52 +00:00
//native int cursectnum;// , one_parallax_sectnum
2021-11-17 23:20:39 +00:00
//native walltype access_wall; // can't do yet.
2021-05-15 12:27:32 +00:00
2021-11-06 19:46:08 +00:00
native int16 last_extra, subweapon;
2021-05-15 12:27:32 +00:00
native int16 ammo_amount[DukeWpn.MAX_WEAPONS], frag, fraggedself;
native int16 curr_weapon, last_weapon, tipincs, wantweaponfire;
native int16 holoduke_amount, hurt_delay, hbomb_hold_delay;
native int16 jumping_counter, airleft, knee_incs, access_incs;
2021-11-07 15:46:23 +00:00
native int16 ftq;
2021-05-15 12:27:32 +00:00
native int16 got_access, weapon_ang, firstaid_amount;
native int16 over_shoulder_on, fist_incs;
native int16 cheat_phase;
native int16 extra_extra8, quick_kick, last_quick_kick;
native int16 heat_amount, timebeforeexit, customexitsound;
2022-02-20 23:19:26 +00:00
native DukeActor actor, actorsqu, wackedbyactor, on_crane, somethingonplayer, access_spritenum, dummyplayersprite, newOwner, holoduke_on;
native sectortype cursector;
2021-05-15 12:27:32 +00:00
native uint interface_toggle_flag;
native int16 dead_flag, show_empty_weapon; // JBF 20031220: added orotscrnang
native int16 scuba_amount, jetpack_amount, steroids_amount, shield_amount;
native int16 pycount, frag_ps;
native int16 transporter_hold, last_full_weapon, footprintshade, boot_amount;
native uint8 on_warping_sector, footprintcount;
native uint8 hbomb_on, jumping_toggle, rapid_fire_hold, on_ground;
//char name[32];
native uint8 inven_icon, buttonpalette;
native uint8 jetpack_on, spritebridge, lastrandomspot;
native uint8 scuba_on, footprintpal, heat_on;
native uint8 holster_weapon;
native uint8 falling_counter;
native uint8 refresh_inventory;
native uint8 toggle_key_flag, knuckle_incs; // ,select_dir;
native uint8 walking_snd_toggle, palookup;
native bool quick_kick_msg;
2023-04-07 07:46:51 +00:00
native int max_secret_rooms, secret_rooms;
2021-05-15 12:27:32 +00:00
// Redneck Rampage additions. Those which did not have names in the reconstructed source got one from either RedneckGDX or RedNukem.
// Items were reordered by size.
native int stairs;
native int detonate_count; // at57e
2022-09-14 15:35:44 +00:00
native double noise_radius; // at286, at28a, at290
2021-05-15 12:27:32 +00:00
native int drink_timer; // at58e
native int eat_timer; // at592
native int SlotWin;
native int16 recoil;
native int16 detonate_time; // at57c
native int16 yehaa_timer;
native int16 drink_amt, eat, drunkang, eatang;
native uint8 shotgun_state[2];
native uint8 donoise; // at28e
native uint8 keys[5];
// RRRA. The same as for the RR block applies.
native int drug_aspect;
native int drug_timer;
native int SeaSick;
native int16 MamaEnd; // raat609
native int16 moto_drink;
2023-03-30 11:42:06 +00:00
native int16 TiltStatus, oTiltStatus;
2021-12-06 11:27:02 +00:00
native double VBumpNow, VBumpTarget;
native int16 TurbCount;
2021-05-15 12:27:32 +00:00
native int16 drug_stat[3]; // raat5f1..5
native uint8 DrugMode, lotag800kill;
native uint8 sea_sick_stat; // raat5dd
native uint8 hurt_delay2, nocheat;
native uint8 OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround;
native uint8 moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud;
2023-03-19 09:42:12 +00:00
native double MotoSpeed;
2021-05-15 12:27:32 +00:00
// input stuff.
//InputPacket sync;
/*
DDukeActor* GetActor();
int GetPlayerNum();
void apply_seasick(double factor);
void backuppos(bool noclipping = false);
void backupweapon();
void checkhardlanding();
2022-09-15 16:41:01 +00:00
void playerweaponsway(double xvel);
2021-05-15 12:27:32 +00:00
float adjustavel(float avel)
{
return (psectlotag == ST_2_UNDERWATER)? avel * 0.875f : avel;
}
*/
native bool IsFrozen();
native int GetGameVar(String varname, int defval);
2022-02-20 23:19:26 +00:00
native void backuppos();
2022-11-12 20:55:14 +00:00
native void backupxyz();
2022-02-20 23:19:26 +00:00
native void setpos(Vector3 pos);
2022-11-19 14:40:35 +00:00
native void addpos(Vector3 pos);
2022-11-12 20:55:14 +00:00
native void settargetangle(double angle, bool backup = false);
native double angle();
2022-01-21 00:04:08 +00:00
native void clearcameras();
2022-11-21 20:33:27 +00:00
native void quickkill();
2022-11-27 20:00:22 +00:00
native void addPitch(double p);
native void centerView();
2022-11-27 22:36:39 +00:00
native int playerinput(int bit);
2022-12-01 09:19:37 +00:00
native int CheckWeapRec(DukeActor item, bool checkonly);
native void addammo(int type, int amount);
native void addweapon(int type, bool switchit);
2022-12-01 19:11:38 +00:00
native bool hitablockingwall();
native double getPitchWithView();
2022-12-02 16:10:50 +00:00
native void setbobpos();
2022-12-03 17:43:15 +00:00
native void StartMotorcycle();
native void StartBoat();
2022-12-22 20:42:43 +00:00
native void checkhitswitch(walltype wal, DukeActor act);
2021-05-15 12:27:32 +00:00
2022-12-28 21:46:13 +00:00
native void playerkick(DukeActor target);
native void playerstomp(DukeActor target);
native void addphealth(int amount, bool bigitem = false);
native void wackplayer();
native void checkweapons();
native void playerreset(DukeActor ac);
native void FTA(int num);
native bool playercheckinventory(DukeActor item, int type, int amount);
native void playeraddinventory(DukeActor item, int type, int amount);
native bool playeraddweapon(int type, int amount);
native bool playeraddammo(int type, int amount);
native void forceplayerangle();
native bool playereat(int amount, bool bigitem);
native void playerdrink(int amount);
2021-05-15 12:27:32 +00:00
}
struct DukeWpn
{
enum dukeweapon_t
{
KNEE_WEAPON, // 0
PISTOL_WEAPON,
SHOTGUN_WEAPON,
CHAINGUN_WEAPON,
RPG_WEAPON,
HANDBOMB_WEAPON, // 5
SHRINKER_WEAPON,
DEVISTATOR_WEAPON,
TRIPBOMB_WEAPON,
FREEZE_WEAPON,
HANDREMOTE_WEAPON, // 10
GROW_WEAPON,
FLAMETHROWER_WEAPON, // World Tour
MIN_WEAPON = 0,
MAX_WEAPON = 9,
MAX_WEAPONS = 17
}
}
struct RRWpn
{
enum redneck_weapon_t
{
// These names have been pieced together from RedneckGDX and RedNukem because the reconstructed source recycled Duke's names for the first 11 weapons.
// Names for 0-2 are the same
KNEE_WEAPON, // 0
PISTOL_WEAPON,
SHOTGUN_WEAPON,
RIFLEGUN_WEAPON,
DYNAMITE_WEAPON,
CROSSBOW_WEAPON, // 5
THROWSAW_WEAPON,
ALIENBLASTER_WEAPON,
POWDERKEG_WEAPON,
TIT_WEAPON,
THROWINGDYNAMITE_WEAPON, // 10
BUZZSAW_WEAPON,
BOWLING_WEAPON,
MOTORCYCLE_WEAPON,
BOAT_WEAPON,
SLINGBLADE_WEAPON, // 15
CHICKEN_WEAPON,
MAX_WEAPONS
}
}
2022-11-14 09:23:54 +00:00
struct DukeGameInfo native
{
// Static constant global state
readonly native double playerfriction;
readonly native double gravity;
2022-12-01 09:19:37 +00:00
readonly native int16 max_ammo_amount[RRWpn.MAX_WEAPONS];
2022-11-14 09:23:54 +00:00
readonly native int respawnactortime;
readonly native int bouncemineblastradius;
readonly native int respawnitemtime;
readonly native int morterblastradius;
readonly native int numfreezebounces;
readonly native int pipebombblastradius;
readonly native int rpgblastradius;
readonly native int seenineblastradius;
readonly native int shrinkerblastradius;
readonly native int tripbombblastradius;
readonly native int camerashitable;
readonly native int max_player_health;
readonly native int max_armour_amount;
readonly native int lasermode;
readonly native int freezerhurtowner;
readonly native int impact_damage;
readonly native double playerheight;
2022-11-22 22:21:45 +00:00
readonly native double gutsscale;
2022-11-14 09:23:54 +00:00
readonly native int displayflags;
2022-12-23 09:53:13 +00:00
readonly native int tripbombcontrol;
readonly native int stickybomb_lifetime;
readonly native int stickybomb_lifetime_var;
readonly native int grenade_lifetime;
readonly native int grenade_lifetime_var;
2022-11-14 09:23:54 +00:00
}
2022-11-17 17:38:25 +00:00
struct DukeUserDefs native
{
2022-12-28 21:46:13 +00:00
native uint8 god, cashman, eog;
2022-11-17 17:38:25 +00:00
native readonly uint8 clipping;
native readonly uint8 user_pals[MAXPLAYERS];
native readonly int16 from_bonus;
2022-12-01 19:11:38 +00:00
native int16 last_level, secretlevel;
2022-11-17 17:38:25 +00:00
native readonly int const_visibility;
native readonly int coop;
native readonly int respawn_monsters, respawn_items, respawn_inventory, recstat, monsters_off, brightness;
native readonly int ffire, multimode;
2022-12-10 19:14:39 +00:00
native readonly int player_skill, marker;
2022-11-30 16:15:44 +00:00
2022-12-10 19:14:39 +00:00
native int earthquaketime, chickenplant;
2022-12-14 20:49:20 +00:00
native uint8 ufospawnsminion, pistonsound, fogactive;
2022-11-17 17:38:25 +00:00
native int16 bomb_tag;
native DukeActor cameraactor;
2022-12-02 20:28:43 +00:00
native bool joe9000;
2022-11-17 17:38:25 +00:00
}
2022-12-28 21:46:13 +00:00
struct ActorMove native
{
native Name qualifiedName; // this is only used for serialization.
native Name name;
native float movex, movez;
}
struct ActorAction native
{
native Name qualifiedName; // this is only used for serialization.
native Name name;
native TextureID base;
native int offset;
native int16 numframes;
native int16 rotationtype;
native int16 increment;
native int16 delay;
};