Shell-throwing hammer bro help

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
Valkyy
Koopa Troopa
Koopa Troopa
Posts: 29
Joined: Sun Apr 23, 2017 3:16 pm
Current Project: 100 trials SMBX edition
Chat Username: Valkyy

Shell-throwing hammer bro help

Postby Valkyy » Thu Apr 27, 2017 10:58 pm

When a hammer bro throws a green shell using this code from lunadll.txt:

Code: Select all

NPCMemSet,30,0xE2,113,0,0,w
It kills itself when it throws the shell (and not just green shells but any type of shell). So I made a npc text file saying

Code: Select all

noshell=1
which means that it won't get killed by other npcs. Well, the hammer bro still died. I don't understand why this happens. I don't really know what to do, because I'm not an expert at lunalua.
Image
Image
Image
Spoiler: show
Image

User avatar
Mosaic
Ludwig von Koopa
Ludwig von Koopa
Posts: 2844
Joined: Fri Feb 27, 2015 8:07 pm
Flair: All has a reason behind it, even if it's tough.
Current Project: The Mosaic Group's Journey, Toad's SMB Adventure, Mosaic Adventures and Other Secret Projects?
Chat Username: Mosaic
Contact:

Re: Shell-throwing hammer bro help

Postby Mosaic » Thu Apr 27, 2017 11:02 pm

sadly, the problem is the fact that the code noshell doesn't exist therefore it won't work, maybe there is a way to do it with lunalua though.

I believe in Jesus Christ as my Lord and Savior. If you do, put this in your signature.
And Here's The Proof
My Rainbow Of Levels
Mosaic's Museum(My Discord)

Image

Image

Danny wrote:Here's some constructive criticism: What the hell.
Witchking wrote:Approved!

Discord Quotes: show
Image


User avatar
FanofSMBX
Bowser
Bowser
Posts: 3877
Joined: Sun Dec 22, 2013 12:01 pm

Re: Shell-throwing hammer bro help

Postby FanofSMBX » Thu Apr 27, 2017 11:56 pm

Valkyy wrote:When a hammer bro throws a green shell using this code from lunadll.txt:

Code: Select all

NPCMemSet,30,0xE2,113,0,0,w
It kills itself when it throws the shell (and not just green shells but any type of shell). So I made a npc text file saying

Code: Select all

noshell=1
which means that it won't get killed by other npcs. Well, the hammer bro still died. I don't understand why this happens. I don't really know what to do, because I'm not an expert at lunalua.
Where you got that code? In my upcoming graphics pack update there is a shell bro. that I didn't test and it must do that :P

I believe in Jesus Christ as my Lord and Savior. If you do, put this in your signature.
My graphics pack!
Supporting forums:

Spoiler: show
SMBX Galaxy forum by Pivot40Channel
http://smbxgalaxy.prophpbb.com/
Come to the SMBX+ forums by illias3000. There is a whole forum category dedicated to the boss rush series with official rushes, submit bosses, and fan boss rushes! It is still open but AirSeus Forums is now open:
http://nsmbx.prophpbb.com/
AirSeus Forums the new home of the Boss Rush series:
http://smbxairseusforums.prophpbb.com/
Spoiler: show
First to discover:
Spark
Eerie
Grinder
Rainbow Shell
Birdo
Boom Boom
Image
Image
Image
Image
Image
KINGBOWSER112 RULES!


User avatar
Hoeloe
Grinder
Grinder
Posts: 1172
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Shell-throwing hammer bro help

Postby Hoeloe » Fri Apr 28, 2017 3:05 am

Lunadll.txt is at this point insanely outdated. It only exists so that older levels aren't broken. I would very strongly suggest NOT using it, and trying LunaLua instead. You could easily do this there by temporarily setting the shell or hammer bro friendly when it's thrown, or by moving the shell when you spawn it.

Valkyy
Koopa Troopa
Koopa Troopa
Posts: 29
Joined: Sun Apr 23, 2017 3:16 pm
Current Project: 100 trials SMBX edition
Chat Username: Valkyy

Re: Shell-throwing hammer bro help

Postby Valkyy » Fri Apr 28, 2017 8:04 am

Hoeloe wrote:Lunadll.txt is at this point insanely outdated. It only exists so that older levels aren't broken. I would very strongly suggest NOT using it, and trying LunaLua instead. You could easily do this there by temporarily setting the shell or hammer bro friendly when it's thrown, or by moving the shell when you spawn it.
How would I do this? I think I have some idea how but not entirely sure. Still learning lunalua.
Image
Image
Image
Spoiler: show
Image

User avatar
ShaolinTrunks
Bob-omb
Bob-omb
Posts: 30
Joined: Mon Mar 06, 2017 9:45 pm
Current Project: Teen Trunks Adventures
Chat Username: ShaolinTrunks

Re: Shell-throwing hammer bro help

Postby ShaolinTrunks » Sun Apr 30, 2017 8:46 am

I know it's a redundant tip. But if you can find a level with a hammer bro throwing a shell in a way you like, then you can like open it. Then you can examine it in all it glory and see the light lol.
Thanks to the SMBX Community.

PixelPest
Link
Link
Posts: 7116
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Shell-throwing hammer bro help

Postby PixelPest » Sun Apr 30, 2017 10:55 am

ShaolinTrunks wrote:I know it's a redundant tip. But if you can find a level with a hammer bro throwing a shell in a way you like, then you can like open it. Then you can examine it in all it glory and see the light lol.
That would only work if someone's done it before...afaik it hasn't been done before.

Well I became interested in trying this and wrote the code. You can use it if you like, it seems to work perfectly. I commented on basically every single line to try to help you understand what's going on. Click "Select all" and then copy it to a lunadll.lua file if you want to make use of it:

Code: Select all

local pnpc = API.load("pnpc"); --init pnpc.lua API

function onTick() --run the code every tick (a unit of time); most logic for NPCs, etc. is performed in this event
	for _, v in pairs(NPC.get(29)) do --iterate over all existing Hammer Bros
		local bro = pnpc.wrap(v); --get/create a wrapper for each Hammer Bro
	
		for _, w in pairs(NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)) do --iterate over all NPCs that are intersecting with its hitbox
			if w.id == 30 then --if the NPC is a hammer
				bro.data.mHammer = pnpc.wrap(w).uid; --get the unique identifier of the hammer and save it to the Hammer Bro's data table
				w.friendly = true; --make the hammer friendly
				w:transform(172); --transform the hammer into an SMB1 green shell
			end
		end
	end
	
	for _, x in pairs(NPC.get(172)) do --iterate over all SMB1 green shells
		local shellID = pnpc.wrap(x).uid; --get the unique identifier of the shell
		local intersects = false; --a variable that will be set to true if the shell is still intersecting with the Hammer Bro that threw it
		
		for _, y in pairs(NPC.getIntersecting(x.x, x.y, x.x + x.width, x.y + x.height)) do --iterate over all NPCs that are intersecting with the shell
			if (y.id == 29) and (pnpc.wrap(y).data.mHammer == shellID) then --if the NPC is a Hammer Bro and its data table reference for "mHammer" is the shell's uid
				intersects = true; --the shell intersects still with the Hammer Bro that threw it, so this variable is set to true
			end
		end
		
		if not intersects then --if the variable intersects is false
			x.friendly = false; --make the shell not be friendly
		else --if the variable intersects is true
			x.friendly = true; --make the shell be friendly
		end
	end
end

function onNPCKill(eventObj, killedNPC, killReason) --an event run every time an NPC is killed; makes sure that if a Hammer Bro is killed before the shell it threw is set to not friendly (the shell was intersecting with the bro when it was killed still) that the shell is set to not friendly
	if killedNPC.id == 29 then --if the killed NPC is a Hammer Bro
		for _, v in pairs(NPC.get(172)) do --iterate over all shells
			if pnpc.wrap(killedNPC).data.mHammer == pnpc.wrap(v).uid then --if the killed Hammer Bro's data table reference for "mHammer" is the shell's uid
				v.friendly = false; --make the shell not friendly
			end
		end
	end
end

Valkyy
Koopa Troopa
Koopa Troopa
Posts: 29
Joined: Sun Apr 23, 2017 3:16 pm
Current Project: 100 trials SMBX edition
Chat Username: Valkyy

Re: Shell-throwing hammer bro help

Postby Valkyy » Sun Apr 30, 2017 12:21 pm

PixelPest wrote:Well I became interested in trying this and wrote the code. You can use it if you like, it seems to work perfectly. I commented on basically every single line to try to help you understand what's going on. Click "Select all" and then copy it to a lunadll.lua file if you want to make use of it:

Code: Select all

local pnpc = API.load("pnpc"); --init pnpc.lua API

function onTick() --run the code every tick (a unit of time); most logic for NPCs, etc. is performed in this event
	for _, v in pairs(NPC.get(29)) do --iterate over all existing Hammer Bros
		local bro = pnpc.wrap(v); --get/create a wrapper for each Hammer Bro
	
		for _, w in pairs(NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)) do --iterate over all NPCs that are intersecting with its hitbox
			if w.id == 30 then --if the NPC is a hammer
				bro.data.mHammer = pnpc.wrap(w).uid; --get the unique identifier of the hammer and save it to the Hammer Bro's data table
				w.friendly = true; --make the hammer friendly
				w:transform(172); --transform the hammer into an SMB1 green shell
			end
		end
	end
	
	for _, x in pairs(NPC.get(172)) do --iterate over all SMB1 green shells
		local shellID = pnpc.wrap(x).uid; --get the unique identifier of the shell
		local intersects = false; --a variable that will be set to true if the shell is still intersecting with the Hammer Bro that threw it
		
		for _, y in pairs(NPC.getIntersecting(x.x, x.y, x.x + x.width, x.y + x.height)) do --iterate over all NPCs that are intersecting with the shell
			if (y.id == 29) and (pnpc.wrap(y).data.mHammer == shellID) then --if the NPC is a Hammer Bro and its data table reference for "mHammer" is the shell's uid
				intersects = true; --the shell intersects still with the Hammer Bro that threw it, so this variable is set to true
			end
		end
		
		if not intersects then --if the variable intersects is false
			x.friendly = false; --make the shell not be friendly
		else --if the variable intersects is true
			x.friendly = true; --make the shell be friendly
		end
	end
end

function onNPCKill(eventObj, killedNPC, killReason) --an event run every time an NPC is killed; makes sure that if a Hammer Bro is killed before the shell it threw is set to not friendly (the shell was intersecting with the bro when it was killed still) that the shell is set to not friendly
	if killedNPC.id == 29 then --if the killed NPC is a Hammer Bro
		for _, v in pairs(NPC.get(172)) do --iterate over all shells
			if pnpc.wrap(killedNPC).data.mHammer == pnpc.wrap(v).uid then --if the killed Hammer Bro's data table reference for "mHammer" is the shell's uid
				v.friendly = false; --make the shell not friendly
			end
		end
	end
end
Thanks so much! I will definitely use this and make sure to credit you.
Image
Image
Image
Spoiler: show
Image

User avatar
ShaolinTrunks
Bob-omb
Bob-omb
Posts: 30
Joined: Mon Mar 06, 2017 9:45 pm
Current Project: Teen Trunks Adventures
Chat Username: ShaolinTrunks

Re: Shell-throwing hammer bro help

Postby ShaolinTrunks » Sun Apr 30, 2017 5:25 pm

I learned something today :)
Thanks to the SMBX Community.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest