git-svn-id: https://svn.eduke32.com/eduke32@610 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-02-06 11:42:34 +00:00
parent 9e834f8e7f
commit b530c1ca75
5 changed files with 56 additions and 64 deletions

View file

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "duke3d.h" #include "duke3d.h"
#include "gamedef.h"
extern int numenvsnds; extern int numenvsnds;
extern int actor_tog; extern int actor_tog;
@ -192,7 +193,6 @@ void addweapon(player_struct *p,int weapon)
void checkavailinven(player_struct *p) void checkavailinven(player_struct *p)
{ {
if (p->firstaid_amount > 0) if (p->firstaid_amount > 0)
p->inven_icon = 1; p->inven_icon = 1;
else if (p->steroids_amount > 0) else if (p->steroids_amount > 0)
@ -544,9 +544,7 @@ int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned in
int ssp(int i,unsigned int cliptype) //The set sprite function int ssp(int i,unsigned int cliptype) //The set sprite function
{ {
spritetype *s= &sprite[i]; spritetype *s= &sprite[i];
int movetype; int movetype = movesprite(i,
movetype = movesprite(i,
(s->xvel*(sintable[(s->ang+512)&2047]))>>14, (s->xvel*(sintable[(s->ang+512)&2047]))>>14,
(s->xvel*(sintable[s->ang&2047]))>>14,s->zvel, (s->xvel*(sintable[s->ang&2047]))>>14,s->zvel,
cliptype); cliptype);
@ -554,15 +552,19 @@ int ssp(int i,unsigned int cliptype) //The set sprite function
return (movetype==0); return (movetype==0);
} }
#undef deletesprite #undef deletesprite
void deletespriteEVENT(int s) void deletespriteEVENT(int s)
{ {
if (apScriptGameEvent[EVENT_KILLIT])
{
int p; int p;
SetGameVarID(g_iReturnVarID,0, -1, -1); SetGameVarID(g_iReturnVarID,0, -1, -1);
OnEvent(EVENT_KILLIT, s, findplayer(&sprite[s],(int *)&p), p); OnEvent(EVENT_KILLIT, s, findplayer(&sprite[s],(int *)&p), p);
if (!GetGameVarID(g_iReturnVarID, -1, -1))deletesprite(s); if (GetGameVarID(g_iReturnVarID, -1, -1))
return;
}
deletesprite(s);
} }
#define deletesprite deletespriteEVENT #define deletesprite deletespriteEVENT
@ -7603,16 +7605,21 @@ void moveobjects(void)
movestandables(); //ST 6 movestandables(); //ST 6
if (apScriptGameEvent[EVENT_GAME])
{
int i, p, j;
for (;k<MAXSTATUS;k++) for (;k<MAXSTATUS;k++)
{ {
int i = headspritestat[k]; i = headspritestat[k];
while (i >= 0) while (i >= 0)
{ {
int p, j = nextspritestat[i]; j = nextspritestat[i];
OnEvent(EVENT_GAME,i, findplayer(&sprite[i],(int *)&p), p); OnEvent(EVENT_GAME,i, findplayer(&sprite[i],(int *)&p), p);
i = j; i = j;
} }
} }
}
doanimations(); doanimations();
movefx(); //ST 11 movefx(); //ST 11

View file

@ -46,9 +46,9 @@ extern int check_activator_motion(int lotag);
extern int isadoorwall(int dapic); extern int isadoorwall(int dapic);
extern int isanunderoperator(int lotag); extern int isanunderoperator(int lotag);
extern int isanearoperator(int lotag); extern int isanearoperator(int lotag);
extern int checkcursectnums(int sect); extern inline int checkcursectnums(int sect);
extern int ldist(spritetype *s1,spritetype *s2); extern inline int ldist(spritetype *s1,spritetype *s2);
extern int dist(spritetype *s1,spritetype *s2); extern inline int dist(spritetype *s1,spritetype *s2);
extern int findplayer(spritetype *s,int *d); extern int findplayer(spritetype *s,int *d);
extern int findotherplayer(int p,int *d); extern int findotherplayer(int p,int *d);
extern void doanimations(void); extern void doanimations(void);

View file

@ -42,6 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "osdcmds.h" #include "osdcmds.h"
#include "scriptfile.h" #include "scriptfile.h"
#include "grpscan.h" #include "grpscan.h"
#include "gamedef.h"
//#include "crc32.h" //#include "crc32.h"
@ -4401,7 +4402,10 @@ int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr,
*/ */
ResetActorGameVars(i); ResetActorGameVars(i);
hittype[i].flags = 0; hittype[i].flags = 0;
if (apScriptGameEvent[EVENT_EGS])
OnEvent(EVENT_EGS,i, findplayer(&sprite[i],&p), p); OnEvent(EVENT_EGS,i, findplayer(&sprite[i],&p), p);
return(i); return(i);
} }
@ -6328,7 +6332,9 @@ int spawn(int j, int pn)
break; break;
} }
if (apScriptGameEvent[EVENT_SPAWN])
OnEvent(EVENT_SPAWN,i, findplayer(&sprite[i],&p), p); OnEvent(EVENT_SPAWN,i, findplayer(&sprite[i],&p), p);
return i; return i;
} }

View file

@ -41,7 +41,7 @@ extern int *actorLoadEventScrptr[MAXTILES];
extern int *apScriptGameEvent[MAXGAMEEVENTS]; extern int *apScriptGameEvent[MAXGAMEEVENTS];
extern short otherp; extern int otherp;
extern int g_currentweapon; extern int g_currentweapon;
extern int g_gun_pos; extern int g_gun_pos;
extern int g_looking_arc; extern int g_looking_arc;

View file

@ -188,7 +188,7 @@ int isanearoperator(int lotag)
return 0; return 0;
} }
int checkcursectnums(int sect) inline int checkcursectnums(int sect)
{ {
int i; int i;
for (i=connecthead;i>=0;i=connectpoint2[i]) for (i=connecthead;i>=0;i=connectpoint2[i])
@ -196,28 +196,21 @@ int checkcursectnums(int sect)
return -1; return -1;
} }
int ldist(spritetype *s1,spritetype *s2) inline int ldist(spritetype *s1,spritetype *s2)
{ {
int vx,vy,ret; int ret = FindDistance2D(s1->x-s2->x, s1->y-s2->y);
vx = s1->x - s2->x; return (ret?ret:1);
vy = s1->y - s2->y;
ret = FindDistance2D(vx,vy);
return(ret?ret:1);
} }
int dist(spritetype *s1,spritetype *s2) inline int dist(spritetype *s1,spritetype *s2)
{ {
int vx,vy,vz; return (FindDistance3D(s1->x-s2->x, s1->y-s2->y, (s1->z-s2->z)>>4));
vx = s1->x - s2->x;
vy = s1->y - s2->y;
vz = s1->z - s2->z;
return(FindDistance3D(vx,vy,vz>>4));
} }
int findplayer(spritetype *s,int *d) int findplayer(spritetype *s,int *d)
{ {
int j, closest_player; int j, closest_player = 0;
int x, closest; int x, closest = 0x7fffffff;
if (ud.multimode < 2) if (ud.multimode < 2)
{ {
@ -225,9 +218,6 @@ int findplayer(spritetype *s,int *d)
return myconnectindex; return myconnectindex;
} }
closest = 0x7fffffff;
closest_player = 0;
for (j=connecthead;j>=0;j=connectpoint2[j]) for (j=connecthead;j>=0;j=connectpoint2[j])
{ {
x = klabs(g_player[j].ps->oposx-s->x) + klabs(g_player[j].ps->oposy-s->y) + ((klabs(g_player[j].ps->oposz-s->z+(28<<8)))>>4); x = klabs(g_player[j].ps->oposx-s->x) + klabs(g_player[j].ps->oposy-s->y) + ((klabs(g_player[j].ps->oposz-s->z+(28<<8)))>>4);
@ -244,11 +234,8 @@ int findplayer(spritetype *s,int *d)
int findotherplayer(int p,int *d) int findotherplayer(int p,int *d)
{ {
int j, closest_player; int j, closest_player = p;
int x, closest; int x, closest = 0x7fffffff;
closest = 0x7fffffff;
closest_player = p;
for (j=connecthead;j>=0;j=connectpoint2[j]) for (j=connecthead;j>=0;j=connectpoint2[j])
if (p != j && sprite[g_player[j].ps->i].extra > 0) if (p != j && sprite[g_player[j].ps->i].extra > 0)
@ -336,10 +323,9 @@ void doanimations(void)
int getanimationgoal(int *animptr) int getanimationgoal(int *animptr)
{ {
int i, j; int i = animatecnt-1, j = -1;
j = -1; for (;i>=0;i--)
for (i=animatecnt-1;i>=0;i--)
if (animptr == (int *)animateptr[i]) if (animptr == (int *)animateptr[i])
{ {
j = i; j = i;
@ -350,13 +336,12 @@ int getanimationgoal(int *animptr)
int setanimation(int animsect,int *animptr, int thegoal, int thevel) int setanimation(int animsect,int *animptr, int thegoal, int thevel)
{ {
int i, j; int i = 0, j = animatecnt;
if (animatecnt >= MAXANIMATES-1) if (animatecnt >= MAXANIMATES-1)
return(-1); return(-1);
j = animatecnt; for (;i<animatecnt;i++)
for (i=0;i<animatecnt;i++)
if (animptr == animateptr[i]) if (animptr == animateptr[i])
{ {
j = i; j = i;
@ -380,12 +365,10 @@ int setanimation(int animsect,int *animptr, int thegoal, int thevel)
void animatecamsprite(void) void animatecamsprite(void)
{ {
int i; int i = camsprite;
if (camsprite <= 0) return; if (camsprite <= 0) return;
i = camsprite;
if (T1 >= 11) if (T1 >= 11)
{ {
T1 = 0; T1 = 0;
@ -406,9 +389,9 @@ void animatecamsprite(void)
void animatewalls(void) void animatewalls(void)
{ {
int i, j, p, t; int i, j, p = 0, t;
for (p=0;p < numanimwalls ;p++) for (;p < numanimwalls ;p++)
// for(p=numanimwalls-1;p>=0;p--) // for(p=numanimwalls-1;p>=0;p--)
{ {
i = animwall[p].wallnum; i = animwall[p].wallnum;
@ -1104,9 +1087,9 @@ void operatemasterswitches(int low)
void operateforcefields(int s, int low) void operateforcefields(int s, int low)
{ {
int i, p; int i, p=numanimwalls;
for (p=numanimwalls;p>=0;p--) for (;p>=0;p--)
{ {
i = animwall[p].wallnum; i = animwall[p].wallnum;
@ -1134,12 +1117,10 @@ void operateforcefields(int s, int low)
int checkhitswitch(int snum,int w,int switchtype) int checkhitswitch(int snum,int w,int switchtype)
{ {
int switchpal, switchpicnum; int switchpal, switchpicnum;
int i, x, lotag,hitag,picnum,correctdips,numdips; int i, x, lotag,hitag,picnum,correctdips = 1, numdips = 0;
int sx,sy; int sx,sy;
if (w < 0) return 0; if (w < 0) return 0;
correctdips = 1;
numdips = 0;
if (switchtype == 1) // A wall sprite if (switchtype == 1) // A wall sprite
{ {
@ -1619,9 +1600,7 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith)
{ {
short sn = -1; short sn = -1;
int j, i, darkestwall; int j, i, darkestwall;
walltype *wal; walltype *wal = &wall[dawallnum];
wal = &wall[dawallnum];
if (wal->overpicnum == MIRROR && checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE) && (hittype[spr].projectile.workslike & PROJECTILE_FLAG_RPG)) if (wal->overpicnum == MIRROR && checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE) && (hittype[spr].projectile.workslike & PROJECTILE_FLAG_RPG))
{ {
@ -2020,7 +1999,7 @@ void checkhitsprite(int i,int sn)
short j; short j;
int k, p, rpg=0; int k, p, rpg=0;
spritetype *s; spritetype *s;
int switchpicnum; int switchpicnum = PN;
i &= (MAXSPRITES-1); i &= (MAXSPRITES-1);