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
23v.energyGod = 0
24
25function init(me)
26	v.energyGod = getEntity("EnergyGod")
27	node_setCursorActivation(me, false)
28	if getStory() >= 5.1 then
29		entity_delete(v.energyGod)
30		v.energyGod = 0
31	end
32end
33
34function song(me, song)
35	if isStory(5) then
36		if song == SONG_ENERGYFORM then
37			entity_flipToEntity(getNaija(), v.energyGod)
38			wnd(1)
39			txt("At last, I am free. Now use the gift of my spirit, little Naija.")
40			--txt("ENERGY GOD FADES AWAY")
41			wnd(0)
42			entity_delete(v.energyGod, 3)
43			watch(3)
44			voice("naija_energyform")
45			setStory(5.1)
46		end
47	end
48end
49
50function update(me, dt)
51	if getStory()<5 then
52		if entity_x(getNaija()) < node_x(me) then
53
54			local naija = getNaija()
55			local energyDoor = node_getNearestEntity(me, "EnergyDoor")
56			if energyDoor ~= 0 then
57				entity_setState(energyDoor, STATE_CLOSE)
58			end
59
60
61			entity_idle(naija)
62			entity_clearVel(naija)
63			setStory(5)
64			watch(3.1)
65			entity_flipToEntity(naija, v.energyGod)
66			wnd(1)
67
68			txt("Creature: Who goes there?")
69			txt("Naija: It... it is I, Naija.")
70			txt("Creature: Naija... what a beautiful name.")
71			txt("Naija: Beautiful?")
72			txt("Creature: Come closer, little Naija.")
73			wnd(0)
74
75			entity_swimToNode(naija, getNode("ENERGYGOD_NAIJA"))
76			entity_watchForPath(naija)
77			cam_toNode(getNode("ENERGYGOD_CAM"))
78
79			wnd(1)
80			txt("Naija: ...")
81			txt("Naija: In the name of the Old Father! What kind of foul creature are you?")
82			txt("Nerhaji: Ha! Foul? I am Nerhaji! Once I was as mighty a God as any. Now reduced to this form... it is more than foul, it is sacrilege.")
83			wnd(0)
84			-- [[ACTION...
85			--txt("Action: ENERGY GOD GRABS NAIJA")
86
87			entity_animate(v.energyGod, "grabTransition")
88			watch(0.25)
89			-- ...ACTION]]
90			setNaijaHeadTexture("Pain")
91			entity_animate(getNaija(), "trapped", LOOP_INF)
92			entity_animate(v.energyGod, "grabLoop", LOOP_INF)
93			watch(1)
94			wnds(1)
95			txt("Naija: What? Put me down!")
96			txt("Nerhaji: You are a defiant one, indeed. One I would have called a sinner, so long ago. One who would have been fed to me, as nothing more than a tasty morsel.")
97			txt("Naija: *pain* Let... me... go!")
98			-- [[ACTIoN...
99			txt("Action: SQUEEZING SOUND")
100			-- ...ActioN]]
101			--entity_animate(getNaija(), "trapped2", LOOP_INF)
102			txt("Nerhaji: This pain you feel Naija, does it make you feel alive?")
103			txt("Naija: *pain* What...?")
104			txt("Nerhaji: Your bones could be crushed in an instant. Your spirit extinguished from this realm forever.")
105			txt("Naija: *pain* ...")
106			txt("Nerhaji: You may very well be asking yourself, 'Why am I still alive?'")
107			txt("Nerhaji: The answer is simple.")
108			txt("Nerhaji: It is by my grace that you are allowed to continue squirming in my mighty grasp.")
109			txt("Nerhaji: For you see, Naija; I need something from you.")
110			txt("Nerhaji: I require a gift, and it is a gift that even a frail mortal as yourself, can provide.")
111			txt("Naija: *pain* What... do you want...")
112			txt("Nerhaji: Quite simply, Naija, I am old. I am tired.")
113			txt("Nerhaji: I have spent an eternity in this place, longing to be free.")
114			txt("Naija: *pain* What... makes you think... that I would free you...")
115			txt("Nerhaji: Ha! As if I would desire to rule in this dying age. No, Naija... I wish to be free from existence.")
116			txt("Naija: You want to... die?")
117			wnd(0)
118
119			entity_animate(v.energyGod, "idle", LOOP_INF)
120			--ENERGY GOD RELASES NAIJA
121
122			setNaijaHeadTexture("")
123			entity_idle(naija)
124
125			entity_swimToNode(naija, getNode("NAIJA_BACKOFF"))
126			entity_watchForPath(naija)
127			entity_flipToEntity(naija, v.energyGod)
128			wnd(1)
129			txt("Nerhaji: What was truly me has long since died. All that remains is to free my spirit.")
130			txt("Nerhaji: I will teach you the Song that will bind me to the void, once and for all.")
131			wnd(0)
132
133			cam_toEntity(naija)
134
135			-- gain energy form song
136			learnSong(SONG_ENERGYFORM)
137		end
138	end
139end
140