1-- Copyright (C) 2007, 2010 - Bit-Blot
2--
3-- This file is part of Aquaria.
4--
5-- Aquaria is free software; you can redistribute it and/or
6-- modify it under the terms of the GNU General Public License
7-- as published by the Free Software Foundation; either version 2
8-- of the License, or (at your option) any later version.
9--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13--
14-- See the GNU General Public License for more details.
15--
16-- You should have received a copy of the GNU General Public License
17-- along with this program; if not, write to the Free Software
18-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20if not v then v = {} end
21if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end
22
23local function foundSecrets()
24	--return true
25	if not isFlag(FLAG_SKIPSECRETCHECK, 0) then
26		return false
27	else
28		return (isFlag(FLAG_SECRET01, 1) and isFlag(FLAG_SECRET02, 1) and isFlag(FLAG_SECRET03, 1))
29	end
30end
31
32function init()
33
34	setInvincible(false)
35	entity_setInvincible(getNaija(), false)
36
37	--return
38
39
40	setOverrideMusic("")
41
42	local n = getNaija()
43	local mia = 0
44	local thir = 0
45
46	stopMusic()
47
48	if foundSecrets() then
49		local li = getLi()
50		if li ~= 0 then
51			entity_delete(li)
52		end
53		setLi(0)
54		setFlag(FLAG_LI, 0)
55
56		entity_heal(n, 100)
57
58
59
60		overrideZoom(1)
61
62		local bg = getEntity("falsebg")
63
64		n = getNaija()
65
66		local nd = getNode("START")
67		entity_setPosition(n, node_x(nd), node_y(nd))
68
69
70		entity_animate(n, "sitback", -1)
71
72		watch(0.3)
73
74		fade2(0, 1, 1, 1, 1)
75		fade(0, 1)
76
77		watch(5)
78
79		entity_setState(bg, STATE_CLOSE)
80
81		watch(0.4)
82		playSfx("naijagasp")
83		entity_idle(n)
84
85		watch(0.6)
86
87
88
89		watch(3)
90
91		overrideZoom(0)
92	else
93
94		stopMusic()
95
96		overrideZoom(0.5)
97
98		watch(4)
99
100		setCameraLerpDelay(0.0001)
101
102		cam_toNode(getNode("theend"))
103
104		playMusicOnce("prelude")
105
106		watch(10)
107
108		fade2(0,4)
109		fadeIn(4)
110
111		overrideZoom(0.9, 20)
112
113		watch(4)
114
115		watch(4)
116
117
118		while not isLeftMouse() and not isRightMouse() do
119			watch(FRAME_TIME)
120		end
121
122
123
124		fadeOutMusic(5)
125		fade2(1, 5)
126		watch(5)
127
128		stopAllSfx()
129
130		watch(3)
131
132		setCameraLerpDelay(0)
133
134
135		if isFlag(FLAG_SKIPSECRETCHECK, 0) then
136			voice("naija_endingpart2")
137			watchForVoice()
138		end
139
140		watch(4)
141		goToTitle()
142	end
143end
144
145