Page 1 of 1

Thunder and Fx for Skuggs Tileset

Posted: Sun Mar 22, 2015 10:54 am
by Eleven Warrior
Hi all. A friend of mine wrote this script for me. It adds Thunder noise and Light fx to the rain system that Skuggs has in his Winter Tile Set.

1 - Connect a floor trigger to: function enableThunder() to activate the script and to end add floor trigger to: function disableThunder()

2 - This code line (if party.level ~= 6 or THUNDER == false then --ONLY THIS LEVEL--) The number 6 represents the level this script will work on eg: once you leave level 6 the Thunder script stops. When you enter level 6 again the Thunder script activates. What it means if you are in level 5 you don't hear the sound etc.. until return to level 6.

3 - You can change the number to what ever level you want the script to work on. If you want more than one level then copy/paste the script to that level and change level number eg: 1 etc...

Big Thank You to ArtTru :)

Code: Select all

THUNDER = false

function enableThunder()
if THUNDER == false then
THUNDER = true
ThunderSound()
end
THUNDER = true
end

function disableThunder()
THUNDER = false
end


-- Random Thunder Sound --
function ThunderSound()

if party.level ~= 6 or THUNDER == false then -- ONLY THIS LEVEL --party.level ~= 3 or
THUNDER = false 
return false
end

playSound("lightning_bolt_hit",party.level, party.x, party.y, 0)

local dx = math.random(-6,6) + party.x
local dy = math.random(-6,6) + party.y
dx = math.max(math.min(dx, 31),0)
dy = math.max(math.min(dy, 31),0)
local Target = spawn("thunder_light", party.level, dx, dy, 0, party.elevation )

local ThTimeMin = 3.0
local ThTimeMax = 6.0
local TimeToNext = math.random(ThTimeMin*10, ThTimeMax*10)/10.0
delayedCall(self.go.id, TimeToNext, "ThunderSound")
end

Re: Thunder and Fx for Skuggs Tileset

Posted: Sun Mar 22, 2015 7:03 pm
by AdrTru
Hi all.
Eleven Warrior forgot post object definition for thunder_light:

Code: Select all

defineObject{
	name = "thunder_light",
	components = {
		{
			class = "Light",
			offset = vec(0, 12, 0),
			range = 30,
			color = vec(1, 1, 1),
			brightness = 80,
			castShadow = true,
--			fillLight = true,
			fadeOut = 0.5,
			destroyObject = true,
		},
	},
	placement = "floor",
	editorIcon = 88,
}
and there is descripted code WITH tabs on lines

Code: Select all

THUNDER = false				-- variable is true when thunder is enabled

function enableThunder()	-- function for enabling thunder storm
	if THUNDER == false then
		THUNDER = true
		ThunderSound()
	end
	THUNDER = true
end

function disableThunder()	-- function for disabling thunder storm
	THUNDER = false
end


-- Random Thunder Sound --
function ThunderSound()
	
	if THUNDER == false then -- ONLY THIS LEVEL --party.level ~= 3 or  -- input test for continue thunder storm
    	THUNDER = false 
    	return false
	end
	
   	playSound("lightning_bolt_hit",party.level, party.x, party.y, 0)


	local dx = math.random(-6,6) + party.x		-- generate random tile for this thunder
	local dy = math.random(-6,6) + party.y
	dx = math.max(math.min(dx, 31),0)			-- fix for random tile is out of map
	dy = math.max(math.min(dy, 31),0)
	local Target = spawn("thunder_light", party.level, dx, dy, 0, party.elevation )

	local ThTimeMin = 3.0						-- get random time for next thunder
	local ThTimeMax = 6.0
	local TimeToNext  = math.random(ThTimeMin*10, ThTimeMax*10)/10.0
	delayedCall(self.go.id, TimeToNext, "ThunderSound")
end

Re: Thunder and Fx for Skuggs Tileset

Posted: Mon Mar 23, 2015 6:10 am
by Eleven Warrior
Opps Thxs for that ArdTru most :oops: lol :)

Re: Thunder and Fx for Skuggs Tileset

Posted: Mon Mar 23, 2015 9:07 am
by Drakkan
sounds pretty. some screenshots ? :)