Forum archive
Maphack Functions
- Hello all, this is me again.
I have put up several requests on the 3D Realms boards and even did some coding myself for new maphack functions. I was just wondering if they could be added into JFDuke3D and JFSW. As far as I know, maphacks either don't work or are not implemented into JFSW.
Here is the documentation, with all parameters included:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sprite <spritenum>- notmd - Disables a certain sprite from being rendered as a model, instead, it will render as a flat texture.
- nomdanim - Disables a certain sprite from having its model perform its animation. This might be a better alternative than notmd for the enemies in _ZOO.MAP.
- angoff <value> - Turns a model (not the sprite itself) a certain number of degrees to have it aligned correctly. (exempli gratia: 1024 = 180° ½ turn)
- hide - Makes a sprite invisible. Can be used for the E1L1 “Cinema” sign or double-rendered space suits, among other things.
- xadd <value> - Adds <value> to the x coordinate of the model, not the sprite.
- yadd <value> - Same as above, but for y.
- zadd <value> - Same as above, but for z.
- size <xsize> <ysize> - Sets a sprite's size to the values <xsize> and <ysize>. This is very similar to the CON command “sizeat”.
- pitch <value> - Sets a model's pitch to <value>.
- roll <value> - Same as above, but a model's roll.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wall <wallnum>- wallalign <xsize> <ysize> <xpanning> <ypanning> - Aligns the wall's texture. <x\ysize> would be if you pressed [NumPad 2\4\6\8] on a wall. <x\ypanning> would be [Shift]+[NumPad 2\4\6\8].
- wallpic <picnum> - The texture of the wall.
- walloverpic <picnum> - The texture of wall that is the upper part of a split window wall.
- wallcstat <cstat> - Mainly for red\pink-line walls (in Mapster32\Build 2D Mode) to switch between hittable\blockable or not. Adjusting this on white-line walls could result in crashing. See here.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sector <sectornum>- sectorfloorpic <picnum> - The texture of the floor.
- sectorceilingpic <picnum> - Same as above, but for the ceiling.
- sectorflooralign <xpanning> <ypanning> <stat> - Aligns the floor's texture. <x\ypanning> would be [Shift]+[NumPad 2\4\6\8] on the floor. <stat> is a series of flags for the floor, such as parallaxed skies, relativity, and sloping. If you do not want to modify <stat>, set it as -1 and it will not be changed.
- sectorceilingalign <xpanning> <ypanning> <stat> - Same as above, but for the ceiling.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some of you may think that it will make the game go out-of-sync in multiplayer. The only parameter that might have a chance of that would be size\repeat. Even then it will print a warning to the log file. All of the others are safe to use in multiplayer.
This will replace the old code in engine.c.
The code is attached.Edited by Hendricks266 at - notmd - Disables a certain sprite from being rendered as a model, instead, it will render as a flat texture.
Re: Maphack Functions
Excuse my ignorance on this but although it looks like a tremendous effort, how would this improve things etc, as I have not followed Duke lately too much except some stuff.
Most "maphacks" have been taken care of over time by Parkar, TX, JF and myself mainly in the mdsprite.c and other classes.
Sw currently dont need any maphacks yet as far as I know.- Really? Personally, I doubt it. I got the base of the maphack code from the latest version of any JF-related source available, which was when someone on the 3DR forums request the EDuke32 source a month or two back. The only functions it contained were angoff, notmd, and nomdanim. Keep in mind, though that these are for the <corresponding map name>.mhk files. From the .def files, the only control we have is shade, scale, and zadd, but these will affect all sprites in all maps, so it is of little use. There has been no progress at all besides what I have done for map-based sprite, wall, and sector attribute modification.
There are many cases that this could be used for.
Duke3D:- The E1L1: Hollywood Holocaust “Cinema” Sign (and almost all neon signs for that matter) are put in the map twice, using an effect with one-way sprites so that you can read it both ways. One-way models do not exist, so the resulting picture does not look pretty.
- Somewhere in Episode 2 (E2L8: Dark Side ?) there are redundant space suits, meaning that there is a sprite there and that one texture with the space suit in it behind the sprite.
- In E4L9: Derelict, there is a marble texture that is shaded down and used for an oil spill.
- Pretty much every texture in the unmodified game is misaligned. These maphacks could fix it.
- Many of the captured babes have an incorrect z offset for their model, and the source has been lost. This can fix it without altering the sprite.
- There are more than these that I can't think of off of the top of my head.
SW:- The warrior helmets in Seppuku Station and another registered level are misaligned in the map itself.
- There may be other problems, but it is hard to tell without much contribution to the SW HRP.
The only other way I can think of these problems being resolved is someone making case-by-case adjustments in the source. That could be very, very bad, since sometimes people use the map names of levels for their own maps. This is done in Duke: Nuclear Winter, but I plan to fix that in the NWHRP.Edited by Hendricks266 at - You really shouldn't be directly modifying wall[], sector[], or sprite[] in maphacks. There's no way to know whether the values being modified will ruin sync. Instead, add variables to the spriteext structure, and create new wallext and sectorext structures for your new overrides, and then patch values at render time if you want to hack those values. The point of maphacks is to be a cosmetic correction, not a direct patch of the map data.
Jonathon - Here is some maphack code that simply utilizes members of the spriteext struct that haven't been available in maphacks before. The new ones are mdxoff, mdyoff, mdzoff, pitch, and roll. It also adds an error that gets printed to the log file if there is an invalid token.
I can't do things like add new members of the spriteext struct or create the wallext or sectorext structs, since what I have already done is just a collection of simple adjustments to the existing code that I could figure out how to do. I'm not worth much in creating new C\C++ code from scratch. :-[//
// Maphack Loading Code in engine.c
//
#if defined(POLYMOST) && defined(USE_OPENGL)
#include "scriptfile.h"
long loadmaphack(char *filename)
{
static struct { char *text; int tokenid; } legaltokens[] = {
{ "sprite", 0 },
{ "angleoff", 1 },
{ "angoff", 1 },
{ "angadd", 1 },
{ "yaw", 1 },
{ "notmd2", 2 },
{ "notmd3", 2 },
{ "notmd", 2 },
{ "nomd2anim", 3 },
{ "nomd3anim", 3 },
{ "nomdanim", 3 },
{ "xadd", 4 },
{ "xoff", 4 },
{ "xoffset", 4 },
{ "mdxoff", 4 },
{ "yadd", 5 },
{ "yoff", 5 },
{ "yoffset", 5 },
{ "mdyoff", 5 },
{ "zadd", 6 },
{ "zoff", 6 },
{ "zoffset", 6 },
{ "mdzoff", 6 },
{ "pitch", 7 },
{ "roll", 8 },
{ NULL, -1 }
};
scriptfile *script;
char *tok, *cmdtokptr;
int i;
int whichsprite = -1;
script = scriptfile_fromfile(filename);
if (!script) return -1;
memset(spriteext, 0, sizeof(spriteext));
while (1) {
tok = scriptfile_gettoken(script);
if (!tok) break;
for (i=0;legaltokens[i].text;i++) if (!Bstrcasecmp(tok,legaltokens[i].text)) break;
cmdtokptr = script->ltextptr;
switch (legaltokens[i].tokenid) {
case 0: // sprite <xx>
if (scriptfile_getnumber(script, &whichsprite)) break;
if ((unsigned)whichsprite >= (unsigned)MAXSPRITES) {
// sprite number out of range
initprintf("Sprite number out of range 0-%d on line %s:%d\n",
MAXSPRITES-1,script->filename, scriptfile_getlinum(script,cmdtokptr));
whichsprite = -1;
break;
}
break;
case 1: // angoff <xx>
{
int ang;
if (scriptfile_getnumber(script, &ang)) break;
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring angle offset directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].angoff = (short)ang;
}
break;
case 2: // notmd
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring not-MD2/MD3 directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].flags |= SPREXT_NOTMD;
break;
case 3: // nomdanim
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring no-MD2/MD3-anim directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].flags |= SPREXT_NOMDANIM;
break;
case 4: // xadd <value>
{
int ang;
if (scriptfile_getnumber(script, &xaddnum)) break;
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring x coordinate offset directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].mdxoff = (short)xaddnum;
}
break;
case 5: // yadd <value>
{
int ang;
if (scriptfile_getnumber(script, &yaddnum)) break;
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring y coordinate offset directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].mdyoff = (short)yaddnum;
}
break;
case 6: // zadd <value>
{
int ang;
if (scriptfile_getnumber(script, &zaddnum)) break;
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring z coordinate offset directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].mdzoff = (short)zaddnum;
}
break;
case 7: // pitch <value>
{
int ang;
if (scriptfile_getnumber(script, &pitchnum)) break;
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring pitch coordinate offset directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].pitch = (short)pitchnum;
}
break;
case 8: // roll <value>
{
int ang;
if (scriptfile_getnumber(script, &rollnum)) break;
if (whichsprite < 0) {
// no sprite directive preceeding
initprintf("Ignoring roll coordinate offset directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
spriteext[whichsprite].roll = (short)rollnum;
}
break;
default: // unrecognised token
initprintf("Unrecognized token on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
}
scriptfile_close(script);
return 0;
}
#else
long loadmaphack(char *filename) { return -1; }
#endif
On a side note, I seemed to be having some trouble uploading the .txt file, so I just put it in the post here. Perhaps there is something wrong with the forum upload system since you changed addresses.