TempleOSCDV4.12.ISO
This commit is contained in:
1 parent
93ca216483
commit
b84bbff6db
381 files changed
+18356
-18798
No files matched your search
@@ -1,158 +1,164 @@
|
||||
U0 TanksPlot()
|
||||
U0 PlayerIndirect()
|
||||
{
|
||||
Unit *tempu=NULL;
|
||||
I64 msg_code,a1,a2;
|
||||
Unit *tmpu=NULL;
|
||||
I64 i,remaining=0,msg_code,a1,a2;
|
||||
F64 target_x,target_y;
|
||||
SetViewPlayer(cur_player);
|
||||
while (TRUE) {
|
||||
ViewPlayerSet(cur_player);
|
||||
for (i=0;i<MAX_UNITS;i++) {
|
||||
tmpu=&units[cur_player][i];
|
||||
if (tmpu->life>0 && tmpu->indirect_fire)
|
||||
remaining++;
|
||||
}
|
||||
while (remaining) {
|
||||
if (!alive_cnt[0] || !alive_cnt[1])
|
||||
throw('GameOver',TRUE);
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|
|
||||
1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
1<<MSG_IP_R_UP);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
HandleChar(a1);
|
||||
CharDo(a1);
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
if (CursorInWindow(Fs,a1,a2)) {
|
||||
UpdateCursor(Fs,a1,a2);
|
||||
if (tempu=FindUnit(cursor_row,cursor_col)) {
|
||||
if (tempu->player==enemy_player || tempu->fired ||
|
||||
!tempu->indirect_fire)
|
||||
tempu=NULL;
|
||||
if (CursorInWin(Fs,a1,a2)) {
|
||||
a1-=x0; a2-=y0;
|
||||
CursorUpdate(Fs,a1,a2);
|
||||
if (tmpu=UnitFind(cursor_row,cursor_col)) {
|
||||
if (tmpu->player==enemy_player || tmpu->fired ||
|
||||
!tmpu->indirect_fire)
|
||||
tmpu=NULL;
|
||||
else {
|
||||
RowCol2XY(&fire_radius_x,&fire_radius_y,tempu->row,tempu->col);
|
||||
fire_radius=tempu->range*2*HEX_RADIUS;
|
||||
RowCol2XY(&fire_radius_x,&fire_radius_y,tmpu->row,tmpu->col);
|
||||
fire_radius=tmpu->range*2*HEX_RADIUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_IP_L_UP:
|
||||
if (CursorInWindow(Fs,a1,a2)) {
|
||||
UpdateCursor(Fs,a1,a2);
|
||||
if (CursorInWin(Fs,a1,a2)) {
|
||||
a1-=x0; a2-=y0;
|
||||
CursorUpdate(Fs,a1,a2);
|
||||
RowCol2XY(&target_x,&target_y,cursor_row,cursor_col);
|
||||
if (!tempu)
|
||||
if (!tmpu)
|
||||
Beep;
|
||||
else {
|
||||
if (Sqrt(Sqr(fire_radius_x-target_x)+Sqr(fire_radius_y-target_y))>
|
||||
fire_radius)
|
||||
Beep;
|
||||
else
|
||||
PlotShot(tempu,cursor_row,cursor_col);
|
||||
else {
|
||||
IndirectAdd(tmpu,cursor_row,cursor_col);
|
||||
remaining--;
|
||||
}
|
||||
}
|
||||
}
|
||||
tempu=NULL;
|
||||
tmpu=NULL;
|
||||
fire_radius=0;
|
||||
break;
|
||||
case MSG_IP_R_UP:
|
||||
if (CursorInWindow(Fs,a1,a2))
|
||||
if (CursorInWin(Fs,a1,a2))
|
||||
throw('PhaseOvr',TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw('PhaseOvr',TRUE);
|
||||
}
|
||||
|
||||
U0 TanksMove()
|
||||
U0 PlayerMove()
|
||||
{
|
||||
Unit *tempu=NULL,*target;
|
||||
Unit *tmpu=NULL;
|
||||
I64 msg_code,a1,a2;
|
||||
SetViewPlayer(cur_player);
|
||||
ViewPlayerSet(cur_player);
|
||||
while (TRUE) {
|
||||
if (!alive_cnt[0] || !alive_cnt[1])
|
||||
throw('GameOver',TRUE);
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|
|
||||
1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
1<<MSG_IP_R_UP);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
HandleChar(a1);
|
||||
CharDo(a1);
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
if (CursorInWindow(Fs,a1,a2)) {
|
||||
UpdateCursor(Fs,a1,a2);
|
||||
if (tempu=FindUnit(cursor_row,cursor_col)) {
|
||||
if (tempu->player==enemy_player || !tempu->remaining_movement)
|
||||
tempu=NULL;
|
||||
if (CursorInWin(Fs,a1,a2)) {
|
||||
a1-=x0; a2-=y0;
|
||||
CursorUpdate(Fs,a1,a2);
|
||||
if (tmpu=UnitFind(cursor_row,cursor_col)) {
|
||||
if (tmpu->player==enemy_player || !tmpu->remaining_movement)
|
||||
tmpu=NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_IP_L_UP:
|
||||
if (CursorInWindow(Fs,a1,a2)) {
|
||||
UpdateCursor(Fs,a1,a2);
|
||||
target=FindUnit(cursor_row,cursor_col);
|
||||
if (!tempu)
|
||||
if (CursorInWin(Fs,a1,a2)) {
|
||||
a1-=x0; a2-=y0;
|
||||
CursorUpdate(Fs,a1,a2);
|
||||
if (!tmpu)
|
||||
Beep;
|
||||
else {
|
||||
if (target)
|
||||
Beep;
|
||||
else
|
||||
MoveUnit(tempu,a1+Fs->horz_scroll.pos,
|
||||
a2+Fs->vert_scroll.pos);
|
||||
UnitMove(tmpu,a1,a2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tempu=NULL;
|
||||
tmpu=NULL;
|
||||
break;
|
||||
case MSG_IP_R_UP:
|
||||
if (CursorInWindow(Fs,a1,a2))
|
||||
if (CursorInWin(Fs,a1,a2))
|
||||
throw('PhaseOvr',TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 TanksFire()
|
||||
U0 PlayerDirect()
|
||||
{
|
||||
Unit *tempu=NULL,*target;
|
||||
Unit *tmpu=NULL,*target;
|
||||
I64 msg_code,a1,a2;
|
||||
SetViewPlayer(cur_player);
|
||||
ViewPlayerSet(cur_player);
|
||||
while (TRUE) {
|
||||
if (!alive_cnt[0] || !alive_cnt[1])
|
||||
throw('GameOver',TRUE);
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|
|
||||
1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
1<<MSG_IP_R_UP);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
HandleChar(a1);
|
||||
CharDo(a1);
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
if (CursorInWindow(Fs,a1,a2)) {
|
||||
UpdateCursor(Fs,a1,a2);
|
||||
if (tempu=FindUnit(cursor_row,cursor_col)) {
|
||||
if (tempu->player==enemy_player || tempu->fired ||
|
||||
tempu->indirect_fire)
|
||||
tempu=NULL;
|
||||
if (CursorInWin(Fs,a1,a2)) {
|
||||
a1-=x0; a2-=y0;
|
||||
CursorUpdate(Fs,a1,a2);
|
||||
if (tmpu=UnitFind(cursor_row,cursor_col)) {
|
||||
if (tmpu->player==enemy_player || tmpu->fired ||
|
||||
tmpu->indirect_fire)
|
||||
tmpu=NULL;
|
||||
else {
|
||||
RVSetUp(cur_player);
|
||||
RowCol2XY(&fire_radius_x,&fire_radius_y,tempu->row,tempu->col);
|
||||
fire_radius=tempu->range*2*HEX_RADIUS;
|
||||
RecalcVisible(RV_ONE_FRIENDLY_UNIT,tempu);
|
||||
VRSetUp(cur_player);
|
||||
RowCol2XY(&fire_radius_x,&fire_radius_y,tmpu->row,tmpu->col);
|
||||
fire_radius=tmpu->range*2*HEX_RADIUS;
|
||||
VisRecalc(VR_ONE_FRIENDLY_UNIT,tmpu);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_IP_L_UP:
|
||||
if (CursorInWindow(Fs,a1,a2)) {
|
||||
UpdateCursor(Fs,a1,a2);
|
||||
target=FindUnit(cursor_row,cursor_col);
|
||||
if (!tempu)
|
||||
if (CursorInWin(Fs,a1,a2)) {
|
||||
a1-=x0; a2-=y0;
|
||||
CursorUpdate(Fs,a1,a2);
|
||||
target=UnitFind(cursor_row,cursor_col);
|
||||
if (!tmpu)
|
||||
Beep;
|
||||
else {
|
||||
if (!target || target->player!=enemy_player ||
|
||||
!Bt(&target->visible,0))
|
||||
!Bt(&target->vis,0))
|
||||
Beep;
|
||||
else
|
||||
FireShot(tempu,target);
|
||||
RecalcVisible(RV_UPDATE_FRIENDLY_UNIT,tempu);
|
||||
UnitDirectFire(tmpu,target);
|
||||
VisRecalc(VR_UPDATE_FRIENDLY_UNIT,tmpu);
|
||||
}
|
||||
}
|
||||
tempu=NULL;
|
||||
tmpu=NULL;
|
||||
fire_radius=0;
|
||||
break;
|
||||
case MSG_IP_R_UP:
|
||||
if (CursorInWindow(Fs,a1,a2))
|
||||
if (CursorInWin(Fs,a1,a2))
|
||||
throw('PhaseOvr',TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Unit *FindNearestUnit(I64 row,I64 col,I64 player,Bool in_LOS,F64 range=-1)
|
||||
Unit *UnitNearestFind(I64 row,I64 col,I64 player,Bool in_LOS,F64 range=-1)
|
||||
{
|
||||
I64 i;
|
||||
F64 dd,best_dd=MAX_F64,x1,y1,x2,y2;
|
||||
@@ -23,36 +23,36 @@ Unit *FindNearestUnit(I64 row,I64 col,I64 player,Bool in_LOS,F64 range=-1)
|
||||
return best;
|
||||
}
|
||||
|
||||
U0 TanksPlot()
|
||||
U0 PlayerIndirect()
|
||||
{
|
||||
Unit *target,*tempu;
|
||||
Unit *target,*tmpu;
|
||||
I64 i;
|
||||
for (i=0;i<MAX_UNITS;i++) {
|
||||
CheckUser;
|
||||
tempu=&units[cur_player][i];
|
||||
if (tempu->life>0 && tempu->indirect_fire &&
|
||||
(target=FindNearestUnit(tempu->row,tempu->col,enemy_player,TRUE,
|
||||
tempu->range*2*HEX_RADIUS)))
|
||||
PlotShot(tempu,target->row,target->col);
|
||||
UserChk;
|
||||
tmpu=&units[cur_player][i];
|
||||
if (tmpu->life>0 && tmpu->indirect_fire &&
|
||||
(target=UnitNearestFind(tmpu->row,tmpu->col,enemy_player,TRUE,
|
||||
tmpu->range*2*HEX_RADIUS)))
|
||||
IndirectAdd(tmpu,target->row,target->col);
|
||||
}
|
||||
throw('PhaseOvr',TRUE);
|
||||
}
|
||||
|
||||
U0 TanksMove()
|
||||
U0 PlayerMove()
|
||||
{
|
||||
Unit *target,*tempu;
|
||||
Unit *target,*tmpu;
|
||||
I64 i;
|
||||
F64 x,y;
|
||||
for (i=0;i<MAX_UNITS;i++) {
|
||||
CheckUser;
|
||||
tempu=&units[cur_player][i];
|
||||
if (tempu->life>0) {
|
||||
UserChk;
|
||||
tmpu=&units[cur_player][i];
|
||||
if (tmpu->life>0) {
|
||||
//Cheats because it violates Line-of-Sight
|
||||
if (target=FindNearestUnit(tempu->row,tempu->col,enemy_player,FALSE)) {
|
||||
if (target=UnitNearestFind(tmpu->row,tmpu->col,enemy_player,FALSE)) {
|
||||
RowCol2XY(&x,&y,target->row,target->col);
|
||||
if (!MoveUnit(tempu,x,y)) {
|
||||
RowCol2XY(&x,&y,tempu->row,tempu->col);
|
||||
MoveUnit(tempu,x+RandI16,y+RandI16);
|
||||
if (!UnitMove(tmpu,x,y)) {
|
||||
RowCol2XY(&x,&y,tmpu->row,tmpu->col);
|
||||
UnitMove(tmpu,x+RandI16,y+RandI16);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,18 +60,18 @@ U0 TanksMove()
|
||||
throw('PhaseOvr',TRUE);
|
||||
}
|
||||
|
||||
U0 TanksFire()
|
||||
U0 PlayerDirect()
|
||||
{
|
||||
Unit *target,*tempu;
|
||||
Unit *target,*tmpu;
|
||||
I64 i;
|
||||
for (i=0;i<MAX_UNITS;i++) {
|
||||
CheckUser;
|
||||
tempu=&units[cur_player][i];
|
||||
if (tempu->life>0 && !tempu->indirect_fire &&
|
||||
(target=FindNearestUnit(tempu->row,tempu->col,enemy_player,TRUE,
|
||||
tempu->range*2*HEX_RADIUS))) {
|
||||
FireShot(tempu,target);
|
||||
Sleep(250*ANIMATION_DELAY);
|
||||
UserChk;
|
||||
tmpu=&units[cur_player][i];
|
||||
if (tmpu->life>0 && !tmpu->indirect_fire &&
|
||||
(target=UnitNearestFind(tmpu->row,tmpu->col,enemy_player,TRUE,
|
||||
tmpu->range*2*HEX_RADIUS))) {
|
||||
UnitDirectFire(tmpu,target);
|
||||
Sleep(250*animation_delay);
|
||||
}
|
||||
}
|
||||
throw('PhaseOvr',TRUE);
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
#help_index "Games"
|
||||
|
||||
Cd(__DIR__);;
|
||||
#include "TTFGlbls"
|
||||
#include "TTFLib"
|
||||
#include "TTFInit"
|
||||
#include "TTFVis"
|
||||
#include "TTFFire"
|
||||
#include "TTFMove"
|
||||
#include "TTFDraw"
|
||||
#include "ToTheFront"
|
||||
|
||||
#help_index ""
|
||||
Binary file not shown.
@@ -0,0 +1,278 @@
|
||||
U0 AttackHeader(Unit *tmpu,U8 *st,Unit *target)
|
||||
{
|
||||
I64 i=9+StrLen(st);
|
||||
if (target) {
|
||||
i+=9;
|
||||
if (target->armor)
|
||||
i+=8;
|
||||
else
|
||||
i+=10;
|
||||
}
|
||||
'\n\n';
|
||||
"$$BLACK$$%h*c$$FG$$\n",i,'-';
|
||||
if (tmpu->player)
|
||||
"$$PURPLE$$Player 2$$FG$$ ";
|
||||
else
|
||||
"$$CYAN$$Player 1$$FG$$ ";
|
||||
"%s",st;
|
||||
if (target) {
|
||||
if (target->player)
|
||||
" $$PURPLE$$Player 2";
|
||||
else
|
||||
" $$CYAN$$Player 1";
|
||||
if (target->armor)
|
||||
" Armored";
|
||||
else
|
||||
" Unarmored";
|
||||
'$$FG$$';
|
||||
}
|
||||
'\n';
|
||||
"$$BLACK$$%h*c$$FG$$\n",i,'-';
|
||||
}
|
||||
|
||||
F64 HitDamage(Unit *tmpu,Unit *target,I64 facing=1,F64 range_factor=0)
|
||||
{
|
||||
F64 d,res=200.0*Rand;
|
||||
"\nRoll Out of 200\t\t:%6.2f Damage\n",res;
|
||||
if (target->armor) {
|
||||
d=target->armor/100.0*(5-facing)/5.0;
|
||||
if (d>=0) {
|
||||
"Armor Attack\t\t:%6.2f\n",ToF64(tmpu->armored_attack);
|
||||
res*=(tmpu->armored_attack/100.0)/d;
|
||||
} else
|
||||
res=0;
|
||||
"Armor(%z) Defense\t:%6.2f\n",facing,
|
||||
"Front\0FrontSide\0RearSide\0Rear\0",100*d;
|
||||
} else {
|
||||
d=1.0-range_factor;
|
||||
if (d>0) {
|
||||
"Unarmored Attack\t:%6.2f\n",ToF64(tmpu->unarmored_attack);
|
||||
"Range Adjust\t\t:%6.2f%%\n",100*d;
|
||||
res*=(tmpu->unarmored_attack/100.0)*d;
|
||||
} else
|
||||
res=0;
|
||||
}
|
||||
"Attack/Defense Adjusted\t:%6.2f Damage\n",res;
|
||||
return Round(res);
|
||||
}
|
||||
|
||||
Bool DamageDo(Unit *target,F64 damage)
|
||||
{
|
||||
if (damage>0) {
|
||||
if (target->armor)
|
||||
"Armor Hit Score %6.2f\t:",damage;
|
||||
else
|
||||
"%3d Life - %3f Damage\t=",target->life,damage;
|
||||
if (damage>=target->life) {
|
||||
"$$RED$$Killed$$FG$$\n";
|
||||
Noise(1000*animation_delay,1000,4000);
|
||||
Sleep(1000*animation_delay);
|
||||
target->life=0;
|
||||
VisRecalc(VR_FRIENDLY_UNIT_DIED,target);
|
||||
alive_cnt[target->player]--;
|
||||
return TRUE;
|
||||
} else {
|
||||
if (target->armor) {
|
||||
if (damage>0.6*target->life) {
|
||||
target->movement=0;
|
||||
"$$RED$$Immobilized$$FG$$\n";
|
||||
} else
|
||||
"$$GREEN$$No Penetration$$FG$$\n";
|
||||
} else {
|
||||
target->life-=damage;
|
||||
"$$RED$$%6.2f Life$$FG$$\n",ToF64(target->life);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
U0 IndirectAdd(Unit *tmpu,I64 row,I64 col)
|
||||
{
|
||||
IndirectOrders *tmpi;
|
||||
if (tmpu->life<=0 || tmpu->range<=0)
|
||||
return;
|
||||
tmpu->fired=TRUE;
|
||||
tmpi=CAlloc(sizeof(IndirectOrders));
|
||||
tmpi->attacker=tmpu;
|
||||
tmpi->row=row;
|
||||
tmpi->col=col;
|
||||
QueIns(tmpi,indirect_head.last);
|
||||
}
|
||||
|
||||
Bool BulletPlot(U0,I64 x,I64 y,I64)
|
||||
{
|
||||
fire_x=x; fire_y=y;
|
||||
firing=TRUE;
|
||||
Sleep(3*animation_delay);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
U0 UnitDirectFire(Unit *tmpu,Unit *target)
|
||||
{
|
||||
I64 r,c,facing,
|
||||
t1=terrain[tmpu->row][tmpu->col],t2=terrain[target->row][target->col];
|
||||
F64 x1,y1,x2,y2,d,a,range_factor;
|
||||
if (tmpu->life<=0 || target->life<=0 || tmpu->range<=0)
|
||||
return;
|
||||
AttackHeader(tmpu,"DirectFire",target);
|
||||
RowCol2XY(&x1,&y1,tmpu->row,tmpu->col);
|
||||
RowCol2XY(&x2,&y2,target->row,target->col);
|
||||
d=100*Rand;
|
||||
"+%5.2f Roll\n",d;
|
||||
d+=tmpu->accuracy;
|
||||
"+%2d.00 Accuracy\n",tmpu->accuracy;
|
||||
|
||||
range_factor=Sqrt(Sqr(x2-x1)+Sqr(y2-y1))/(tmpu->range*2*DSIN);
|
||||
"-%5.2f%% of Range\n",100*range_factor;
|
||||
d-=100*range_factor;
|
||||
if (t2==TREES) {
|
||||
"-30.00 Target in Trees Penalty\n";
|
||||
d-=30;
|
||||
}
|
||||
if (t1==MOUNTAINS && t2!=MOUNTAINS) {
|
||||
"+30.00 High Ground Bonus\n";
|
||||
d+=30;
|
||||
}
|
||||
"_______\n";
|
||||
target_unit=target;
|
||||
if (d>=0) {
|
||||
"+%5.2f Hit\n",d;
|
||||
target_hit=TRUE;
|
||||
Noise(500*animation_delay,100,150);
|
||||
Sleep(500*animation_delay);
|
||||
Line(NULL,x1,y1,0,x2,y2,0,&BulletPlot);
|
||||
} else {
|
||||
"-%5.2f Miss\n",-d;
|
||||
target_hit=FALSE;
|
||||
Noise(1000*animation_delay,750,1000);
|
||||
Sleep(1000*animation_delay);
|
||||
a=ã*2*Rand;
|
||||
d=(0.5-d/100)*HEX_SIDE;
|
||||
Line(NULL,x1,y1,0,x2+d*Cos(a),y2+d*Sin(a),0,&BulletPlot);
|
||||
}
|
||||
firing=FALSE;
|
||||
tmpu->fired=TRUE;
|
||||
if (target_hit) {
|
||||
r=target->row;c=target->col;
|
||||
if ((facing=HexMoveOne(&r,&c,x1,y1))>=0)
|
||||
facing=FacingChg(facing,target->facing);
|
||||
else
|
||||
facing=0;
|
||||
DamageDo(target,HitDamage(tmpu,target,facing,range_factor));
|
||||
}
|
||||
while (snd.freq) //see $LK,"Snd",A="MN:Snd"$()
|
||||
Yield;
|
||||
target_unit=NULL;
|
||||
}
|
||||
|
||||
Bool HexOccupy(Bool overrun,Unit *tmpu,Unit *target)
|
||||
{
|
||||
I64 t2=terrain[target->row][target->col];
|
||||
F64 damage;
|
||||
if (tmpu->life<=0 || target->life<=0)
|
||||
return FALSE;
|
||||
if (overrun)
|
||||
AttackHeader(tmpu,"OverRun",target);
|
||||
else
|
||||
AttackHeader(tmpu,"CloseAssault",target);
|
||||
Noise(500*animation_delay,100,150);
|
||||
Sleep(500*animation_delay);
|
||||
tmpu->fired=TRUE;
|
||||
target->fired=TRUE;
|
||||
damage=HitDamage(tmpu,target);
|
||||
if (overrun) {
|
||||
damage*=2.0;
|
||||
"x2 OverRun Bonus\t=%6.2f Damage\n",damage;
|
||||
if (t2!=PLAINS) {
|
||||
damage/=2.0;
|
||||
"/2 Terrain Penalty\t=%6.2f Damage\n",damage;
|
||||
}
|
||||
} else {
|
||||
damage*=3.0;
|
||||
"x3 CloseAssault Bonus\t=%6.2f Damage\n",damage;
|
||||
}
|
||||
if (DamageDo(target,Round(damage))) {
|
||||
"$$RED$$Success$$FG$$\n";
|
||||
while (snd.freq) //see $LK,"Snd",A="MN:Snd"$()
|
||||
Yield;
|
||||
return TRUE;
|
||||
} else {
|
||||
tmpu->life=0;
|
||||
VisRecalc(VR_FRIENDLY_UNIT_DIED,tmpu);
|
||||
alive_cnt[tmpu->player]--;
|
||||
"$$RED$$Failure$$FG$$\n";
|
||||
while (snd.freq) //see $LK,"Snd",A="MN:Snd"$()
|
||||
Yield;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
U0 IndirectResolveAll()
|
||||
{
|
||||
I64 i,r,c;
|
||||
F64 x1,y1,x2,y2,d,range_factor;
|
||||
Unit *tmpu,*target;
|
||||
IndirectOrders *tmpi=indirect_head.next,*tmpi1;
|
||||
while (tmpi!=*indirect_head) {
|
||||
tmpi1=tmpi->next;
|
||||
tmpu=tmpi->attacker;
|
||||
AttackHeader(tmpu,"IndirectFire",NULL);
|
||||
RowCol2XY(&x1,&y1,tmpu->row,tmpu->col);
|
||||
RowCol2XY(&x2,&y2,tmpi->row,tmpi->col);
|
||||
d=100*Rand;
|
||||
"+%5.2f Roll\n",d;
|
||||
d+=tmpu->accuracy;
|
||||
"+%2d.00 Accuracy\n",tmpu->accuracy;
|
||||
range_factor=Sqrt(Sqr(x2-x1)+Sqr(y2-y1))/(tmpu->range*2*DSIN);
|
||||
"-%5.2f%% of Range\n",100*range_factor;
|
||||
d-=100*range_factor;
|
||||
'_______\n';
|
||||
|
||||
|
||||
if (d>=0) {
|
||||
"+%5.2f Hit\n",d;
|
||||
Noise(500*animation_delay,100,150);
|
||||
Sleep(500*animation_delay);
|
||||
} else {
|
||||
"-%5.2f Miss\n",-d;
|
||||
Noise(1000*animation_delay,750,1000);
|
||||
Sleep(1000*animation_delay);
|
||||
i=RandU16%6;
|
||||
if (tmpi->row&1)
|
||||
tmpi->col+=col_offsets_odd[i];
|
||||
else
|
||||
tmpi->col+=col_offsets_even[i];
|
||||
tmpi->row+=row_offsets[i];
|
||||
RowCol2XY(&x2,&y2,tmpi->row,tmpi->col);
|
||||
}
|
||||
|
||||
Line(NULL,x1,y1,0,x2,y2,0,&BulletPlot);
|
||||
firing=FALSE;
|
||||
tmpu->fired=TRUE;
|
||||
indirect_row=tmpi->row;
|
||||
indirect_col=tmpi->col;
|
||||
indirect_explosion=TRUE;
|
||||
for (i=0;i<7;i++) {
|
||||
if (tmpi->row&1)
|
||||
c=tmpi->col+col_offsets_odd[i];
|
||||
else
|
||||
c=tmpi->col+col_offsets_even[i];
|
||||
r=tmpi->row+row_offsets[i];
|
||||
if (0<=r<map_rows && 0<=c<map_cols && (target=UnitFind(r,c))) {
|
||||
AttackHeader(tmpu,"IndirectFire",target);
|
||||
DamageDo(target,HitDamage(tmpu,target));
|
||||
}
|
||||
}
|
||||
Noise(2000*animation_delay,800,1000);
|
||||
Sleep(2000*animation_delay);
|
||||
while (snd.freq) //see $LK,"Snd",A="MN:Snd"$()
|
||||
Yield;
|
||||
indirect_explosion=FALSE;
|
||||
|
||||
QueRem(tmpi);
|
||||
Free(tmpi);
|
||||
tmpi=tmpi1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
#define MAP_WIDTH 640 //Change this, if you like.
|
||||
#define MAX_UNITS 32 //Change this, if you like.
|
||||
#define HEX_SIDE 11
|
||||
|
||||
U0 InitDefines()
|
||||
{
|
||||
DefinePrint("MAP_HEIGHT","%d",(GR_HEIGHT-FONT_HEIGHT*2)*MAP_WIDTH/GR_WIDTH);
|
||||
DefinePrint("DCOS", "%12.9f", HEX_SIDE*Cos(60.0/180*ã));
|
||||
DefinePrint("DSIN", "%12.9f", HEX_SIDE*Sin(60.0/180*ã));
|
||||
DefinePrint("HEX_RADIUS","%12.9f", HEX_SIDE*Sin(60.0/180*ã)+0.01); //Slop
|
||||
} InitDefines;
|
||||
|
||||
I64 map_cols=(MAP_WIDTH-DCOS)/(2*HEX_SIDE+2*DCOS),
|
||||
map_rows=ToI64((MAP_HEIGHT-DSIN)/DSIN)&~1,
|
||||
map_width=map_cols*(2*HEX_SIDE+2*DCOS)+DCOS,
|
||||
map_height=map_rows*DSIN+DSIN+1,
|
||||
x0,y0;
|
||||
|
||||
CDC *map_dc;
|
||||
U8 terrain[map_rows][map_cols];
|
||||
|
||||
//Centers of hexes
|
||||
class Pt
|
||||
{
|
||||
F64 x,y;
|
||||
};
|
||||
Pt hex_centers[map_rows][map_cols];
|
||||
|
||||
I64 show_vis_row,show_vis_col;
|
||||
Bool roads[map_rows][map_cols],
|
||||
rivers[map_rows][map_cols],
|
||||
vis_map[map_rows][map_cols];
|
||||
|
||||
//Other options for PLAINS are WHITE or YELLOW
|
||||
#define PLAINS LTGREEN
|
||||
#define TREES GREEN
|
||||
#define MOUNTAINS DKGRAY
|
||||
|
||||
//These are used to display a range circle when they player
|
||||
//is firing.
|
||||
F64 fire_radius,fire_radius_x,fire_radius_y;
|
||||
|
||||
//These display "phase", "turn" and "game over".
|
||||
U8 msg_buf[STR_LEN];
|
||||
I64 msg_off_timeout; //Jiffies. Goes away after a time.
|
||||
|
||||
//Unit types
|
||||
#define UT_INFANTRY 0
|
||||
#define UT_ARTILLERY 1
|
||||
#define UT_LT_TANK 2
|
||||
#define UT_MD_TANK 3
|
||||
|
||||
class Unit
|
||||
{
|
||||
U8 *img;
|
||||
I64 num,row,col,
|
||||
armored_attack,unarmored_attack,armor;
|
||||
I8 type,player,facing,movement,life,
|
||||
range,remaining_movement,accuracy;
|
||||
Bool vis[2],fired,infantry,indirect_fire,pad[3];
|
||||
};
|
||||
|
||||
Unit units[2][MAX_UNITS];
|
||||
|
||||
// Bt(vis_unit_bitmap,player1+player0*((MAX_UNITS+7)&~7))
|
||||
U8 vis_unit_bitmap[2][(((MAX_UNITS+7)&~7)*MAX_UNITS)>>3];
|
||||
|
||||
#define PHASE_START 0
|
||||
#define PHASE_INDIRECT 0
|
||||
#define PHASE_INDIRECT0 0
|
||||
#define PHASE_INDIRECT1 1
|
||||
#define PHASE_MOVE 2
|
||||
#define PHASE_MOVE0 2
|
||||
#define PHASE_MOVE1 3
|
||||
#define PHASE_DIRECT 4
|
||||
#define PHASE_DIRECT0 4
|
||||
#define PHASE_DIRECT1 5
|
||||
#define PHASE_END 6
|
||||
|
||||
I64 phase,cur_player,enemy_player,view_player,turn,
|
||||
cursor_row,cursor_col,alive_cnt[2],
|
||||
player_indirect[2],player_move[2],player_direct[2];
|
||||
F64 animation_delay=0.5;
|
||||
|
||||
Bool moving=FALSE;
|
||||
I64 move_x,move_y;
|
||||
F64 move_facing;
|
||||
Unit *moving_unit;
|
||||
extern I64 HexMoveOne(I64 *_row,I64 *_col,F64 x,F64 y);
|
||||
|
||||
class IndirectOrders
|
||||
{
|
||||
IndirectOrders *next,*last;
|
||||
Unit *attacker;
|
||||
I64 row,col;
|
||||
} indirect_head;
|
||||
|
||||
Bool firing=FALSE;
|
||||
I64 fire_x,fire_y;
|
||||
Unit *target_unit;
|
||||
Bool target_hit;
|
||||
|
||||
Bool indirect_explosion=FALSE;
|
||||
I64 indirect_row,indirect_col;
|
||||
|
||||
I64 row_offsets[7]={-1,-2,-1,1,2,1,0};
|
||||
I64 col_offsets_even[7]={-1, 0, 0,0,0,-1,0};
|
||||
I64 col_offsets_odd [7]={ 0, 0, 1,1,0, 0,0};
|
||||
@@ -0,0 +1,436 @@
|
||||
/*I got tricky by not defining a color
|
||||
right away in these $LK,"CSprite",A="MN:CSprite"$s so they can
|
||||
work for both players by setting dc->color
|
||||
before drawing them. I actually made these
|
||||
graphics by defining a color in the <CTRL-r>
|
||||
menu, drawing the unit and deleting the color.
|
||||
|
||||
I had to leave a gap between the tank tread
|
||||
and body because of how it is rendered when rotated.
|
||||
*/
|
||||
|
||||
$SP,"<1>",BI=1$
|
||||
|
||||
$SP,"<2>",BI=2$
|
||||
|
||||
//This is an infantry.
|
||||
|
||||
$SP,"<3>",BI=3$
|
||||
|
||||
$SP,"<4>",BI=4$
|
||||
|
||||
|
||||
U0 DrawHexes()
|
||||
{
|
||||
F64 dx=2*HEX_SIDE+2*DCOS,dy=2*DSIN,
|
||||
x,y,x1,y1,x2,y2;
|
||||
I64 i,j;
|
||||
map_dc->color=WHITE;
|
||||
GrRect(map_dc,0,0,map_dc->width,map_dc->height);
|
||||
map_dc->color=BLACK;
|
||||
y=0;
|
||||
for (j=0;j<map_rows;j+=2) {
|
||||
x=DCOS;
|
||||
GrLine(map_dc,x,y,x-DCOS,y+DSIN);
|
||||
GrLine(map_dc,x-DCOS,y+DSIN,x,y+2*DSIN);
|
||||
for (i=0;i<map_cols;i++) {
|
||||
x1=x; y1=y;
|
||||
x2=x1+HEX_SIDE; y2=y1;
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
x1=x2; y1=y2;
|
||||
x2+=DCOS; y2+=DSIN;
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
GrLine(map_dc,x2,y2,x2-DCOS,y2+DSIN);
|
||||
x1=x2; y1=y2;
|
||||
x2+=HEX_SIDE;
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
GrLine(map_dc,x2,y2,x2+DCOS,y2+DSIN);
|
||||
x1=x2; y1=y2;
|
||||
x2+=DCOS; y2-=DSIN;
|
||||
if (j || i<map_cols-1)
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
x+=dx;
|
||||
}
|
||||
y+=dy;
|
||||
}
|
||||
x=DCOS;
|
||||
for (i=0;i<map_cols;i++) {
|
||||
x1=x; y1=y;
|
||||
x2=x1+HEX_SIDE; y2=y1;
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
x1=x2; y1=y2;
|
||||
x2+=DCOS; y2+=DSIN;
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
x1=x2; y1=y2;
|
||||
x2+=HEX_SIDE;
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
x1=x2; y1=y2;
|
||||
x2+=DCOS; y2-=DSIN;
|
||||
GrLine(map_dc,x1,y1,x2,y2);
|
||||
x+=dx;
|
||||
}
|
||||
}
|
||||
|
||||
U0 MakeTerrain(U8 color,I64 cnt,I64 cluster_lo,I64 cluster_hi)
|
||||
{
|
||||
I64 i,j,l,row,col;
|
||||
for (i=0;i<cnt;i++) {
|
||||
col=RandU32%map_cols;
|
||||
row=RandU32%map_rows;
|
||||
l=cluster_lo+RandU16%(cluster_hi-cluster_lo+1);
|
||||
for (j=0;j<l;j++) {
|
||||
terrain[row][col]=color;
|
||||
Toward(&row,&col,RandU16%6);
|
||||
col=ClampI64(col,0,map_cols-1);
|
||||
row=ClampI64(row,0,map_rows-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 MakeRivers()
|
||||
{
|
||||
I64 i,row,col,direction;
|
||||
for (i=0;i<4;i++) {
|
||||
row=RandU32%map_rows;
|
||||
col=RandU32%map_cols;
|
||||
direction=RandU16%6;
|
||||
while (TRUE) {
|
||||
rivers[row][col]=TRUE;
|
||||
Toward(&row,&col,direction);
|
||||
if (!(0<=row<map_rows && 0<=col<map_cols))
|
||||
break;
|
||||
if (!(RandU16&3))
|
||||
direction=(direction+(7-RandU16%3))%6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 MakeRoads()
|
||||
{
|
||||
I64 i,row,col,direction;
|
||||
for (i=0;i<5;i++) {
|
||||
row=RandU32%map_rows;
|
||||
col=RandU32%map_cols;
|
||||
direction=RandU16%6;
|
||||
while (TRUE) {
|
||||
roads[row][col]=TRUE;
|
||||
Toward(&row,&col,direction);
|
||||
if (!(0<=row<map_rows && 0<=col<map_cols))
|
||||
break;
|
||||
if (!(RandU16%3))
|
||||
direction=(direction+(7-RandU16%3))%6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 DrawTerrain()
|
||||
{
|
||||
I64 i,j;
|
||||
F64 x,y;
|
||||
for (j=0;j<map_rows;j++)
|
||||
for (i=0;i<map_cols;i++) {
|
||||
map_dc->color=terrain[j][i];
|
||||
RowCol2XY(&x,&y,j,i);
|
||||
GrFloodFill(map_dc,x,y);
|
||||
}
|
||||
}
|
||||
|
||||
U0 DrawRivers()
|
||||
{
|
||||
I64 i,j,k,r,c;
|
||||
F64 x1,y1,x2,y2;
|
||||
for (j=0;j<map_rows;j++)
|
||||
for (i=0;i<map_cols;i++) {
|
||||
if (rivers[j][i]) {
|
||||
RowCol2XY(&x1,&y1,j,i);
|
||||
for (k=0;k<6;k++) {
|
||||
r=j;c=i;
|
||||
Toward(&r,&c,k);
|
||||
if (0<=r<map_rows && 0<=c<map_cols &&
|
||||
rivers[r][c]) {
|
||||
RowCol2XY(&x2,&y2,r,c);
|
||||
map_dc->color=LTBLUE;
|
||||
map_dc->pen_width=4;
|
||||
GrLine3(map_dc,x1,y1,0,x2,y2,0);
|
||||
map_dc->color=BLUE;
|
||||
map_dc->pen_width=2;
|
||||
GrLine3(map_dc,x1,y1,0,x2,y2,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 DrawRoads()
|
||||
{
|
||||
I64 i,j,k,r,c;
|
||||
F64 x1,y1,x2,y2;
|
||||
map_dc->color=RED;
|
||||
map_dc->pen_width=3;
|
||||
for (j=0;j<map_rows;j++)
|
||||
for (i=0;i<map_cols;i++) {
|
||||
if (roads[j][i]) {
|
||||
RowCol2XY(&x1,&y1,j,i);
|
||||
for (k=0;k<6;k++) {
|
||||
r=j;c=i;
|
||||
Toward(&r,&c,k);
|
||||
if (0<=r<map_rows && 0<=c<map_cols &&
|
||||
roads[r][c]) {
|
||||
RowCol2XY(&x2,&y2,r,c);
|
||||
GrLine3(map_dc,x1,y1,0,x2,y2,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 DrawDots()
|
||||
{
|
||||
I64 i,j;
|
||||
F64 x,y;
|
||||
map_dc->color=BLACK;
|
||||
for (j=0;j<map_rows;j++)
|
||||
for (i=0;i<map_cols;i++) {
|
||||
RowCol2XY(&x,&y,j,i);
|
||||
GrPlot(map_dc,x,y);
|
||||
}
|
||||
}
|
||||
|
||||
U0 HexCentersCalc()
|
||||
{
|
||||
I64 i,j;
|
||||
F64 x,y;
|
||||
for (j=0;j<map_rows;j++)
|
||||
for (i=0;i<map_cols;i++) {
|
||||
x=(2*HEX_SIDE+2*DCOS)*i+HEX_SIDE/2+DCOS;
|
||||
if (j&1)
|
||||
x+=HEX_SIDE+DCOS;
|
||||
y=DSIN*(j+1);
|
||||
hex_centers[j][i].x=x;
|
||||
hex_centers[j][i].y=y;
|
||||
}
|
||||
}
|
||||
|
||||
U0 InitMap()
|
||||
{
|
||||
HexCentersCalc;
|
||||
DrawHexes;
|
||||
MemSet(terrain,PLAINS,sizeof(terrain));
|
||||
MemSet(roads,FALSE,sizeof(roads));
|
||||
MemSet(rivers,FALSE,sizeof(rivers));
|
||||
MemSet(vis_map,FALSE,sizeof(vis_map));
|
||||
MakeTerrain(MOUNTAINS,0.03*map_cols*map_cols,5,35);
|
||||
MakeTerrain(TREES,0.03*map_cols*map_cols,5,35);
|
||||
DrawTerrain;
|
||||
MakeRivers;
|
||||
DrawRivers;
|
||||
MakeRoads;
|
||||
DrawRoads;
|
||||
DrawDots;
|
||||
}
|
||||
|
||||
U0 InitUnits()
|
||||
{
|
||||
I64 i,j,row,col,type;
|
||||
Unit *tmpu;
|
||||
MemSet(units,0,sizeof(units));
|
||||
alive_cnt[0]=alive_cnt[1]=MAX_UNITS;
|
||||
for (j=0;j<2;j++)
|
||||
for (i=0;i<alive_cnt[j];i++) {
|
||||
tmpu=&units[j][i];
|
||||
tmpu->player=j;
|
||||
tmpu->num=i;
|
||||
tmpu->life=100;
|
||||
tmpu->facing=RandU16%6;
|
||||
if (!j) {
|
||||
if (i>=MAX_UNITS/2) {
|
||||
if (i>=15*MAX_UNITS/16)
|
||||
type=UT_ARTILLERY;
|
||||
else
|
||||
type=UT_INFANTRY;
|
||||
} else {
|
||||
if (i>=MAX_UNITS/4)
|
||||
type=UT_MD_TANK;
|
||||
else
|
||||
type=UT_LT_TANK;
|
||||
}
|
||||
} else {
|
||||
if (i>=MAX_UNITS/2) {
|
||||
if (i>=15*MAX_UNITS/16)
|
||||
type=UT_ARTILLERY;
|
||||
else
|
||||
type=UT_INFANTRY;
|
||||
} else {
|
||||
if (i>=MAX_UNITS/4)
|
||||
type=UT_MD_TANK;
|
||||
else
|
||||
type=UT_LT_TANK;
|
||||
}
|
||||
}
|
||||
tmpu->type=type;
|
||||
switch (type) {
|
||||
case UT_INFANTRY:
|
||||
tmpu->infantry=TRUE;
|
||||
tmpu->indirect_fire=FALSE;
|
||||
tmpu->armor =0;
|
||||
tmpu->armored_attack =15;
|
||||
tmpu->unarmored_attack=180;
|
||||
tmpu->accuracy=45;
|
||||
tmpu->range =5;
|
||||
tmpu->movement=4;
|
||||
tmpu->img =$IB,"<1>",BI=1$;
|
||||
break;
|
||||
case UT_ARTILLERY:
|
||||
tmpu->infantry=TRUE;
|
||||
tmpu->indirect_fire=TRUE;
|
||||
tmpu->armor =0;
|
||||
tmpu->armored_attack =60;
|
||||
tmpu->unarmored_attack=180;
|
||||
tmpu->accuracy=25;
|
||||
tmpu->range =20;
|
||||
tmpu->movement=2;
|
||||
tmpu->img =$IB,"<2>",BI=2$;
|
||||
break;
|
||||
case UT_LT_TANK:
|
||||
tmpu->infantry=FALSE;
|
||||
tmpu->indirect_fire=FALSE;
|
||||
tmpu->armor =30;
|
||||
tmpu->armored_attack =40;
|
||||
tmpu->unarmored_attack=60;
|
||||
tmpu->accuracy=25;
|
||||
tmpu->range =8;
|
||||
tmpu->movement=24;
|
||||
tmpu->img =$IB,"<3>",BI=3$;
|
||||
break;
|
||||
case UT_MD_TANK:
|
||||
tmpu->infantry=FALSE;
|
||||
tmpu->indirect_fire=FALSE;
|
||||
tmpu->armor =60;
|
||||
tmpu->armored_attack =60;
|
||||
tmpu->unarmored_attack=80;
|
||||
tmpu->accuracy=25;
|
||||
tmpu->range =12;
|
||||
tmpu->movement=16;
|
||||
tmpu->img =$IB,"<4>",BI=4$;
|
||||
break;
|
||||
}
|
||||
do {
|
||||
row=RandU32%map_rows;
|
||||
col=RandU32%(map_cols/3);
|
||||
if (j)
|
||||
col+=2*map_cols/3;
|
||||
} while (UnitFind(row,col));
|
||||
tmpu->row=row;
|
||||
tmpu->col=col;
|
||||
LBts(&tmpu->vis[cur_player],0);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ViewPlayerSet(I8 p)
|
||||
{
|
||||
CMenuEntry *tmpse;
|
||||
view_player=p;
|
||||
if (tmpse=MenuEntryFind(Fs->cur_menu,"View/Player1"))
|
||||
tmpse->checked= view_player==0;
|
||||
if (tmpse=MenuEntryFind(Fs->cur_menu,"View/Player2"))
|
||||
tmpse->checked= view_player==1;
|
||||
}
|
||||
|
||||
U0 Init()
|
||||
{
|
||||
DocClear;
|
||||
"GameSeed(0x%X)\n",Seed(PopUpGetI64("GameSeed(0x%X):",Seed));
|
||||
moving_unit=NULL;
|
||||
InitMap;
|
||||
ViewPlayerSet(cur_player=0);
|
||||
enemy_player=1;
|
||||
if (map_width<GR_WIDTH) {
|
||||
x0=(MAP_WIDTH-map_width)>>1;
|
||||
y0=(MAP_HEIGHT-map_height)>>1+FONT_HEIGHT;
|
||||
} else {
|
||||
x0=0;
|
||||
y0=FONT_HEIGHT;
|
||||
}
|
||||
InitUnits;
|
||||
QueInit(&indirect_head);
|
||||
turn=0;
|
||||
fire_radius=0;
|
||||
show_vis_row=-1;
|
||||
show_vis_col=-1;
|
||||
*msg_buf=0;
|
||||
msg_off_timeout=0;
|
||||
phase=PHASE_END;
|
||||
}
|
||||
|
||||
U0 CleanUp()
|
||||
{
|
||||
QueDel(&indirect_head,TRUE);
|
||||
}
|
||||
|
||||
U0 PlayerPick(U8 *dirname,I64 player)
|
||||
{
|
||||
I64 i=0;
|
||||
U8 *st;
|
||||
CDirEntry *tmpde,*tmpde1,*tmpde2;
|
||||
CDoc *doc=DocNew;
|
||||
Bool *old_silent=Silent;
|
||||
st=MStrPrint("%s/*.HC*",dirname);
|
||||
tmpde=FilesFind(st);
|
||||
Free(st);
|
||||
tmpde2=FilesFind("~/ToTheFront/*.HC*");
|
||||
tmpde1=tmpde;
|
||||
Silent(old_silent);
|
||||
|
||||
DocPrint(doc,"Player %d Type\n\n$$LTBLUE$$",player+1);
|
||||
while (tmpde1) {
|
||||
if (!(i++&3))
|
||||
DocPrint(doc,"\n");
|
||||
st=StrNew(tmpde1->name);
|
||||
FileExtRem(st);
|
||||
tmpde1->user_data=DocPrint(doc,"$$MU-UL,\"%-10ts\",LE=%d$$ ",st,tmpde1);
|
||||
Free(st);
|
||||
tmpde1=tmpde1->next;
|
||||
}
|
||||
tmpde1=tmpde2;
|
||||
while (tmpde1) {
|
||||
if (!(i++&3))
|
||||
DocPrint(doc,"\n");
|
||||
st=StrNew(tmpde1->name);
|
||||
FileExtRem(st);
|
||||
tmpde1->user_data=DocPrint(doc,"$$MU-UL,\"%-10ts\",LE=%d$$ ",st,tmpde1);
|
||||
Free(st);
|
||||
tmpde1=tmpde1->next;
|
||||
}
|
||||
DocPrint(doc,"\n\n\n$$FG$$Create your own AI in ~/ToTheFront.");
|
||||
while ((tmpde1=PopUpMenu(doc))<=0);
|
||||
ExeFile(tmpde1->full_name);
|
||||
DocDel(doc);
|
||||
DirTreeDel(tmpde);
|
||||
DirTreeDel(tmpde2);
|
||||
ExePrint("player_indirect[%d]=&PlayerIndirect;"
|
||||
"player_move[%d]=&PlayerMove;"
|
||||
"player_direct[%d]=&PlayerDirect;",
|
||||
player,player,player);
|
||||
}
|
||||
| ||||