SMBX - Hammer Starman (Repost)
Posted: Fri May 22, 2015 4:05 pm
I got a lot of emails about if i could repost the Starman code from a while ago,if you guys really want it,then here:
Make sure to tweak the code to make it work better.
Code: Select all
--Set some Variables first:
local StarPower_P1 = false
local StarTimer_P1 = 0
-- Find Starman:
function countNPCID(id)
local npcs = findnpcs(id, -1)
local count = 0
for k,v in pairs(npcs) do
count = count + 1
end
return count
end
function onLoop()
local HNPC = findnpcs(171, -1) -- The Hammer in section!
hud(false)
printText("GOT STARPOWER: "..tostring(StarPower_P1), 30, 50)
printText("STARMAN NPC IN ROOM: "..tostring(count), 30, 70)
printText("INVINCIBILITY LEFT: "..tostring(StarTimer_P1), 30, 90)
-- Get Star Power:
if(StarPower_P1 == false and countNPCID(103) == 0 and count ~= -1 )then
count = -1
StarTimer_P1 = 600
end
-- Check Stuff:
if(StarTimer_P1 >= 1)then
StarPower_P1 = true -- Keep Power state to true.
mem(0x00B2C8C0, FIELD_WORD, 0xFFFF) -- Make the Player Invincible.
else
StarPower_P1 = false -- Keep Power state to false.
mem(0x00B2C8C0, FIELD_WORD, 0) -- Make the Player NOT Invincible.
HNPC[0].x = -1000000 HNPC[0].y = -1000000 -- Reset Hammer Position!
end
-- If you're in Invincibility State:
if(StarPower_P1 == true and StarTimer_P1 >= 1)then -- Reduce Invincibility Time!
StarTimer_P1 = StarTimer_P1 - 1
HNPC[0].x = player.x HNPC[0].y = player.y -- Set Hammer position to player.
end
end