Random Dust Generator

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
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Random Dust Generator

Post by Mysterious »

Hi all.

Ok in Grimrock 1 there was a Mine Wallset created. I downloaded the Editor version and noticed it had random dust spawning. I found the code for it but it does not work for Grimrock 2 due to the new ways thing work.

Basically the scrip spawns dust infront or all around the party at given times, I assume.

A Timer was connected to function bigQuake() - timerInteval = 0.2

I really need help on getting the Scrip (below) to work. I just don't know how to do it.

Code: Select all

quakeTick1 = 1

function bigQuake()

local dustTargY = {-3, -2, -1, 0, 1, 2, 3}
dY = dustTargY[math.random(1, #dustTargY)]
local dustTargX = {-3, -2, -1, 0, 1, 2, 3}
dX = dustTargX[math.random(1, #dustTargX)]
if quakeTick1 < 50 then
spawn("fx", party.level, party.x+dX, party.y+dY, 0):setParticleSystem("party_earthquake_dust")
else
quakeTick1 = 1
return
end
quakeTick1 = quakeTick1 + 1
end
Thank you for any help on this matter.
User avatar
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Random Dust Generator

Post by Zo Kath Ra »

Where do you define "fx" and "party_earthquake_dust"?
Where/how do you stop the timer?
Please post a link to the Mine Wallset.
And please use indentation when you post code, it's easier to read that way.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Random Dust Generator

Post by akroma222 »

Phitt created the Mine wallset
The wallset is featured/tested in his mod: The Mine of Malan Vael
viewtopic.php?f=14&t=4502&hilit=mines

The dust code will be easy to adapt to LoG2.
I will tackle it when im free later today
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Random Dust Generator

Post by Isaac »

Fx was an object class in LoG1 that doesn't exist in LoG2; but the function shouldn't be hard to adapt. With the additional features of LoG2's engine, it would be difficult not to improve upon it. :D
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Random Dust Generator

Post by akroma222 »

Isaac wrote:Fx was an object class in LoG1 that doesn't exist in LoG2; but the function shouldn't be hard to adapt. With the additional features of LoG2's engine, it would be difficult not to improve upon it. :D
So true Isaac!
(However, here is a basic adaption without any improvements - I tend to complicate when I try to improve :lol: :roll: )

Mysterious,
place the timer,
set timer's Interval to 0.2
connect it to the function bigQuake(),
.... and place the code into a script entity
SpoilerShow

Code: Select all

quakeTick1 = 1

function bigQuake()

	local dX, dY
	local dustTargY = {-3, -2, -1, 0, 1, 2, 3}
	local dustTargX = {-3, -2, -1, 0, 1, 2, 3}
	
	dX = dustTargX[math.random(1, #dustTargX)]
	dY = dustTargY[math.random(1, #dustTargY)]

	if quakeTick1 < 50 then

		local dustFX = spawn("particle_system", party.level, party.x + dX, party.y + dY, party.elevation)
		dustFX.particle:setParticleSystem("earthquake_dust")
		dustFX.particle:setDestroySelf(true)
		dustFX.particle:fadeIn(1.0)
		dustFX.particle:fadeOut(1.5)
	
	else
		
		quakeTick1 = 1
		return
	
	end
	
	quakeTick1 = quakeTick1 + 1
end

User avatar
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Random Dust Generator

Post by Zo Kath Ra »

I still don't understand when/how the earthquake stops.
There is no code that stops the timer.
Maybe you also need to connect the timer to a counter that counts down, and when the counter reaches zero, it stops the timer? But then you don't need the "quakeTick1" variable anymore.
User avatar
THOM
Posts: 1281
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Random Dust Generator

Post by THOM »

If you use the dusteffect from LoG1 you do not need a timer to stop it.

You either do not need a particle:fadeIn and fadeOut. The particleSystem has a defined beginning and end and will destroy it's object when ended (if coded correct - see below).

So the code in the post above can be triggered 50 times from - let's say - ivisible pressure pads in the mod.


Code: Select all

defineObject{
	name = "earthquake_dust_THOM",
	components = {

		{
			offset = { 0, 0, 1, 0 },
			particleSystem = "earthquake_dust",
			name = "particle",
			class = "Particle",
			destroyObject = true,
		}
	},
	replacesFloor = false,
	editorIcon = 88,
	placement = "floor",
}
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Random Dust Generator

Post by Zo Kath Ra »

THOM wrote:If you use the dusteffect from LoG1 you do not need a timer to stop it.
The individual particle systems self-destruct after a while, but bigQuake() keeps getting called ad infinitum, and keeps spawning new particle systems.
Or am I missing something here?
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Random Dust Generator

Post by akroma222 »

THOM wrote:If you use the dusteffect from LoG1 you do not need a timer to stop it.
You either do not need a particle:fadeIn and fadeOut. The particleSystem has a defined beginning and end and will destroy it's object when ended (if coded correct - see below).
So the code in the post above can be triggered 50 times from - let's say - ivisible pressure pads in the mod.
Cheers THOM ;) I did indeed overlook the definitions themselves
Zo Kath Ra wrote:
THOM wrote:If you use the dusteffect from LoG1 you do not need a timer to stop it.
The individual particle systems self-destruct after a while, but bigQuake() keeps getting called ad infinitum, and keeps spawning new particle systems.
Or am I missing something here?
Yes, the code I posted will do as you say
(I tried not to stray from a basic adaption of the LoG1 code Mysterious posted)
Regarding how this script (and the DUST particles) fit into Phitt's Malan Vael mod ....
there is an event at the beginning of one of the levels:
SpoilerShow
there is an earthquake w screen shaking, sound FX, the stairs you entered the level through collapse into rubble ....
AND there is DUST falling from the ceiling while the earthquake sound lasts
The dust particle fx did stop after this event, so yes Id say there would be (?something?) to stop the potentially infinite dust
I have a nagging feeling the script was used again later in the mod, but details are hazy at best
It was a good 4 - 5 years ago that I beta tested it with Phitt (Its quite an enjoyable and well paced mod :ugeek: )
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Random Dust Generator

Post by Mysterious »

I start the (timer ) I use a floor_trigger and then I use another one to stop the (timer) same as then Mine Mod did.

Thant you kindly Akroam.
Post Reply