Page 1 of 1

Cloud Flower

Posted: Wed Aug 24, 2016 2:34 pm
by Hatebz
I wrote a simple Cloud Flower API, you can customize how much clouds will be fired before you'll become Small Mario again. It maybe isn't the best, but I hope it will be useful. It also comes with needed graphics.



Download (old): http://www.mediafire.com/download/rysh0 ... flower.zip

Update 1.1:
-Mario doesn't get hurt now, you just can't shoot more clouds.
-Added cloud shooting sfx.
-Clouds disappear after a while.
-After collecting Cloud Flower while being in Cloud Mario form your clouds replenish.
Update 1.2:
-Hitbox of clouds is now fixed (thanks to FanofSMBX).

Download (new): http://www.mediafire.com/download/6igh2 ... er_new.rar

Re: Cloud Flower

Posted: Wed Aug 24, 2016 2:42 pm
by PixelPest
Don't the clouds disappear after a certain amount of time in SMG? Also, it might be a good idea to add a poof-like sound instead of the fireball sound. Looks okay though so far. It's at least a good start

Re: Cloud Flower

Posted: Wed Aug 24, 2016 2:43 pm
by Yoshi021
It would be cool if the clouds appeared below you and the clouds didn't hurt you.

Re: Cloud Flower

Posted: Wed Aug 24, 2016 2:43 pm
by Emral
In the original game, Mario doesn't power down when all his clouds are gone. He just can't shoot any anymore. Maybe impliment that? It's kinda awkward having him power down after shooting the third cloud, and I can imagine that being extremely exploitable in terms of invincibility frame abuse.

Re: Cloud Flower

Posted: Wed Aug 24, 2016 2:44 pm
by PixelPest
Yoshi021 wrote:It would be cool if the clouds appeared below you and the clouds didn't hurt you.
I don't think they hurt the player. I made that mistake originally of thinking that too, but the player just powers down after they launch a third cloud

Re: Cloud Flower

Posted: Wed Aug 24, 2016 2:47 pm
by Yoshi021
PixelPest wrote: I don't think they hurt the player. I made that mistake originally of thinking that too, but the player just powers down after they launch a third cloud
Oops... I just noticed that with Enjl's post.

Re: Cloud Flower

Posted: Thu Aug 25, 2016 2:52 am
by Hatebz
I did what you suggested, the download and changelog are in first post.

Re: Cloud Flower

Posted: Thu Aug 25, 2016 5:10 am
by lotus006
Nice, and I love how bad is the evil cloud in the 1st video :D (an hurting power :) )

Re: Cloud Flower

Posted: Sun Aug 28, 2016 10:16 pm
by MECHDRAGON777
Also, not sure if this is fixed, but you should be able to stand on the top, not 16 pixels into them.

Re: Cloud Flower

Posted: Sun Aug 28, 2016 11:33 pm
by Hatebz
MECHDRAGON777 wrote:Also, not sure if this is fixed, but you should be able to stand on the top, not 16 pixels into them.
IDK why it works like that, tried changing NPC, but still it's hitbox is so small for some reason. :/

Re: Cloud Flower

Posted: Mon Aug 29, 2016 9:43 am
by FanofSMBX
Hatebz wrote:
MECHDRAGON777 wrote:Also, not sure if this is fixed, but you should be able to stand on the top, not 16 pixels into them.
IDK why it works like that, tried changing NPC, but still it's hitbox is so small for some reason. :/
Whatever NPC you use, you must do npc-13.txt with the changed height.

Re: Cloud Flower

Posted: Mon Aug 29, 2016 5:16 pm
by Hatebz
Oh, how could I forget it. Thanks for help. Fixed version: http://www.mediafire.com/download/6igh2 ... er_new.rar

Re: Cloud Flower

Posted: Fri Sep 02, 2016 3:43 am
by aero
Your code could be cleaned up a bit. I played around with it myself to see how it works, but I'm not sure what's going on in your code and it's good practice to insert comments to show what each part of your code does. Using the tab button to indent lines will also make it easier to read.

Original:

Code: Select all

local cloudflowerAPI = {}
local encrypt = loadSharedAPI("encrypt")
local cloudsData = encrypt.Data(Data.DATA_WORLD,true)
local clouds = 3
local clouds_max = 0
local pressing = 0
local cloudtimer = 0
local xtimer = 0
local clouds_check = 0
local seffect = Audio.SfxOpen("cloudflowerapi\\cloud-sfx.mp3")

local cloudcounter = Graphics.loadImage(Misc.resolveFile("cloudflowerapi\\cloud_counter.png"))

function cloudflowerAPI.setAmmount(value)
	if value > 0 then
		clouds_max = value
	end
	if value == 0 then
		clouds_max = -1
	end
end

function cloudflowerAPI.onStart()
	if cloudsData:get("cflower") == nil then
	cloudsData:set("cflower",0)
	end
end

function cloudflowerAPI.onInitAPI() 
    registerEvent(cloudflowerAPI, "onLoop", "showClouds") 
	registerEvent(cloudflowerAPI, "onStart", "onStart") 
	registerEvent(cloudflowerAPI, "onTick", "check") 
end

function cloudflowerAPI.showClouds()
	Audio.sounds[18].sfx = seffect
	if clouds > 0 then
	Graphics.placeSprite(1, cloudcounter, 24, 24)
	Text.print(clouds-1, 56, 24)
	end
	if clouds == 0 then
	Graphics.placeSprite(1, cloudcounter, 24, 24)
	Text.print(clouds, 56, 24)
	end
	if clouds < 0 then
	Graphics.placeSprite(1, cloudcounter, 24, 24)
	Text.print("infinity", 56, 24)
	end
	if player.powerup == PLAYER_BIG then
		clouds = clouds_max+1
	end
	if clouds >= clouds_max+1 then
		clouds = clouds_max+1
	end
	if player.powerup == PLAYER_FIREFLOWER and player:mem(0x140, FIELD_WORD) == 0 then
		if player.runKeyPressing == true and pressing == 0 and clouds ~= 0 then
		clouds = clouds - 1
		pressing = 1
		xtimer = 2
		end
		if player.runKeyPressing == false then
			pressing = 0
		end
	end
	if xtimer == 1 then
	for k,v in pairs(NPC.get(46,-1)) do
		v.y = player.y +64
		v.x = player.x
		v.speedX = 0
		v.speedY = 0
		v.id = 212
	end
	end
	if player.powerup == PLAYER_FIREFLOWER and clouds == 0 and player.reservePowerup == 14 then
	player.reservePowerup = 0
	clouds = clouds_max+1
	end
end

function cloudflowerAPI.check()
	for k,v in pairs(NPC.get(212,-1)) do
		v.ai3 = v.ai3 + 1
	if v.speedX > 1 then
		v.speedX = 0
		v.speedY = 0
		end
	if v.ai3 >= 250 then
		v.y = v.y + v.ai3*10
		end
	end
	if clouds ~= 0 then
	for k,v in pairs(NPC.get(13,-1)) do
		v.id = 46
	end
	end
	if clouds == 0 then
	for k,v in pairs(NPC.get(13,-1)) do
		v.id = 178
	end
	for k,v in pairs(NPC.get(178,-1)) do
		v.y = player.y
		v.x = player.x
	end
	end
	xtimer = xtimer - 1
end

return cloudflowerAPI
Revisions (from what I could make sense of):

Code: Select all

local cloudflowerAPI = {}
local encrypt = loadSharedAPI("encrypt")
local cloudsData = encrypt.Data(Data.DATA_WORLD,true)
local clouds = 0
local clouds_max = 0
local pressing = 0
local cloudtimer = 0
local xtimer = 0
local clouds_check = 0
local seffect = Audio.SfxOpen("cloudflowerapi\\cloud-sfx.mp3")

local cloudcounter = Graphics.loadImage(Misc.resolveFile("cloudflowerapi\\cloud_counter.png"))

function cloudflowerAPI.setAmmount(value)
	if value > 0 then
		clouds_max = value
	else
		clouds_max = -1
	end
end

function cloudflowerAPI.onStart()
	if cloudsData:get("cflower") == nil then
		cloudsData:set("cflower",0)
	end
end

function cloudflowerAPI.onInitAPI() 
    registerEvent(cloudflowerAPI, "onLoop", "showClouds") 
	registerEvent(cloudflowerAPI, "onStart", "onStart") 
	registerEvent(cloudflowerAPI, "onTick", "check") 
end

function cloudflowerAPI.showClouds()
	Audio.sounds[18].sfx = seffect
	
	Graphics.placeSprite(1, cloudcounter, 24, 100)
	Text.print(math.max(0, clouds - 1), 56, 100)
	
	if (player.powerup == PLAYER_BIG) or (clouds >= clouds_max + 1) then
		clouds = clouds_max + 1
	end
	
	if player.powerup == PLAYER_FIREFLOWER and player:mem(0x140, FIELD_WORD) == 0 then
		if player.runKeyPressing == true and pressing == 0 and clouds > 0 then
			clouds = clouds - 1
			pressing = 1
			xtimer = 2
		end
		
		if player.runKeyPressing == false then
			pressing = 0
		end
	end
	
	if xtimer == 1 then
		for k,v in pairs(NPC.get(46,-1)) do
			v.y = player.y + 64
			v.x = player.x
			v.speedX = 0
			v.speedY = 0
			v.id = 212
		end
	end
	
	if player.powerup == PLAYER_FIREFLOWER and clouds == 0 and player.reservePowerup == 14 then
		player.reservePowerup = 0
		clouds = clouds_max + 1
	end
end

function cloudflowerAPI.check()
	for k,v in pairs(NPC.get(212,-1)) do
		v.ai3 = v.ai3 + 1
		
		if v.speedX > 1 then
			v.speedX = 0
			v.speedY = 0
		end
		
		if v.ai3 >= 250 then
			v.y = v.y + v.ai3*10
		end
		
	end
	
	if clouds ~= 0 then
		for k,v in pairs(NPC.get(13,-1)) do
			v.id = 46
		end
	end
	
	if clouds == 0 then
		for k,v in pairs(NPC.get(13,-1)) do
			v.id = 178
		end
		
		for k,v in pairs(NPC.get(178,-1)) do
			v.y = player.y
			v.x = player.x
		end
	end
	
	xtimer = xtimer - 1
end

return cloudflowerAPI