-
Notifications
You must be signed in to change notification settings - Fork 1
/
CHKSECT.RX
131 lines (127 loc) · 3.59 KB
/
CHKSECT.RX
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
/* BREXX */
/* CHECKS IF ANOTHER PLAYER IS IN THIS SECTOR */
/* RIGHT NOW, DOES NOTHING BUT */
CALL ISHERE
RETURN
ISHERE:
/* SCANS ALL PLAYERS TO FIND OUT IF THEYRE IN */
/* THIS SECTOR */
THIS_SECTOR=CURSEC
CURRENT_PLR=PLRKEY
THISPLY=''
ADDRESS TSO
"VSAMIO OPEN UNISET (READ"
"VSAMIO LOCATE UNISET (KEY PLY"
DO FOREVER
"VSAMIO READ UNISET (NEXT UPDATE VAR THISPLY"
CALL SPLITRECORD 'PLWORK',THISPLY
IF LEFT(WPLRKEY,3)<>'PLY' THEN LEAVE
IF RC<>0 THEN LEAVE
IF WPLRKEY=PLRKEY THEN ITERATE /* IT'S ME */
IF WCURSEC=THIS_SECTOR THEN
DO
CALL BATTLESCREEN
END
END
"VSAMIO CLOSE UNISET"
ADDRESS FSS
RETURN
COMPSCORE:
MYSCORE=0
THEIRSCORE=0
MYCARGO=(FOOD+EQUIP+MATL)*HOLDS
MYDEFENSE=(FIGHTERS*2)
MYSCORE=(MYCARGO+MYDEFENSE)+MONEY
THEIRCARGO=(WFOOD+WEQUIP+WMATL)*WHOLDS
THEIRDEFENSE=(WFIGHTERS*2)
THEIRSCORE=(THEIRCARGO+THEIRDEFENSE)+WMONEY
TOTALSCORES=THEIRSCORE+MYSCORE
IF MYSCORE>THEIRSCORE THEN
ODDS=THEIRSCORE/MYSCORE
ELSE
ODDS=MYSCORE/THEIRSCORE
PCT=FORMAT(ODDS*100)
RETURN
BATTLE:
THEYLOSE=0
WELOSE=0
WESTART=FIGHTERS
THEYSTART=WFIGHTERS
IF WESTART>THEYSTART THEN
DOBATTLE=THEYSTART
ELSE
DOBATTLE=WESTART
DO I=1 TO DOBATTLE
PCT=FORMAT(ODDS*100)
LOW=PCT
HIGH=200-PCT
BRAND=RANDOM(1,350,MILLIS())
IF BRAND>200 THEN
ITERATE /* BATTLE A DRAW */
IF (BRAND>=LOW)&(BRAND<=HIGH) THEN
DO
WELOSE=WELOSE+1
END
ELSE
DO
THEYLOSE=THEYLOSE+1
END
END
MELEFT=FIGHTERS-WELOSE
THEYLEFT=WFIGHTERS-THEYLOSE
IF MELEFT<0 THEN MELEFT=0
IF THEYLEFT<0 THEN THEYLEFT=0
RETURN
BATTLESCREEN:
ADDRESS FSS
CALL FSSCLOSE
CALL FSSINIT
ENEMY=STRIP(WHANDLE)
CALL COMPSCORE
CALL FSSTITLE 'BATTLE CONTROL SYSTEM ('||PCT||')'
CALL FSSTEXT ENEMY||' is in this sector with '||STRIP(WFIGHTERS)||' fighters',4,2,,#PROT+#RED
CALL FSSTEXT ENEMY||' attacks!',5,2,,#PROT+#RED+#BLINK
CALL FSSTEXT 'Response:',7,2,,#PROT+#GREEN
CALL FSSTEXT 'Fighters:',8,2,,#PROT+#GREEN
CALL FSSTEXT '<A>ggressive, <D>efensive',7,40,,#PROT+#WHITE
CALL FSSTEXT 'Fighters to send to action',8,40,,#PROT+#WHITE
CALL FSSTEXT '<ENTER> Confirm <PFK03> RETREAT!',23,2,,#PROT+#WHITE
CALL FSSFIELD 'ZRESPONSE',7,12,1,#YELLOW+#USCORE
CALL FSSFSET 'ZRESPONSE','A'
CALL FSSFIELD 'ZFIGHTER',8,12,15,#YELLOW+#USCORE
CALL BATTLE
CALL FSSTEXT 'The battle raged for a time, eventually the war weary soldiers returned.',10,2,,#prot+#pink
CALL FSSTEXT 'You destroyed '||THEYLOSE||' of the '||ENEMY||' fighters.',11,2,,#prot+#pink
CALL FSSTEXT 'The '||ENEMY||' onslaught destroyed '||WELOSE||' of your valiant fighters',12,2,,#prot+#pink
FIGHTERS=FIGHTERS-WELOSE
WFIGHTERS=WFIGHTERS-THEYLOSE
CALL FSSTEXT 'You have '||FIGHTERS||' fighters remaining.',14,2,,#prot+#yellow
CALL FSSTEXT ENEMY||' has '||WFIGHTERS||' fighters remaining.',15,2,,#prot+#yellow
CALL FSSFSET 'ZFIGHTER',FIGHTERS
IF FIGHTERS>0 THEN
DO
IF THEYLOSE>WELOSE THEN
RESLT='You were victorous in this battle'
ELSE
RESLT='Your forces were repelled in this battle'
IF WFIGHTERS=0 THEN
RESLT=RESLT||', ending in a glorios win!'
ELSE
RESLT=RESLT||', but the war isn''t over!'
END
ELSE
RESLT="Despite your bravery, this war is lost. Youve been repelled"
CALL FSSTEXT RESLT,17,2,,#PROT+#YELLOW
CALL FSSCURSOR 'ZRESPONSE'
DO
PKEY=FSSREFRESH()
IF PKEY=#PFK03 THEN
DO
RETREAT=1
END
IF PKEY=#ENTER THEN
DO
RETREAT=0
END
END
RETURN