mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
Rework findnearactor3d/findnearsprite3d/findnearactor3dvar/findnearsprite3dvar and add a findnearactorz/findnearspritez/findnearactorzvar/findnearspritezvar. This breaks the previous syntax of all of the "3d" variants.
git-svn-id: https://svn.eduke32.com/eduke32@169 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
bfa46aa711
commit
ac14852079
5 changed files with 54 additions and 42 deletions
|
@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "util_lib.h"
|
#include "util_lib.h"
|
||||||
|
|
||||||
#define VERSION " 1.4.0 beta 1"
|
#define VERSION " 1.4.0svn"
|
||||||
|
|
||||||
#define HEAD "EDuke32"VERSION" (shareware mode)"
|
#define HEAD "EDuke32"VERSION" (shareware mode)"
|
||||||
#define HEAD2 "EDuke32"VERSION
|
#define HEAD2 "EDuke32"VERSION
|
||||||
|
|
|
@ -435,6 +435,10 @@ char *keyw[] = {
|
||||||
"save", // 288
|
"save", // 288
|
||||||
"cansee", // 289
|
"cansee", // 289
|
||||||
"canseespr", // 290
|
"canseespr", // 290
|
||||||
|
"findnearactorz", // 291
|
||||||
|
"findnearactorzvar", // 292
|
||||||
|
"findnearspritez", // 293
|
||||||
|
"findnearspritezvar", // 294
|
||||||
"<null>"
|
"<null>"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2921,6 +2925,8 @@ char parsecommand(void)
|
||||||
case CON_FINDNEARACTOR3D:
|
case CON_FINDNEARACTOR3D:
|
||||||
case CON_FINDNEARSPRITE:
|
case CON_FINDNEARSPRITE:
|
||||||
case CON_FINDNEARSPRITE3D:
|
case CON_FINDNEARSPRITE3D:
|
||||||
|
case CON_FINDNEARACTORZ:
|
||||||
|
case CON_FINDNEARSPRITEZ:
|
||||||
{
|
{
|
||||||
// syntax findnearactor <type> <maxdist> <getvar>
|
// syntax findnearactor <type> <maxdist> <getvar>
|
||||||
// gets the sprite ID of the nearest actor within max dist
|
// gets the sprite ID of the nearest actor within max dist
|
||||||
|
@ -2932,8 +2938,8 @@ char parsecommand(void)
|
||||||
|
|
||||||
switch(tw)
|
switch(tw)
|
||||||
{
|
{
|
||||||
case CON_FINDNEARACTOR3D:
|
case CON_FINDNEARACTORZ:
|
||||||
case CON_FINDNEARSPRITE3D:
|
case CON_FINDNEARSPRITEZ:
|
||||||
transnum(LABEL_DEFINE);
|
transnum(LABEL_DEFINE);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2949,6 +2955,8 @@ char parsecommand(void)
|
||||||
case CON_FINDNEARACTOR3DVAR:
|
case CON_FINDNEARACTOR3DVAR:
|
||||||
case CON_FINDNEARSPRITEVAR:
|
case CON_FINDNEARSPRITEVAR:
|
||||||
case CON_FINDNEARSPRITE3DVAR:
|
case CON_FINDNEARSPRITE3DVAR:
|
||||||
|
case CON_FINDNEARACTORZVAR:
|
||||||
|
case CON_FINDNEARSPRITEZVAR:
|
||||||
{
|
{
|
||||||
transnum(LABEL_DEFINE); // get <type>
|
transnum(LABEL_DEFINE); // get <type>
|
||||||
|
|
||||||
|
@ -2956,8 +2964,8 @@ char parsecommand(void)
|
||||||
transvar();
|
transvar();
|
||||||
switch(tw)
|
switch(tw)
|
||||||
{
|
{
|
||||||
case CON_FINDNEARACTOR3DVAR:
|
case CON_FINDNEARACTORZVAR:
|
||||||
case CON_FINDNEARSPRITE3DVAR:
|
case CON_FINDNEARSPRITEZVAR:
|
||||||
transvar();
|
transvar();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -720,5 +720,9 @@ enum keywords {
|
||||||
CON_SAVE, // 288
|
CON_SAVE, // 288
|
||||||
CON_CANSEE, // 289
|
CON_CANSEE, // 289
|
||||||
CON_CANSEESPR, // 290
|
CON_CANSEESPR, // 290
|
||||||
|
CON_FINDNEARACTORZ, // 291
|
||||||
|
CON_FINDNEARACTORZVAR, // 292
|
||||||
|
CON_FINDNEARSPRITEZ, // 293
|
||||||
|
CON_FINDNEARSPRITEZVAR, // 294
|
||||||
END
|
END
|
||||||
};
|
};
|
||||||
|
|
|
@ -5494,18 +5494,15 @@ good:
|
||||||
|
|
||||||
case CON_FINDNEARACTOR:
|
case CON_FINDNEARACTOR:
|
||||||
case CON_FINDNEARSPRITE:
|
case CON_FINDNEARSPRITE:
|
||||||
|
case CON_FINDNEARACTOR3D:
|
||||||
|
case CON_FINDNEARSPRITE3D:
|
||||||
{
|
{
|
||||||
// syntax findnearactorvar <type> <maxdist> <getvar>
|
// syntax findnearactorvar <type> <maxdist> <getvar>
|
||||||
// gets the sprite ID of the nearest actor within max dist
|
// gets the sprite ID of the nearest actor within max dist
|
||||||
// that is of <type> into <getvar>
|
// that is of <type> into <getvar>
|
||||||
// -1 for none found
|
// -1 for none found
|
||||||
// <type> <maxdist> <varid>
|
// <type> <maxdist> <varid>
|
||||||
long lType;
|
long lType, lMaxDist, lVarID, lTemp, lFound;
|
||||||
long lMaxDist;
|
|
||||||
long lVarID;
|
|
||||||
long lTemp;
|
|
||||||
long lFound;
|
|
||||||
long lDist;
|
|
||||||
short j, k;
|
short j, k;
|
||||||
|
|
||||||
insptr++;
|
insptr++;
|
||||||
|
@ -5515,17 +5512,18 @@ good:
|
||||||
lVarID=*insptr++;
|
lVarID=*insptr++;
|
||||||
|
|
||||||
lFound=-1;
|
lFound=-1;
|
||||||
lDist=32767; // big number
|
|
||||||
|
|
||||||
for (k=0;k<MAXSTATUS;k++)
|
for (k=0;k<MAXSTATUS;k++)
|
||||||
{
|
{
|
||||||
j=headspritestat[tw==CON_FINDNEARACTOR?1:k]; // all sprites
|
j=headspritestat[(tw==CON_FINDNEARACTOR||tw==CON_FINDNEARACTOR3D)?1:k]; // all sprites
|
||||||
while(j>=0)
|
while(j>=0)
|
||||||
{
|
{
|
||||||
if(sprite[j].picnum == lType && j != g_i)
|
if(sprite[j].picnum == lType && j != g_i)
|
||||||
{
|
{
|
||||||
lTemp=ldist(&sprite[g_i], &sprite[j]);
|
if(tw==CON_FINDNEARACTOR3D || tw==CON_FINDNEARSPRITE3D)
|
||||||
if(lTemp < lMaxDist && lTemp < lDist)
|
lTemp=dist(&sprite[g_i], &sprite[j]);
|
||||||
|
else lTemp=ldist(&sprite[g_i], &sprite[j]);
|
||||||
|
if(lTemp < lMaxDist)
|
||||||
{
|
{
|
||||||
lFound=j;
|
lFound=j;
|
||||||
j = MAXSPRITES;
|
j = MAXSPRITES;
|
||||||
|
@ -5534,7 +5532,7 @@ good:
|
||||||
}
|
}
|
||||||
j = nextspritestat[j];
|
j = nextspritestat[j];
|
||||||
}
|
}
|
||||||
if(tw==CON_FINDNEARACTOR || j == MAXSPRITES)
|
if((tw==CON_FINDNEARACTOR||tw==CON_FINDNEARACTOR3D) || j == MAXSPRITES)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetGameVarID(lVarID, lFound, g_i, g_p);
|
SetGameVarID(lVarID, lFound, g_i, g_p);
|
||||||
|
@ -5543,6 +5541,8 @@ good:
|
||||||
|
|
||||||
case CON_FINDNEARACTORVAR:
|
case CON_FINDNEARACTORVAR:
|
||||||
case CON_FINDNEARSPRITEVAR:
|
case CON_FINDNEARSPRITEVAR:
|
||||||
|
case CON_FINDNEARACTOR3DVAR:
|
||||||
|
case CON_FINDNEARSPRITE3DVAR:
|
||||||
{
|
{
|
||||||
// syntax findnearactorvar <type> <maxdistvar> <getvar>
|
// syntax findnearactorvar <type> <maxdistvar> <getvar>
|
||||||
// gets the sprite ID of the nearest actor within max dist
|
// gets the sprite ID of the nearest actor within max dist
|
||||||
|
@ -5564,12 +5564,14 @@ good:
|
||||||
|
|
||||||
for (k=0;k<MAXSTATUS;k++)
|
for (k=0;k<MAXSTATUS;k++)
|
||||||
{
|
{
|
||||||
j=headspritestat[tw==CON_FINDNEARACTORVAR?1:k]; // all sprites
|
j=headspritestat[(tw==CON_FINDNEARACTORVAR||tw==CON_FINDNEARACTOR3DVAR)?1:k]; // all sprites
|
||||||
while(j>=0)
|
while(j>=0)
|
||||||
{
|
{
|
||||||
if(sprite[j].picnum == lType && j != g_i)
|
if(sprite[j].picnum == lType && j != g_i)
|
||||||
{
|
{
|
||||||
lTemp=ldist(&sprite[g_i], &sprite[j]);
|
if(tw==CON_FINDNEARACTOR3DVAR || tw==CON_FINDNEARSPRITE3DVAR)
|
||||||
|
lTemp=dist(&sprite[g_i], &sprite[j]);
|
||||||
|
else lTemp=ldist(&sprite[g_i], &sprite[j]);
|
||||||
if( lTemp < lMaxDist && lTemp < lDist)
|
if( lTemp < lMaxDist && lTemp < lDist)
|
||||||
{
|
{
|
||||||
lFound=j;
|
lFound=j;
|
||||||
|
@ -5579,7 +5581,7 @@ good:
|
||||||
}
|
}
|
||||||
j = nextspritestat[j];
|
j = nextspritestat[j];
|
||||||
}
|
}
|
||||||
if(tw==CON_FINDNEARACTORVAR || j == MAXSPRITES)
|
if((tw==CON_FINDNEARACTORVAR||tw==CON_FINDNEARACTOR3DVAR) || j == MAXSPRITES)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetGameVarID(lVarID, lFound, g_i, g_p);
|
SetGameVarID(lVarID, lFound, g_i, g_p);
|
||||||
|
@ -5609,8 +5611,8 @@ good:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CON_FINDNEARACTOR3DVAR:
|
case CON_FINDNEARACTORZVAR:
|
||||||
case CON_FINDNEARSPRITE3DVAR:
|
case CON_FINDNEARSPRITEZVAR:
|
||||||
{
|
{
|
||||||
// syntax findnearactorvar <type> <maxdistvar> <getvar>
|
// syntax findnearactorvar <type> <maxdistvar> <getvar>
|
||||||
// gets the sprite ID of the nearest actor within max dist
|
// gets the sprite ID of the nearest actor within max dist
|
||||||
|
@ -5618,7 +5620,7 @@ good:
|
||||||
// -1 for none found
|
// -1 for none found
|
||||||
// <type> <maxdistvarid> <varid>
|
// <type> <maxdistvarid> <varid>
|
||||||
long lType, lMaxDistVar, lMaxZDistVar, lMaxDist, lMaxZDist;
|
long lType, lMaxDistVar, lMaxZDistVar, lMaxDist, lMaxZDist;
|
||||||
long lVarID, lTemp, lTemp2, lFound, lDist;
|
long lVarID, lTemp, lTemp2, lFound;
|
||||||
short j, k;
|
short j, k;
|
||||||
|
|
||||||
insptr++;
|
insptr++;
|
||||||
|
@ -5630,19 +5632,18 @@ good:
|
||||||
lMaxDist=GetGameVarID(lMaxDistVar, g_i, g_p);
|
lMaxDist=GetGameVarID(lMaxDistVar, g_i, g_p);
|
||||||
lMaxZDist=GetGameVarID(lMaxZDistVar, g_i, g_p);
|
lMaxZDist=GetGameVarID(lMaxZDistVar, g_i, g_p);
|
||||||
lFound=-1;
|
lFound=-1;
|
||||||
lDist=32767; // big number
|
|
||||||
|
|
||||||
for (k=0;k<MAXSTATUS;k++)
|
for (k=0;k<MAXSTATUS;k++)
|
||||||
{
|
{
|
||||||
j=headspritestat[tw==CON_FINDNEARACTOR3DVAR?1:k]; // all sprites
|
j=headspritestat[tw==CON_FINDNEARACTORZVAR?1:k]; // all sprites
|
||||||
while(j>=0)
|
while(j>=0)
|
||||||
{
|
{
|
||||||
if(sprite[j].picnum == lType && j != g_i)
|
if(sprite[j].picnum == lType && j != g_i)
|
||||||
{
|
{
|
||||||
lTemp=ldist(&sprite[g_i], &sprite[j]);
|
lTemp=ldist(&sprite[g_i], &sprite[j]);
|
||||||
if(lTemp < lMaxDist && lTemp < lDist)
|
if(lTemp < lMaxDist)
|
||||||
{
|
{
|
||||||
lTemp2=txdist(&sprite[g_i], &sprite[j]);
|
lTemp2=klabs(sprite[g_i].z-sprite[j].z);//txdist(&sprite[g_i], &sprite[j]);
|
||||||
if (lTemp2 < lMaxZDist)
|
if (lTemp2 < lMaxZDist)
|
||||||
{
|
{
|
||||||
lFound=j;
|
lFound=j;
|
||||||
|
@ -5653,7 +5654,7 @@ good:
|
||||||
}
|
}
|
||||||
j = nextspritestat[j];
|
j = nextspritestat[j];
|
||||||
}
|
}
|
||||||
if(tw==CON_FINDNEARACTOR3DVAR || j == MAXSPRITES)
|
if(tw==CON_FINDNEARACTORZVAR || j == MAXSPRITES)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetGameVarID(lVarID, lFound, g_i, g_p);
|
SetGameVarID(lVarID, lFound, g_i, g_p);
|
||||||
|
@ -5661,8 +5662,8 @@ good:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CON_FINDNEARACTOR3D:
|
case CON_FINDNEARACTORZ:
|
||||||
case CON_FINDNEARSPRITE3D:
|
case CON_FINDNEARSPRITEZ:
|
||||||
{
|
{
|
||||||
// syntax findnearactorvar <type> <maxdist> <getvar>
|
// syntax findnearactorvar <type> <maxdist> <getvar>
|
||||||
// gets the sprite ID of the nearest actor within max dist
|
// gets the sprite ID of the nearest actor within max dist
|
||||||
|
@ -5670,7 +5671,7 @@ good:
|
||||||
// -1 for none found
|
// -1 for none found
|
||||||
// <type> <maxdist> <varid>
|
// <type> <maxdist> <varid>
|
||||||
long lType, lMaxDist, lMaxZDist, lVarID;
|
long lType, lMaxDist, lMaxZDist, lVarID;
|
||||||
long lTemp, lTemp2, lFound, lDist;
|
long lTemp, lTemp2, lFound;
|
||||||
short j, k;
|
short j, k;
|
||||||
|
|
||||||
insptr++;
|
insptr++;
|
||||||
|
@ -5681,19 +5682,18 @@ good:
|
||||||
lVarID=*insptr++;
|
lVarID=*insptr++;
|
||||||
|
|
||||||
lFound=-1;
|
lFound=-1;
|
||||||
lDist=32767; // big number
|
|
||||||
|
|
||||||
for (k=0;k<MAXSTATUS;k++)
|
for (k=0;k<MAXSTATUS;k++)
|
||||||
{
|
{
|
||||||
j=headspritestat[tw==CON_FINDNEARACTOR3D?1:k]; // all sprites
|
j=headspritestat[tw==CON_FINDNEARACTORZ?1:k]; // all sprites
|
||||||
while(j>=0)
|
while(j>=0)
|
||||||
{
|
{
|
||||||
if(sprite[j].picnum == lType && j != g_i)
|
if(sprite[j].picnum == lType && j != g_i)
|
||||||
{
|
{
|
||||||
lTemp=ldist(&sprite[g_i], &sprite[j]);
|
lTemp=ldist(&sprite[g_i], &sprite[j]);
|
||||||
if(lTemp < lMaxDist && lTemp < lDist)
|
if(lTemp < lMaxDist)
|
||||||
{
|
{
|
||||||
lTemp2=txdist(&sprite[g_i], &sprite[j]);
|
lTemp2=klabs(sprite[g_i].z-sprite[j].z); // txdist(&sprite[g_i], &sprite[j]);
|
||||||
if (lTemp2 < lMaxZDist)
|
if (lTemp2 < lMaxZDist)
|
||||||
{
|
{
|
||||||
lFound=j;
|
lFound=j;
|
||||||
|
@ -5704,7 +5704,7 @@ good:
|
||||||
}
|
}
|
||||||
j = nextspritestat[j];
|
j = nextspritestat[j];
|
||||||
}
|
}
|
||||||
if(tw==CON_FINDNEARACTOR3D || j == MAXSPRITES)
|
if(tw==CON_FINDNEARACTORZ || j == MAXSPRITES)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetGameVarID(lVarID, lFound, g_i, g_p);
|
SetGameVarID(lVarID, lFound, g_i, g_p);
|
||||||
|
|
Loading…
Reference in a new issue