-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplanet.bas
7722 lines (7024 loc) · 254 KB
/
planet.bas
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
function deletemonsters(a as short) as short
dim b as short
dim m as _monster
if a>0 then
for b=0 to 16
planets(a).mon_template(b)=m
planets(a).mon_noamin(b)=0
planets(a).mon_noamax(b)=0
next
endif
return 0
end function
function makefinalmap(m as short) as short
dim as _cords p,p2
dim as short f,x,y,c,l
planets(m).darkness=5
planets(m).teleport=1
f=freefile
open "data/lstlvl.dat" for binary as #f
for y=0 to 20
for x=0 to 60
get #f,,l
planetmap(x,y,m)=l
if planetmap(x,y,m)=-80 and rnd_range(1,100)<20 then planetmap(x,y,m)=-81
if planetmap(x,y,m)=-54 and rnd_range(1,100)<80 then planetmap(x,y,m)=-55
next
next
close #f
p2.x=31
p2.y=2
do
p=rnd_point(m,0)
loop until distance(p,p2)>15
planetmap(p.x,p.y,m)=-127
for y=0 to 20
for x=0 to 60
if show_all=1 then planetmap(x,y,m)=planetmap(x,y,m)*-1
next
next
planets(m).depth=10
planets(m).mon_template(0)=makemonster(19,m)
planets(m).Mon_noamax(0)=28
planets(m).mon_noamin(0)=22
planets(m).mon_template(1)=makemonster(56,m)
planets(m).Mon_noamax(1)=12
planets(m).mon_noamin(1)=10
planets(m).mon_template(2)=makemonster(55,m)
planets(m).Mon_noamax(2)=12
planets(m).mon_noamin(2)=10
planets(m).mon_template(3)=makemonster(91,m)
planets(m).Mon_noamax(3)=12
planets(m).mon_noamin(3)=10
planets(m).grav=0.5
planets(m).atmos=3
return 0
end function
function makeplatform(slot as short,platforms as short,rooms as short, translate as short, adddoors as short=0) as short
dim map(60,20) as short
dim as short x,y,a,w,h,c,d,b,n,flag,door,c0
dim as _cords p(platforms)
dim sides(4) as byte
for x=0 to 60
for y=0 to 20
'map(x,y)=99
next
next
n=rnd_range(5,12)
for a=1 to platforms
d=0
do
p(a).x=rnd_range(1,50)
p(a).y=rnd_range(1,14)
w=rnd_range(5,9)
h=rnd_range(3,5)
c=0
for x=p(a).x-1 to p(a).x+w+1
for y=p(a).y-1 to p(a).y+h+1
if map(x,y)>0 then c=1
next
next
d+=1
loop until c=0 or d>=100
if c=0 then
for x=p(a).x to p(a).x+w
for y=p(a).y to p(a).y+h
map(x,y)=1
next
next
map(p(a).x,p(a).y)=0
map(p(a).x,p(a).y+h)=0
map(p(a).x+w,p(a).y)=0
map(p(a).x+w,p(a).y+h)=0
p(a).x=p(a).x+w/2
p(a).y=p(a).y+h/2
endif
next
for a=1 to platforms-1
do
while p(a).x<>p(a+1).x
if p(a).x>p(a+1).x then p(a).x-=1
if p(a).x<p(a+1).x then p(a).x+=1
if (map(p(a).x,p(a).y-1)<>2 and map(p(a).x,p(a).y+1)<>2) and p(a).x<>p(a+1).x and map(p(a).x,p(a).y)=0 then map(p(a).x,p(a).y)=2
wend
if map(p(a).x,p(a).y)=0 then map(p(a).x,p(a).y)=2
while p(a).y<>p(a+1).y
if p(a).y>p(a+1).y then p(a).y-=1
if p(a).y<p(a+1).y then p(a).y+=1
if (map(p(a).x-1,p(a).y)<>2 and map(p(a).x+1,p(a).y)<>2) and p(a).y<>p(a+1).y and map(p(a).x,p(a).y)=0 then map(p(a).x,p(a).y)=2
wend
loop until (p(a).x=p(a+1).x and p(a).y=p(a+1).y) 'or map(p(0).x,p(0).y)=1
c=0
next
for a=0 to rooms
flag=0
c0=0
do
p(0).x=rnd_range(1,49)
p(0).y=rnd_range(1,14)
p(1).x=p(0).x+rnd_range(3,10)
p(1).y=p(0).y+rnd_range(3,5)
flag=0
c0=0
for x=p(0).x-1 to p(1).x+1
for y=p(0).y-1 to p(1).y+1
if map(x,y)=0 then c0+=1
if map(x,y)=3 then flag=1
if (x=p(0).x-1 or x=p(0).x+1 or y=p(0).y-1 or y=p(0).y+1) and map(x,y)=4 then flag=1
next
next
loop until flag=0 and c0>0 and c0<(2+p(1).x-p(0).x)*(2+p(1).y-p(0).y)
for x=p(0).x to p(1).x
for y=p(0).y to p(1).y
if x=p(0).x or x=p(1).x or y=p(0).y or y=p(1).y then
map(x,y)=4
else
map(x,y)=3
endif
next
next
sides(1)=0
sides(2)=0
sides(3)=0
sides(4)=0
for x=p(0).x to p(1).x
for y=p(0).y to p(1).y
if x=p(0).x or x=p(1).x or y=p(0).y or y=p(1).y then
if (map(x-1,y)<4 and map(x+1,y)<4 and map(x-1,y)>0 and map(x+1,y)>0 and (map(x,y-1)=4 or map(x,y+1)=4)) then
door=5
if x=p(0).x and sides(1)=1 then door=4
if x=p(1).x and sides(2)=1 then door=4
if y=p(0).y and sides(3)=1 then door=4
if y=p(1).y and sides(4)=1 then door=4
map(x,y)=door
if x=p(0).x then sides(1)=1
if x=p(1).x then sides(2)=1
if y=p(0).y then sides(3)=1
if y=p(1).y then sides(4)=1
endif
if (map(x,y-1)<4 and map(x,y+1)<4 and map(x,y-1)>0 and map(x,y+1)>0 and (map(x-1,y)=4 or map(x+1,y)=4)) then
door=5
if x=p(0).x and sides(1)=1 then door=4
if x=p(1).x and sides(2)=1 then door=4
if y=p(0).y and sides(3)=1 then door=4
if y=p(1).y and sides(4)=1 then door=4
map(x,y)=door
if x=p(0).x then sides(1)=1
if x=p(1).x then sides(2)=1
if y=p(0).y then sides(3)=1
if y=p(1).y then sides(4)=1
endif
endif
next
next
for x=p(0).x to p(1).x
for y=p(0).y to p(1).y
if (x=p(0).x and y=p(0).y) or (x=p(0).x and y=p(1).y) or (x=p(1).x and y=p(0).y) or (x=p(1).x and y=p(1).y) then
if map(x+1,y)=2 or map(x-1,y)=2 or map(x,y+1)=2 or map(x,y-1)=2 then
if map(x+1,y)<>5 and map(x-1,y)<>5 and map(x,y+1)<>5 and map(x,y-1)<>5 then map(x,y)=5
endif
endif
next
next
next
for x=0 to 60
for y=0 to 20
if translate=1 then
if map(x,y)=0 then planetmap(x,y,slot)=-rnd_range(175,177) 'gasclouds
if map(x,y)=1 then planetmap(x,y,slot)=-68 'platform
if map(x,y)=2 then 'corridor
planetmap(x,y,slot)=-80
if rnd_range(1,100)<10 then planetmap(x,y,slot)=-81
endif
if map(x,y)=3 then planetmap(x,y,slot)=-80 'internal of room
if map(x,y)=4 then planetmap(x,y,slot)=-52 'wall
if map(x,y)=5 then planetmap(x,y,slot)=-54 'door
endif
if translate=2 then
if map(x,y)=0 then
planetmap(x,y,slot)=-rnd_range(49,51) 'stone walls
p(0).x=x
p(0).y=y
c=0
for b=1 to 9
p(2)=movepoint(p(0),b)
if planetmap(p(2).x,p(2).y,slot)=-158 then c=c+5
next
if rnd_range(1,100)<30+c-adddoors*3 then planetmap(p(0).x,p(0).y,slot)=-158
endif
if map(x,y)=1 then planetmap(x,y,slot)=-80 'platform
if map(x,y)=2 then 'corridor
planetmap(x,y,slot)=-80
if rnd_range(1,100)<10 then planetmap(x,y,slot)=-81
endif
if map(x,y)=3 then planetmap(x,y,slot)=-80 'internal of room
if map(x,y)=4 then planetmap(x,y,slot)=-52 'wall
if map(x,y)=5 then
if rnd_range(1,100)>66 then 'door
planetmap(x,y,slot)=-54
else
planetmap(x,y,slot)=-55
endif
endif
if rnd_range(1,100)<adddoors and x>0 and x<60 and y>0 and y<20 then
if map(x+1,y)>0 and map(x+1,y)<4 and map(x-1,y)>0 and map(x-1,y)<4 and map(x,y+1)=4 and map(x,y-1)=4 then planetmap(x,y,slot)=-54
if map(x,y+1)>0 and map(x,y+1)<4 and map(x,y-1)>0 and map(x,y-1)<4 and map(x+1,y)=4 and map(x-1,y)=4 then planetmap(x,y,slot)=-54
endif
endif
if translate=3 then
if map(x,y)=0 then
planetmap(x,y,slot)=-rnd_range(49,51) 'stone walls
p(0).x=x
p(0).y=y
c=0
for b=1 to 9
p(2)=movepoint(p(0),b)
if planetmap(p(2).x,p(2).y,slot)=-158 then c=c+(10-adddoors)
next
if rnd_range(1,100)<adddoors+c then planetmap(p(0).x,p(0).y,slot)=-158
endif
if map(x,y)=1 then planetmap(x,y,slot)=-4 'platform
if map(x,y)=2 then planetmap(x,y,slot)=-4
if map(x,y)=3 then planetmap(x,y,slot)=-4 'internal of room
if map(x,y)=4 then planetmap(x,y,slot)=-51 'wall
if map(x,y)=5 then planetmap(x,y,slot)=-156
endif
if translate=4 then
if map(x,y)=0 then planetmap(x,y,slot)=-rnd_range(175,177) 'gasclouds
if map(x,y)=1 then planetmap(x,y,slot)=-68 'platform
if map(x,y)=2 then planetmap(x,y,slot)=-80 'Corridor
if map(x,y)=3 then planetmap(x,y,slot)=-80 'internal of room
if map(x,y)=4 then planetmap(x,y,slot)=-52 'wall
if map(x,y)=5 then planetmap(x,y,slot)=-156 'door
endif
next
next
return 0
end function
function makecomplex(byref enter as _cords, down as short,blocked as byte=0) as short
dim as short last,wantsize,larga,largb,lno,x,y,mi,slot,old,a,dx,dy,dis,d,b,c,best,startdigging
dim t as _rect
dim r(255) as _rect
dim rfl(255) as short
dim map2(60,20) as short
dim sp(255) as _cords
dim as short roomsize
dim p as _cords
dim p1 as _cords
dim p2 as _cords
dim as integer counter,bigc
dim as short varchance
slot=enter.m
if show_all=1 then dprint "Made complex at "&slot
if planets(slot).depth=0 then planets(slot).depth=1
planets(slot).darkness=5
planets(slot).vault(0)=r(0)
planets(slot).teleport=1
planets(slot).temp=25
planets(slot).atmos=3
planets(slot).grav=.8
planets(slot).mon_template(0)=makemonster(9,slot)
planets(slot).mon_noamin(0)=8
planets(slot).mon_noamax(0)=16+planets(slot).depth
planets(slot).mon_template(1)=makemonster(90,slot)
planets(slot).mon_noamin(1)=16
planets(slot).mon_noamax(1)=26+planets(slot).depth
if rnd_range(1,100)<15+planets(slot).depth*3 then
planets(slot).mon_template(2)=makemonster(56,slot)
planets(slot).mon_noamin(2)=1
planets(slot).mon_noamax(2)=2+planets(slot).depth
endif
if rnd_range(1,100)<25+planets(slot).depth*5 then
planets(slot).mon_template(3)=makemonster(19,slot)
planets(slot).mon_noamin(3)=0
planets(slot).mon_noamax(3)=1+planets(slot).depth
endif
if rnd_range(1,100)<15+planets(slot).depth*5 then
planets(slot).mon_template(4)=makemonster(91,slot)
planets(slot).mon_noamin(4)=1
planets(slot).mon_noamax(4)=2+planets(slot).depth
endif
do
last=0
for a=0 to 255
r(a)=r(255)
next
roomsize=25
wantsize=100 'chop to this size
mi=2 'minimum
r(0).x=0
r(0).y=0
r(0).h=20
r(0).w=60
do
larga=0
largb=0
'find largestrect
for a=0 to last
if r(a).h>larga then
larga=r(a).h
lno=a
endif
if r(a).w>larga then
larga=r(a).w
lno=a
endif
if r(a).h*r(a).w>largb then
largb=r(a).h*r(a).w
lno=a
endif
next
' Half largest _rect
last=last+1
if r(lno).h>r(lno).w then
y=rnd_range(mi,r(lno).h-mi)
old=r(lno).h
t=r(lno)
r(last)=t
t.h=y-1
r(last).y=r(last).y+y
r(last).h=old-y
r(lno)=t
else
x=rnd_range(mi,r(lno).w-mi)
old=r(lno).w
t=r(lno)
r(last)=t
t.w=x-1
r(last).x=r(last).x+x
r(last).w=old-x
r(lno)=t
endif
loop until largb<wantsize
for a=0 to last
fill_rect(r(a),1,0,map2())
next
for a=0 to last
'make rects smaller
fill_rect(r(a),1,1,map2())
if r(a).h*r(a).w>roomsize then
r(a).x=r(a).x+1
r(a).y=r(a).y+1
r(a).w=r(a).w-2
r(a).h=r(a).h-2
do
b=rnd_range(1,4)
if r(a).w>=r(a).h then
if b=1 then
r(a).x=r(a).x+1
r(a).w=r(a).w-2
endif
if b=4 then r(a).w=r(a).w-2
endif
if r(a).h>r(a).w then
if b=2 then
r(a).y=r(a).y+1
r(a).h=r(a).h-2
endif
if b=3 then r(a).h=r(a).h-2
endif
loop until r(a).h*r(a).w<=roomsize
if r(a).h>1 and r(a).w>1 then
fill_rect(r(a),0,0,map2())
else
r(a).wd(5)=1
endif
else
r(a).wd(5)=1
endif
next
for a=0 to last
if r(a).wd(5)=0 then
c=0
do
do
if b>-1 then r(a).wd(b)=1
b=rndwall(r(a))
if b=-1 or c>52 then exit do
p1=rndwallpoint(r(a),b)
c=c+1
loop until p1.x>2 and p1.y>1 and p1.x<58 and p1.y<19 and r(a).wd(b)=0
if c<=52 and b>0 then
if rnd_range(1,100)<33 then map2(p1.x,p1.y)=3
b=digger(p1,map2(),b)
if rnd_range(1,100)<33 then map2(p1.x,p1.y)=3
endif
loop until b<=0 or c>52
endif
next a
flood_fill(r(1).x,r(1).y,map2())
counter=counter+1
c=0
for a=0 to last
if map2(r(a).x,r(a).y)<10 and r(a).wd(5)=0 then c=c+1
next
loop until c=0
for x=0 to 60
for y=0 to 20
planetmap(x,y,slot)=-52
if map2(x,y)=1 then planetmap(x,y,slot)=-52 'Wall
if map2(x,y)=11 then planetmap(x,y,slot)=-80 'Floor
if map2(x,y)=13 then planetmap(x,y,slot)=-80 'Wall
if map2(x,y)=14 then
if rnd_range(1,100)>planets(slot).depth*10 then
if rnd_range(1,100)<88 then
planetmap(x,y,slot)=-55 'Door
else
planetmap(x,y,slot)=-54
endif
else
planetmap(x,y,slot)=-289 'secretdoor
endif
endif
if map2(x,y)=15 then planetmap(x,y,slot)=-81 'Trap
next
next
do
a=rnd_range(0,last)
loop until r(a).wd(5)=0
'Put portal in room a
enter.x=r(a).x+r(a).w/2
enter.y=r(a).y+r(a).h/2
b=a
for c=1 to rnd_range(1,planets(slot).depth+1)
do
a=rnd_range(0,last)
loop until r(a).wd(5)=0 and a<>b
x=r(a).x+r(a).w/2
y=r(a).y+r(a).h/2
planetmap(x,y,slot)=-82
next
for a=1 to rnd_range(1,planets(slot).depth+1)-rnd_range(1,planets(slot).depth-1)
do
a=rnd_range(0,last)
loop until r(a).wd(5)=0 and a<>b
x=r(a).x+r(a).w/2
y=r(a).y+r(a).h/2
planetmap(x,y,slot)=-84
placeitem(make_item(99),x,y,slot)
next
for a=0 to rnd_range(1,planets(slot).depth+1)+rnd_range(1,planets(slot).depth-1)
do
a=rnd_range(0,last)
loop until r(a).wd(5)=0 and a<>b
x=rnd_range(r(a).x,r(a).x+r(a).w)
y=rnd_range(r(a).y,r(a).y+r(a).h)
planetmap(x,y,slot)=-84
next
if (rnd_range(1,100)<33 or planets(slot).depth>7) and blocked=0 then
do
a=rnd_range(0,last)
loop until r(a).wd(5)=0 and a<>b
x=rnd_range(r(a).x,r(a).x+r(a).w)
y=rnd_range(r(a).y,r(a).y+r(a).h)
lastportal+=1
lastplanet+=1
a=lastportal
portal(a).desig="A shaft. "
portal(a).tile=111
portal(a).ti_no=3003
portal(a).col=14
portal(a).from.s=enter.s
portal(a).from.m=enter.m
'portal(a).from.m=map(portal(a).from.s).planets(portal(a).from.p)
portal(a).from.x=x
portal(a).from.y=y
portal(a).dest.m=lastplanet
portal(a).dest.s=portal(a).from.s
portal(a).dest.x=rnd_range(1,59)
portal(a).dest.y=rnd_range(1,19)
portal(a).discovered=show_portals
map(portal(a).from.s).discovered=3
planetmap(portal(a).from.x,portal(a).from.y,slot)=0
endif
for a=0 to planets(slot).depth*5
do
p=rnd_point(slot,0)
if p.x=0 then p.x=1
if p.x=60 then p.x=59
if p.y=0 then p.y=1
if p.y=20 then p.y=19
loop until (abs(planetmap(p.x,p.y-1,slot))=52 and abs(planetmap(p.x,p.y+1,slot))=52) or (abs(planetmap(p.x-1,p.y,slot))=52 and abs(planetmap(p.x+1,p.y,slot))=52)
planetmap(p.x,p.y,slot)=-289
next
planetmap(enter.x,enter.y,slot)=-80
varchance=0
if rnd_range(1,100)<planets(slot).depth*2 then
planets(slot).vault(0)=r(rnd_range(0,last))
planets(slot).vault(0).wd(5)=1
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<15+planets(slot).depth*2+varchance then
p=rnd_point(slot,0)
planetmap(p.x,p.y,slot)=-298
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<15+planets(slot).depth*2+varchance then
p=rnd_point(slot,0)
planetmap(p.x,p.y,slot)=-288
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<15+planets(slot).depth*2+varchance then
p=rnd_point(slot,0)
planetmap(p.x,p.y,slot)=-288
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<15+planets(slot).depth*2+varchance then
p=rnd_point(slot,0)
planetmap(p.x,p.y,slot)=-291
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<5+planets(slot).depth*2+varchance then
p=rnd_point(slot,0)
planetmap(p.x,p.y,slot)=-293
varchance-=4
endif
varchance+=5
if rnd_range(1,100)<25+planets(slot).depth*2+varchance then
for b=0 to rnd_range(1,planets(slot).depth)
p=rnd_point(slot,0)
if abs(planetmap(p.x,p.y,slot))=80 then planetmap(p.x,p.y,slot)=-225
next
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<25+planets(slot).depth*2+varchance then
p=rnd_point(slot,0)
if abs(planetmap(p.x,p.y,slot))=80 then planetmap(p.x,p.y,slot)=-292
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<25+planets(slot).depth*2+varchance then
for b=0 to rnd_range(1,planets(slot).depth)
p=rnd_point(slot,0)
if abs(planetmap(p.x,p.y,slot))=80 then planetmap(p.x,p.y,slot)=-290
next
varchance-=5
endif
varchance+=5
if rnd_range(1,100)<15+planets(slot).depth*2+varchance then
p=rnd_point(slot,0)
planetmap(p.x,p.y,slot)=-231
planets(slot).atmos=1
planets(slot).grav=1
endif
return 0
end function
function makecomplex2(slot as short,gc1 as _cords, gc2 as _cords, roundedcorners1 as short,roundedcorners2 as short,nocol1 as short,nocol2 as short,doorchance as short,loopchance as short,loopdoor as short,adddoor as short,addloop as short,nosmallrooms as short,culdesacruns as short, t as short) as short
dim as short map(60,20)
dim as short map2(60,20)
dim as short map3(60,20)
dim as short x,y,c,a,ff,x1,y1,xx,yy,coll
dim as short rw1,rh1 ,rn1 ,rmw1 ,rmh1 ,rw2 ,rh2,rn2 ,rmw2 ,rmh2
dim valid(1300) as _cords
dim lastvalid as short
dim valneigh(4) as _cords
dim lastneig as short
dim collision as short
dim as short w,h
rmw1=gc1.x
rmh1=gc1.y
rw1=gc1.p
rh1=gc1.s
rn1=gc1.m
rmw2=gc2.x
rmh2=gc2.y
rw2=gc2.p
rh2=gc2.s
rn2=gc2.m
for x=0 to 60
for y=0 to 20
map(x,y)=1
next
next
for x=1 to 59 step 2
for y=1 to 19 step 2
map(x,y)=0
next
next
if rn1>0 then
a=0
do
w=rnd_range(rmw1,rw1)
h=rnd_range(rmh1,rh1)
valid(c).x=rnd_range(1,59-w)
valid(c).y=rnd_range(1,19-h)
if nocol1=1 then
do
w=rnd_range(rmw1,rw1)
h=rnd_range(rmh1,rh1)
valid(c).x=rnd_range(1,59-w)
valid(c).y=rnd_range(1,19-h)
collision=0
for x=valid(c).x-1 to valid(c).x+w+1
for y=valid(c).y-1 to valid(c).y+h+1
if map2(x,y)=1 then
collision=1
endif
next
next
if collision=0 then
for x=valid(c).x to valid(c).x+w
for y=valid(c).y to valid(c).y+h
map2(x,y)=1
next
next
endif
loop until collision=0
else
collision=0
endif
if collision=0 then
for x=valid(c).x to valid(c).x+w
for y=valid(c).y to valid(c).y+h
if x=valid(c).x or y=valid(c).y or x=valid(c).x+w or y=valid(c).y+h then
map(x,y)=1
else
if map(x,y)=1 then map(x,y)=0
endif
next
next
if rnd_range(1,100)<roundedcorners1 and h>4 and w>4 then
map(valid(c).x+1,valid(c).y+1)=1
map(valid(c).x+w-1,valid(c).y+1)=1
map(valid(c).x+w-1,valid(c).y+h-1)=1
map(valid(c).x+1,valid(c).y+h-1)=1
endif
a+=1
endif
loop until a>=rn1
endif
if rn2>0 then
a=0
do
w=rnd_range(rmw2,rw2)
h=rnd_range(rmh2,rh2)
valid(c).x=rnd_range(1,59-w)
valid(c).y=rnd_range(1,19-h)
if nocol2=1 then
collision=0
for x=valid(c).x-1 to valid(c).x+w+1
for y=valid(c).y-1 to valid(c).y+h+1
if map2(x,y)=1 then
collision=1
endif
next
next
if collision=0 then
for x=valid(c).x to valid(c).x+w
for y=valid(c).y to valid(c).y+h
map2(x,y)=1
next
next
endif
else
collision=0
endif
if collision=0 then
for x=valid(c).x to valid(c).x+w
for y=valid(c).y to valid(c).y+h
if x=valid(c).x or y=valid(c).y or x=valid(c).x+w or y=valid(c).y+h then
map(x,y)=1
else
if map(x,y)=1 then map(x,y)=0
endif
next
next
if rnd_range(1,100)<roundedcorners2 and h>4 and w>4 then
map(valid(c).x+1,valid(c).y+1)=1
map(valid(c).x+w-1,valid(c).y+1)=1
map(valid(c).x+w-1,valid(c).y+h-1)=1
map(valid(c).x+1,valid(c).y+h-1)=1
endif
a+=1
endif
loop until a>=rn2
endif
do
lastvalid=0
for x=1 to 59
for y=1 to 19
if checkvalid(x,y,map()) then
lastvalid+=1
valid(lastvalid).x=x
valid(lastvalid).y=y
endif
next
next
if lastvalid>=1 then
c=rnd_range(1,lastvalid)
x=valid(c).x
y=valid(c).y
lastneig=0
if checkvalid(x-2,y,map()) then
lastneig+=1
valneigh(lastneig).x=x-2
valneigh(lastneig).y=y
endif
if checkvalid(x+2,y,map()) then
lastneig+=1
valneigh(lastneig).x=x+2
valneigh(lastneig).y=y
endif
if checkvalid(x,y+2,map()) then
lastneig+=1
valneigh(lastneig).x=x
valneigh(lastneig).y=y+2
endif
if checkvalid(x,y-2,map()) then
lastneig+=1
valneigh(lastneig).x=x
valneigh(lastneig).y=y-2
endif
if lastneig>0 then
c=rnd_range(1,lastneig)
if valneigh(c).x>x then map(x+1,y)=0
if valneigh(c).x<x then map(x-1,y)=0
if valneigh(c).y>y then map(x,y+1)=0
if valneigh(c).y<y then map(x,y-1)=0
else
'print "No valid neighbour"
endif
endif
loop until lastvalid=0 or lastneig=0
do
ff=1
for x=0 to 60
for y=0 to 20
if map(x,y)=-1 then map(x,y)=0
'if map(x,y)=-2 then map(x,y)=2
next
next
floodfill3(1,1,map())
lastvalid=0
for x=1 to 59
for y=1 to 19
if checkdoor(x,y,map()) then
lastvalid+=1
valid(lastvalid).x=x
valid(lastvalid).y=y
endif
next
next
if lastvalid>0 then
c=rnd_range(1,lastvalid)
if rnd_range(1,100)<doorchance then
map(valid(c).x,valid(c).y)=2
else
map(valid(c).x,valid(c).y)=0
endif
endif
for x=0 to 60
for y=0 to 20
if map(x,y)=0 then ff=0
next
next
loop until ff=1 or lastvalid=0
for x=0 to 60
for y=0 to 20
if map(x,y)=-1 then map(x,y)=0
if map(x,y)=-2 then map(x,y)=2
next
next
if culdesacruns>0 then
for a=0 to culdesacruns
for x=0 to 60
for y=0 to 20
map2(x,y)=map(x,y)
next
next
for x=1 to 59
for y=1 to 19
ff=0
for x1=x-1 to x+1
for y1=y-1 to y+1
if map(x1,y1)=1 then ff=ff+1
next
next
if map(x,y)=1 or map(x,y)=0 then
if map(x-1,y)<>2 and map(x+1,y)<>2 and map(x,y-1)<>2 and map(x,y+1)<>2 then
if ff<3 and map(x,y)=1 then
map2(x,y)=0
map3(x,y)=1
endif
if ff>=7 and map(x,y)=0 then
map2(x,y)=1
map3(x,y)=1
endif
if map(x,y)=0 then
if map(x-1,y-1)=1 and map(x-1,y)=1 and map(x-1,y+1)=1 and map(x,y-1)=1 and map(x,y+1)=1 then
map2(x,y)=1
map3(x,y)=1
endif
if map(x+1,y-1)=1 and map(x+1,y)=1 and map(x+1,y+1)=1 and map(x,y-1)=1 and map(x,y+1)=1 then
map2(x,y)=1
map3(x,y)=2
endif
if map(x+1,y-1)=1 and map(x,y-1)=1 and map(x-1,y-1)=1 and map(x-1,y)=1 and map(x+1,y)=1 then
map2(x,y)=1
map3(x,y)=3
endif
if map(x+1,y+1)=1 and map(x,y+1)=1 and map(x-1,y+1)=1 and map(x-1,y)=1 and map(x+1,y)=1 then
map2(x,y)=1
map3(x,y)=4
endif
endif
endif
endif
next
next
for x=0 to 60
for y=0 to 20
map(x,y)=map2(x,y)
next
next
next
endif
if nosmallrooms>0 then
for a=0 to nosmallrooms
for x=0 to 60
for y=0 to 20
map2(x,y)=map(x,y)
next
next
for x=1 to 59
for y=1 to 19
ff=0
for x1=x-1 to x+1
for y1=y-1 to y+1
if map(x1,y1)=1 then ff=ff+1
next
next
if ff=7 and nosmallrooms=1 then
if map(x-1,y)=2 and map(x+1,y)=1 and map(x,y-1)=1 and map(x,y+1)=1 then
map2(x-1,y)=1
map3(x-1,y)=2
map2(x,y)=1
map3(x,y)=2
endif
if map(x-1,y)=1 and map(x+1,y)=2 and map(x,y-1)=1 and map(x,y+1)=1 then
map2(x+1,y)=1
map3(x+1,y)=3
map2(x,y)=1
map3(x,y)=3
endif
if map(x-1,y)=1 and map(x+1,y)=1 and map(x,y-1)=2 and map(x,y+1)=1 then
map2(x,y-1)=1
map3(x,y-1)=4
map2(x,y)=1
map3(x,y)=4
endif
if map(x-1,y)=1 and map(x+1,y)=1 and map(x,y-1)=1 and map(x,y+1)=2 then
map2(x,y+1)=1
map3(x,y+1)=5
map2(x,y)=1
map3(x,y)=5
endif
endif
next
next
for x=0 to 60
for y=0 to 20
map(x,y)=map2(x,y)
next
next
next
endif
for x=0 to 58
for y=0 to 18
if map(x+1,y+1)=1 then
'if rnd_range(1,100)<loopchance and map(x,y)=1 and map(x+1,y)=0 and map(x+2,y)=1 and map(x,y+1)=1 and map(x+1,y+1)=1 and map(x+2,y+1)=1 and map(x+2,y)=1 and map(x+2,y+1)=0 and map(x+3,y+2)=1 then map2(x+1,y+1)=0
'if rnd_range(1,100)<loopchance and map(x,y)=1 and map(x,y+1)=0 and map(x,y+2)=1 and map(x+1,y)=1 and map(x+1,y+1)=1 and map(x+1,y+2)=1 and map(x+2,y)=1 and map(x+2,y+1)=0 and map(x+2,y+2)=1 then map2(x+1,y+1)=0
if map(x+1,y)=1 and map(x+1,y+2)=1 and map(x,y+1)=0 and map(x+2,y+1)=0 then
if rnd_range(1,100)<loopdoor and adddoor=1 then map(x+1,y+1)=2
if rnd_range(1,100)<loopchance and addloop=1 then map(x+1,y+1)=0
endif
if map(x,y+1)=1 and map(x+2,y+1)=1 and map(x+1,y)=0 and map(x+1,y+2)=0 then
if rnd_range(1,100)<loopdoor and adddoor=1 then map(x+1,y+1)=2
if rnd_range(1,100)<loopchance and addloop=1 then map(x+1,y+1)=0
endif
endif
next
next
x1=0