-
Notifications
You must be signed in to change notification settings - Fork 0
/
CONQLB.R
2575 lines (2260 loc) · 59.1 KB
/
CONQLB.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
###############################################################################
#
# C O N Q L B
#
# Copyright (C)1983-1986 by Jef Poskanzer and Craig Leres
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted,
# provided that this copyright notice appear in all copies and in all
# supporting documentation. Jef Poskanzer and Craig Leres make no
# representations about the suitability of this software for any
# purpose. It is provided "as is" without express or implied warranty.
#
###############################################################################
#
# Detailed revision history lives in "incl/conqdef"
#
###############################################################################
include "conqdef"
### chalkup - perform kills accoutinng
#
# SYNOPSIS
# integer snum
# call chalkup( snum )
#
# Note: This routines ASSUMES you have the common locked before you call it.
#
subroutine chalkup( snum )
NOIMPLICIT
integer snum
integer i, unum, team
real x, w, l, m
include "conqcom"
unum = suser(snum)
team = steam(snum)
# Update wins.
ustats(unum,USTAT_WINS) = ustats(unum,USTAT_WINS) + ifix(skills(snum))
tstats(team,TSTAT_WINS) = tstats(team,TSTAT_WINS) + ifix(skills(snum))
# Update max kills.
i = ifix( skills(snum) )
if ( i > ustats(unum,USTAT_MAXKILLS) )
ustats(unum,USTAT_MAXKILLS) = i
# Update rating.
l = ustats(unum,USTAT_LOSSES)
if ( l == 0 )
l = 1
w = ustats(unum,USTAT_WINS)
m = ustats(unum,USTAT_MAXKILLS)
urating(unum) = ( w / l ) + ( m / 4.0 )
x = w - l
if ( x >= 0.0 )
urating(unum) = urating(unum) + x ** ( 1.0 / 3.0 )
else
urating(unum) = urating(unum) - (- x ) ** ( 1.0 / 3.0 )
return
end
### cloak - attempt to engage the cloaking device
#
# SYNOPSIS
# logical didit, cloak
# integer snum
# didit = cloak( snum )
#
logical function cloak( snum )
NOIMPLICIT
integer snum
logical usefuel
include "conqcom"
srmode(snum) = .false.
if ( ! usefuel( snum, CLOAK_ON_FUEL, .false. ) )
return ( .false. )
scloaked(snum) = .true.
return ( .true. )
end
### damage - damage a ship
#
# SYNOPSIS
# integer snum, kb
# real dam
# call damage( snum, dam, kb )
#
subroutine damage( snum, dam, kb )
NOIMPLICIT
integer snum
real dam
integer kb
real mw
include "conqcom"
sdamage(snum) = sdamage(snum) + dam
if ( sdamage(snum) >= 100.0 )
call kill( snum, kb )
else
{
mw = maxwarp( snum )
sdwarp(snum) = min( sdwarp(snum), mw )
}
return
end
### detonate - blow up a torpedo (DOES LOCKING)
#
# SYNOPSIS
# integer snum, tnum
# call detonate( snum, tnum )
#
subroutine detonate( snum, tnum )
NOIMPLICIT
integer snum, tnum
include "conqcom"
PVLOCK(lockword)
if ( tstatus(snum,tnum) == TS_LIVE )
tstatus(snum,tnum) = TS_DETONATE
PVUNLOCK(lockword)
return
end
### display - do one update of a ships screen
#
# SYNOPSIS
# integer snum
# call display( snum )
#
subroutine display( snum )
NOIMPLICIT
integer snum
integer i, j, k, idx, lin, col, datacol, minenemy, minsenemy
integer modp1, length, strcmp
integer linofs(8), colofs(8)
character ch, buf(MSGMAXLINE)
logical cvtcoords, beep, lsmap
real x, scale, cenx, ceny, dis, mindis, minsdis, fl, cd, sd
static real zzskills, zzswarp
static character zzbuf(MSGMAXLINE)
static integer zzsshields, zzcshields, zzshead, zzsfuel, zzcfuel
static integer zzsweapons, zzsengines, zzsdamage, zzcdamage, zzsarmies
static integer zzsetemp, zzswtemp, zzctemp, zzstowedby, zzssdfuse
static real prevsh, prevdam
include "conqcom"
include "conqcom2"
string dirch "-/|\-/|\"
data linofs / 0, -1, -1, -1, 0, 1, 1, 1 /
data colofs / 1, 1, 0, -1, -1, -1, 0, 1 /
data prevsh / 0.0 /, prevdam / 100.0 /
if ( credraw )
{
call cdclear
lin = DISPLAY_LINS + 1
call cdline( 1, STAT_COLS, lin, STAT_COLS )
call cdline( lin, 1, lin, cmaxcol )
}
else
call cdclra( 1, STAT_COLS + 1, DISPLAY_LINS, cmaxcol )
beep = .false.
mindis = 1.0e6
minsdis = 1.0e6
minenemy = 0
minsenemy = 0
lsmap = smap(snum)
if ( lsmap )
{
scale = MAP_FAC
cenx = 0.0
ceny = 0.0
}
else
{
scale = SCALE_FAC
cenx = sx(snum)
ceny = sy(snum)
}
if ( closed )
call cdputs( "CLOSED", 1, STAT_COLS+(cmaxcol-STAT_COLS-6)/2+1 )
else if ( srobot(snum) )
call cdputs( "ROBOT", 1, STAT_COLS+(cmaxcol-STAT_COLS-5)/2+1 )
# Display the planets and suns.
for ( i = NUMPLANETS; i >= 1; i = i - 1 )
{
if ( ! preal(i) )
next
if ( ! cvtcoords( cenx, ceny, px(i), py(i), scale, lin, col ) )
next
if ( lsmap )
{
# Strategic map.
# Can't see moons.
if ( ptype(i) == PLANET_MOON )
next
# If it's a sun or we any planet we haven't scanned...
if ( ptype(i) == PLANET_SUN | ! pscanned(i,steam(snum)) )
call cdput( chrplanets(ptype(i)), lin, col )
else
{
# Pick a planet owner character.
if ( parmies(i) <= 0 | pteam(i) < 1 | pteam(i) > NUMTEAMS )
ch = '-'
else
ch = chrtorps(pteam(i))
# Display the planet; either it's numeric or it's not.
if ( soption(snum,OPT_NUMERICMAP) )
{
call prints( buf, "%c%d%c", ch, parmies(i), ch )
call cdputs( buf, lin, col+2-length( buf ) )
}
else if ( pscanned(i,steam(snum)) )
{
buf(1) = ch
buf(2) = chrplanets(ptype(i))
buf(3) = ch
buf(4) = EOS
call cdputs( buf, lin, col-1 )
}
}
# If necessary, display the planet name.
if ( soption(snum,OPT_PLANETNAMES) )
{
buf(1) = pname(1,i)
buf(2) = pname(2,i)
buf(3) = pname(3,i)
buf(4) = EOS
call cdputs( buf, lin, col+2 )
}
}
else
{
# Tactical map.
call puthing( ptype(i), lin, col )
call cdput( chrplanets(ptype(i)), lin, col )
if ( soption(snum,OPT_PLANETNAMES) )
if ( lin+1 <= DISPLAY_LINS )
call cdputs( pname(1,i), lin+1, col+2 )
}
}
# Display the planet eater.
if ( dstatus == DS_LIVE )
if ( ! lsmap )
if ( cvtcoords( cenx, ceny, dx, dy, scale, lin, col ) )
{
beep = .true.
sd = sind(dhead)
cd = cosd(dhead)
# Draw the body.
for ( fl = -DOOMSDAY_LENGTH/2.0;
fl < DOOMSDAY_LENGTH/2.0;
fl = fl + 50.0 )
if ( cvtcoords( cenx, ceny, dx+fl*cd, dy+fl*sd, scale, lin, col ) )
call cdput( '#', lin, col )
# Draw the head.
if ( cvtcoords( cenx, ceny, dx+DOOMSDAY_LENGTH/2.0*cd,
dy+DOOMSDAY_LENGTH/2.0*sd,
scale, lin, col ) )
call cdput( '*', lin, col )
}
# Display phaser graphics.
if ( ! lsmap & spfuse(snum) > 0 )
if ( soption(snum, OPT_PHASERGRAPHICS) )
{
sd = sind(slastphase(snum))
cd = cosd(slastphase(snum))
ch = dirch(modp1( round( slastphase(snum) + 22.5 ) / 45 + 1, 8 ))
for ( fl = 0; fl <= PHASER_DIST; fl = fl + 50.0 )
if ( cvtcoords( cenx, ceny,
sx(snum)+fl*cd, sy(snum)+fl*sd,
scale, lin, col ) )
call cdput( ch, lin, col )
}
# Display the ships.
for ( i = 1; i <= MAXSHIPS; i = i + 1 )
if ( sstatus(i) != SS_OFF )
{
# Display the torps if we're not strategic.
if ( ! lsmap )
{
# First display exploding torps.
if ( soption(snum, OPT_EXPLOSIONS) )
for ( j = 1; j <= MAXTORPS; j = j + 1 )
if ( tstatus(i,j) == TS_FIREBALL )
if ( cvtcoords( cenx, ceny, tx(i,j), ty(i,j),
scale, lin, col) )
call puthing( THING_EXPLOSION, lin, col )
# Now display the live torps.
for ( j = 1; j <= MAXTORPS; j = j + 1 )
if ( tstatus(i,j) == TS_LIVE | tstatus(i,j) == TS_DETONATE )
if ( cvtcoords( cenx, ceny, tx(i,j), ty(i,j),
scale, lin, col ) )
call cdput( chrtorps(steam(i)), lin, col )
}
# Display the ships.
if ( sstatus(i) == SS_LIVE )
{
# It's alive.
dis = dist( sx(snum), sy(snum), sx(i), sy(i) )
# Here's where ship to ship accurate information is "gathered".
if ( dis < ACCINFO_DIST & ! scloaked(i) & ! selfwar( snum ) )
sscanned(i,steam(snum)) = SCANNED_FUSE
# Check for nearest enemy and nearest scanned enemy.
if ( satwar( i, snum ) )
if ( i != snum )
{
if ( dis < mindis )
{
# New nearest enemy.
mindis = dis
minenemy = i
}
if ( dis < minsdis )
if ( ! selfwar( snum ) )
if ( sscanned(i,steam(snum)) > 0 )
{
# New nearest scanned enemy.
minsdis = dis
minsenemy = i
}
}
# There is potential for un-cloaked ships and ourselves.
if ( ! scloaked(i) | i == snum )
{
# ... especially if he's in the bounds of our current
# display (either tactical or strategic map)
if ( cvtcoords( cenx, ceny, sx(i), sy(i),
scale, lin, col ) )
{
# He's on the screen.
# We can see him if one of the following is true:
#
# - We are not looking at our strategic map
# - We're mutually at peace
# - Our team has scanned him and we're not self-war
# - He's within accurate scanning range
#
if ( ( ! lsmap ) |
( ! satwar(i, snum) ) |
( sscanned(i,steam(snum)) & ! selfwar(snum) ) |
( dis <= ACCINFO_DIST ) )
{
if ( ( i == snum ) & scloaked(snum) )
ch = CHAR_CLOAKED
else
ch = chrteams(steam(i))
call cdput( ch, lin, col )
call cdputn( i, 0, lin, col + 2 )
idx = modp1( round( shead(i) + 22.5 ) / 45 + 1, 8 )
j = lin+linofs(idx)
k = col+colofs(idx)
if ( j >= 1 & j <= DISPLAY_LINS & k > STAT_COLS &
k <= cmaxcol )
call cdput( dirch(idx), j, k )
}
}
if ( snum == i )
{
# If it's our ship and we're off the screen, fake it.
if ( lin < 1 )
lin = 1
else
lin = min( lin, DISPLAY_LINS )
if ( col < STAT_COLS + 1 )
col = STAT_COLS + 1
else
col = min( col, cmaxcol )
call cdmove( lin, col )
}
}
} # it's alive
} # for each ship
# Construct alert status line.
if ( credraw )
zzbuf(1) = EOS
buf(1) = EOS
if ( minenemy != 0 | stalert(snum) )
{
if ( mindis <= PHASER_DIST )
{
# Nearest enemy is very close.
call strcpy( "RED ALERT ", buf )
beep = .true.
}
else if ( mindis < ALERT_DIST )
{
# Nearest enemy is close.
call strcpy( "Alert ", buf )
beep = .true.
}
else if ( stalert(snum) )
{
# Nearby torpedos.
call strcpy( "Torp alert", buf )
minenemy = 0 # disable nearby enemy code
beep = .true.
}
else if ( mindis < YELLOW_DIST )
{
# Near an enemy.
call strcpy( "Yellow alert ", buf )
}
else if ( minsenemy != 0 )
{
# An enemy near one of our ships or planets.
minenemy = minsenemy # for cloaking code below
call strcpy( "Yellow alert ", buf )
}
else
minenemy = 0
if ( minenemy != 0 )
{
call appship( minenemy, buf )
if ( scloaked(minenemy) )
call appstr( " (CLOAKED)", buf )
}
}
if ( strcmp( buf, zzbuf ) != 0 )
{
lin = DISPLAY_LINS + 1
call cdline( lin, STAT_COLS, lin, cmaxcol )
if ( buf(1) != EOS )
{
col = (cmaxcol-STAT_COLS-length(buf))/2+STAT_COLS+1
call cdputs( buf, DISPLAY_LINS+1, col )
}
call strcpy( buf, zzbuf )
}
# Build and display the status info as necessary.
lin = 1
col = 1
datacol = col + 14
# Shields.
if ( sshields(snum) < prevsh )
beep = .true.
prevsh = sshields(snum)
if ( credraw )
{
zzsshields = -9
zzcshields = ' '
}
i = round( sshields(snum) )
if ( ! sshup(snum) | srmode(snum) )
i = -1
if ( i != zzsshields )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
if ( i == -1 )
call cdputs( "DOWN", lin, datacol )
else
{
call prints( buf, "%d", i )
call cdputs( buf, lin, datacol )
}
zzsshields = i
}
if ( i < 60 )
j = 'S'
else
j = 's'
if ( j != zzcshields )
{
if ( j == 'S' )
call cdputs( "SHIELDS =", lin, col )
else
call cdputs( "shields =", lin, col )
zzcshields = j
}
# Kills.
lin = lin + 2
if ( credraw )
{
call cdputs( "kills =", lin, col )
zzskills = -20.0
}
x = oneplace(skills(snum))
if ( x != zzskills )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
call prints( buf, "%g", x )
call cdputs( buf, lin, datacol )
zzskills = x
}
# Warp.
lin = lin + 2
if ( credraw )
{
call cdputs( "warp =", lin, col )
zzswarp = 92.0 # "Warp 92 Mr. Sulu."
}
x = oneplace(swarp(snum))
if ( x != zzswarp )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
if ( x >= 0 )
{
call prints( buf, "%g", x )
call cdputs( buf, lin, datacol )
}
else
call cdput( 'o', lin, datacol )
zzswarp = x
}
# Heading.
lin = lin + 2
if ( credraw )
{
call cdputs( "heading =", lin, col )
zzshead = 999
}
i = slock(snum)
if ( i >= 0 | swarp(snum) < 0.0 )
i = round( shead(snum) )
if ( i != zzshead )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
if ( -i >= 1 & -i <= NUMPLANETS )
call prints( buf, "%.3s", pname(1,-i) )
else
call prints( buf, "%d", i )
call cdputs( buf, lin, datacol )
zzshead = i
}
# Fuel.
lin = lin + 2
if ( credraw )
{
zzsfuel = -99
zzcfuel = ' '
}
i = round( sfuel(snum) )
if ( i != zzsfuel )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
call prints( buf, "%d", i )
call cdputs( buf, lin, datacol )
zzsfuel = i
}
if ( i < 200 )
j = 'F'
else
j = 'f'
if ( j != zzcfuel )
{
if ( j == 'F' )
call cdputs( "FUEL =", lin, col )
else if ( j == 'f' )
call cdputs( "fuel =", lin, col )
zzcfuel = j
}
# Allocation.
lin = lin + 2
if ( credraw )
{
call cdputs( "w/e =", lin, col )
zzsweapons = -9
zzsengines = -9
}
i = sweapons(snum)
j = sengines(snum)
if ( swfuse(snum) > 0 )
i = 0
if ( sefuse(snum) > 0 )
j = 0
if ( i != zzsweapons | j != zzsengines )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
buf(1) = EOS
if ( i == 0 )
call appstr( "**", buf )
else
call appint( i, buf )
call appchr( '/', buf )
if ( j == 0 )
call appstr( "**", buf )
else
call appint( j, buf )
call cdputs( buf, lin, datacol )
zzsweapons = i
}
# Temperature.
lin = lin + 2
if ( credraw )
{
zzswtemp = 0
zzsetemp = 0
zzctemp = ' '
}
i = round( swtemp(snum) )
j = round( setemp(snum) )
if ( i > 100 )
i = 100
if ( j > 100 )
j = 100
if ( i != zzswtemp | j != zzsetemp )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
if ( i != 0 | j != 0 )
{
buf(1) = EOS
if ( i >= 100 )
call appstr( "**", buf )
else
call appint( i, buf )
call appchr( '/', buf )
if ( j >= 100 )
call appstr( "**", buf )
else
call appint( j, buf )
call cdputs( buf, lin, datacol )
}
zzswtemp = i
zzsetemp = j
}
if ( i == 0 & j == 0 )
j = ' '
else if ( i >= 80 | j >= 80 )
j = 'T'
else
j = 't'
if ( j != zzctemp )
{
call cdclra( lin, col, lin, datacol-1 )
if ( j == 't' )
call cdputs( "temp =", lin, col )
else if ( j == 'T' )
call cdputs( "TEMP =", lin, col )
zzctemp = j
}
# Damage/repair.
if ( sdamage(snum) > prevdam )
beep = .true.
prevdam = sdamage(snum)
lin = lin + 2
if ( credraw )
{
zzsdamage = -9
zzcdamage = ' '
}
i = round( sdamage(snum) )
if ( i != zzsdamage )
{
call cdclra( lin, datacol, lin, STAT_COLS-1 )
if ( i > 0 )
{
call prints( buf, "%d", i )
call cdputs( buf, lin, datacol )
}
zzsdamage = i
}
if ( srmode(snum) )
j = 'r'
else if ( i >= 50 )
j = 'D'
else if ( i > 0 )
j = 'd'
else
j = ' '
if ( j != zzcdamage )
{
call cdclra( lin, col, lin, datacol-1 )
if ( j == 'r' )
call cdputs( "REPAIR, dmg =", lin, col )
else if ( j == 'd' )
call cdputs( "damage =", lin, col )
else if ( j == 'D' )
call cdputs( "DAMAGE =", lin, col )
zzcdamage = j
}
# Armies.
lin = lin + 2
if ( credraw )
zzsarmies = -666
i = sarmies(snum)
if ( i == 0 )
i = -saction(snum)
if ( i != zzsarmies )
{
call cdclra( lin, col, lin, STAT_COLS-1 )
if ( i > 0 )
{
call cdputs( "armies =", lin, col )
call prints( buf, "%d", i )
call cdputs( buf, lin, datacol )
}
else if ( i < 0 )
{
call cdputs( "action =", lin, col )
call robstr( -i, buf )
call cdputs( buf, lin, datacol )
}
zzsarmies = i
}
# Tractor beams.
lin = lin + 2
if ( credraw )
zzstowedby = 0
i = stowedby(snum)
if ( i == 0 )
i = -stowing(snum)
if ( i != zzstowedby )
{
call cdclra( lin, col, lin, datacol-1 )
if ( i == 0 )
buf(1) = EOS
else if ( i < 0 )
{
call strcpy( "towing ", buf )
call appship( -i, buf )
}
else if ( i > 0 )
{
call strcpy( "towed by ", buf )
call appship( i, buf )
}
call cdputs( buf, lin, col )
zzstowedby = i
}
# Self destruct fuse.
lin = lin + 2
if ( credraw )
zzssdfuse = -9
if ( scloaked(snum) )
i = -1
else
i = max( 0, ssdfuse(snum) )
if ( i != zzssdfuse )
{
call cdclra( lin, col, lin, STAT_COLS-1 )
if ( i > 0 )
{
call prints( buf, "DESTRUCT MINUS %-3d", i )
call cdputs( buf, lin, col )
}
else if ( i == -1 )
call cdputs( "CLOAKED", lin, col )
zzssdfuse = i
}
if ( beep )
if ( soption(snum,OPT_ALARMBELL) )
call scbeep
call cdplay( .true. )
credraw = .false.
return
end
### enemydet - detonate enemy torpedos
#
# SYNOPSIS
# logical didit, enemydet
# integer snum
# didit = enemydet( snum )
#
logical function enemydet( snum )
NOIMPLICIT
integer snum
integer i, j
logical usefuel
include "conqcom"
# Stop repairing.
srmode(snum) = .false.
if ( ! usefuel( snum, DETONATE_FUEL, .true. ) )
return ( .false. )
for ( i = 1; i <= MAXSHIPS; i = i + 1 )
if ( sstatus(i) != SS_OFF & i != snum )
for ( j = 1; j <= MAXTORPS; j = j + 1 )
if ( tstatus(i,j) == TS_LIVE )
if ( twar(i,j,steam(snum)) | swar(snum,steam(i)) )
if ( dist( sx(snum), sy(snum), tx(i,j), ty(i,j) ) <=
DETONATE_DIST )
call detonate( i, j )
return ( .true. )
end
### hit - hit a ship
#
# SYNOPSIS
# integer snum, kb
# real ht
# call hit( snum, ht, kb )
#
subroutine hit( snum, ht, kb )
NOIMPLICIT
integer snum
real ht
integer kb
include "conqcom"
if ( ht > 0.0 )
if ( sshup(snum) & ! srmode(snum) )
if ( ht > sshields(snum) )
{
call damage( snum, ht-sshields(snum), kb )
sshields(snum) = 0.0
}
else
sshields(snum) = sshields(snum) - ht
else
call damage( snum, ht, kb )
return
end
### ikill - ikill a ship
#
# SYNOPSIS
# integer snum, kb
# call ikill( snum, kb )
#
# Note: This routines ASSUMES you have the common locked before you call it.
#
subroutine ikill( snum, kb )
NOIMPLICIT
integer snum, kb
integer i, unum, team, kunum, kteam
real tkills
include "conqcom"
# Only procede if the ship is alive
if ( sstatus(snum) != SS_LIVE )
return
# The ship is alive; kill it.
skilledby(snum) = kb
sstatus(snum) = SS_DYING
unum = suser(snum)
team = steam(snum)
# Detonate all torpedos.
for ( i = 1; i <= MAXTORPS; i = i + 1 )
if ( tstatus(snum,i) == TS_LIVE )
tstatus(snum,i) = TS_DETONATE
# Release any tows.
if ( stowing(snum) != 0 )
stowedby(stowing(snum)) = 0
if ( stowedby(snum) != 0 )
stowing(stowedby(snum)) = 0
# Zero team scan fuses.
for ( i = 1; i <= NUMTEAMS; i = i + 1 )
sscanned(snum,i) = 0
if ( kb == KB_CONQUER )
skills(snum) = skills(snum) + CONQUER_KILLS
else if ( kb == KB_GOTDOOMSDAY )
skills(snum) = skills(snum) + DOOMSDAY_KILLS
else if ( kb > 0 ) # if a ship did the killing
{
kunum = suser(kb)
kteam = steam(kb)
tkills = 1.0 + skills(snum) * KILLS_KILLS
if ( sarmies(snum) > 0 )
{
# Keep track of carried armies killed - they are special.
tkills = tkills + sarmies(snum) * ARMY_KILLS
ustats(kunum,USTAT_ARMSHIP) =
ustats(kunum,USTAT_ARMSHIP) + sarmies(snum)
tstats(kteam,TSTAT_ARMSHIP) =
tstats(kteam,TSTAT_ARMSHIP) + sarmies(snum)
}
# Kills accounting.
if ( sstatus(kb) == SS_LIVE )
skills(kb) = skills(kb) + tkills
else
{
# Have to do some hacking when our killer is dead.
ustats(kunum,USTAT_WINS) =
ustats(kunum,USTAT_WINS) - ifix(skills(kb))
tstats(kteam,TSTAT_WINS) =
tstats(kteam,TSTAT_WINS) - ifix(skills(kb))
skills(kb) = skills(kb) + tkills
call chalkup( kb )
}
# Sticky war logic.
if ( ! swar(snum,kteam) )
{
swar(kb,team) = .true.
srwar(kb,team) = .true.
}
}
# Kills accounting.
call chalkup( snum )
if ( kb != KB_SELF & kb != KB_CONQUER & kb != KB_NEWGAME &
kb != KB_EVICT & kb != KB_SHIT & kb != KB_GOD )
{
# Update losses.
ustats(unum,USTAT_LOSSES) = ustats(unum,USTAT_LOSSES) + 1
tstats(team,TSTAT_LOSSES) = tstats(team,TSTAT_LOSSES) + 1
}
if ( ! srobot(snum) | spid(snum) != 0 )
{
sstatus(snum) = SS_DEAD
ssdfuse(snum) = -TIMEOUT_PLAYER # setup dead timeout timer
}
else
{
sstatus(snum) = SS_OFF # turn robots off
# We'd like to remove this next line so that you could
# use conqoper to see what killed him, but then robots
# show up on the debugging playlist...
skilledby(snum) = 0
}
return
end
### infoplanet - write out information about a planet
#
# SYNOPSIS
# character str()
# integer pnum, snum
# call infoplanet( str, pnum, snum )
#
subroutine infoplanet( str, pnum, snum )
NOIMPLICIT
character str(ARB)
integer pnum, snum
integer i, j, phoon, length
logical godlike, canscan, spwar
character buf(MSGMAXLINE*2), junk(MSGMAXLINE)
real x, y, angle
include "conqcom"