Page 1 of 1

Random Dust Generator

Posted: Sat Jan 13, 2018 1:09 am
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.

Re: Random Dust Generator

Posted: Sat Jan 13, 2018 2:49 am
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.

Re: Random Dust Generator

Posted: Sat Jan 13, 2018 5:31 am
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

Re: Random Dust Generator

Posted: Sat Jan 13, 2018 6:04 am
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

Re: Random Dust Generator

Posted: Sat Jan 13, 2018 9:59 am
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


Re: Random Dust Generator

Posted: Sat Jan 13, 2018 8:27 pm
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.

Re: Random Dust Generator

Posted: Sat Jan 13, 2018 10:01 pm
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",
}

Re: Random Dust Generator

Posted: Sat Jan 13, 2018 11:19 pm
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?

Re: Random Dust Generator

Posted: Sun Jan 14, 2018 2:33 am
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: )

Re: Random Dust Generator

Posted: Mon Jan 15, 2018 3:09 am
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.