What's wrong with SMW Lakitu?

Need help with any SMBX game-related issues? Ask your questions here.
User avatar
Animebryan
Snifit
Snifit
Posts: 225
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

What's wrong with SMW Lakitu?

Postby Animebryan » Sat Mar 06, 2021 8:15 pm

I found a Angry Sun graphic that replaces SMW Lakitu & thought it would be perfect for my level. But the damn thing don't act right! It moves like SMB3 Lakitu, only moving sideways but never up or down. The SMW Lakitu is supposed to move up and down along with it's horizontal movement, not to mention moving higher up if the section is more than 1 screen tall & the player gets above it, but it acts like vertical movement is locked or something. I removed the custom graphic & txt file so that it went back to vanilla SMW Lakitu & it still has that movement problem.

Also, when it throws a npc (npc-361 Lightning Bolt resprited as a SMB2 Fireball), it doesn't throw it in a arc like it's supposed to. It just throws it straight down at an angle at you. Something is not right here.
Last edited by Animebryan on Mon Mar 08, 2021 4:53 pm, edited 1 time in total.
Need serious help with Lua based features :(

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: What the hell is wrong with SMW Lakitu?

Postby Hoeloe » Sun Mar 07, 2021 11:45 am

I can confirm that SMW Lakitu does indeed move up and down, so I'm not sure what you're seeing there. If the Lakitu is set to "doesn't move" it'll move ONLY vertically, but that doesn't seem to be what you're seeing.

The lightning bolt, on the other hand, does appear to fall instantly, but I know for a fact you did not test this with any other NPC. The fact is, the way the lightning bolt NPC works is to immediately give itself downward speed when it's spawned, which is why it appears to be thrown straight down. Any NPC without this behaviour will be thrown in an arc as normal.

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9254
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: What the hell is wrong with SMW Lakitu?

Postby Enjl » Sun Mar 07, 2021 12:46 pm

Hoeloe wrote:
Sun Mar 07, 2021 11:45 am
I can confirm that SMW Lakitu does indeed move up and down, so I'm not sure what you're seeing there. If the Lakitu is set to "doesn't move" it'll move ONLY vertically, but that doesn't seem to be what you're seeing.
If you place lakitu a certain distance from the top of the section it only moves horizontally.
All my assets from packs and episodes are free to use for non-Stargate levels and projects, as long as proper credit is given.

User avatar
Animebryan
Snifit
Snifit
Posts: 225
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

Re: What's wrong with SMW Lakitu?

Postby Animebryan » Sun Mar 07, 2021 4:50 pm

Hoeloe wrote:
Sun Mar 07, 2021 11:45 am
I can confirm that SMW Lakitu does indeed move up and down, so I'm not sure what you're seeing there. If the Lakitu is set to "doesn't move" it'll move ONLY vertically, but that doesn't seem to be what you're seeing.

The lightning bolt, on the other hand, does appear to fall instantly, but I know for a fact you did not test this with any other NPC. The fact is, the way the lightning bolt NPC works is to immediately give itself downward speed when it's spawned, which is why it appears to be thrown straight down. Any NPC without this behavior will be thrown in an arc as normal.
This explains the other issue I had with the Lightning Bolt viewtopic.php?f=35&t=26853

This 'downward speed' behavior, can it be changed or removed using it's lua template file?
Enjl wrote: If you place lakitu a certain distance from the top of the section it only moves horizontally.
What do you mean 'certain distance'? Does that mean it needs to be close to the top of the section/screen in order to move vertically like normal?
Last edited by Animebryan on Mon Mar 08, 2021 4:59 pm, edited 1 time in total.
Need serious help with Lua based features :(

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9254
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: What the hell is wrong with SMW Lakitu?

Postby Enjl » Sun Mar 07, 2021 4:59 pm

Animebryan wrote:
Sun Mar 07, 2021 4:50 pm
Enjl wrote: If you place lakitu a certain distance from the top of the section it only moves horizontally.
What do you mean 'certain distance'? Does that mean it needs to be close to the top of the section/screen in order to move vertically like normal?
There is a very specific pixel coordinate at which it only moves horizontally. I'm not sure of the exact distance, but I believe it's pixel-perfect becuase I've always struggled with intentionally getting it.
All my assets from packs and episodes are free to use for non-Stargate levels and projects, as long as proper credit is given.

User avatar
Animebryan
Snifit
Snifit
Posts: 225
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

Re: What's wrong with SMW Lakitu?

Postby Animebryan » Sun Mar 07, 2021 5:22 pm

Well I fixed Lakitu's movement by setting it no lower than 2 blocks down from the top of the section, although the custom graphic also jitters up & down too.

Anyway, is there a way to change the lightning bolt's downward movement behavior? Because I also tried to change Red Panser's SMB2 Fireball into a Lightning Bolt that looks like a SMB2 Fireball only to have it not only fire downward at an angle but also firing several fireballs per second (surprised the game didn't freeze up or crash with the number of flame pillars it was generating) viewtopic.php?f=35&t=26853
Last edited by Animebryan on Mon Mar 08, 2021 4:59 pm, edited 1 time in total.
Need serious help with Lua based features :(

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: What the hell is wrong with SMW Lakitu?

Postby Hoeloe » Sun Mar 07, 2021 6:00 pm

You'd be best off just copying its lua file into a new NPC and removing the bit that sets speed on spawn.

User avatar
Animebryan
Snifit
Snifit
Posts: 225
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

Re: What's wrong with SMW Lakitu?

Postby Animebryan » Sun Mar 07, 2021 7:02 pm

Hoeloe wrote:
Sun Mar 07, 2021 6:00 pm
You'd be best off just copying its lua file into a new NPC and removing the bit that sets speed on spawn.
Where would that be in there?
Spoiler: show

Code: Select all

local lightning = {}

local npcManager = require("npcManager")

local npcID = NPC_ID

npcManager.setNpcSettings({
	id = npcID,
	gfxoffsetx = 0,
	gfxoffsety = 0,
	gfxwidth = 32, 
	gfxheight = 32, 
	width = 16,
	height = 32,
	frames = 1,
	harmlessgrab=true,
	ignorethrownnpcs = true,
	framespeed = 8,
	framestyle = 0,
	nofireball=1,
	noiceball=-1,
	noyoshi=1,
	nohurt=-1,
	speed=1,
	nogravity=-1,
	noblockcollision=-1,
	jumphurt = 1,
	nowaterphysics=true,
	spinjumpsafe = false,
	lightradius=32,
	lightbrightness=1,
	lightcolor=Color.white,

	spawnid = 362
})

function lightning.onInitAPI()
	npcManager.registerEvent(npcID, lightning, "onTickNPC")
end

local function initFire(v, f, dir)
	f.data._basegame = {}
	f.data._basegame.dir = dir
	f.data._basegame.spread = v.data._basegame.spread - 1
	f.data._basegame.wasThrown = v.data._basegame.wasThrown or false
	if v.data._basegame.friendly ~= nil then
		f.friendly = v.data._basegame.friendly
	else
		f.friendly = v.friendly
	end
	f.layerName = "Spawned NPCs"
	return f
end

function lightning.onTickNPC(v)
	if Defines.levelFreeze
		or v.isHidden
		or v:mem(0x12C, FIELD_WORD) > 0
		or v:mem(0x138, FIELD_WORD) > 0
		or v:mem(0x12A, FIELD_WORD) <= 0 then return end

	local data = v.data._basegame
	
	if data.feet == nil then
		data.feet = Colliders.Box(0,0,v.width,1)
		data.lastFrameCollision = true
	end
	
	if v:mem(0x136, FIELD_BOOL) == false then
		v.speedY = NPC.config[npcID].speed * 7
	else
		v.speedY = v.speedY + Defines.npc_grav
		data.wasThrown = data.wasThrown or v:mem(0x132, FIELD_WORD) > 0
	end

	if v.speedY > 0 then
		data.feet.x = v.x
		data.feet.y = v.y + v.height
		local collidesWithSolid = false
		local footCollisions = Colliders.getColliding{
		
			a=	data.feet,
			b=	Block.SOLID ..
				Block.PLAYER ..
				Block.SEMISOLID,
			btype = Colliders.BLOCK,
			filter= function(other)
				if (not collidesWithSolid and not other.isHidden and other:mem(0x5A, FIELD_WORD) == 0) then
					if Block.SOLID_MAP[other.id] or Block.PLAYER_MAP[other.id] then
						return true
					end
					if data.feet.y <= other.y + 8 then
						return true
					end
				end
				return false
			end
			
		}
		
		if #footCollisions > 0 then
			collidesWithSolid = true
			
			if not data.lastFrameCollision then
				local id = NPC.config[v.id].spawnid
				local f = NPC.spawn(id, v.x + 0.5 * v.width, footCollisions[1].y - 0.5 * NPC.config[id].height, v:mem(0x146, FIELD_WORD), false, true)
				if NPC.config[id].spread then
					data.spread = NPC.config[id].spread + 1
					initFire(v, f, 0)
				end
				SFX.play(42)
				v:kill(9)
				return
			end
		end
		data.lastFrameCollision = collidesWithSolid
	end
end

return lightning
Last edited by Animebryan on Mon Mar 08, 2021 4:58 pm, edited 1 time in total.
Need serious help with Lua based features :(

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: What the hell is wrong with SMW Lakitu?

Postby Hoeloe » Mon Mar 08, 2021 11:33 am

I'd think... the bit that sets speedY? Like seriously is it really that hard to read through the code and find a bit that sets speedY?

Code: Select all

        if v:mem(0x136, FIELD_BOOL) == false then
		v.speedY = NPC.config[npcID].speed * 7
	else
		v.speedY = v.speedY + Defines.npc_grav
		data.wasThrown = data.wasThrown or v:mem(0x132, FIELD_WORD) > 0
	end

User avatar
Animebryan
Snifit
Snifit
Posts: 225
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

Re: What's wrong with SMW Lakitu?

Postby Animebryan » Mon Mar 08, 2021 3:29 pm

Hoeloe wrote:
Mon Mar 08, 2021 11:33 am
I'd think... the bit that sets speedY? Like seriously is it really that hard to read through the code and find a bit that sets speedY?

Code: Select all

        if v:mem(0x136, FIELD_BOOL) == false then
		v.speedY = NPC.config[npcID].speed * 7
	else
		v.speedY = v.speedY + Defines.npc_grav
		data.wasThrown = data.wasThrown or v:mem(0x132, FIELD_WORD) > 0
	end
First of all, that's rude to say. When you don't have any programming experience or understand lua terms & functions, then yes, it is hard. Especially when, as a programmer, you should know how strict programming language is. One wrong extra space in the wrong place, or a missing bracket { } / [ ] or parenthesis ( ) or simply forgetting a comma at the end of a line is all it takes to screw a whole function up & cause errors.

And speaking of errors, your idea didn't work. Now instead of firing it down at an angle, it now fires UP at an angle:

Image

And it's not just the fact that it still won't fire in an arc, it also rapidly fires like a machine gun instead of 1 at a time or 1 every few seconds.
Last edited by Animebryan on Mon Mar 08, 2021 4:58 pm, edited 1 time in total.
Need serious help with Lua based features :(

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9254
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: What the hell is wrong with SMW Lakitu?

Postby Enjl » Mon Mar 08, 2021 3:49 pm

i think you lost your "that's rude to say" privileges when you set the thread mood by titling it "what the hell is wrong with..."
All my assets from packs and episodes are free to use for non-Stargate levels and projects, as long as proper credit is given.

User avatar
Animebryan
Snifit
Snifit
Posts: 225
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

Re: What's wrong with SMW Lakitu?

Postby Animebryan » Mon Mar 08, 2021 4:53 pm

Enjl wrote:
Mon Mar 08, 2021 3:49 pm
i think you lost your "that's rude to say" privileges when you set the thread mood by titling it "what the hell is wrong with..."
That's just another cheap excuse to not wanting to help somebody. I swear, getting any form of help around here is like pulling teeth.
It's always one reason or another just to weasel your way out of offering any kind of help because developers like you two just can't accept the fact that not everyone knows how to code & not everyone can learn it for one reason or another.

EDIT: There! Changed the topic title. Happy now?!
Need serious help with Lua based features :(

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: What's wrong with SMW Lakitu?

Postby Hoeloe » Tue Mar 09, 2021 12:15 pm

Animebryan wrote:
Mon Mar 08, 2021 4:53 pm
That's just another cheap excuse to not wanting to help somebody. I swear, getting any form of help around here is like pulling teeth.
No-one else seems to have a problem with it.

Honestly, every time you "just ask for help" you're always needlessly aggressive and antagonistic. You don't think that might make people somewhat unwilling to help you if all you end up doing is complaining at them?

User avatar
Animebryan
Snifit
Snifit
Posts: 225
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

Re: What's wrong with SMW Lakitu?

Postby Animebryan » Tue Mar 09, 2021 5:04 pm

Kinda hard to not be 'aggressive and antagonistic' when I keep having to deal with one technical problem after another in a vicious cycle that never ends. I just want things to work properly. And everytime I ask for help with something, I'm treated like I'm supposed to know how to code with lua when I don't.
Need serious help with Lua based features :(

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: What's wrong with SMW Lakitu?

Postby Hoeloe » Wed Mar 10, 2021 11:31 am

You're aggressive and antagonistic every time you ask for help. You complain constantly, and every time you do, you act like it's everyone elses fault. The fact is, things are working as intended, but because they're not working exactly how you want them to, you yell at everyone.

And if you want to solve this problem without Lua - just use a different NPC. More advanced behaviours will require some Lua because that's just the nature of programs. I would strongly suggest, though, that if you want help with something, you get off your high horse and actually ask for help rather than demanding it and yelling at everyone who tries.


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 7 guests