Initial (manual) import
This commit is contained in:
1 parent
f39611c506
commit
895fe109de
661 files changed
+245862
No files matched your search
@@ -0,0 +1,166 @@
|
||||
U0 PlayerIndirect()
|
||||
{
|
||||
Unit *tmpu=NULL;
|
||||
I64 i,remaining=0,msg_code,arg1,arg2;
|
||||
F64 target_x,target_y;
|
||||
ViewPlayerSet(cur_player);
|
||||
for (i=0;i<UNITS_NUM;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(&arg1,&arg2,1<<MSG_KEY_DOWN|1<<MSG_MS_L_DOWN|1<<MSG_MS_L_UP|
|
||||
1<<MSG_MS_R_UP);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
CharDo(arg1);
|
||||
break;
|
||||
case MSG_MS_L_DOWN:
|
||||
if (CursorInWin(Fs,arg1,arg2)) {
|
||||
arg1-=x0; arg2-=y0;
|
||||
CursorUpdate(Fs,arg1,arg2);
|
||||
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,tmpu->row,tmpu->col);
|
||||
fire_radius=tmpu->range*2*HEX_RADIUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_MS_L_UP:
|
||||
if (CursorInWin(Fs,arg1,arg2)) {
|
||||
arg1-=x0; arg2-=y0;
|
||||
CursorUpdate(Fs,arg1,arg2);
|
||||
RowCol2XY(&target_x,&target_y,cursor_row,cursor_col);
|
||||
if (!tmpu)
|
||||
Beep;
|
||||
else {
|
||||
if (Sqrt(Sqr(fire_radius_x-target_x)+Sqr(fire_radius_y-target_y))>
|
||||
fire_radius)
|
||||
Beep;
|
||||
else {
|
||||
IndirectAdd(tmpu,cursor_row,cursor_col);
|
||||
remaining--;
|
||||
}
|
||||
}
|
||||
}
|
||||
tmpu=NULL;
|
||||
fire_radius=0;
|
||||
break;
|
||||
case MSG_MS_R_UP:
|
||||
if (CursorInWin(Fs,arg1,arg2))
|
||||
throw('PhaseOvr',TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw('PhaseOvr',TRUE);
|
||||
}
|
||||
|
||||
U0 PlayerMove()
|
||||
{
|
||||
Unit *tmpu=NULL;
|
||||
I64 msg_code,arg1,arg2;
|
||||
ViewPlayerSet(cur_player);
|
||||
while (TRUE) {
|
||||
if (!alive_cnt[0] || !alive_cnt[1])
|
||||
throw('GameOver',TRUE);
|
||||
msg_code=GetMsg(&arg1,&arg2,1<<MSG_KEY_DOWN|1<<MSG_MS_L_DOWN|1<<MSG_MS_L_UP|
|
||||
1<<MSG_MS_R_UP);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
CharDo(arg1);
|
||||
break;
|
||||
case MSG_MS_L_DOWN:
|
||||
if (CursorInWin(Fs,arg1,arg2)) {
|
||||
arg1-=x0; arg2-=y0;
|
||||
CursorUpdate(Fs,arg1,arg2);
|
||||
if (tmpu=UnitFind(cursor_row,cursor_col)) {
|
||||
if (tmpu->player==enemy_player || !tmpu->remaining_movement)
|
||||
tmpu=NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_MS_L_UP:
|
||||
if (CursorInWin(Fs,arg1,arg2)) {
|
||||
arg1-=x0; arg2-=y0;
|
||||
CursorUpdate(Fs,arg1,arg2);
|
||||
if (!tmpu)
|
||||
Beep;
|
||||
else {
|
||||
UnitMove(tmpu,arg1,arg2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tmpu=NULL;
|
||||
break;
|
||||
case MSG_MS_R_UP:
|
||||
if (CursorInWin(Fs,arg1,arg2))
|
||||
throw('PhaseOvr',TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 PlayerDirect()
|
||||
{
|
||||
Unit *tmpu=NULL,*target;
|
||||
I64 msg_code,arg1,arg2;
|
||||
ViewPlayerSet(cur_player);
|
||||
while (TRUE) {
|
||||
if (!alive_cnt[0] || !alive_cnt[1])
|
||||
throw('GameOver',TRUE);
|
||||
msg_code=GetMsg(&arg1,&arg2,1<<MSG_KEY_DOWN|1<<MSG_MS_L_DOWN|1<<MSG_MS_L_UP|
|
||||
1<<MSG_MS_R_UP);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
CharDo(arg1);
|
||||
break;
|
||||
case MSG_MS_L_DOWN:
|
||||
if (CursorInWin(Fs,arg1,arg2)) {
|
||||
arg1-=x0; arg2-=y0;
|
||||
CursorUpdate(Fs,arg1,arg2);
|
||||
if (tmpu=UnitFind(cursor_row,cursor_col)) {
|
||||
if (tmpu->player==enemy_player || tmpu->fired ||
|
||||
tmpu->indirect_fire)
|
||||
tmpu=NULL;
|
||||
else {
|
||||
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_MS_L_UP:
|
||||
if (CursorInWin(Fs,arg1,arg2)) {
|
||||
arg1-=x0; arg2-=y0;
|
||||
CursorUpdate(Fs,arg1,arg2);
|
||||
target=UnitFind(cursor_row,cursor_col);
|
||||
if (!tmpu)
|
||||
Beep;
|
||||
else {
|
||||
if (!target || target->player!=enemy_player ||
|
||||
!Bt(&target->vis,0))
|
||||
Beep;
|
||||
else
|
||||
UnitDirectFire(tmpu,target);
|
||||
VisRecalc(VR_UPDATE_FRIENDLY_UNIT,tmpu);
|
||||
}
|
||||
}
|
||||
tmpu=NULL;
|
||||
fire_radius=0;
|
||||
break;
|
||||
case MSG_MS_R_UP:
|
||||
if (CursorInWin(Fs,arg1,arg2))
|
||||
throw('PhaseOvr',TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
Unit *UnitNearestFind(I64 row,I64 col,I64 player,Bool in_LOS,F64 range=-1)
|
||||
{
|
||||
I64 i;
|
||||
F64 dd,best_dd=F64_MAX,x1,y1,x2,y2;
|
||||
Unit *best=NULL;
|
||||
//$LK,"Sqrt",A="MN:Sqrt"$() is slow, so work with squared distances.
|
||||
if (range<0)
|
||||
range=F64_MAX;
|
||||
else
|
||||
range*=range;
|
||||
RowCol2XY(&x1,&y1,row,col);
|
||||
for (i=0;i<UNITS_NUM;i++)
|
||||
if (units[player][i].life>0) {
|
||||
if (!in_LOS || LOS(row,col,units[player][i].row,units[player][i].col)) {
|
||||
RowCol2XY(&x2,&y2,units[player][i].row,units[player][i].col);
|
||||
dd=Sqr(x2-x1)+Sqr(y2-y1);
|
||||
if (dd<=range && dd<best_dd) {
|
||||
best=&units[player][i];
|
||||
best_dd=dd;
|
||||
}
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
U0 PlayerIndirect()
|
||||
{
|
||||
Unit *target,*tmpu;
|
||||
I64 i;
|
||||
for (i=0;i<UNITS_NUM;i++) {
|
||||
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 PlayerMove()
|
||||
{
|
||||
Unit *target,*tmpu;
|
||||
I64 i;
|
||||
F64 x,y;
|
||||
for (i=0;i<UNITS_NUM;i++) {
|
||||
UserChk;
|
||||
tmpu=&units[cur_player][i];
|
||||
if (tmpu->life>0) {
|
||||
//Cheats because it violates Line-of-Sight
|
||||
if (target=UnitNearestFind(tmpu->row,tmpu->col,enemy_player,FALSE)) {
|
||||
RowCol2XY(&x,&y,target->row,target->col);
|
||||
if (!UnitMove(tmpu,x,y)) {
|
||||
RowCol2XY(&x,&y,tmpu->row,tmpu->col);
|
||||
UnitMove(tmpu,x+RandI16,y+RandI16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw('PhaseOvr',TRUE);
|
||||
}
|
||||
|
||||
U0 PlayerDirect()
|
||||
{
|
||||
Unit *target,*tmpu;
|
||||
I64 i;
|
||||
for (i=0;i<UNITS_NUM;i++) {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user