-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScenario.cos
425 lines (400 loc) · 9.78 KB
/
Scenario.cos
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
@IF @IsDefined("__BUILD_ONE__") == 0
Include "yosuga.ch"
@ENDIF
Function InitScenarioData()
Debug("InitScenarioData()")
scObj.version := 200
scObj.familyName := "春日野"
scObj.familyName_read := "かすがの"
scObj.firstName := "悠"
scObj.firstName_read := "はるか"
scObj.flag.create(512)
scObj.flagBackup.create(512)
scObj.nameLog.create(512)
scObj.messLog.create(512)
scObj.seqLog.create(512)
scObj.voiceLog.create(512)
EndFunc
Function ScenarioLoop(String func)
Debug("ScenarioLoop()")
StopBgm()
SetupAdvScreen()
Change(func)
adv.setToneFilter("NORMAL")
adv.setCg("BLACK")
While (scObj.scenarioCall != "EXIT_SCENARIO")
If (IsDebug == true)
Debug("\\c;8888FF:Jump-" + scObj.scenarioCall + "\\c:")
EndIf
String tempCall
tempCall := "sc" + scObj.scenarioCall
tempCall := tempCall.Replace("-", "_")
If (tempCall.Call() == true)
Break
EndIf
EndWhile
adv.setToneFilter("NORMAL")
adv.hideMessage()
adv.setCg("BLACK")
adv.bustupClear()
adv.update(false, true)
StopVoice()
StopSe()
StopEnvSe()
StopBgm(false)
DestroyAdvScreen()
EndFunc
Function Change(String str)
Debug("Change()")
str.MakeUpper()
scObj.scenarioCall := str
EndFunc
Function EnterLoad()
Debug("EnterLoad()")
scObj.isLoad := true
scObj.hitretCountTemp := 0
scObj.selectCount := 0
adv.msgInfo.clear()
EndFunc
Function LeaveLoad()
Debug("LeaveLoad()")
scObj.isLoad := false
adv.flushUpdate()
If (scObj.playBgm != "")
PlayBgm(scObj.playBgm)
If (scObj.fPauseBgm == true)
PauseBgm()
EndIf
EndIf
Integer i := 0
While (i < scObj.playEnvSe.GetLength())
PlayEnvSe(scObj.playEnvSe[i])
i += 1
EndWhile
adv.messageView(scObj.viewType)
adv.msgFrame.clearPage()
String showName
String trueName
CheckTrueName(scObj.nameLog.get(0), showName, trueName)
adv.msgFrame.output(showName, scObj.seqLog.get(0) + scObj.messLog.get(0), true)
If (scObj.voiceLog.get(0) != "")
adv.msgFrame.showVoice()
Else
adv.msgFrame.hideVoice()
EndIf
adv.msgFrame.show(true)
adv.skip(false)
adv.autoMode(false)
If (scObj.fToneFilter == true)
adv.setToneFilter(scObj.toneFilter)
Else
adv.setToneFilter("NORMAL")
EndIf
If (scObj.fCgRGB == 0)
SetCg(scObj.cg.filename, scObj.cg.pt.x, scObj.cg.pt.y)
Else
Integer col := scObj.colSetCgRGB
SetCgRGB((col & 16711680).ShiftRight(16), (col & 65280).ShiftRight(8), (col & 255))
EndIf
i := 0
While (i < scObj.bustup.GetLength())
Reference info := scObj.bustup[i]
If (info.status != 0)
If (info.fPosFix == 0)
SetBustup(info.basename, -info.pos, info.priority)
Else
SetBustup(info.basename, info.pos, info.priority)
EndIf
If (info.basePosition.y != info.localPosition.y)
adv.bustupDown(info.id, info.localPosition.y - info.basePosition.y)
EndIf
EndIf
i += 1
EndWhile
If (scObj.fZoom == true)
Reference param
param := scObj.zoomParam
adv.zoom(scObj.zoomParam.pt.x, scObj.zoomParam.pt.y, scObj.zoomParam.size.w, scObj.zoomParam.size.h)
Else
adv.zoom(0, 0, 800, 600)
EndIf
adv.update(true)
HideLoadEffect()
If (scObj.voiceLog.get(0) != "")
If (CheckPlayVoice(trueName) == true)
PlayVoice(scObj.voiceLog.get(0))
EndIf
EndIf
EndFunc
Function IsLoad()
Debug("IsLoad()")
Return scObj.isLoad
EndFunc
Function Save(String filename, Integer fThumb, Reference arrayHideSpr, Reference arrayShowSpr)
Debug("Save()")
Debug("Save:" + filename)
Array arrayShowTrans
Array arrayHideTrans
screen.Lock()
Integer i
If (arrayHideSpr.GetType() == "Array")
i := 0
While(i < arrayHideSpr.GetLength())
arrayHideTrans[i] := arrayHideSpr[i].GetTransparency()
arrayHideSpr[i].SetTransparency(256)
i += 1
EndWhile
EndIf
If (arrayShowSpr.GetType() == "Array")
i := 0
While(i < arrayShowSpr.GetLength())
arrayShowTrans[i] := arrayShowSpr[i].GetTransparency()
arrayShowSpr[i].SetTransparency(0)
i += 1
EndWhile
EndIf
screen.Refresh()
Sprite sprScreen
sprScreen.CreateSprite(67108865, ScreenSize.w, ScreenSize.h)
SpriteParam param
screen.GetParameter(param)
sprScreen.DrawImage(screen, param)
scObj.cg := adv.cg
scObj.fCgRGB := adv.fSetCgRGB
scObj.colSetCgRGB := adv.colSetCgRGB
scObj.bustup := adv.bustupMan.info
scObj.fToneFilter := adv.isToneFilter()
scObj.toneFilter := adv.getToneFilter()
scObj.viewType := adv.getMessageView()
scObj.fZoom := adv.isZoom()
scObj.zoomParam := adv.getZoomParam()
scObj.playBgm := GetPlayBgmName()
scObj.fPauseBgm := IsPauseBgm()
scObj.playEnvSe.Remove()
GetPlayEnvSeList(scObj.playEnvSe)
Integer fHScene := IsHScene(scObj.cg.filename)
File file
file.Open(filename + ".dat", 5 | 4)
If (fHScene == false)
If (fThumb == true)
file.SaveThumbnailImage(sprScreen, 120, 90)
EndIf
Else
Sprite sprThumb
sprThumb.LoadImage(scObj.cg.filename.Left(4) + "thm.eri")
If (fThumb == true)
file.SaveThumbnailImage(sprThumb, 120, 90)
EndIf
EndIf
file.SaveObject(scObj)
file.Close()
If (IsDebug == true)
DumpContext("_save.log")
EndIf
If (arrayHideSpr.GetType() == "Array")
i := 0
While (i < arrayHideSpr.GetLength())
arrayHideSpr[i].SetTransparency(arrayHideTrans[i])
i += 1
EndWhile
EndIf
If (arrayShowSpr.GetType() == "Array")
i := 0
While (i < arrayShowSpr.GetLength())
arrayShowSpr[i].SetTransparency(arrayShowTrans[i])
i += 1
EndWhile
EndIf
screen.Unlock()
EndFunc
Function Load(String filename)
Debug("Load()")
Debug("Load:" + filename)
StopBgm()
StopEnvSe()
StopSe()
StopVoice()
File file
file.Open(filename + ".dat", 2)
Integer ret := file.LoadObject(scObj)
file.Close()
If ((ret == false) & (200 == scObj.version))
ShowLoadEffect()
EnterLoad()
Else
Confirm("セーブデータに異常があり、ゲームを終了します。", false, false, 5000)
screen.Lock()
Throw()
EndIf
EndFunc
Function QuickSave()
Debug("QuickSave()")
String comment
If (scObj.nameLog.get(0) != "")
comment += scObj.nameLog.get(0)
EndIf
comment += scObj.messLog.get(0)
If (comment.GetLength() > 10)
comment := comment.Left(9) + "…"
EndIf
Save("QSave", 0)
sysObj.fQSave := true
SaveSystemData()
Confirm("クイックセーブしました", false)
EndFunc
Function QuickLoad(Integer id)
Debug("QuickLoad()")
Load("QSave")
EndFunc
Function IsHScene(String str)
Debug("IsHScene()")
If (IsUNK1)
ElseIf (str.Find("EA10") != true)
ElseIf (str.Find("EA11") != true)
ElseIf (str.Find("EA12") != true)
ElseIf (str.Find("EA13") != true)
ElseIf (str.Find("EA16") != true)
ElseIf (str.Find("EA17") != true)
ElseIf (str.Find("EB01") != true)
ElseIf (str.Find("EB10") != true)
ElseIf (str.Find("EB11") != true)
ElseIf (str.Find("EB12") != true)
ElseIf (str.Find("EB13") != true)
ElseIf (str.Find("EB16") != true)
ElseIf (str.Find("EB17") != true)
ElseIf (str.Find("EC10") != true)
ElseIf (str.Find("EC11") != true)
ElseIf (str.Find("EC12") != true)
ElseIf (str.Find("EC13") != true)
ElseIf (str.Find("EC16") != true)
ElseIf (str.Find("EC17") != true)
ElseIf (str.Find("ED10") != true)
ElseIf (str.Find("ED11") != true)
ElseIf (str.Find("ED12") != true)
ElseIf (str.Find("ED13") != true)
ElseIf (str.Find("ED16") != true)
ElseIf (str.Find("ED17") != true)
ElseIf (str.Find("EE10") != true)
ElseIf (str.Find("EE11") != true)
ElseIf (str.Find("EE12") != true)
ElseIf (str.Find("EE13") != true)
ElseIf (str.Find("EE16") != true)
ElseIf (str.Find("EE17") != true)
Else
Return false
EndIf
Return true
EndFunc
Function ScPlayMovie(String file)
Debug("ScPlayMovie()")
DestroyAdvScreen()
Resource rs
If (cnfObj.flgPlayBgm == true)
rs.SetTotalVolume(0, cnfObj.volBgm * 0.0)
Else
rs.SetTotalVolume(0, 0.0)
EndIf
PlayMovie(file + ".mei")
rs.SetTotalVolume(0, 0.0)
SetupAdvScreen()
EndFunc
Function ScPlayVoice(String file)
Debug("ScPlayVoice()")
If (IsLoad() == true)
Return
EndIf
PlayVoice(file)
EndFunc
Function ScRestartBgm()
Debug("ScRestartBgm()")
If (IsLoad() == true)
Return
EndIf
RestartBgm()
EndFunc
Function ScStopBgm(Integer fNonFade)
Debug("ScStopBgm()")
If (IsLoad() == true)
Return
EndIf
StopBgm(fNonFade)
EndFunc
Function ScStopSe()
Debug("ScStopSe()")
StopSe()
EndFunc
Function ScStopEnvSe(String file, Integer fFade)
Debug("ScStopEnvSe()")
If (IsLoad() == true)
Return
EndIf
StopEnvSe(file, fFade)
EndFunc
Function ScStopVoice()
Debug("ScStopVoice()")
StopVoice()
EndFunc
Function ScWaitVoice(Integer fKeyDisable)
Debug("ScWaitVoice()")
If (IsLoad() == true)
Return
EndIf
WaitVoice(fKeyDisable)
EndFunc
Function ScenarioEnter()
Debug("ScenarioEnter()")
If (IsLoad() == true)
Return
EndIf
scObj.hitretCount := 0
scObj.hitretCountTemp := 0
scObj.select.Remove()
scObj.selectCount := 0
EndFunc
Function ScWait(Integer time, Integer fKeyDisable)
Debug("ScWait()")
If (IsLoad() == true)
Return
EndIf
Integer fFlush := adv.isKeyUpdateFlush()
If (fFlush == true)
Return
EndIf
WndSpriteCmd wscmd
FlushJoyButton()
Integer nowTime := GetCurrentTime()
While ((nowTime + time) > GetCurrentTime())
If (fKeyDisable == false)
GetCommand(wscmd, 50)
If ((input.GetJoyButtonPushed(4) > 0) | (input.GetJoyButtonPushed(5) > 0))
break
EndIf
EndIf
EndWhile
FlushJoyButton()
EndFunc
Function SceneTitle(String str)
Debug("SceneTitle()")
scObj.sceneTitle := str
EndFunc
Function ShowLoadEffect()
Debug("ShowLoadEffect()")
resLoadEffectAlpha.LoadImage("WIP_TLBR.eri")
sprLoadEffectBase.SetAlphaImage(resLoadEffectAlpha, 8)
sprLoadEffectBase.SetBlendDegree(256)
sprLoadEffectBase.SetVisible(true)
screen.AddSprite(50100, sprLoadEffectBase)
sprLoadEffect.LoadImage("BLACK.eri")
sprLoadEffect.SetVisible(true)
sprLoadEffectBase.AddSprite(10, sprLoadEffect)
sprLoadEffectBase.SetBlendingEnvelope(0)
sprLoadEffectBase.BeginActivation(300)
WaitUntilSpriteActive(sprLoadEffectBase, false)
EndFunc
Function SetName(String familyName, String familyName_read, String firstName, String firstName_read)
Debug("SetName()")
scObj.familyName := familyName
scObj.familyName_read := familyName_read
scObj.firstName := firstName
scObj.firstName_read := firstName_read
EndFunc