-
Notifications
You must be signed in to change notification settings - Fork 10
/
script02.s
339 lines (309 loc) · 11.9 KB
/
script02.s
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
include macros.s
include mainsym.s
; Script 2, conversations in the game beginning
org scriptCodeStart
dc.w GameStart
dc.w Scientist1
dc.w Scientist2
dc.w RadioUpperLabsEntrance
; Finalize game start. Create persistent NPCs to the leveldata and randomize entry codes
;
; Parameters: -
; Returns: -
; Modifies: various
GameStart: ldx #MAX_PERSISTENTNPCS-1
GS_Loop: jsr GetLevelActorIndex
lda npcX,x
sta lvlActX,y
lda npcY,x
sta lvlActY,y
lda npcF,x
sta lvlActF,y
lda npcT,x
sta lvlActT,y
lda npcWpn,x
sta lvlActWpn,y
lda npcOrg,x
sta lvlActOrg,y
dex
bpl GS_Loop
lda #<EP_SCIENTIST2 ;Initial NPC scripts to drive the plot forward
ldx #>EP_SCIENTIST2
sta actScriptEP
stx actScriptF
if SKIP_PLOT > 0
if SKIP_PLOT2 > 0
lda #PLOT_HIDEOUTAMBUSH
jsr SetPlotBit
lda #<EP_HACKERAMBUSH
ldx #>EP_HACKERAMBUSH
else
lda #<EP_HACKER3
ldx #>EP_HACKER3
endif
else
lda #<EP_HACKER
ldx #>EP_HACKER
endif
if SKIP_PLOT3 > 0
lda #PLOT_ELEVATOR2
jsr SetPlotBit
lda #<EP_HACKERFOLLOWZONE
ldx #>EP_HACKERFOLLOWZONE
jsr SetZoneScript
lda #<EP_HACKERFOLLOW
ldx #>EP_HACKERFOLLOW
endif
sta actScriptEP+2
stx actScriptF+2
ldx #(MAX_CODES)*3-1
GS_CodeLoop: if CODE_CHEAT > 0
lda #$00
else
jsr Random
and #$0f
cmp #$0a
bcs GS_CodeLoop
endif
sta codes,x
dex
bpl GS_CodeLoop
lda codes+MAX_CODES*3-1 ;Make the last (nether tunnels) code initially
ora #$80 ;impossible to enter, even by guessing
sta codes+MAX_CODES*3-1
jsr FindPlayerZone ;Need to get starting level's charset so that save is named properly
jsr SaveCheckpoint ;Save first in-memory checkpoint immediately
jmp CenterPlayer
; Scientist 1 (intro) move routine
;
; Parameters: X actor number
; Returns: -
; Modifies: various
Scientist1: jsr MoveHuman
lda menuMode
cmp #MENU_DIALOGUE
beq S1_InDialogue
lda scriptVariable
asl
tay
lda S1_JumpTbl,y
sta S1_Jump+1
lda S1_JumpTbl+1,y
sta S1_Jump+2
S1_Jump: jsr $0000
ldx actIndex
S1_InDialogue: rts
S1_JumpTbl: dc.w S1_WaitFrame
dc.w S1_IntroDialogue
dc.w S1_SetAttack
dc.w S1_Dying
dc.w S1_DoNothing
S1_WaitFrame: inc scriptVariable ;Special case wait 1 frame (loading)
ldx #MENU_INTERACTION ;Set interaction mode meanwhile so that player can't move away
jmp SetMenuMode
S1_IntroDialogue:
inc scriptVariable
ldy #ACT_SCIENTIST1
lda #<txtIntroDialogue
ldx #>txtIntroDialogue
jmp SpeakLine
S1_SetAttack: jsr S1_LimitControl
lda actHp,x
beq S1_Dead
lda #JOY_RIGHT
sta actMoveCtrl,x
lda #ACT_SMALLDROID
jsr FindActor
bcc S1_NoDroid
lda #AIMODE_FLYER
sta actAIMode,x
lda actIndex ;Make sure targets the scientist
sta actAITarget,x
lda actTime,x ;Artificially increase aggression to guarantee kill
bmi S1_NoAggression
clc
adc #$20
bpl S1_AggressionOK
lda #$7f
S1_AggressionOK:sta actTime,x
S1_NoAggression:lda #LINE_YES
sta actLine,x
S1_DyingContinue:
S1_NoDroid: rts
S1_Dead: inc scriptVariable
lda #ACT_SMALLDROID
jsr FindActor
bcc S1_NoDroid
lda #JOY_LEFT|JOY_UP
sta actMoveCtrl,x
lda #AIMODE_FLYERFREEMOVE
sta actAIMode,x ;Fly away after kill, become nonpersistent (not found anymore)
jmp SetNotPersistent
S1_Dying: jsr S1_LimitControl
lda actF1,x ;Wait until on the ground
cmp #FR_DUCK+1
beq S1_DieAgain
cmp #FR_DIE+2
bcc S1_DyingContinue
lda actTime,x
cmp #DEATH_FLICKER_DELAY+1
bcs S1_DyingContinue
ldy #ACTI_PLAYER ;Turn to player
jsr GetActorDistance
lda temp5
sta actD,x
inc actHp,x ;Halt dying for now to speak
lda #FR_DUCK+1
sta actF1,x
sta actF2,x
lda #JOY_DOWN
sta actMoveCtrl,x
ldy #ACT_SCIENTIST1
lda #<txtDyingDialogue
ldx #>txtDyingDialogue
jmp SpeakLine
S1_DieAgain: inc scriptVariable
lda #DEATH_FLICKER_DELAY+25
sta actTime,x
lda #FR_DIE+2
sta actF1,x
sta actF2,x
dec actHp,x
lda #$00
sta temp4
lda #ITEM_PISTOL
jsr DI_ItemNumber
ldy temp8
lda #10
sta actHp,y ;Full mag
S1_DoNothing: rts
S1_LimitControl:lda #JOY_RIGHT|JOY_LEFT|JOY_DOWN|JOY_UP ;Don't allow entering the container in the beginning,
ldy actXH+ACTI_PLAYER ;or going too far to the left
cpy #$67
bcs S1_LimitLeft
lda #JOY_RIGHT|JOY_DOWN
S1_LimitLeft: and joystick
sta joystick
rts
; Scientist 2 (hideout 1) script
;
; Parameters: -
; Returns: -
; Modifies: various
Scientist2: lda actXH+ACTI_PLAYER ;Wait until player close enough
cmp #$37
bcc S2_Wait
cmp #$3c
bcs S2_Wait
lda actYH+ACTI_PLAYER
cmp #$29
bcs S2_Wait
lda actMB+ACTI_PLAYER
lsr
bcc S2_Wait
lda scriptVariable
asl
tay
lda S2_JumpTbl,y
sta S2_Jump+1
lda S2_JumpTbl+1,y
sta S2_Jump+2
S2_Jump: jmp $0000
S2_Wait: rts
S2_JumpTbl: dc.w S2_Dialogue1
dc.w S2_Dialogue2
dc.w S2_Dialogue3
dc.w S2_Dialogue4
S2_Dialogue1: jsr AddQuestScore
inc scriptVariable
ldy #ACT_SCIENTIST2
lda #<txtHideoutDialogue1
ldx #>txtHideoutDialogue1
jmp SpeakLine
S2_Dialogue2: inc scriptVariable
ldy #ACT_SCIENTIST3
lda #<txtHideoutDialogue2
ldx #>txtHideoutDialogue2
jmp SpeakLine
S2_Dialogue3: inc scriptVariable
ldy #ACT_SCIENTIST2
lda #<txtHideoutDialogue3
ldx #>txtHideoutDialogue3
jmp SpeakLine
S2_Dialogue4: lda #ITEM_COMMGEAR
ldx #1
jsr AddItem
ldx actIndex
lda #$00
sta temp4
lda #ITEM_SECURITYPASS
jsr DI_ItemNumber
lda actD,x
asl
lda #$7f
adc #$00
ldx temp8
jsr MoveActorX ;Move item to scientist's facing direction
lda #-16*8
jsr MoveActorY
lda #SFX_PICKUP
jsr PlaySfx
lda #$00
sta actScriptF ;No more script exec here
ldy #ACT_SCIENTIST2
lda #<txtHideoutDialogue4
ldx #>txtHideoutDialogue4
jmp SpeakLine
; Radio speech for upper labs entrance
;
; Parameters: -
; Returns: -
; Modifies: various
RadioUpperLabsEntrance:
ldy #ITEM_SECURITYPASS
jsr FindItem
bcc RULI_NoPass
lda #SFX_RADIO
jsr PlaySfx
lda #<txtRadioUpperLabsIntro
ldx #>txtRadioUpperLabsIntro
ldy #ACT_PLAYER
jmp SpeakLine
RULI_NoPass: ldy lvlObjNum
jmp InactivateObject ;Retry later to check for pass
; Persistent NPC table
npcX: dc.b $39,$38,$17
npcY: dc.b $28,$28,$30
npcF: dc.b $30+AIMODE_TURNTO,$10+AIMODE_TURNTO,$30+AIMODE_TURNTO
npcT: dc.b ACT_SCIENTIST2, ACT_SCIENTIST3,ACT_HACKER
npcWpn: dc.b $00,$00,$00
npcOrg: dc.b 1+ORG_GLOBAL,1+ORG_GLOBAL,4+ORG_GLOBAL
; Texts
txtIntroDialogue:
dc.b 34,"GOOD, YOU'RE ON YOUR FEET. I'M VIKTOR - WE NEED TO REACH THE OTHERS, WHO ARE HOLED UP ON THE PARKING GARAGE BOTTOM LEVEL. FOLLOW ME.",34,0
txtDyingDialogue:
dc.b 34,"ARGH, I'M NO GOOD TO GO ON. SEARCH THE UPSTAIRS - YOU'LL NEED A PASSCARD WE USED TO LOCK UP THIS PLACE. "
dc.b "WATCH OUT FOR MORE OF THOSE BASTARDS.. AND ONE FINAL THING - THE NANOBOTS RUNNING YOUR BODY DEPEND ON BATTERY POWER. "
dc.b "DON'T RUN OUT.",34,0
txtHideoutDialogue1:
dc.b 34,"I SEE VIKTOR DIDN'T MAKE IT. BUT YOU DID, THAT'S WHAT COUNTS. AMOS, NANOSURGEON. SHE'S LINDA, CYBER-PSYCHOLOGIST. "
dc.b "YOU'VE SEEN HOW OUR CREATIONS HAVE TURNED ON US. THERE'S A TOTAL COMMS BLACKOUT. WE'RE STUCK AND HELP IS UNLIKELY. "
dc.b "AS THE ONLY ENHANCED PERSON IN THIS ROOM, RIGHT NOW YOU'RE OUR BEST BET.",34,0
txtHideoutDialogue2:
dc.b 34,"COMMON SENSE WOULD DICTATE WE ATTEMPT TO ESCAPE. BUT THESE MACHINES' HIGHLY COORDINATED ACTIONS "
dc.b "SUGGEST A CENTRAL AI, WHICH I DIDN'T KNOW WE HAD DEVELOPED. "
dc.b "THERE MAY BE MORE THAN OUR LIVES AT STAKE.",34,0
txtHideoutDialogue3:
dc.b 34,"YES. WE MUST FIND OUT THEIR ULTIMATE AIM BEYOND JUST KILLING EVERYONE. "
dc.b "TAKE THIS SECURITY PASS TO ACCESS THE UPPER LABS, PLUS A WIRELESS CAMERA/RADIO "
dc.b "SET SO WE CAN STAY IN TOUCH.",34,0
txtHideoutDialogue4:
dc.b 34,"GOOD LUCK.",34,0
txtRadioUpperLabsIntro:
dc.b 34,"AMOS HERE. YOU'RE CLOSE TO THE UPPER LABS. SEE IF YOU CAN FIND ANY CLUES. "
dc.b "IF NOT, YOU'LL HAVE TO PUSH ON TO THE HIGH-CLEARANCE LOWER LABS. "
dc.b "ALSO LOOK FOR CODE-LOCKED ROOMS. THESE WERE PART OF THE 'HESSIAN' MILITARY CONTRACT, "
dc.b "WHICH LED TO THE NANO-ENHANCEMENT TECHNOLOGY. IF YOU CAN FIND THE "
dc.b "ENTRY CODES, YOU CAN IMPROVE YOUR ABILITIES FURTHER, AT THE COST OF INCREASED "
dc.b "BATTERY USE.",34,0
checkscriptend