Minor fixes and a couple of improvements to the fake AI players

git-svn-id: https://svn.eduke32.com/eduke32@419 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-12-15 01:09:25 +00:00
parent cd4e66b71a
commit ccb6ff7141
7 changed files with 83 additions and 63 deletions

View file

@ -5945,8 +5945,7 @@ long getlinehighlight(long xplc, long yplc)
closest = wall[closest].nextwall; closest = wall[closest].nextwall;
} }
if ((pointhighlight&0xc000) == 16384) return (-1); if ((pointhighlight&0xc000) == 16384) return (-1);
else return(closest); return(closest);
} }
long getpointhighlight(long xplc, long yplc) long getpointhighlight(long xplc, long yplc)

View file

@ -886,6 +886,7 @@ int getexternaladdress(char *buffer)
return(1); return(1);
} }
#ifdef _WIN32
int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game land int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game land
{ {
int bytes_sent, i=0, j=0; int bytes_sent, i=0, j=0;
@ -970,3 +971,4 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game
} }
return(0); return(0);
} }
#endif

View file

@ -377,7 +377,7 @@ inline int mpgametext(int y,char *t,char s,short dabits)
{ {
if (xdim >= 640 && ydim >= 480) if (xdim >= 640 && ydim >= 480)
return(gametext_(1,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1)); return(gametext_(1,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
else return(gametext_(0,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1)); return(gametext_(0,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
} }
static int minitext_(int x,int y,char *t,char s,char p,short sb) static int minitext_(int x,int y,char *t,char s,char p,short sb)
@ -1436,8 +1436,7 @@ int checkspriteflags(short sActor, int iType)
{ {
int i; int i;
i = spriteflags[sprite[sActor].picnum]; i = (spriteflags[sprite[sActor].picnum]^actorspriteflags[sActor]);
i ^= actorspriteflags[sActor];
if (i & iType) return 1; if (i & iType) return 1;
return 0; return 0;
} }
@ -2707,7 +2706,7 @@ inline short mpstrget(short x,short y,char *t,short dalen,short c)
{ {
if (xdim >= 640 && ydim >= 480) if (xdim >= 640 && ydim >= 480)
return(strgetsm(x,y,t,dalen,c)); return(strgetsm(x,y,t,dalen,c));
else return(strget(x,y,t,dalen,c)); return(strget(x,y,t,dalen,c));
} }
static void typemode(void) static void typemode(void)
@ -3253,14 +3252,14 @@ void displayrest(long smoothratio)
dotint = 1; dotint = 1;
} }
// reset a normal palette // reset a normal palette
else if (restorepalette) /* else */ if (restorepalette)
{ {
//setbrightness(ud.brightness>>2,&pp->palette[0],0); //setbrightness(ud.brightness>>2,&pp->palette[0],0);
setgamepalette(pp,pp->palette,2); setgamepalette(pp,pp->palette,2);
restorepalette = 0; restorepalette = 0;
} }
// loogies courtesy of being snotted on // loogies courtesy of being snotted on
else if (pp->loogcnt > 0) /* else */ if (pp->loogcnt > 0)
{ {
//palto(0,64,0,(pp->loogcnt>>1)+128); //palto(0,64,0,(pp->loogcnt>>1)+128);
fader = 0; fader = 0;
@ -9797,6 +9796,7 @@ void app_main(int argc,char **argv)
} }
} }
} }
else initprintf("update: failed to check for updates\n");
} }
} }
#endif #endif

View file

@ -440,13 +440,13 @@ long GetGameVarID(int id, short sActor, short sPlayer)
{ {
//Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %ld\n",id,sActor,sPlayer, aGameVars[id].plValues[sPlayer]); //Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %ld\n",id,sActor,sPlayer, aGameVars[id].plValues[sPlayer]);
//AddLog(g_szBuf); //AddLog(g_szBuf);
if (m) return -aGameVars[id].plValues[sPlayer]; if (m) return (-aGameVars[id].plValues[sPlayer]);
else return aGameVars[id].plValues[sPlayer]; return (aGameVars[id].plValues[sPlayer]);
} }
else else
{ {
if (m) return -aGameVars[id].lValue; if (m) return (-aGameVars[id].lValue);
else return aGameVars[id].lValue; return (aGameVars[id].lValue);
} }
} }
else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR)
@ -454,24 +454,24 @@ long GetGameVarID(int id, short sActor, short sPlayer)
// for the current actor // for the current actor
if (sActor >= 0 && sActor <=MAXSPRITES) if (sActor >= 0 && sActor <=MAXSPRITES)
{ {
if (m) return -aGameVars[id].plValues[sActor]; if (m) return (-aGameVars[id].plValues[sActor]);
else return aGameVars[id].plValues[sActor]; return (aGameVars[id].plValues[sActor]);
} }
else else
{ {
if (m) return -aGameVars[id].lValue; if (m) return (-aGameVars[id].lValue);
else return aGameVars[id].lValue; return (aGameVars[id].lValue);
} }
} }
else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG) else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG)
{ {
if (m) return -(*((long*)aGameVars[id].lValue)); if (m) return -(*((long*)aGameVars[id].lValue));
else return(*((long*)aGameVars[id].lValue)); return(*((long*)aGameVars[id].lValue));
} }
else else
{ {
if (m) return -aGameVars[id].lValue; if (m) return (-aGameVars[id].lValue);
else return aGameVars[id].lValue; return (aGameVars[id].lValue);
} }
} }

View file

@ -177,7 +177,7 @@ static int probe_(int type,int x,int y,int i,int n)
return(probey); return(probey);
else if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && (WHEELUP || mii > 256))) else if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && (WHEELUP || mii > 256)))
return(probey); return(probey);
else return(-probey-2); return(-probey-2);
} }
} }
static inline int probe(int x,int y,int i,int n) static inline int probe(int x,int y,int i,int n)
@ -2649,8 +2649,11 @@ cheat_for_port_credits:
break; break;
#ifdef _WIN32 #ifdef _WIN32
case 7: case 7:
i = checkforupdates;
if (x==io) checkforupdates = 1-checkforupdates; if (x==io) checkforupdates = 1-checkforupdates;
modval(0,1,(int *)&checkforupdates,1,probey==io); modval(0,1,(int *)&checkforupdates,1,probey==io);
if (checkforupdates != i)
lastupdatecheck = 0;
gametextpal(d,yy, checkforupdates ? "On" : "Off", MENUHIGHLIGHT(io), 0); gametextpal(d,yy, checkforupdates ? "On" : "Off", MENUHIGHLIGHT(io), 0);
break; break;
case 8: case 8:

View file

@ -5093,71 +5093,69 @@ int getspritescore(long snum, long dapicnum)
case FREEZEAMMO__STATIC: case FREEZEAMMO__STATIC:
if (ps[snum].ammo_amount[FREEZE_WEAPON] < max_ammo_amount[FREEZE_WEAPON]) return(10); if (ps[snum].ammo_amount[FREEZE_WEAPON] < max_ammo_amount[FREEZE_WEAPON]) return(10);
else return(0); return(0);
case AMMO__STATIC: case AMMO__STATIC:
if (ps[snum].ammo_amount[PISTOL_WEAPON] < max_ammo_amount[PISTOL_WEAPON]) return(10); if (ps[snum].ammo_amount[PISTOL_WEAPON] < max_ammo_amount[PISTOL_WEAPON]) return(10);
else return(0); return(0);
case BATTERYAMMO__STATIC: case BATTERYAMMO__STATIC:
if (ps[snum].ammo_amount[CHAINGUN_WEAPON] < max_ammo_amount[CHAINGUN_WEAPON]) return(20); if (ps[snum].ammo_amount[CHAINGUN_WEAPON] < max_ammo_amount[CHAINGUN_WEAPON]) return(20);
else return(0); return(0);
case DEVISTATORAMMO__STATIC: case DEVISTATORAMMO__STATIC:
if (ps[snum].ammo_amount[DEVISTATOR_WEAPON] < max_ammo_amount[DEVISTATOR_WEAPON]) return(25); if (ps[snum].ammo_amount[DEVISTATOR_WEAPON] < max_ammo_amount[DEVISTATOR_WEAPON]) return(25);
else return(0); return(0);
case RPGAMMO__STATIC: case RPGAMMO__STATIC:
if (ps[snum].ammo_amount[RPG_WEAPON] < max_ammo_amount[RPG_WEAPON]) return(50); if (ps[snum].ammo_amount[RPG_WEAPON] < max_ammo_amount[RPG_WEAPON]) return(50);
else return(0); return(0);
case CRYSTALAMMO__STATIC: case CRYSTALAMMO__STATIC:
if (ps[snum].ammo_amount[SHRINKER_WEAPON] < max_ammo_amount[SHRINKER_WEAPON]) return(10); if (ps[snum].ammo_amount[SHRINKER_WEAPON] < max_ammo_amount[SHRINKER_WEAPON]) return(10);
else return(0); return(0);
case HBOMBAMMO__STATIC: case HBOMBAMMO__STATIC:
if (ps[snum].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) return(30); if (ps[snum].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) return(30);
else return(0); return(0);
case SHOTGUNAMMO__STATIC: case SHOTGUNAMMO__STATIC:
if (ps[snum].ammo_amount[SHOTGUN_WEAPON] < max_ammo_amount[SHOTGUN_WEAPON]) return(25); if (ps[snum].ammo_amount[SHOTGUN_WEAPON] < max_ammo_amount[SHOTGUN_WEAPON]) return(25);
else return(0); return(0);
case COLA__STATIC: case COLA__STATIC:
if (sprite[ps[snum].i].extra < 100) return(10); if (sprite[ps[snum].i].extra < 100) return(10);
else return(0); return(0);
case SIXPAK__STATIC: case SIXPAK__STATIC:
if (sprite[ps[snum].i].extra < 100) return(30); if (sprite[ps[snum].i].extra < 100) return(30);
else return(0); return(0);
case FIRSTAID__STATIC: case FIRSTAID__STATIC:
if (ps[snum].firstaid_amount < 100) return(100); if (ps[snum].firstaid_amount < 100) return(100);
else return(0); return(0);
case SHIELD__STATIC: case SHIELD__STATIC:
if (ps[snum].shield_amount < 100) return(50); if (ps[snum].shield_amount < 100) return(50);
else return(0); return(0);
case STEROIDS__STATIC: case STEROIDS__STATIC:
if (ps[snum].steroids_amount < 400) return(30); if (ps[snum].steroids_amount < 400) return(30);
else return(0); return(0);
case AIRTANK__STATIC: case AIRTANK__STATIC:
if (ps[snum].scuba_amount < 6400) return(30); if (ps[snum].scuba_amount < 6400) return(30);
else return(0); return(0);
case JETPACK__STATIC: case JETPACK__STATIC:
if (ps[snum].jetpack_amount < 1600) return(100); if (ps[snum].jetpack_amount < 1600) return(100);
else return(0); return(0);
case HEATSENSOR__STATIC: case HEATSENSOR__STATIC:
if (ps[snum].heat_amount < 1200) return(5); if (ps[snum].heat_amount < 1200) return(5);
else return(0); return(0);
case ACCESSCARD__STATIC: case ACCESSCARD__STATIC:
return(1); return(1);
case BOOTS__STATIC: case BOOTS__STATIC:
if (ps[snum].boot_amount < 200) return(15); if (ps[snum].boot_amount < 200) return(15);
else return(0); return(0);
case ATOMICHEALTH__STATIC: case ATOMICHEALTH__STATIC:
if (sprite[ps[snum].i].extra < max_player_health<<1) return(50); if (sprite[ps[snum].i].extra < max_player_health<<1) return(50);
else return(0); return(0);
case HOLODUKE__STATIC: case HOLODUKE__STATIC:
if (ps[snum].holoduke_amount < 2400) return(5); if (ps[snum].holoduke_amount < 2400) return(5);
else return(0); return(0);
case SECTOREFFECTOR__STATIC:
return(1);
case TOUCHPLATE__STATIC: case TOUCHPLATE__STATIC:
return(1); return(5);
case MUSICANDSFX__STATIC: case MUSICANDSFX__STATIC:
return(1); return(10);
} }
return(0); return(0);
} }
@ -5180,7 +5178,7 @@ static long fdmatrix[12][12] =
}; };
static long goalx[MAXPLAYERS], goaly[MAXPLAYERS], goalz[MAXPLAYERS]; static long goalx[MAXPLAYERS], goaly[MAXPLAYERS], goalz[MAXPLAYERS];
static long goalsect[MAXPLAYERS], goalwall[MAXPLAYERS], goalsprite[MAXPLAYERS]; static long goalsect[MAXPLAYERS], goalwall[MAXPLAYERS], goalsprite[MAXPLAYERS], goalspritescore[MAXPLAYERS];
static long goalplayer[MAXPLAYERS], clipmovecount[MAXPLAYERS]; static long goalplayer[MAXPLAYERS], clipmovecount[MAXPLAYERS];
short searchsect[MAXSECTORS], searchparent[MAXSECTORS]; short searchsect[MAXSECTORS], searchparent[MAXSECTORS];
char dashow2dsector[(MAXSECTORS+7)>>3]; char dashow2dsector[(MAXSECTORS+7)>>3];
@ -5522,6 +5520,8 @@ void computergetinput(long snum, input *syn)
{ {
if (goalsprite[snum] < 0) if (goalsprite[snum] < 0)
{ {
int bestsprite = -1, spritescore = 0;
for (k=0;k<4;k++) for (k=0;k<4;k++)
{ {
i = (rand()%numsectors); i = (rand()%numsectors);
@ -5531,16 +5531,25 @@ void computergetinput(long snum, input *syn)
if (getspritescore(snum,sprite[j].picnum) <= 0) continue; if (getspritescore(snum,sprite[j].picnum) <= 0) continue;
if (cansee(x1,y1,z1-(32<<8),damysect,sprite[j].x,sprite[j].y,sprite[j].z-(4<<8),i)) if (cansee(x1,y1,z1-(32<<8),damysect,sprite[j].x,sprite[j].y,sprite[j].z-(4<<8),i))
{ {
goalx[snum] = sprite[j].x; if (getspritescore(snum,sprite[j].picnum) > spritescore)
goaly[snum] = sprite[j].y; {
goalz[snum] = sprite[j].z; spritescore = getspritescore(snum,sprite[j].picnum);
goalsprite[snum] = j; bestsprite = j;
break;
} }
// break;
} }
} }
} }
if (bestsprite != -1 && (!cansee(x1,y1,z1-(32<<8),damysect,sprite[goalsprite[snum]].x,sprite[goalsprite[snum]].y,sprite[goalsprite[snum]].z-(4<<8),i) ||
spritescore > goalspritescore[snum]))
{
goalx[snum] = sprite[bestsprite].x;
goaly[snum] = sprite[bestsprite].y;
goalz[snum] = sprite[bestsprite].z;
goalsprite[snum] = bestsprite;
goalspritescore[snum] = spritescore;
}
}
x2 = goalx[snum]; x2 = goalx[snum];
y2 = goaly[snum]; y2 = goaly[snum];
dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
@ -5550,8 +5559,11 @@ void computergetinput(long snum, input *syn)
syn->svel += (y2-y1)*2047/dist; syn->svel += (y2-y1)*2047/dist;
syn->avel = min(max((((daang+1024-damyang)&2047)-1024)>>3,-127),127); syn->avel = min(max((((daang+1024-damyang)&2047)-1024)>>3,-127),127);
} }
else else if (goalsprite[snum] != -1)
{
if (!cansee(x1,y1,z1-(32<<8),damysect,sprite[goalsprite[snum]].x,sprite[goalsprite[snum]].y,sprite[goalsprite[snum]].z-(4<<8),i))
goalsprite[snum] = -1; goalsprite[snum] = -1;
}
x3 = p->posx; x3 = p->posx;
y3 = p->posy; y3 = p->posy;
@ -5602,8 +5614,12 @@ void computergetinput(long snum, input *syn)
clipmovecount[snum] = 0; clipmovecount[snum] = 0;
} }
if (goalsprite[snum] != -1)
{
if (!cansee(x1,y1,z1-(32<<8),damysect,sprite[goalsprite[snum]].x,sprite[goalsprite[snum]].y,sprite[goalsprite[snum]].z-(4<<8),i))
goalsprite[snum] = -1; goalsprite[snum] = -1;
} }
}
else else
clipmovecount[snum] = 0; clipmovecount[snum] = 0;

View file

@ -642,7 +642,7 @@ int issoundplaying(short i, int num)
{ {
if (Sound[num].lock == 200) if (Sound[num].lock == 200)
return 1; return 1;
else return 0; return 0;
} }
else return(Sound[num].num); return(Sound[num].num);
} }