Page 1 of 1

can i edit the fire rate of wart's bubbles?

Posted: Fri Sep 22, 2017 4:15 pm
by squp
hey, i was just wondering if it was possible to slow the rate (preferably decrease it) of Wart's bubbles? i want to make a boss which uses wart, but with how many things he fires out, it'll make it too hard for the first boss.

Re: can i edit the fire rate of wart's bubbles?

Posted: Fri Sep 22, 2017 7:06 pm
by PixelPest
Basically your code would look something like what I've shown below. You can change the delay and maxN variables as you wish to suit your needs.

Code: Select all

local pnpc = API.load("pnpc"); --load the pnpc library which allows us to give variables to specific instances of NPCs, such as Wart

local delay = 55; --set how long it takes in ticks between bubbles (you can change this!)
local maxN = 3; --set how many bubbles wart should shoot (you can change this!)

function onTick() --every tick (unit of time in SMBX)
	for _, v in pairs(NPC.get(201)) do --for each of the Warts in the level assign them to v one at a time so we can do stuff to all of them
		local wart = pnpc.wrap(v); --wrap our Wart using the pnpc library to give us the ability to give it variables specific to that Wart
		
		if wart.data.counter == nil then --if there wasn't been a value set for the counter within our Wart's data table (of variables)
			wart.data.counter = 0; --set the counter to 0 (this variable will be used to make sure we don't exceed the max number of bubbles we have selected being shot each attack phase)
			wart.data.reloops = 0; --set our reloops variable to 0 (this variable will be used to make the delay occur)
		end
	
		if v.ai1 == 1 then --if the Wart is shooting bubbles (for AI #1: 0 - Idle, 1 - Bubbles, 2 - Hit, 3 - Death)
			if v.ai3 == 9 then --if our Wart is about to shoot a bubble on the next tick (shoots a bubble when AI #3 is a multiple of 10)
				if wart.data.reloops > 0 then --if our reloops variable is more than zero
					wart.data.reloops = wart.data.reloops - 1; --subtract one from the reloops variable
					v.ai3 = 8; --lower the AI #3 field to 8 so we can check it again on the next tick when it has increases to 9 between ticks
				end
			elseif v.ai3 == 10 then --if the AI #3 field equals 10 (which is when our Wart shoots a bubble)
				wart.data.counter = wart.data.counter + 1; --add one to the counter which counts how many bubbles our Wart has shot
				
				if wart.data.counter == maxN then --if the number of bubbles our Wart has shot is equal to our max number allowed per attack phase
					v.ai3 = 130; --set the AI #3 field to 130 which ends the attack phase for Wart's AI in general (but not others)
					wart.data.counter = 0; --set the number of bubbles our Wart has shot to zero so that this variable is ready for the next time we use it
				else --if the number of bubbles our wart has shot is not equal to our max number allowed per attack phase (it will be less and mean that our Wart should still be shooting bubbles)
					wart.data.reloops = delay; --set the reloops variable to the value of our delay variable
					v.ai3 = 8; --set the AI #3 field to 8
				end
			end
		end
	end
end
Here's a .gif of what the code above does with the way the variables are set rn:
Image

Re: can i edit the fire rate of wart's bubbles?

Posted: Sat Sep 23, 2017 1:56 am
by squp
[quote=PixelPest]
Code and stuff, this quote would be long if I directly quoted the reply[/quote]

Thanks, but how do I put the code in the list file? (I am VERY dumb)

Re: can i edit the fire rate of wart's bubbles?

Posted: Sat Sep 23, 2017 5:17 am
by ElectriKong
FlatKiwi wrote:
PixelPest wrote: Code and stuff, this quote would be long if I directly quoted the reply
Thanks, but how do I put the code in the list file? (I am VERY dumb)
Create a file called lunadll.lua in your GFX folder (you need LunaLua or 2.0) and copy and paste the code in there.

Re: can i edit the fire rate of wart's bubbles?

Posted: Sat Sep 23, 2017 12:45 pm
by squp
Electriking wrote: Create a file called lunadll.lua in your GFX folder (you need LunaLua or 2.0) and copy and paste the code in there.
So I just copy/paste the code he gave me? I'm not too sure due to the notes

Re: can i edit the fire rate of wart's bubbles?

Posted: Sat Sep 23, 2017 12:50 pm
by PixelPest
Yes. Just copy and paste all of what I posted in the code

Re: can i edit the fire rate of wart's bubbles?

Posted: Sat Sep 23, 2017 3:58 pm
by squp
PixelPest wrote:Yes. Just copy and paste all of what I posted in the code
thanks dude, your help is appreciated :D

Re: can i edit the fire rate of wart's bubbles?

Posted: Sun Sep 24, 2017 7:22 am
by squp

PixelPest wrote:I AM REPLYING TO PIXELPEST BOI
hey, i was just wondering: can i make him shoot a vegetable instead at a random point?

Re: can i edit the fire rate of wart's bubbles?

Posted: Sun Sep 24, 2017 3:54 pm
by PixelPest
FlatKiwi wrote:

PixelPest wrote:I AM REPLYING TO PIXELPEST BOI
hey, i was just wondering: can i make him shoot a vegetable instead at a random point?
Just after a random number of times?

Re: can i edit the fire rate of wart's bubbles?

Posted: Mon Sep 25, 2017 11:33 am
by squp
PixelPest wrote:
FlatKiwi wrote:

PixelPest wrote:I AM REPLYING TO PIXELPEST BOI
hey, i was just wondering: can i make him shoot a vegetable instead at a random point?
Just after a random number of times?
As in, every round of shooting has at least one veggie in... lol is this even possible