TempleOSCDV4.06.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:47:19 +02:00
1 parent 6fe38d2d9d
commit b632ab9a4f
261 files changed
+6282 -5801

No files matched your search

+4 -4
View File
@@ -65,7 +65,7 @@ U0 HoldCourt()
Bool TakeTurn()
{
I64 i;
Bool result,old_form=LBts(&(DocPut)->flags,DOCf_FORM);
Bool res,old_form=LBts(&(DocPut)->flags,DOCf_FORM);
num_people*=1.0+0.01*((RandU16%100)-30);
if (num_people>MAX_PEOPLE)
num_people=MAX_PEOPLE;
@@ -96,7 +96,7 @@ Bool TakeTurn()
DocBottom;
if (!(0<=i<T_QUIT))
result=FALSE;
res=FALSE;
else {
switch (i) {
case T_BREAK_CAMP:
@@ -130,11 +130,11 @@ Bool TakeTurn()
PopUpOk("Add your own story-line...\nLike old school toys.\n");
break;
}
result=TRUE;
res=TRUE;
}
WinMgrSync;
Fs->song_task=NULL;
return result;
return res;
}
U0 TMsg(CDC *dc,U8 *msg)
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7 -7
View File
@@ -5,18 +5,18 @@ U0 BgtAcctsUpdate()
tempb=b_root.next;
while (tempb!=&b_root) {
if (tempb->type!=BE_TEMPLATE_COPY) {
tempb->credit_index=StrFileAdd(tempb->credit,
tempb->credit_idx=StrFileAdd(tempb->credit,
&accts_table_strs,accts_table);
tempb->debit_index =StrFileAdd(tempb->debit,
tempb->debit_idx =StrFileAdd(tempb->debit,
&accts_table_strs,accts_table);
}
tempb=tempb->next;
}
tempt=t_root.next;
while (tempt!=&t_root) {
tempt->b.credit_index=StrFileAdd(tempt->b.credit,
tempt->b.credit_idx=StrFileAdd(tempt->b.credit,
&accts_table_strs,accts_table);
tempt->b.debit_index =StrFileAdd(tempt->b.debit,
tempt->b.debit_idx =StrFileAdd(tempt->b.debit,
&accts_table_strs,accts_table);
tempt=tempt->next;
}
@@ -54,7 +54,7 @@ I64 BgtAcctColor(U8 *st)
U8 *BgtPopUpAcct(U8 *header=NULL,U8 *dft=NULL)
{
I64 i;
U8 *result;
U8 *res;
CDoc *doc=DocNew;
CDocEntry *doc_e,*doc_dft=NULL;
CHashGeneric *temph;
@@ -77,7 +77,7 @@ U8 *BgtPopUpAcct(U8 *header=NULL,U8 *dft=NULL)
doc->cur_entry=doc_dft;
doc->cur_col=0;
}
result=PopUpMenu(doc,DOF_DONT_HOME);
res=PopUpMenu(doc,DOF_DONT_HOME);
DocDel(doc);
return result;
return res;
}
+12 -12
View File
@@ -19,9 +19,9 @@ U0 BgtDataRead()
for (i=0;i<cnt;i++) {
tempb=CAlloc(sizeof(CBgtEntry));
MemCpy(&tempb->start,ptr,BE_SIZE);
tempb->credit=StrNew(s[tempb->credit_index]);
tempb->debit =StrNew(s[tempb->debit_index]);
tempb->desc =StrNew(s[tempb->desc_index]);
tempb->credit=StrNew(s[tempb->credit_idx]);
tempb->debit =StrNew(s[tempb->debit_idx]);
tempb->desc =StrNew(s[tempb->desc_idx]);
QueIns(tempb,b_root.last);
ptr+=BE_SIZE;
}
@@ -33,9 +33,9 @@ U0 BgtDataRead()
ptr+=BT_SIZE;
MemCpy(&tempt->b.start,ptr,BE_SIZE);
ptr+=BE_SIZE;
tempt->b.credit=StrNew(s[tempt->b.credit_index]);
tempt->b.debit =StrNew(s[tempt->b.debit_index]);
tempt->b.desc =StrNew(s[tempt->b.desc_index]);
tempt->b.credit=StrNew(s[tempt->b.credit_idx]);
tempt->b.debit =StrNew(s[tempt->b.debit_idx]);
tempt->b.desc =StrNew(s[tempt->b.desc_idx]);
QueIns(tempt,t_root.last);
}
}
@@ -67,9 +67,9 @@ U0 BgtDataWrite()
cnt1=0;
while (tempb!=&b_root) {
if (tempb->type!=BE_TEMPLATE_COPY) {
tempb->credit_index =StrFileAdd(tempb->credit,&num,table);
tempb->debit_index =StrFileAdd(tempb->debit,&num,table);
tempb->desc_index =StrFileAdd(tempb->desc,&num,table);
tempb->credit_idx =StrFileAdd(tempb->credit,&num,table);
tempb->debit_idx =StrFileAdd(tempb->debit,&num,table);
tempb->desc_idx =StrFileAdd(tempb->desc,&num,table);
cnt1++;
}
tempb=tempb->next;
@@ -78,9 +78,9 @@ U0 BgtDataWrite()
tempt=t_root.next;
cnt2=0;
while (tempt!=&t_root) {
tempt->b.credit_index =StrFileAdd(tempt->b.credit,&num,table);
tempt->b.debit_index =StrFileAdd(tempt->b.debit,&num,table);
tempt->b.desc_index =StrFileAdd(tempt->b.desc,&num,table);
tempt->b.credit_idx =StrFileAdd(tempt->b.credit,&num,table);
tempt->b.debit_idx =StrFileAdd(tempt->b.debit,&num,table);
tempt->b.desc_idx =StrFileAdd(tempt->b.desc,&num,table);
cnt2++;
tempt=tempt->next;
}
+4 -4
View File
@@ -6,7 +6,7 @@ public U8 **StrFileRead(U8 *name,I64 *_max_num=NULL,
CDoc *doc=DocRead(name,DOCF_DBL_DOLLARS|DOCF_NO_CURSOR);
CDocEntry *doc_e=doc->root.next;
I64 i,max_num=0;
U8 *ptr,**result,*colors;
U8 *ptr,**res,*colors;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_TEXT) {
@@ -25,12 +25,12 @@ public U8 **StrFileRead(U8 *name,I64 *_max_num=NULL,
doc_e=doc_e->next;
}
result=CAlloc(sizeof(U8 *)*(max_num+1));
res=CAlloc(sizeof(U8 *)*(max_num+1));
colors=CAlloc(sizeof(U8)*(max_num+1));
doc_e=doc->root.next;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_TEXT && 0<=doc_e->user_data<=max_num) {
result[doc_e->user_data]=doc_e->tag;
res[doc_e->user_data]=doc_e->tag;
doc_e->tag=NULL;
colors[doc_e->user_data]=doc_e->type.u8[1]&15;
}
@@ -43,7 +43,7 @@ public U8 **StrFileRead(U8 *name,I64 *_max_num=NULL,
*_colors=colors;
else
Free(colors);
return result;
return res;
}
public U0 StrFileArrDel(U8 **a,I64 max_num)
+7 -7
View File
@@ -17,7 +17,7 @@ class CBgtEntry
U0 start;
CDate date;
U16 type,flags;
U32 credit_index,debit_index,desc_index;
U32 credit_idx,debit_idx,desc_idx;
F64 amount;
U0 end;
@@ -60,17 +60,17 @@ I64 accts_table_strs=0;
CDate MyStr2Date(U8 *st)
{
CDateStruct ds;
CDate result;
CDate res;
if (st&&*st) {
if (StrOcc(st,'['))
result=b_root.next->date;
res=b_root.next->date;
else if (StrOcc(st,']'))
result=b_root.last->date;
res=b_root.last->date;
else
result=Str2Date(st);
res=Str2Date(st);
} else
result=Now;
Date2Struct(&ds,result);
res=Now;
Date2Struct(&ds,res);
if (ds.year>2050)
ds.year-=100;
return Struct2Date(&ds);
+14 -14
View File
@@ -47,21 +47,21 @@ I64 AddVertex(BallDefineStruct *,I64 x,I64 y,I64 z)
I64 AddTri(BallDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
{
I64 result=b->tri_cnt++;
b->t[result].color=c;
b->t[result].nums[0]=n0;
b->t[result].nums[1]=n1;
b->t[result].nums[2]=n2;
return result;
I64 res=b->tri_cnt++;
b->t[res].color=c;
b->t[res].nums[0]=n0;
b->t[res].nums[1]=n1;
b->t[res].nums[2]=n2;
return res;
}
U8 *Ball2CSprite()
{
//See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ for how CSprite are stored.
U8 *result=MAlloc(sizeof(CSpriteMeshU8s)+
U8 *res=MAlloc(sizeof(CSpriteMeshU8s)+
b->vertex_cnt*sizeof(CD3I32)+b->tri_cnt*sizeof(CMeshTri)
+sprite_elem_base_sizes[SPT_END]),
*dst=result;
*dst=res;
*dst++ =SPT_MESH;
*dst(I32 *)++ =b->vertex_cnt;
*dst(I32 *)++ =b->tri_cnt;
@@ -70,12 +70,12 @@ U8 *Ball2CSprite()
MemCpy(dst,&b->t,b->tri_cnt*sizeof(CMeshTri));
dst+=b->tri_cnt*sizeof(CMeshTri);
*dst++ =SPT_END;
return result;
return res;
}
public U8 *BallGen()
{
U8 *result;
U8 *res;
I64 i,j,n,m,c,p1,p2,p3,p4;
BallDefineStruct bd1,bd2;
F64 r,r1,r2,z1,z2,d_a1,d_a2;
@@ -112,17 +112,17 @@ public U8 *BallGen()
}
}
result=Ball2CSprite;
res=Ball2CSprite;
"%h7c",'\n';
Sprite(result,"\t\t$$SP,\"<1>\",BI=%d$$");
Sprite(res,"\t\t$$SP,\"<1>\",BI=%d$$");
"%h7c",'\n';
"Vertices:%d\n",b->vertex_cnt;
Free(b);
"Do another";
if (YorN)
Free(result);
Free(res);
else
break;
}
return result;
return res;
}
+19 -19
View File
@@ -142,21 +142,21 @@ U0 MDCorrect(ManDefineStruct *md)
I64 AddVertex(ManDefineStruct *md,I64 x,I64 y,I64 z)
{
I64 result=m->vertex_cnt++;
m->v[result].x=-x;
m->v[result].y=-y-md->leg_len-md->foot_rad*2;
m->v[result].z=-z;
return result;
I64 res=m->vertex_cnt++;
m->v[res].x=-x;
m->v[res].y=-y-md->leg_len-md->foot_rad*2;
m->v[res].z=-z;
return res;
}
I64 AddTri(ManDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
{
I64 result=m->tri_cnt++;
m->t[result].color=c;
m->t[result].nums[0]=n1;
m->t[result].nums[1]=n0;
m->t[result].nums[2]=n2;
return result;
I64 res=m->tri_cnt++;
m->t[res].color=c;
m->t[res].nums[0]=n1;
m->t[res].nums[1]=n0;
m->t[res].nums[2]=n2;
return res;
}
U0 AddBox(ManDefineStruct *md,I64 c,I64 x1,I64 y1,I64 z1,
@@ -212,10 +212,10 @@ U0 AddBox(ManDefineStruct *md,I64 c,I64 x1,I64 y1,I64 z1,
U8 *Man2CSprite()
{
//See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ for how CSprite are stored.
U8 *result=MAlloc(sizeof(CSpriteMeshU8s)+
U8 *res=MAlloc(sizeof(CSpriteMeshU8s)+
m->vertex_cnt*sizeof(CD3I32)+m->tri_cnt*sizeof(CMeshTri)+
sprite_elem_base_sizes[SPT_END]),
*dst=result;
*dst=res;
*dst++ =SPT_MESH;
*dst(I32 *)++ =m->vertex_cnt;
*dst(I32 *)++ =m->tri_cnt;
@@ -224,12 +224,12 @@ U8 *Man2CSprite()
MemCpy(dst,&m->t,m->tri_cnt*sizeof(CMeshTri));
dst+=m->tri_cnt*sizeof(CMeshTri);
*dst++ =SPT_END;
return result;
return res;
}
public U8 *ManGen()
{
U8 *result;
U8 *res;
I64 x,y,z,c1,c2,c3,c4;
ManDefineStruct md1,md2;
MDInit(&md1);
@@ -305,16 +305,16 @@ public U8 *ManGen()
md2.leg_rad*2,-md2.foot_len,md2.foot_rad*2,md2.leg_rad,0,
md2.l_hip_a2,0,md2.l_ankle_a,&x,&y,&z);
result=Man2CSprite;
res=Man2CSprite;
"%h7c",'\n';
Sprite(result,"\t\t$$SP,\"<1>\",BI=%d$$");
Sprite(res,"\t\t$$SP,\"<1>\",BI=%d$$");
"%h7c",'\n';
Free(m);
"Do another";
if (YorN)
Free(result);
Free(res);
else
break;
}
return result;
return res;
}
+3 -3
View File
@@ -279,9 +279,9 @@ U0 DrawObj(CDC *dc,Obj *o,F64 tt)
if (o==ball)
Sprite3(dc,o->x,(o->y-o->z)/2,GR_Z_ALL-o->y,$IB,"<1>",BI=1$);
else {
temps=SpriteInterpolate(imgs[o->last_img].img[o->team],
imgs[o->next_img].img[o->team],
(tt-o->last_t0)/(o->next_t0-o->last_t0));
temps=SpriteInterpolate((tt-o->last_t0)/(o->next_t0-o->last_t0),
imgs[o->last_img].img[o->team],
imgs[o->next_img].img[o->team]);
SpriteY3B(dc,o->x,(o->y-o->z)/2,GR_Z_ALL-o->y,temps,o->ay);
Free(temps);
}
+1 -1
View File
@@ -6,7 +6,7 @@ U0 PsmNoteDel(PsmNote *tempo)
PsmNote *PsmNoteCopy(PsmNote *tempo)
{
PsmNote *tempo1=MAllocIdentical(tempo);
PsmNote *tempo1=MAllocIdent(tempo);
if (tempo->word)
tempo1->word=StrNew(tempo->word);
else
+2 -2
View File
@@ -14,7 +14,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
while (tempm1!=&ode->next_mass) {
tempm2=tempm1->next;
while (tempm2!=&ode->next_mass) {
D3Sub(&tempm2->state->x,&tempm1->state->x,&p);
D3Sub(&p,&tempm2->state->x,&tempm1->state->x);
dd=D3NormSqr(&p);
if (dd<=Sqr(tempm1->radius+tempm2->radius)) {
d=Sqrt(dd)+0.0001;
@@ -39,7 +39,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
p2.x=ip.pos.x-task->pix_left-task->scroll_x;
p2.y=ip.pos.y-task->pix_top-task->scroll_y;
p2.z=0;
D3Sub(&p2,&cursor_mass->state->x,&p);
D3Sub(&p,&p2,&cursor_mass->state->x);
d=10.0*D3NormSqr(&p);
D3MulEqu(&p,d);
D3AddEqu(&cursor_mass->DstateDt->DxDt,&p);
+4 -4
View File
@@ -10,18 +10,18 @@ F64 Cost(CMathODE *ode)
{
MyMass *tempm;
MySpring *temps;
F64 result=0;
F64 res=0;
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
result+=tempm->cost;
res+=tempm->cost;
tempm=tempm->next;
}
temps=ode->next_spring;
while (temps!=&ode->next_spring) {
result+=temps->cost;
res+=temps->cost;
temps=temps->next;
}
return result;
return res;
}
U0 DrawIt(CTask *task,CDC *dc)
+6 -6
View File
@@ -25,7 +25,7 @@ U0 SpanDel(CMathODE *ode)
U8 *SpanSave(CMathODE *ode,I64 *_size=NULL)
{
I64 cnt;
U8 *result,*ptr;
U8 *res,*ptr;
MyMass *tempm;
MySpring *temps;
SpanHeader h;
@@ -43,7 +43,7 @@ U8 *SpanSave(CMathODE *ode,I64 *_size=NULL)
cnt=sizeof(SpanHeader)+h.num_masses*M_SIZE+h.num_springs*S_SIZE;
ptr=result=MAlloc(cnt);
ptr=res=MAlloc(cnt);
MemCpy(ptr,&h,sizeof(SpanHeader));
ptr+=sizeof(SpanHeader);
@@ -61,25 +61,25 @@ U8 *SpanSave(CMathODE *ode,I64 *_size=NULL)
temps=temps->next;
}
if (_size) *_size=cnt;
return result;
return res;
}
Bool SpanWrite(CMathODE *ode)
{
U8 *name,*buf;
I64 size;
Bool result=FALSE,old_silent=Silent;
Bool res=FALSE,old_silent=Silent;
MkDir("::/Home/Span");
Silent(old_silent);
if (name=PopUpFileName("::/Home/Span/Game.DAT")) {
if (buf=SpanSave(ode,&size)) {
FileWrite(name,buf,size);
Free(buf);
result=TRUE;
res=TRUE;
}
Free(name);
}
return result;
return res;
}
U0 SpanLoad(CMathODE *ode,U8 *src)
+2 -2
View File
@@ -194,7 +194,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
while (tempm1!=&ode->next_mass) {
tempm2=tempm1->next;
while (tempm2!=&ode->next_mass) {
D3Sub(&tempm2->state->x,&tempm1->state->x,&p);
D3Sub(&p,&tempm2->state->x,&tempm1->state->x);
dd=D3NormSqr(&p);
if (dd<=Sqr(2*RADIUS)) {
d=Sqrt(dd)+0.0001;
@@ -212,7 +212,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
while (temps!=&ode->next_spring) {
if (main_mode_button.state==MMD_PLAY && temps->type==EMD_THRUSTER &&
Bt(kbd.down_bitmap,action_scan_codes[temps->action_key-'0'])) {
D3Sub(&temps->end2->state->x,&temps->end1->state->x,&p);
D3Sub(&p,&temps->end2->state->x,&temps->end1->state->x);
D3Unit(&p);
D3MulEqu(&p,2000);
D3AddEqu(&temps->end1->DstateDt->DxDt,&p);
+1 -1
View File
@@ -198,7 +198,7 @@ U0 MPDrawMen(CDC *dc2)
tt=4*Wrap(tempm->phase+5*ts,0)/(2*ã);
}
phase=tt; tt%=1.0;
temps=SpriteInterpolate(_temps[phase&3],_temps[(phase+1)&3],tt);
temps=SpriteInterpolate(tt,_temps[phase&3],_temps[(phase+1)&3]);
SpriteMat3B(dc,tempm->x,yy,GR_Z_ALL,temps,r);
Free(temps);
}
+31 -31
View File
@@ -199,11 +199,11 @@ U0 Toward(I64 *_row,I64 *_col,I64 direction)
I64 FacingChg(I64 f1,I64 f2)
{
I64 result=(f1+6-f2)%6;
if (result>=3)
return 6-result;
I64 res=(f1+6-f2)%6;
if (res>=3)
return 6-res;
else
return result;
return res;
}
U0 RowCol2XY(F64 *_x,F64 *_y,I64 row,I64 col)
@@ -335,7 +335,7 @@ U0 RVMerge(I64 player)
Bool MPRecalcVisible(MPCtrl1 *job)
{
Bool result=FALSE,seen;
Bool res=FALSE,seen;
I64 i,j,row,col;
F64 x1,y1,x2,y2,dd,range;
Unit *ut0,*ut1;
@@ -376,7 +376,7 @@ Bool MPRecalcVisible(MPCtrl1 *job)
LOS(row,col,ut1->row,ut1->col)) {
LBts(&visible_unit_bitmap[enemy_player],
job->tempu->num+i*((MAX_UNITS+7)&~7));
result=TRUE;
res=TRUE;
} else
LBtr(&visible_unit_bitmap[enemy_player],
job->tempu->num+i*((MAX_UNITS+7)&~7));
@@ -416,13 +416,13 @@ Bool MPRecalcVisible(MPCtrl1 *job)
LBtr(&visible_unit_bitmap[enemy_player],j+i*((MAX_UNITS+7)&~7));
break;
}
return result;
return res;
}
Bool RecalcVisible(I64 mode,Unit *tempu=NULL)
{
I64 i,hi,k,cnt;
Bool result;
Bool res;
/*The compiler doesn't go out of it's way
to know if something is const.;-) This
just compiles with the val at compile
@@ -462,15 +462,15 @@ $LK,"MAlloc",A="MN:MAlloc"$() would probably be the better choice.
job[i].lo=k;
}
result=FALSE;
res=FALSE;
for (i=0;i<cnt;i++)
cmd[i]=JobQue(&MPRecalcVisible,&job[i],i,0);
for (i=0;i<cnt;i++)
if (JobResultGet(cmd[i]))
result=TRUE;
if (JobResGet(cmd[i]))
res=TRUE;
if (mode==RV_UPDATE_FRIENDLY_UNIT)
RVMerge(cur_player);
return result;
return res;
}
class MPCtrl2
@@ -512,30 +512,30 @@ U0 RecalcVisibleMap(I64 row,I64 col)
for (i=0;i<cnt;i++)
cmd[i]=JobQue(&MPRecalcVisibleMap,&job[i],i,0);
for (i=0;i<cnt;i++)
JobResultGet(cmd[i]);
JobResGet(cmd[i]);
}
I64 MoveCost(Unit *tempu,I64 r,I64 c,I64 facing)
{
I64 result;
I64 res;
if (tempu->infantry)
result=0;
res=0;
else {
result=FacingChg(facing,tempu->facing);
if (result>0) result--;
res=FacingChg(facing,tempu->facing);
if (res>0) res--;
}
if (roads[r][c] && roads[tempu->row][tempu->col])
result+=1;
res+=1;
else {
if (tempu->infantry)
result+=2;
res+=2;
else {
result+=movement_costs[terrain[r][c]];
res+=movement_costs[terrain[r][c]];
if (rivers[r][c])
result=tempu->movement;
res=tempu->movement;
}
}
return result;
return res;
}
I64 MoveOneHex(I64 *_row,I64 *_col,F64 x,F64 y)
@@ -1633,7 +1633,7 @@ U0 TaskEndCB()
I64 DoPhase()
{
I64 result='ExitGame';
I64 res='ExitGame';
NewPhase;
try {
if (phase&~1==PHASE_PLOT)
@@ -1643,15 +1643,15 @@ I64 DoPhase()
else
Call(fire_routines[cur_player]);
} catch {
result=Fs->except_ch;
res=Fs->except_ch;
Fs->catch_except=TRUE;
}
return result;
return res;
}
U0 ToTheFront()
{
I64 result,ch;
I64 res,ch;
map_dc=DCNew(MAP_WIDTH,MAP_HEIGHT);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
@@ -1697,8 +1697,8 @@ U0 ToTheFront()
try {
do {
result=DoPhase;
if (result=='GameOver') {
res=DoPhase;
if (res=='GameOver') {
while (TRUE) {
msg_off_timeout=0;
StrCpy(msg_buf,"Game Over");
@@ -1709,18 +1709,18 @@ U0 ToTheFront()
Init;
break;
} else if (ch==CH_ESC || ch==CH_SHIFT_ESC) {
result='ExitGame';
res='ExitGame';
break;
} else if (ch=='1')
SetViewPlayer(0);
else if (ch=='2')
SetViewPlayer(1);
}
} else if (result=='NewGame') {
} else if (res=='NewGame') {
CleanUp;
Init;
}
} while (result!='ExitGame');
} while (res!='ExitGame');
} catch
PutExcept;
ProgressBarsRst;
+365 -101
View File
@@ -41,6 +41,7 @@ class MyMass:CMass
F64 temperature;
F64 radius;
I64 color;
Bool no_overlap;
};
class MySpring:CSpring
@@ -52,9 +53,26 @@ class MySpring:CSpring
#define SPIN_GAIN 0.25
#define MAX_MASSES 8
#define MAX_SPRINGS 16
#define MAX_MISSILES 2
#define ST_HUMAN1 0
#define ST_ENEMY1 1
#define ST_ENEMY2 2
extern class Ship;
#define MISSILE_LEN 5
class Missile
{
Missile *next,*last;
F64 explosion_radius;
F64 fuse_time,die_timeout;
MyMass p_front,p_back;
MySpring s[5];
U8 *img;
Ship *owner,*target;
Bool active,launched,exploding;
U8 label[5];
} missile_root;
class Ship
{
Ship *next,*last;
@@ -66,19 +84,20 @@ class Ship
F64 die_time,die_timeout;
I64 spacewalk_side;
F64 laser_temperature;
Missile missiles[MAX_MISSILES];
Bool lasering,exploding,laser_overheat;
} *human;
} ship_root,*human;
F64 human_t_left,human_t_right,human_antispin;
class Shot
{
Shot *next,*last;
F64 radius;
F64 radius,explosion_radius;
F64 fuse_time,die_timeout;
MyMass p;
Bool exploding;
};
} shot_root;
#define MAX_THRUST 200.0
#define MAX_ANTISPIN 25.0
@@ -95,8 +114,6 @@ Bool game_over,show_level_msg;
#define NUM_STARS 100
I64 stars_x[NUM_STARS],stars_y[NUM_STARS];
Ship ship_root;
Shot shot_root;
CMathODE *ode=NULL;
I64 level,score,remaining;
@@ -114,6 +131,10 @@ $SP,"<5>",BI=5$
$SP,"<6>",BI=6$
$SP,"<7>",BI=7$
$SP,"<8>",BI=8$
$BG$
//********************************** Ship
Bool CheckOverlap()
@@ -124,8 +145,8 @@ Bool CheckOverlap()
while (tempm!=&ode->next_mass) {
tempm1=ode->next_mass;
while (tempm1!=&ode->next_mass) {
if (tempm!=tempm1) {
D3Sub(&tempm->x,&tempm1->x,&p);
if (tempm!=tempm1 && !tempm->no_overlap && !tempm1->no_overlap) {
D3Sub(&p,&tempm->x,&tempm1->x);
if (D3NormSqr(&p)<=Sqr(tempm->radius+tempm1->radius))
return TRUE;
}
@@ -136,6 +157,63 @@ Bool CheckOverlap()
return FALSE;
}
U0 MissileNew(Ship *tempsp,I64 n)
{
I64 i;
CD3 p,p1,p2;
Missile *tempmi=&tempsp->missiles[n];
MemSet(tempmi,0,sizeof(Missile));
D3Equ(&tempmi->p_front.x,
(tempsp->p[n+1].x+tempsp->p[n+3].x)/2,
(tempsp->p[n+1].y+tempsp->p[n+3].y)/2,0);
D3Copy(&tempmi->p_back.x,&tempmi->p_front.x);
if (n&1)
StrCpy(tempmi->label,"L");
else
StrCpy(tempmi->label,"R");
tempmi->owner=tempsp;
tempmi->explosion_radius=5;
tempmi->p_front.mass=0.1;
tempmi->p_back.mass =0.1;
tempmi->p_front.radius=2;
tempmi->p_back.radius =2;
tempmi->p_front.no_overlap=TRUE;
tempmi->p_back.no_overlap =TRUE;
D3Sub(&p1,&tempsp->p[0].x,&tempsp->p[1].x);
D3Sub(&p2,&tempsp->p[0].x,&tempsp->p[2].x);
D3Unit(D3Add(&p,&p1,&p2));
D3AddEqu(&tempmi->p_front.x,D3MulEqu(D3Copy(&p1,&p),MISSILE_LEN/2+1));
D3SubEqu(&tempmi->p_back.x ,D3MulEqu(D3Copy(&p1,&p),MISSILE_LEN/2-1));
D3Copy(&tempmi->p_front.DxDt,&tempsp->p[n].DxDt);
D3Copy(&tempmi->p_back.DxDt,&tempsp->p[n].DxDt);
QueIns(&tempmi->p_front,ode->last_mass);
QueIns(&tempmi->p_back, ode->last_mass);
tempmi->s[0].end1=&tempmi->p_front;
tempmi->s[0].end2=&tempmi->p_back;
tempmi->s[1].end1=&tempmi->p_front;
tempmi->s[1].end2=&tempsp->p[n+1];
tempmi->s[2].end1=&tempmi->p_back;
tempmi->s[2].end2=&tempsp->p[n+1];
tempmi->s[3].end1=&tempmi->p_front;
tempmi->s[3].end2=&tempsp->p[n+3];
tempmi->s[4].end1=&tempmi->p_back;
tempmi->s[4].end2=&tempsp->p[n+3];
for (i=0;i<5;i++) {
tempmi->s[i].const=10000;
tempmi->s[i].strength =20000;
tempmi->s[i].color=BLACK;
tempmi->s[i].rest_len=D3Dist(&tempmi->s[i].end1->x,&tempmi->s[i].end2->x);
QueIns(&tempmi->s[i],ode->last_spring);
}
tempmi->img=$IB,"<7>",BI=7$;
tempmi->active=TRUE;
QueIns(tempmi,missile_root.last);
}
Ship *ShipNew(I64 x,I64 y,I64 type)
{
I64 i;
@@ -195,6 +273,8 @@ Ship *ShipNew(I64 x,I64 y,I64 type)
tempsp->s[i].color=LTGRAY;
QueIns(&tempsp->s[i],ode->last_spring);
}
MissileNew(tempsp,0);
MissileNew(tempsp,1);
remaining=0;
break;
@@ -289,6 +369,19 @@ Ship *ShipNew(I64 x,I64 y,I64 type)
return tempsp;
}
U0 MissileDel(Missile *tempmi)
{
I64 i;
if (tempmi->active) {
QueRem(tempmi);
for(i=0;i<5;i++)
QueRem(&tempmi->s[i]);
QueRem(&tempmi->p_front);
QueRem(&tempmi->p_back);
tempmi->active=FALSE;
}
}
U0 ShipDel(Ship *tempsp)
{
I64 i;
@@ -297,6 +390,8 @@ U0 ShipDel(Ship *tempsp)
QueRem(&tempsp->p[i]);
for (i=0;i<tempsp->springs;i++)
QueRem(&tempsp->s[i]);
for (i=0;i<2;i++)
MissileDel(&tempsp->missiles[i]);
QueRem(tempsp);
Free(tempsp);
remaining--;
@@ -323,12 +418,12 @@ I64 Tweaked()
{
CD3 p,p1,p2;
if (human) {
D3Sub(&human->p[0].x,&human->p[1].x,&p1);
D3Sub(&human->p[0].x,&human->p[2].x,&p2);
D3Add(&p1,&p2,&p);
D3Sub(&p1,&human->p[0].x,&human->p[1].x);
D3Sub(&p2,&human->p[0].x,&human->p[2].x);
D3Add(&p,&p1,&p2);
D3Unit(&p);
D3Sub(&human->p[0].x,&human->p[3].x,&p1);
D3Sub(&human->p[0].x,&human->p[4].x,&p2);
D3Sub(&p1,&human->p[0].x,&human->p[3].x);
D3Sub(&p2,&human->p[0].x,&human->p[4].x);
D3Unit(&p1);
D3Unit(&p2);
if (!(human->s[3].flags&SSF_INACTIVE) && D3Dot(&p,&p1)>Cos(20*ã/180))
@@ -373,6 +468,7 @@ U0 DrawIt(CTask *task,CDC *dc)
F64 arg;
Ship *tempsp;
Shot *temps;
Missile *tempmi;
CD3 p,p1,p2;
F64 t_left,t_right,spin,d,x,y;
MySpring *tempsps;
@@ -398,7 +494,7 @@ U0 DrawIt(CTask *task,CDC *dc)
tempsps=ode->next_spring;
while (tempsps!=&ode->next_spring) {
if (!(tempsps->flags&SSF_INACTIVE)) {
if (!(tempsps->flags&SSF_INACTIVE) && tempsps->color) {
dc->color=tempsps->color;
GrLine(dc,tempsps->end1->x,tempsps->end1->y,
tempsps->end2->x,tempsps->end2->y);
@@ -406,6 +502,28 @@ U0 DrawIt(CTask *task,CDC *dc)
tempsps=tempsps->next;
}
tempmi=missile_root.next;
while (tempmi!=&missile_root) {
if (tempmi->active) {
if (tempmi->launched && tempmi->exploding) {
d=(tS-tempmi->fuse_time)/(tempmi->die_timeout-tempmi->fuse_time);
d=7*Sin(ã*d)*tempmi->explosion_radius+1;
for (i=1;i<d;i++) {
if (i&1)
dc->color=YELLOW;
else
dc->color=LTRED;
GrCircle(dc,tempmi->p_front.x,tempmi->p_front.y,i);
}
} else
SpriteZ3B(dc,(tempmi->p_front.x+tempmi->p_back.x)/2,
(tempmi->p_front.y+tempmi->p_back.y)/2,0,tempmi->img,
Arg(tempmi->p_front.x-tempmi->p_back.x,
tempmi->p_front.y-tempmi->p_back.y));
}
tempmi=tempmi->next;
}
tempsp=ship_root.next;
while (tempsp!=&ship_root) {
if (!tempsp->exploding)
@@ -415,18 +533,18 @@ U0 DrawIt(CTask *task,CDC *dc)
t_left=0;
t_right=0;
} else {
if (d=D3Norm(D3Sub(&tempsp->p[0].x,&tempsp->p[1].x,&p1))) {
D3Sub(&tempsp->p[0].DxDt,&tempsp->p[1].DxDt,&p2);
D3Cross(&p1,&p2,&p);
if (d=D3Norm(D3Sub(&p1,&tempsp->p[0].x,&tempsp->p[1].x))) {
D3Sub(&p2,&tempsp->p[0].DxDt,&tempsp->p[1].DxDt);
D3Cross(&p,&p1,&p2);
spin=p.z/d;
} else
spin=0;
t_left =Clamp(human_t_left+SPIN_GAIN*spin*human_antispin,
0,MAX_THRUST);
if (d=D3Norm(D3Sub(&tempsp->p[0].x,&tempsp->p[2].x,&p1))) {
D3Sub(&tempsp->p[0].DxDt,&tempsp->p[2].DxDt,&p2);
D3Cross(&p1,&p2,&p);
if (d=D3Norm(D3Sub(&p1,&tempsp->p[0].x,&tempsp->p[2].x))) {
D3Sub(&p2,&tempsp->p[0].DxDt,&tempsp->p[2].DxDt);
D3Cross(&p,&p1,&p2);
spin=p.z/d;
} else
spin=0;
@@ -434,13 +552,13 @@ U0 DrawIt(CTask *task,CDC *dc)
0,MAX_THRUST);
}
D3Sub(&tempsp->p[1].x,&tempsp->p[0].x,&p1);
D3Sub(&tempsp->p[2].x,&tempsp->p[0].x,&p2);
D3Unit(D3Add(&p1,&p2,&p));
D3Sub(&p1,&tempsp->p[1].x,&tempsp->p[0].x);
D3Sub(&p2,&tempsp->p[2].x,&tempsp->p[0].x);
D3Unit(D3Add(&p,&p1,&p2));
if (!(tempsp->s[3].flags&SSF_INACTIVE)) {
dc->color=YELLOW;
D3AddEqu(D3Mul(t_left/25,&p,&p1),&tempsp->p[3].x);
D3AddEqu(D3Mul(&p1,t_left/25,&p),&tempsp->p[3].x);
GrLine(dc,tempsp->p[1].x,tempsp->p[1].y,p1.x,p1.y);
arg=Arg(p.x,p.y);
SpriteZ3B(dc,tempsp->p[3].x,tempsp->p[3].y,0,$IB,"<thruster>",BI=1$,arg);
@@ -448,7 +566,7 @@ U0 DrawIt(CTask *task,CDC *dc)
if (!(tempsp->s[5].flags&SSF_INACTIVE)) {
dc->color=YELLOW;
D3AddEqu(D3Mul(t_right/25,&p,&p2),&tempsp->p[4].x);
D3AddEqu(D3Mul(&p2,t_right/25,&p),&tempsp->p[4].x);
GrLine(dc,tempsp->p[2].x,tempsp->p[2].y,p2.x,p2.y);
arg=Arg(p.x,p.y);
SpriteZ3B(dc,tempsp->p[4].x,tempsp->p[4].y,0,$IB,"<thruster>",BI=1$,arg);
@@ -522,9 +640,9 @@ U0 DrawIt(CTask *task,CDC *dc)
GrCircle(dc,tempsp->p[i].x,tempsp->p[i].y,tempsp->p[i].radius);
}
case ST_ENEMY1:
D3DivEqu(D3Sub(&tempsp->p[1].x,&tempsp->p[0].x,&p1),2.0);
D3DivEqu(D3Sub(&tempsp->p[2].x,&tempsp->p[0].x,&p2),2.0);
D3Unit(D3Add(&p1,&p2,&p));
D3DivEqu(D3Sub(&p1,&tempsp->p[1].x,&tempsp->p[0].x),2.0);
D3DivEqu(D3Sub(&p2,&tempsp->p[2].x,&tempsp->p[0].x),2.0);
D3Unit(D3Add(&p,&p1,&p2));
if (tS>tempsp->reload_timeout)
img=$IB,"<gun_ready>",BI=2$;
else
@@ -562,9 +680,9 @@ U0 DrawIt(CTask *task,CDC *dc)
temps=shot_root.next;
while (temps!=&shot_root) {
if (tS>temps->fuse_time) {
if (temps->exploding) {
d=(tS-temps->fuse_time)/(temps->die_timeout-temps->fuse_time);
d=7*Sin(ã*d)*temps->radius+1;
d=7*Sin(ã*d)*temps->explosion_radius+1;
for (i=1;i<d;i++) {
if (i&1)
dc->color=YELLOW;
@@ -589,16 +707,26 @@ U0 DrawIt(CTask *task,CDC *dc)
}
if (human && draw_laser_line) {
D3Sub(&human->p[1].x,&human->p[0].x,&p1);
D3Sub(&human->p[2].x,&human->p[0].x,&p2);
D3Unit(D3Add(&p1,&p2,&p));
D3Sub(&p1,&human->p[1].x,&human->p[0].x);
D3Sub(&p2,&human->p[2].x,&human->p[0].x);
D3Unit(D3Add(&p,&p1,&p2));
dc->color=LTBLUE;
Line(dc,human->p[0].x-10*p.x,human->p[0].y-10*p.y,0,
human->p[0].x-800*p.x,human->p[0].y-800*p.y,0,&LaserPlot);
}
tempmi=missile_root.next;
while (tempmi!=&missile_root) {
if (tempsp=tempmi->target) {
dc->color=LTRED;
GrCircle(dc,tempsp->p[0].x,tempsp->p[0].y,10);
GrPrint(dc,tempsp->p[0].x+12,tempsp->p[0].y-4,tempmi->label);
}
tempmi=tempmi->next;
}
}
U0 Explosion(MyMass *tempm1,F64 r)
U0 Explosion(MyMass *tempm1,MyMass *tempm2,F64 r)
{
MyMass *tempm;
CD3 p1;
@@ -606,8 +734,8 @@ U0 Explosion(MyMass *tempm1,F64 r)
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
if (tempm!=tempm1) {
D3Sub(&tempm->state->x,&tempm1->state->x,&p1);
if (tempm!=tempm1 && tempm!=tempm2) {
D3Sub(&p1,&tempm->state->x,&tempm1->state->x);
d=D3NormSqr(&p1)-tempm->radius*tempm->radius;
if (d<100.0*100.0) {
if (d<1)
@@ -624,14 +752,42 @@ U0 Explosion(MyMass *tempm1,F64 r)
}
}
Ship TargetGet(Missile *tempmi)
{
Ship *tempsp,*res=NULL;
F64 dd,best_dd=MAX_F64;
I64 i;
CD3 p,p1,p2;
D3Unit(D3Sub(&p,&tempmi->p_front.state->x,&tempmi->p_back.state->x));
tempsp=ship_root.next;
while (tempsp!=&ship_root) {
if (!tempsp->exploding && tempsp!=tempmi->owner)
for (i=0;i<tempsp->masses;i++) {
D3Sub(&p1,&tempsp->p[i].state->x,&tempmi->p_front.state->x);
D3Unit(D3Copy(&p2,&p1));
D3Cross(&p1,&p,&p2);
if (D3Dot(&p,&p2)>0 && D3Norm(&p1)<=ã/16) {
dd=D3NormSqr(&p1);
if (dd<best_dd) {
best_dd=dd;
res=tempsp;
}
}
}
tempsp=tempsp->next;
}
return res;
}
U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
{
I64 i;
F64 d,dd,dd2,spin,t_left,t_right;
F64 d,dd,dd2,spin,t_left,t_right,é_err,é_thrust,DéDt;
CTask *task=ode->win_task;
CD3 p,p1,p2;
Shot *temps;
Ship *tempsp;
Shot *temps;
Missile *tempmi;
MyMass *tempm,*tempm1;
tempm=ode->next_mass;
@@ -650,7 +806,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
tempm1=ode->next_mass;
while (tempm1!=&ode->next_mass) {
if (tempm!=tempm1) {
D3Sub(&tempm->state->x,&tempm1->state->x,&p);
D3Sub(&p,&tempm->state->x,&tempm1->state->x);
dd=D3NormSqr(&p);
dd2=Sqr(tempm->radius+tempm1->radius);
if (dd<=dd2) {
@@ -669,7 +825,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
while (tempsp!=&ship_root) {
if (tempsp->exploding && tempsp->die_time<=tS<=tempsp->die_timeout)
for (i=0;i<tempsp->masses;i++)
Explosion(&tempsp->p[i],tempsp->p[i].radius/3.0);
Explosion(&tempsp->p[i],NULL,tempsp->p[i].radius/3.0);
switch (tempsp->type) {
case ST_HUMAN1:
if (!tempsp->exploding) {
@@ -678,7 +834,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
t_right=0;
d=1.0-(tempsp->spacewalk_timeout-tS)/SPACEWALK_TIME;
if (0.485<d<0.515) {
D3Unit(D3Sub(&tempsp->p[2].state->x,&tempsp->p[1].state->x,&p));
D3Unit(D3Sub(&p,&tempsp->p[2].state->x,&tempsp->p[1].state->x));
if (tempsp->spacewalk_side==3) {
tempsp->p[3].DstateDt->DxDt-=10*MAX_THRUST*p.x;
tempsp->p[3].DstateDt->DyDt-=10*MAX_THRUST*p.y;
@@ -692,35 +848,35 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
}
}
} else {
if (d=D3Norm(D3Sub(&tempsp->p[0].state->x,
&tempsp->p[1].state->x,&p1))) {
D3Sub(&tempsp->p[0].state->DxDt,&tempsp->p[1].state->DxDt,&p2);
D3Cross(&p1,&p2,&p);
if (d=D3Norm(D3Sub(&p1,&tempsp->p[0].state->x,
&tempsp->p[1].state->x))) {
D3Sub(&p2,&tempsp->p[0].state->DxDt,&tempsp->p[1].state->DxDt);
D3Cross(&p,&p1,&p2);
spin=p.z/d;
} else
spin=0;
t_left =Clamp(human_t_left+SPIN_GAIN*spin*human_antispin,
0,MAX_THRUST);
if (d=D3Norm(D3Sub(&tempsp->p[0].state->x,
&tempsp->p[2].state->x,&p1))) {
D3Sub(&tempsp->p[0].state->DxDt,&tempsp->p[2].state->DxDt,&p2);
D3Cross(&p1,&p2,&p);
if (d=D3Norm(D3Sub(&p1,&tempsp->p[0].state->x,
&tempsp->p[2].state->x))) {
D3Sub(&p2,&tempsp->p[0].state->DxDt,&tempsp->p[2].state->DxDt);
D3Cross(&p,&p1,&p2);
spin=p.z/d;
} else
spin=0;
t_right=Clamp(human_t_right-SPIN_GAIN*spin*human_antispin,
0,MAX_THRUST);
D3Sub(&tempsp->p[0].state->x,&tempsp->p[1].state->x,&p1);
D3Sub(&tempsp->p[0].state->x,&tempsp->p[2].state->x,&p2);
D3Unit(D3Add(&p1,&p2,&p));
D3Sub(&p1,&tempsp->p[0].state->x,&tempsp->p[1].state->x);
D3Sub(&p2,&tempsp->p[0].state->x,&tempsp->p[2].state->x);
D3Unit(D3Add(&p,&p1,&p2));
if (!(tempsp->s[3].flags&SSF_INACTIVE)) {
D3Mul(t_left,&p,&p1);
D3Mul(&p1,t_left,&p);
D3AddEqu(&tempsp->p[3].DstateDt->DxDt,&p1);
}
if (!(tempsp->s[5].flags&SSF_INACTIVE)) {
D3Mul(t_right,&p,&p2);
D3Mul(&p2,t_right,&p);
D3AddEqu(&tempsp->p[4].DstateDt->DxDt,&p2);
}
}
@@ -732,10 +888,44 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
temps=shot_root.next;
while (temps!=&shot_root) {
if (temps->fuse_time<=tS<=temps->die_timeout)
Explosion(&temps->p,temps->radius);
if (temps->exploding)
Explosion(&temps->p,NULL,temps->explosion_radius);
temps=temps->next;
}
tempmi=missile_root.next;
while (tempmi!=&missile_root) {
if (tempmi->active) {
if (tempmi->launched) {
if (tempmi->exploding)
Explosion(&tempmi->p_front,&tempmi->p_back,tempmi->explosion_radius);
else {
//Guide missile
if (tempsp=tempmi->target) {
D3Unit(D3Sub(&p,&tempmi->p_front.state->x,
&tempmi->p_back.state->x));
D3Sub(&p1,&tempsp->p[0].state->x,&tempmi->p_front.state->x);
d=D3Norm(&p1);
D3Unit(&p1);
é_err=D3Dot(&p,&p1);
D3Sub(&p1,&tempmi->p_front.state->DxDt,&tempmi->p_back.state->DxDt);
D3Cross(&p2,&p,&p1);
DéDt=D3Norm(&p2);
if (p2.z<0)
DéDt=-DéDt;
é_thrust=Clamp(200*(é_err+2*DéDt)/(d+200),-ã/8,ã/8);
p2.x=p.x*Cos(é_thrust)-p.y*Sin(é_thrust);
p2.y=p.y*Cos(é_thrust)+p.x*Sin(é_thrust);
p2.z=0;
D3AddEqu(&tempmi->p_back.DstateDt->DxDt,D3MulEqu(&p2,MAX_THRUST));
}
}
} else
tempmi->target=TargetGet(tempmi);
} else
tempmi->target=NULL;
tempmi=tempmi->next;
}
}
U0 CheckDamage()
@@ -764,9 +954,9 @@ U0 CheckDamage()
Snd(0);
} else {
human->laser_temperature+=1.0;
D3Sub(&human->p[0].x,&human->p[1].x,&p1);
D3Sub(&human->p[0].x,&human->p[2].x,&p2);
D3Unit(D3Add(&p1,&p2,&p));
D3Sub(&p1,&human->p[0].x,&human->p[1].x);
D3Sub(&p2,&human->p[0].x,&human->p[2].x);
D3Unit(D3Add(&p,&p1,&p2));
p2.x=p.y;
p2.y=-p.x;
p2.z=0;
@@ -774,7 +964,7 @@ U0 CheckDamage()
best_distance=MAX_F64;
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
D3Sub(&human->p[0].x,&tempm->x,&p1);
D3Sub(&p1,&human->p[0].x,&tempm->x);
if (Abs(D3Dot(&p1,&p2))<tempm->radius &&
D3Dot(&p1,&p)<0.0) {
d=D3NormSqr(&p1);
@@ -803,8 +993,13 @@ U0 CheckDamage()
}
} else
for (i=0;i<tempsp->springs;i++) {
if (Abs(tempsp->s[i].f)>tempsp->s[i].strength)
if (Abs(tempsp->s[i].f)>tempsp->s[i].strength) {
tempsp->s[i].flags|=SSF_INACTIVE;
if (i==4)
MissileDel(&tempsp->missiles[0]);
else if (i==5)
MissileDel(&tempsp->missiles[1]);
}
if (tempsp->s[i].flags&SSF_INACTIVE) {
if (i<3) {
if (!tempsp->exploding) {
@@ -856,33 +1051,47 @@ U0 CheckDamage()
//********************************** Shots
U0 FireOneGun(Ship *tempsp,I64 g,F64 r,F64 fuse_time)
U0 FireOneGun(Ship *tempsp,I64 n,F64 r,F64 fuse_time)
{
CD3 p,p1,p2;
Shot *temps;
temps=CAlloc(sizeof(Shot));
D3Copy(&temps->p.x,&tempsp->p[g].x);
temps->radius=r;
D3Copy(&temps->p.x,&tempsp->p[n].x);
temps->explosion_radius=temps->radius=r;
temps->fuse_time=tS+1.5*fuse_time;
temps->die_timeout=temps->fuse_time+0.125;
temps->p.mass=0.3*r*r*r;
D3Sub(&tempsp->p[0].x,&tempsp->p[1].x,&p1);
D3Sub(&tempsp->p[0].x,&tempsp->p[2].x,&p2);
D3Add(&p1,&p2,&p);
D3AddEqu(&temps->p.x,
D3MulEqu(D3Copy(&p1,D3Unit(&p)),r+tempsp->p[0].radius+5));
D3AddEqu(D3MulEqu(&p,1000/(r+1)),&tempsp->p[g].DxDt);
D3Sub(&p1,&tempsp->p[0].x,&tempsp->p[1].x);
D3Sub(&p2,&tempsp->p[0].x,&tempsp->p[2].x);
D3Unit(D3Add(&p,&p1,&p2));
D3AddEqu(&temps->p.x,D3MulEqu(D3Copy(&p1,&p),r+tempsp->p[0].radius+5));
D3AddEqu(D3MulEqu(&p,1000/(r+1)),&tempsp->p[n].DxDt);
D3Copy(&temps->p.DxDt,&p);
D3MulEqu(&p,temps->p.mass/tempsp->p[g].mass/100.0);
D3SubEqu(&tempsp->p[g].DxDt,&p);
D3MulEqu(&p,temps->p.mass/tempsp->p[n].mass/100.0);
D3SubEqu(&tempsp->p[n].DxDt,&p);
QueIns(&temps->p,ode->last_mass);
QueIns(temps,shot_root.last);
tempsp->reload_timeout=tS+r/tempsp->fire_rate;
Noise(100,r*200,r*400);
}
U0 HumanFireBegin()
U0 FireOneMissile(Ship *tempsp,I64 n)
{
I64 i;
Missile *tempmi=&tempsp->missiles[n];
if (!tempmi->launched && tempmi->target) {
tempmi->fuse_time=tS+1.0;
tempmi->die_timeout=tempmi->fuse_time+0.125;
tempmi->img=$IB,"<8>",BI=8$;
for (i=1;i<5;i++)
tempmi->s[i].flags|=SSF_INACTIVE;
tempmi->launched=TRUE;
Sweep(250,300,350);
}
}
U0 HumanFireGunBegin()
{
F64 r=3.0*ctrl_panel.shot_radius/CTRL_PANEL_RANGE+0.5,
fuse_time=ToF64(ctrl_panel.fuse_time+1)/CTRL_PANEL_RANGE;
@@ -902,41 +1111,72 @@ U0 HumanFireBegin()
case 1:
FireOneGun(human,0,r,fuse_time);
break;
default:
human->lasering=TRUE;
}
}
}
U0 HumanFireEnd()
U0 HumanFireMissileBegin(I64 n)
{
if (human && !human->exploding)
switch (level) {
case 3:
case 2:
case 1:
break;
default:
human->lasering=FALSE;
Snd(0);
}
if (human && !human->exploding &&
!human->spacewalk_side && tS>human->reload_timeout)
FireOneMissile(human,n);
}
U0 HumanFireLaserBegin()
{
if (human && !human->exploding &&
!human->spacewalk_side && tS>human->reload_timeout)
human->lasering=TRUE;
}
U0 HumanFireLaserEnd()
{
if (human && !human->exploding) {
human->lasering=FALSE;
Snd(0);
}
}
U0 ExpireShots()
{
Shot *temps=shot_root.next,*tempb1;
Shot *temps=shot_root.next,*temps1;
while (temps!=&shot_root) {
tempb1=temps->next;
if (tS>temps->fuse_time && !temps->exploding) {
temps1=temps->next;
if (!temps->exploding && tS>temps->fuse_time) {
temps->exploding=TRUE;
Noise(50,3000,6000);
}
if (tS>temps->die_timeout) {
} else if (tS>temps->die_timeout) {
QueRem(temps);
QueRem(&temps->p);
Free(temps);
}
temps=tempb1;
temps=temps1;
}
}
U0 ExpireMissiles()
{
I64 i;
F64 dd,best_dd;
Missile *tempmi=missile_root.next,*tempm1;
while (tempmi!=&missile_root) {
tempm1=tempmi->next;
if (tempmi->launched) {
best_dd=MAX_F64;
if (tempmi->target)
for (i=0;i<tempmi->target->masses;i++) {
dd=D3DistSqr(&tempmi->p_front.x,&tempmi->target->p[i].x);
if (dd<best_dd)
best_dd=dd;
}
if (!tempmi->exploding && (best_dd<30*30 || tS>tempmi->fuse_time)) {
tempmi->p_front.mass=10.0; //They go flying, if too light.
tempmi->p_back.mass =10.0;
tempmi->exploding=TRUE;
Noise(50,3000,6000);
} else if (tS>tempmi->die_timeout)
MissileDel(tempmi);
}
tempmi=tempm1;
}
}
@@ -948,10 +1188,10 @@ U0 AI()
Ship *tempsp=ship_root.next;
if (human && !human->exploding) {
while (tempsp!=&ship_root) {
D3Sub(&tempsp->p[0].x,&tempsp->p[1].x,&p1);
D3Sub(&tempsp->p[0].x,&tempsp->p[2].x,&p2);
D3Add(&p1,&p2,&p);
D3Sub(&human->p[0].x,&tempsp->p[0].x,&p1);
D3Sub(&p1,&tempsp->p[0].x,&tempsp->p[1].x);
D3Sub(&p2,&tempsp->p[0].x,&tempsp->p[2].x);
D3Add(&p,&p1,&p2);
D3Sub(&p1,&human->p[0].x,&tempsp->p[0].x);
if (D3Dot(D3Unit(&p),D3Unit(&p1))>0.995 &&
tS>tempsp->reload_timeout) {
FireOneGun(tempsp,0,1.5+.5,.4);
@@ -983,8 +1223,9 @@ U0 Init()
score=0;
level=1;
ship_root.next=ship_root.last=&ship_root;
shot_root.next=shot_root.last=&shot_root;
QueInit(&ship_root);
QueInit(&shot_root);
QueInit(&missile_root);
for (i=0;i<NUM_STARS;i++) {
stars_x[i]=RandU16%GR_WIDTH;
@@ -1011,13 +1252,19 @@ U0 XCaliber()
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
"Game {"
" Restart(,'\n');"
" LevelUp(,'+');"
" LevelDown(,'-');"
"}"
"Play {"
" Fire(,CH_SPACE);"
" Thrust(,,SC_CURSOR_UP);"
" StopSpin(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
" LeftMissile(,'l');"
" RightMissile(,'r');"
" Spackwalk(,'w');"
" LongerFuse(,,SC_CURSOR_RIGHT|SCF_SHIFT);"
" ShorterFuse(,,SC_CURSOR_LEFT|SCF_SHIFT);"
@@ -1079,11 +1326,26 @@ U0 XCaliber()
}
break;
case CH_SPACE:
HumanFireBegin;
if (level<4)
HumanFireGunBegin;
else
HumanFireLaserBegin;
break;
case 'l':
HumanFireMissileBegin(1);
break;
case 'r':
HumanFireMissileBegin(0);
break;
case 'w':
ctrl_panel.spacewalk=TRUE;
break;
case '+':
level++;
break;
case '-':
level--;
break;
}
break;
case MSG_KEY_UP:
@@ -1110,7 +1372,8 @@ U0 XCaliber()
ch=0;
break;
case CH_SPACE:
HumanFireEnd;
if (level>=4)
HumanFireLaserEnd;
break;
}
break;
@@ -1118,6 +1381,7 @@ U0 XCaliber()
}
AI;
ExpireShots;
ExpireMissiles;
CheckDamage;
WinMgrSync; //msgs are only qued by winmngr
if (show_level_msg) {
@@ -1196,4 +1460,4 @@ U0 XCaliber()
ùÿÿÿþÿÿÿ– úÿÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿúÿÿÿúÿÿÿüÿÿÿþÿÿÿúÿÿÿ
ýÿÿÿùÿÿÿ
ùÿÿÿùÿÿÿÿÿÿÿ
ùÿÿÿÿÿÿÿýÿÿÿÿÿÿÿ
ùÿÿÿÿÿÿÿýÿÿÿÿÿÿÿbüÿÿÿþÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿb÷ÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
+1 -1
View File
@@ -109,7 +109,7 @@ U0 UpdateDerivedCtrlPanelCtrl(CCtrl *c)
CTRL_PANEL_RANGE+CTRL_PANEL_BUTTON_SIZE);
c->bottom=c->top+CTRL_PANEL_SPACING*2+CTRL_PANEL_RANGE;
s->shot_radius =ClampI64(s->shot_radius,0,CTRL_PANEL_RANGE-1);
s->shot_radius=ClampI64(s->shot_radius,0,CTRL_PANEL_RANGE-1);
s->fuse_time=ClampI64(s->fuse_time,0,CTRL_PANEL_RANGE-1);
}