Thunder and Fx for Skuggs Tileset

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Thunder and Fx for Skuggs Tileset

Post 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
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Thunder and Fx for Skuggs Tileset

Post 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
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Thunder and Fx for Skuggs Tileset

Post by Eleven Warrior »

Opps Thxs for that ArdTru most :oops: lol :)
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Thunder and Fx for Skuggs Tileset

Post by Drakkan »

sounds pretty. some screenshots ? :)
Breath from the unpromising waters.
Eye of the Atlantis
Post Reply