Camera control

git-svn-id: https://svn.eduke32.com/eduke32@487 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2007-02-12 07:58:03 +00:00
parent 465b5041f3
commit abcce7e337
5 changed files with 127 additions and 58 deletions

View file

@ -714,7 +714,8 @@ enum events {
EVENT_PRESSEDFIRE, EVENT_PRESSEDFIRE,
EVENT_USE, EVENT_USE,
EVENT_PROCESSINPUT, EVENT_PROCESSINPUT,
EVENT_FAKEDOMOVETHINGS EVENT_FAKEDOMOVETHINGS,
EVENT_DISPLAYROOMS
}; };
// store global game definitions // store global game definitions

View file

@ -3837,11 +3837,14 @@ static void se40code(long x,long y,long z,long a,long h, long smoothratio)
static long oyrepeat=-1; static long oyrepeat=-1;
long camerax,cameray,cameraz;
short cameraang, camerasect, camerahoriz;
void displayrooms(int snum,long smoothratio) void displayrooms(int snum,long smoothratio)
{ {
long cposx,cposy,cposz,dst,j,fz,cz; long dst,j,fz,cz;
long tposx,tposy,i; long tposx,tposy,i;
short sect, cang, k, choriz; short k;
struct player_struct *p = &ps[snum]; struct player_struct *p = &ps[snum];
short tang; short tang;
long tiltcx,tiltcy,tiltcs=0; // JBF 20030807 long tiltcx,tiltcy,tiltcs=0; // JBF 20030807
@ -3868,12 +3871,12 @@ void displayrooms(int snum,long smoothratio)
if (ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536; if (ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536;
sect = p->cursectnum; camerasect = p->cursectnum;
#ifdef POLYMOST #ifdef POLYMOST
if (rendmode != 4) if (rendmode != 4)
#endif #endif
if (sect < 0 || sect >= MAXSECTORS) return; if (camerasect < 0 || camerasect >= MAXSECTORS) return;
dointerpolations(smoothratio); dointerpolations(smoothratio);
@ -3886,12 +3889,12 @@ void displayrooms(int snum,long smoothratio)
if (s->yvel < 0) s->yvel = -100; if (s->yvel < 0) s->yvel = -100;
else if (s->yvel > 199) s->yvel = 300; else if (s->yvel > 199) s->yvel = 300;
cang = hittype[ud.camerasprite].tempang+mulscale16((long)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio); cameraang = hittype[ud.camerasprite].tempang+mulscale16((long)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio);
#ifdef SE40 #ifdef SE40
se40code(s->x,s->y,s->z,cang,s->yvel,smoothratio); se40code(s->x,s->y,s->z,cameraang,s->yvel,smoothratio);
#endif #endif
drawrooms(s->x,s->y,s->z-(4<<8),cang,s->yvel,s->sectnum); drawrooms(s->x,s->y,s->z-(4<<8),cameraang,s->yvel,s->sectnum);
animatesprites(s->x,s->y,cang,smoothratio); animatesprites(s->x,s->y,cameraang,smoothratio);
drawmasks(); drawmasks();
} }
else else
@ -3960,68 +3963,71 @@ void displayrooms(int snum,long smoothratio)
if ((snum == myconnectindex) && (numplayers > 1)) if ((snum == myconnectindex) && (numplayers > 1))
{ {
cposx = omyx+mulscale16((long)(myx-omyx),smoothratio); camerax = omyx+mulscale16((long)(myx-omyx),smoothratio);
cposy = omyy+mulscale16((long)(myy-omyy),smoothratio); cameray = omyy+mulscale16((long)(myy-omyy),smoothratio);
cposz = omyz+mulscale16((long)(myz-omyz),smoothratio); cameraz = omyz+mulscale16((long)(myz-omyz),smoothratio);
cang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); cameraang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio);
choriz = omyhoriz+omyhorizoff+mulscale16((long)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); camerahoriz = omyhoriz+omyhorizoff+mulscale16((long)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio);
sect = mycursectnum; camerasect = mycursectnum;
} }
else else
{ {
cposx = p->oposx+mulscale16((long)(p->posx-p->oposx),smoothratio); camerax = p->oposx+mulscale16((long)(p->posx-p->oposx),smoothratio);
cposy = p->oposy+mulscale16((long)(p->posy-p->oposy),smoothratio); cameray = p->oposy+mulscale16((long)(p->posy-p->oposy),smoothratio);
cposz = p->oposz+mulscale16((long)(p->posz-p->oposz),smoothratio); cameraz = p->oposz+mulscale16((long)(p->posz-p->oposz),smoothratio);
cang = p->oang+mulscale16((long)(((p->ang+1024-p->oang)&2047)-1024),smoothratio); cameraang = p->oang+mulscale16((long)(((p->ang+1024-p->oang)&2047)-1024),smoothratio);
choriz = p->ohoriz+p->ohorizoff+mulscale16((long)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio); camerahoriz = p->ohoriz+p->ohorizoff+mulscale16((long)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio);
} }
cang += p->look_ang; cameraang += p->look_ang;
if (p->newowner >= 0) if (p->newowner >= 0)
{ {
cang = p->ang+p->look_ang; cameraang = p->ang+p->look_ang;
choriz = p->horiz+p->horizoff; camerahoriz = p->horiz+p->horizoff;
cposx = p->posx; camerax = p->posx;
cposy = p->posy; cameray = p->posy;
cposz = p->posz; cameraz = p->posz;
sect = sprite[p->newowner].sectnum; camerasect = sprite[p->newowner].sectnum;
smoothratio = 65536L; smoothratio = 65536L;
} }
else if (p->over_shoulder_on == 0) else if (p->over_shoulder_on == 0)
cposz += p->opyoff+mulscale16((long)(p->pyoff-p->opyoff),smoothratio); cameraz += p->opyoff+mulscale16((long)(p->pyoff-p->opyoff),smoothratio);
else view(p,&cposx,&cposy,&cposz,&sect,cang,choriz); else view(p,&camerax,&cameray,&cameraz,&camerasect,cameraang,camerahoriz);
cz = hittype[p->i].ceilingz; cz = hittype[p->i].ceilingz;
fz = hittype[p->i].floorz; fz = hittype[p->i].floorz;
if (earthquaketime > 0 && p->on_ground == 1) if (earthquaketime > 0 && p->on_ground == 1)
{ {
cposz += 256-(((earthquaketime)&1)<<9); cameraz += 256-(((earthquaketime)&1)<<9);
cang += (2-((earthquaketime)&2))<<2; cameraang += (2-((earthquaketime)&2))<<2;
} }
if (sprite[p->i].pal == 1) cposz -= (18<<8); if (sprite[p->i].pal == 1) cameraz -= (18<<8);
if (p->newowner >= 0) if (p->newowner >= 0)
choriz = 100+sprite[p->newowner].shade; camerahoriz = 100+sprite[p->newowner].shade;
else if (p->spritebridge == 0) else if (p->spritebridge == 0)
{ {
if (cposz < (p->truecz + (4<<8))) cposz = cz + (4<<8); if (cameraz < (p->truecz + (4<<8))) cameraz = cz + (4<<8);
else if (cposz > (p->truefz - (4<<8))) cposz = fz - (4<<8); else if (cameraz > (p->truefz - (4<<8))) cameraz = fz - (4<<8);
} }
if (sect >= 0) if (camerasect >= 0)
{ {
getzsofslope(sect,cposx,cposy,&cz,&fz); getzsofslope(camerasect,camerax,cameray,&cz,&fz);
if (cposz < cz+(4<<8)) cposz = cz+(4<<8); if (cameraz < cz+(4<<8)) cameraz = cz+(4<<8);
if (cposz > fz-(4<<8)) cposz = fz-(4<<8); if (cameraz > fz-(4<<8)) cameraz = fz-(4<<8);
} }
if (choriz > 299) choriz = 299; if (camerahoriz > 299) camerahoriz = 299;
else if (choriz < -99) choriz = -99; else if (camerahoriz < -99) camerahoriz = -99;
OnEvent(EVENT_DISPLAYROOMS, ps[screenpeek].i, screenpeek, -1);
#ifdef SE40 #ifdef SE40
se40code(cposx,cposy,cposz,cang,choriz,smoothratio); se40code(camerax,cameray,cameraz,cameraang,camerahoriz,smoothratio);
#endif #endif
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
{ {
@ -4029,19 +4035,19 @@ void displayrooms(int snum,long smoothratio)
i = 0; i = 0;
for (k=0;k<mirrorcnt;k++) for (k=0;k<mirrorcnt;k++)
{ {
j = klabs(wall[mirrorwall[k]].x-cposx); j = klabs(wall[mirrorwall[k]].x-camerax);
j += klabs(wall[mirrorwall[k]].y-cposy); j += klabs(wall[mirrorwall[k]].y-cameray);
if (j < dst) dst = j, i = k; if (j < dst) dst = j, i = k;
} }
if (wall[mirrorwall[i]].overpicnum == MIRROR) if (wall[mirrorwall[i]].overpicnum == MIRROR)
{ {
preparemirror(cposx,cposy,cposz,cang,choriz,mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang); preparemirror(camerax,cameray,cameraz,cameraang,camerahoriz,mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang);
j = visibility; j = visibility;
visibility = (j>>1) + (j>>2); visibility = (j>>1) + (j>>2);
drawrooms(tposx,tposy,cposz,tang,choriz,mirrorsector[i]+MAXSECTORS); drawrooms(tposx,tposy,cameraz,tang,camerahoriz,mirrorsector[i]+MAXSECTORS);
display_mirror = 1; display_mirror = 1;
animatesprites(tposx,tposy,tang,smoothratio); animatesprites(tposx,tposy,tang,smoothratio);
@ -4054,8 +4060,8 @@ void displayrooms(int snum,long smoothratio)
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7)); gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
} }
drawrooms(cposx,cposy,cposz,cang,choriz,sect); drawrooms(camerax,cameray,cameraz,cameraang,camerahoriz,camerasect);
animatesprites(cposx,cposy,cang,smoothratio); animatesprites(camerax,cameray,cameraang,smoothratio);
drawmasks(); drawmasks();
if (screencapt == 1) if (screencapt == 1)
@ -8189,9 +8195,8 @@ static int load_rancid_net(char *fn)
if (p != NULL) if (p != NULL)
{ {
Bsprintf(tempbuf,"%s",p); if (atoi(p) > 1024)
if (atoi(tempbuf) > 1024) Bsprintf(rancid_local_port_string,"-p %s",p);
Bsprintf(rancid_local_port_string,"-p %s",tempbuf);
} }
} }
} }
@ -10390,12 +10395,10 @@ static int in_menu = 0;
static long playback(void) static long playback(void)
{ {
long i,j,k,l; long i,j,k,l;
char foundemo; int foundemo = 0;
if (ready2send) return 0; if (ready2send) return 0;
foundemo = 0;
RECHECK: RECHECK:
in_menu = ps[myconnectindex].gm&MODE_MENU; in_menu = ps[myconnectindex].gm&MODE_MENU;
@ -10405,7 +10408,7 @@ RECHECK:
flushperms(); flushperms();
if (numplayers < 2) foundemo = opendemoread(which_demo); if (ud.multimode < 2) foundemo = opendemoread(which_demo);
if (foundemo == 0) if (foundemo == 0)
{ {

View file

@ -812,6 +812,7 @@ LABELS userdefslabels[]=
{ "automsg", USERDEFS_AUTOMSG, 0, 0 }, { "automsg", USERDEFS_AUTOMSG, 0, 0 },
{ "idplayers", USERDEFS_IDPLAYERS, 0, 0 }, { "idplayers", USERDEFS_IDPLAYERS, 0, 0 },
{ "team", USERDEFS_TEAM, 0, 0 }, { "team", USERDEFS_TEAM, 0, 0 },
#if 0
{ "myx", USERDEFS_MYX, 0, 0 }, { "myx", USERDEFS_MYX, 0, 0 },
{ "omyx", USERDEFS_OMYX, 0, 0 }, { "omyx", USERDEFS_OMYX, 0, 0 },
{ "myxvel", USERDEFS_MYXVEL, 0, 0 }, { "myxvel", USERDEFS_MYXVEL, 0, 0 },
@ -833,6 +834,13 @@ LABELS userdefslabels[]=
{ "myonground", USERDEFS_MYONGROUND, 0, 0 }, { "myonground", USERDEFS_MYONGROUND, 0, 0 },
{ "myhardlanding", USERDEFS_MYHARDLANDING, 0, 0 }, { "myhardlanding", USERDEFS_MYHARDLANDING, 0, 0 },
{ "myreturntocenter", USERDEFS_MYRETURNTOCENTER, 0, 0 }, { "myreturntocenter", USERDEFS_MYRETURNTOCENTER, 0, 0 },
#endif
{ "camerax", USERDEFS_CAMERAX, 0, 0 },
{ "cameray", USERDEFS_CAMERAY, 0, 0 },
{ "cameraz", USERDEFS_CAMERAZ, 0, 0 },
{ "cameraang", USERDEFS_CAMERAANG, 0, 0 },
{ "camerasect", USERDEFS_CAMERASECT, 0, 0 },
{ "camerahoriz", USERDEFS_CAMERAHORIZ, 0, 0 },
{ "", -1, 0, 0 } // END OF LIST { "", -1, 0, 0 } // END OF LIST
}; };
@ -1036,10 +1044,11 @@ char CheckEventSync(int iEventID)
case EVENT_CHEATGETHOLODUKE: case EVENT_CHEATGETHOLODUKE:
case EVENT_CHEATGETJETPACK: case EVENT_CHEATGETJETPACK:
case EVENT_CHEATGETFIRSTAID: case EVENT_CHEATGETFIRSTAID:
case EVENT_DISPLAYWEAPON:
case EVENT_DRAWWEAPON:
case EVENT_DISPLAYCROSSHAIR: case EVENT_DISPLAYCROSSHAIR:
case EVENT_DISPLAYREST: case EVENT_DISPLAYREST:
case EVENT_DISPLAYROOMS:
case EVENT_DISPLAYWEAPON:
case EVENT_DRAWWEAPON:
case EVENT_ENTERLEVEL: case EVENT_ENTERLEVEL:
case EVENT_FAKEDOMOVETHINGS: case EVENT_FAKEDOMOVETHINGS:
case EVENT_GETLOADTILE: case EVENT_GETLOADTILE:
@ -4537,6 +4546,7 @@ static void AddDefaultDefinitions(void)
AddDefinition("EVENT_CROUCH",EVENT_CROUCH,LABEL_DEFINE); AddDefinition("EVENT_CROUCH",EVENT_CROUCH,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYCROSSHAIR",EVENT_DISPLAYCROSSHAIR,LABEL_DEFINE); AddDefinition("EVENT_DISPLAYCROSSHAIR",EVENT_DISPLAYCROSSHAIR,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYREST",EVENT_DISPLAYREST,LABEL_DEFINE); AddDefinition("EVENT_DISPLAYREST",EVENT_DISPLAYREST,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYROOMS",EVENT_DISPLAYROOMS,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYWEAPON",EVENT_DISPLAYWEAPON,LABEL_DEFINE); AddDefinition("EVENT_DISPLAYWEAPON",EVENT_DISPLAYWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_DOFIRE",EVENT_DOFIRE,LABEL_DEFINE); AddDefinition("EVENT_DOFIRE",EVENT_DOFIRE,LABEL_DEFINE);
AddDefinition("EVENT_DRAWWEAPON",EVENT_DRAWWEAPON,LABEL_DEFINE); AddDefinition("EVENT_DRAWWEAPON",EVENT_DRAWWEAPON,LABEL_DEFINE);

View file

@ -316,6 +316,7 @@ enum userdefslabels {
USERDEFS_IDPLAYERS, USERDEFS_IDPLAYERS,
USERDEFS_TEAM, USERDEFS_TEAM,
// this stuff isn't really userdef stuff, but getuserdef/setuserdef is already set up for what I want to do // this stuff isn't really userdef stuff, but getuserdef/setuserdef is already set up for what I want to do
#if 0
USERDEFS_MYX, USERDEFS_MYX,
USERDEFS_OMYX, USERDEFS_OMYX,
USERDEFS_MYXVEL, USERDEFS_MYXVEL,
@ -336,7 +337,14 @@ enum userdefslabels {
USERDEFS_MYJUMPINGTOGGLE, USERDEFS_MYJUMPINGTOGGLE,
USERDEFS_MYONGROUND, USERDEFS_MYONGROUND,
USERDEFS_MYHARDLANDING, USERDEFS_MYHARDLANDING,
USERDEFS_MYRETURNTOCENTER USERDEFS_MYRETURNTOCENTER,
#endif
USERDEFS_CAMERAX,
USERDEFS_CAMERAY,
USERDEFS_CAMERAZ,
USERDEFS_CAMERAANG,
USERDEFS_CAMERASECT,
USERDEFS_CAMERAHORIZ,
}; };
enum sectorlabels { enum sectorlabels {

View file

@ -37,6 +37,9 @@ static int killit_flag;
extern int32 scripthandle; extern int32 scripthandle;
extern long camerax,cameray,cameraz;
extern short cameraang, camerasect, camerahoriz;
static void DoUserDef(int iSet, int lLabelID, int lVar2) static void DoUserDef(int iSet, int lLabelID, int lVar2)
{ {
long lValue; long lValue;
@ -665,6 +668,7 @@ static void DoUserDef(int iSet, int lLabelID, int lVar2)
SetGameVarID(lVar2, ud.team, g_i, g_p); SetGameVarID(lVar2, ud.team, g_i, g_p);
break; break;
#if 0
case USERDEFS_MYX: case USERDEFS_MYX:
if (iSet) if (iSet)
myx = lValue; myx = lValue;
@ -811,6 +815,49 @@ static void DoUserDef(int iSet, int lLabelID, int lVar2)
else else
SetGameVarID(lVar2, myreturntocenter, g_i, g_p); SetGameVarID(lVar2, myreturntocenter, g_i, g_p);
break; break;
#endif
case USERDEFS_CAMERAX:
if (iSet)
camerax = lValue;
else
SetGameVarID(lVar2, camerax, g_i, g_p);
break;
case USERDEFS_CAMERAY:
if (iSet)
cameray = lValue;
else
SetGameVarID(lVar2, cameray, g_i, g_p);
break;
case USERDEFS_CAMERAZ:
if (iSet)
cameraz = lValue;
else
SetGameVarID(lVar2, cameraz, g_i, g_p);
break;
case USERDEFS_CAMERAANG:
if (iSet)
cameraang = lValue;
else
SetGameVarID(lVar2, cameraang, g_i, g_p);
break;
case USERDEFS_CAMERASECT:
if (iSet)
camerasect = lValue;
else
SetGameVarID(lVar2, camerasect, g_i, g_p);
break;
case USERDEFS_CAMERAHORIZ:
if (iSet)
camerahoriz = lValue;
else
SetGameVarID(lVar2, camerahoriz, g_i, g_p);
break;
default: default:
break; break;