if leaveDelay== 0 and not node_isEntityIn(leaveArea, getNaija()) then
updateMusic()
overrideZoom(0, 1)
bone_alpha(eye, 0)
entity_setPosition(me, node_x(leaveArea), node_y(leaveArea), 2) -- IMPORTANT PART
entity_setTarget(me, 0)
entity_rotate(me, 0, 10)
entity_clearVel(me)
entity_heal(me, 10)
debugLog("nautilusPrime heals 10")
return
end
Can you guess what happens when leaveArea is 0 (zero, i.e. not present)? ;)
Hmm, we should make one in the style of zelda, where you have to kill all the creatures in a room to open the door to the next room. :)For that matter, do rooms like that for each of the forms. The only one I can't work out a good mechanism for right off-hand is Fish Form, although Spirit Form would be a royal pain to get the coordination right on, and the Shield song would probably work better as a straight-up marksmanship test.
If you want a real challenge try: loading the mod, pressing tab to get the editor menu, going into entity edit mode and deleting all the health plants.Yeah, that does make it a bit more interesting- with the health plants gone you need to really pay attention to which enemies drop health. :P I haven't yet managed to beat it without picking up any health boosts, though.
Muahahahahahaa! >:D
As for adding a timer and stuff... Thats getting into scripting. I might possibly be able to do it by looking at the arnassi race scripts and stuff but at the moment I'm feeling really lazy so I wont be doing it. :-XAsk, and ye shall receive. I rather like the scripting end of mod-making, and this made a nice break from bashing my head into a wall over "features" in dofile() and the animation editor. Just put this code in a new lua file named timerbeast.lua, add timerbeast to entities.txt, and add a timerbeast to the level (note: it will be invisible, so be careful to only create one). It will keep track of the time, and when all the enemies are destroyed, it will display the final time for a few seconds, and then exit to the main menu.
Anyone who wants to tweak this or anything feel free though, I'm not holding onto any copyrights or anything. ::) (Although, you know, a mention would be nice ;) )
--[[
A relatively simple entity that will track whether there are any enemies
left in the Big Energy Battle map. Note that should you want to use this
in a different map, you will need to delete or modify the if statements
that check whether the four bosses in the map exist.
Script by Edwards]]--
dofile("scripts/entities/entityinclude.lua")
timer = 0
ekkritdead = false
nautprimedead = false
blasterdead = false
anglerdead = false
winner = false
won = false
function init(me)
n = getNaija()
entity_setPosition(me, entity_x(n), entity_y(n))
setupEntity(me)
entity_alpha(me, 0)
entity_setType(me, ET_NEUTRAL)
end
function postInit(me)
--Display the timer
setTimerTextAlpha(1, 1)
--Failsafe in case multiple copies of the entity exist
local e = getFirstEntity()
while e ~= 0 do
if e ~= me and entity_isName(e, entity_getName(me)) then
entity_msg(e, "suicide")
end
e = getNextEntity()
end
end
function update(me, dt)
--Keep the entity on top of Naija, as an easy way to make sure it never goes out of culling distance.
x,y = entity_getPosition(n)
entity_setPosition(me, x, y)
--Short-circuit test to see if the player has killed the bosses.
--Yes, the game's really fast at executing scripts, but I still want to put as light
-- a load as possible on the script engine.
if nautprimedead or entity_getNearestEntity(me, "nautilusprime") == 0 then
nautprimedead = true
if blasterdead or entity_getNearestEntity(me, "bigblaster") == 0 then
blasterdead = true
if anglerdead or entity_getNearestEntity(me, "anglerfish") == 0 then
anglerdead = true
if ekkritdead or entity_getNearestEntity(me, "ekkrit") == 0 then
--The following code is a test to see whether any of the entities in the level are enemies.
local bad = false
local testEnt = getFirstEntity()
--local i = 0
while testEnt ~= 0 do
if entity_getEntityType(testEnt) == ET_ENEMY then
bad = true
--i = i + 1
--local xe,ye = entity_getPosition(testEnt)
end
testEnt = getNextEntity()
end
--xe = xe - x
--ye = ye - y
--setControlHint(string.format("%d entities exist! Timer = %d BadEntLoc = %d,%d", i, timer, xe,ye), 0, 0, 0, 1)
if not bad then winner = true end
end
end
end
end
-- Check if the player has won, otherwise increment the timer
if not won then
if winner then
won = true
--Generate the congratulatory text and time display
setTimerTextAlpha(0, 1)
mins = math.floor(timer/60)
secs = timer - (mins*60)
secs1 = math.floor(secs/10)
secs2 = secs - (secs1*10)
centerText(string.format("Congratulations! Time: %d:%d%d", mins, secs1, secs2))
--Exit to main menu
wait(3)
watch(0.1)
fadeOutMusic(2)
toggleCursor(false)
fade(1, 3, 0, 0, 0)
watch(3)
watch(0.5)
goToTitle()
else
timer = timer + dt
setTimerText(timer)
end
end
end
--Failsafe in case extra copies were created
function msg(me, msg)
if msg == "suicide" then
entity_delete(me)
end
end
Dude, that is so awesome. It doesn't only tell you the time at the end, it has the time in the bottom right and everything.To allow the ekkrit to live, you'll need to change a couple of lines. Sorry, I hadn't realized the poor thing was supposed to be optional:
My only gripe, if I can even call it that, is that the player has to kill that poor lost Ekkrit creature I put in there. I can't however find a way to let him live with this script. :-\ Even if I remove all references to him he still has to die for the end to take effect... I think it might be because he is counted as an enemy? That would mean that he must die for the all-enemies-dead trigger too. Not sure how to change that... Oh well, I'll just leave him dying in for now at least. ::)
- The big blaster's death scene will no longer try to make you look at her egg (a.k.a. (0,0) lol). It was always rather off-putting staring at blackness for 2 seconds after killing a boss..Ah, nice. I'd been thinking of going after that little issue next- good to see you've already got it fixed.
--[[A relatively simple entity that will track whether there are any enemies
left in the Big Energy Battle map. Note that should you want to use this in a
different map, you may want to delete or modify the if statements that check
whether the bosses in the map exist.
Script by Edwards
]]--
dofile("scripts/entities/entityinclude.lua")
timer = 0
nautprimedead = false
blasterdead = false
anglerdead = false
winner = false
won = false
function init(me)
n = getNaija()
entity_setPosition(me, entity_x(n), entity_y(n))
setupEntity(me)
entity_alpha(me, 0)
entity_setType(me, ET_NEUTRAL)
end
function postInit(me)
--Display the timer
setTimerTextAlpha(1, 1)
--Failsafe in case multiple copies of the entity exist
local e = getFirstEntity()
while e ~= 0 do
if e ~= me and entity_isName(e, entity_getName(me)) then
entity_msg(e, "suicide")
end
e = getNextEntity()
end
end
function update(me, dt)
--Keep the entity on top of Naija, as an easy way to make sure it never goes out of culling distance.
x,y = entity_getPosition(n)
entity_setPosition(me, x, y)
--Short-circuit test to see if the player has killed the bosses.
--Yes, the game's really fast at executing scripts, but I still want to put as light
-- a load as possible on the script engine.
if nautprimedead or entity_getNearestEntity(me, "nautilusprime") == 0 then
nautprimedead = true
if blasterdead or entity_getNearestEntity(me, "bigblaster") == 0 then
blasterdead = true
if anglerdead or entity_getNearestEntity(me, "anglerfish") == 0 then
anglerdead = true
--The following code is a test to see whether any of the entities in the level are enemies.
local bad = false
local testEnt = getFirstEntity()
--local xe = x
--local ye == y
while testEnt ~= 0 do
if entity_getEntityType(testEnt) == ET_ENEMY and not entity_isName(testEnt, "ekkrit") then
bad = true
--xe,ye = entity_getPosition(testEnt)
break
end
testEnt = getNextEntity()
end
--xe = xe - x
--ye = ye - y
--setControlHint(string.format("Enemies exist! Timer = %d BadEntLoc = %d,%d", timer, xe,ye), 0, 0, 0, 1)
if not bad then winner = true end
end
end
end
-- Check if the player has won, otherwise increment the timer
if not won then
if winner then
won = true
--Generate the congratulatory text and time display
setTimerTextAlpha(0, 1)
mins = math.floor(timer/60)
secs = timer - (mins*60)
secs1 = math.floor(secs/10)
secs2 = secs - (secs1*10)
centerText(string.format("Congratulations! Time: %d:%d%d", mins, secs1, secs2))
--Exit to main menu
wait(5)
watch(0.1)
fadeOutMusic(2)
toggleCursor(false)
fade(1, 3, 0, 0, 0)
watch(3)
watch(0.5)
goToTitle()
else
timer = timer + dt
setTimerText(timer)
end
end
end
--Failsafe in case extra copies were created
function msg(me, msg)
if msg == "suicide" then
entity_delete(me)
end
end
Hmm, before I try that script, doesn't it make it so that if the entity it looks at first is Ekkrit then the battle will end? It seems like it gets any entity and checks if its an enemy and its not ekkrit, then keeps the battle going. But it that entity was Ekkrit then would the battle just end, even though there are other enemies around? Sorry if its a hassle. xDWhat you missed was the while loop that cycles through all entities in the level. It gets the first entity, checks if it's an enemy and not an Ekkrit. If it is an enemy non-Ekkrit, it toggles the "did not win" flag, and exits the while loop. Otherwise, it goes on to the next entity, and repeats the process until it runs out of entities on the map. Basically, what keeps the Ekkrit exception from breaking the script is the same thing that keeps it from breaking if it runs into a health plant first, or Naija.
4:04, second try, almost died when Ekkrit started absorbing all my shots, he died soon after. =[Nice. My current record is 7:58 (it would have been two minutes less, but a single blaster somehow managed to evade me for several complete sweeps of the map). I almost kept the Ekkrit alive, too, but it jumped in front of my cursor when I was attempting to target something else, and there were too many nasty things shooting me to attempt to retarget.
And its part of the game having Ekkrit be a shield. A shield to you and a shield to your enemies >:DHave you no heart? D:
Thanks Alec,
It took me a little while to figure out but I got it eventually.
dofile("scripts/entities/entityinclude.lua")I suppose it'd be prettier to break out of the while loop as soon as you find an enemy but the script works (tested it out). The while loop finds exactly how many enemies are in the map each update and will open the door once there are none left.
done = false
door = 0
numEnemies = 0
function init(me)
door = node_getNearestEntity(me, "energydoor")
end
function update(me, dt)
if done == false then
ent = getFirstEntity()
while ent ~= 0 do
if entity_getEntityType(ent) == ET_ENEMY then
numEnemies = numEnemies + 1
end
ent = getNextEntity()
end
--all enemies killed -> open door
if numEnemies == 0 then
entity_setState(door, STATE_OPEN)
done = true
--reset for next test
else
numEnemies = 0
end
end
end
...
if entity_getEntityType(ent) == ET_ENEMY and node_isEntityIn(me, ent) then
numEnemies = numEnemies + 1
end
...