Page 177 of 396

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 26, 2016 8:25 pm
by kelly1111
Ok, got this to work and spawn me some rats near the party. It's is on a timer that activates a math.random function. What I cant figure out is why it only spawns the rats once, and not more often

Code: Select all

	elseif random == 2 then
	playSound("Horror02")
	local dX, dY = getForward(party.facing)
	local x = party.x 
	local y = party.y 
	local map = party.map
	local elevation = map:getElevation(x, y)
	if not map:isBlocked(x, y, elevation) then  
	spawn("rat_swarm", party.level, party.x - dX, party.y - dY, party.facing, party.elevation)
		return
	end 
Anyone know why it spawns once?

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 26, 2016 10:04 pm
by Isaac
kelly1111 wrote:Anyone know why it spawns [only] once?
Does the timer trigger it more than once?

Also, you are checking the party's own tile for whether it's blocked or not.

Code: Select all

 --adjusted snippet
local dX, dY = getForward(party.facing)
   local x = party.x - dX
   local y = party.y - dY
   local elevation = party.map:getElevation(x, y)
   if not party.map:isBlocked(x, y, elevation) then  
   		spawn("rat_swarm", party.level, x, y, party.facing, party.elevation)
     	return
   end

Re: Ask a simple question, get a simple answer

Posted: Mon Jan 02, 2017 9:58 pm
by billb52
Hi all
How do I code a particle effect for dust after a cave in?
Thx in advance

Re: Ask a simple question, get a simple answer

Posted: Mon Jan 02, 2017 10:24 pm
by zimberzimber
billb52 wrote:Hi all
How do I code a particle effect for dust after a cave in?
Thx in advance
You can look up already defined particle systems in the Grimrock 2 asset pack.
Most of the parameters are self explanatory, and I'm sure you can figure out the rest with a bit of testing ;)

Re: Ask a simple question, get a simple answer

Posted: Wed Jan 04, 2017 4:01 pm
by Killcannon
So i have an interesting problem in my dungeon. I have a script that has been troubling me for weeks on end. No matter what I'd do the scripting wouldn't work at all despite multiple changes. After getting beyond frustrated with it I decided to create a new test dungeon and test the script there and lo, it works absolutely fine with the exact same setup. So my question is why is the script working in one dungeon and not in the other?

Here's the setup:

Floor trigger is connected to a timer. The timer is set to a interval of 3 and connected to the following script:

Code: Select all

function frostexplosion()

local fmax = 3

	for x = -fmax,fmax do
	for y = -fmax,fmax do
		if ( (x ~= 0) or (y ~= 0) ) then
			spawn("lightning_bolt_blast", 1, 15 + x, 20 + y, 0)
			spawn("lightning_bolt_blast", 1, 15 + x - 1, 20 + y - 1, 0)
			spawn("lightning_bolt_blast", 1, 15 + x - 2, 20 + y - 2, 0)
			spawn("lightning_bolt_blast", 1, 15, 20, 0)
		else
			return nil
			end
		end
	end
end

Re: Ask a simple question, get a simple answer

Posted: Wed Jan 04, 2017 5:44 pm
by zimberzimber
Killcannon wrote:So i have an interesting problem in my dungeon. I have a script that has been troubling me for weeks on end. No matter what I'd do the scripting wouldn't work at all despite multiple changes. After getting beyond frustrated with it I decided to create a new test dungeon and test the script there and lo, it works absolutely fine with the exact same setup. So my question is why is the script working in one dungeon and not in the other?

Here's the setup:

Floor trigger is connected to a timer. The timer is set to a interval of 3 and connected to the following script:

Code: Select all

function frostexplosion()

local fmax = 3

	for x = -fmax,fmax do
	for y = -fmax,fmax do
		if ( (x ~= 0) or (y ~= 0) ) then
			spawn("lightning_bolt_blast", 1, 15 + x, 20 + y, 0)
			spawn("lightning_bolt_blast", 1, 15 + x - 1, 20 + y - 1, 0)
			spawn("lightning_bolt_blast", 1, 15 + x - 2, 20 + y - 2, 0)
			spawn("lightning_bolt_blast", 1, 15, 20, 0)
		else
			return nil
			end
		end
	end
end
Can you please explain what exactly are you trying to achieve?

EDIT: This works just fine for me. If just nothing happens for you, then you either messed up the connectors, or not in the area you specified for this to happen. (Check elevation)
If it crashes, do send a report. (although I see no reason for this to crash)
(Though I still don't really understand why you complicated spawning a bunch of blasts in an area so much)

Re: Ask a simple question, get a simple answer

Posted: Wed Jan 04, 2017 7:03 pm
by Killcannon
zimberzimber wrote: Can you please explain what exactly are you trying to achieve?

EDIT: This works just fine for me. If just nothing happens for you, then you either messed up the connectors, or not in the area you specified for this to happen. (Check elevation)
If it crashes, do send a report. (although I see no reason for this to crash)
(Though I still don't really understand why you complicated spawning a bunch of blasts in an area so much)
The script is actually part of several things I'm doing and this is also based off a script I'm already using in the dungeon. My electrocution chamber, for which I'll post the script below. This is also the reason I'm asking for help. I created a test dungeon; tossed my script in it along with a timer and floor trigger. Then loaded it up to see if it worked, and it did. Plus I have a similar script that works in the dungeon floor. Yes, I checked the height and XY coordinates a dozen times and they're fine identical even to the test dungeon I created. I've disconnected and reconnected the connectors and they work as well. I've completely destroyed the script and rewritten it by hand, and double checked it. The simple fact is, when I activate the pressure plate in this dungeon; door closes and then nothing. Not even an error message saying 'it's not working'.

Here's what I'm going for:
1. Basically the boss will trigger this then 'teleport' himself to a safe spot to avoid the damage. The of course object is for the party to reach the safe spot when it's available and stop the boss from teleporting to it so the boss takes the damage from the spell and not the party. I need this part to work first so I can test timing for the party to reach the safe zone from any part of the room and the timing before the boss reaches the safe spot as well. So it's more than possible for the party to completely avoid the damage.

2. I have a floor poison gas cloud trap where the party has to trigger floor tiles in a certain order in order to open secret doors that hold items that then are used to deactivate 'the flow of gas' to the room via a lock. Stepping on the wrong tiles activates additional poison clouds in the room temporarily before clearing, resetting the system, and allowing the player to try again. Object is to get the hidden secret items to deactivate the trap to allow access to a special item the party needs later.

Edit: Here's the working script.

Code: Select all

function zappulsechamberpuzzle()
	local max = 0
		if Electricution_lever_1.lever:isDeactivated() and
			Electricution_lever_2.lever:isDeactivated() then
			max = 2 
		elseif Electricution_lever_1.lever:isActivated() and
			Electricution_lever_2.lever:isDeactivated() then
			max = 1
		elseif Electricution_lever_2.lever:isActivated() and
			Electricution_lever_1.lever:isDeactivated() then
			max = 0
		elseif Electricution_lever_1.lever:isActivated() and
			Electricution_lever_2.lever:isActivated() then
			max = 0
		end

	for x = -max,max do
	for y = -max,max do
		if ( (x ~= 0) or (y ~= 0) ) then
			spawn("lightning_bolt_blast", 1, 19 + x, 15 + y, 0)
			spawn("lightning_bolt_blast", 1, 19, 15, 0)
		else if ( (x == 0) or (y == 0) ) then
			spawn("lightning_bolt_blast", 1, 19, 15, 0)
			end
			end
		end
	end
end

Re: Ask a simple question, get a simple answer

Posted: Wed Jan 04, 2017 10:09 pm
by zimberzimber
I don't know why the script is not triggering for you. Try adding a few print lines to see if it reaches a certain point and stop.
Also make sure you're spawning them on the correct level, because right now they spawn on the first level.

I also don't see a reason to spawn a lot of explosions on on tile. If you just want it to deal a lot of damage, set the tile damager power to a higher value.

And are you asking for help implementing what you're going for?

Re: Ask a simple question, get a simple answer

Posted: Wed Jan 04, 2017 11:03 pm
by Isaac
Is it at all possible that the plate isn't calling the script?
What happens when you trigger the script via console?

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 2:49 am
by akroma222
billb52 wrote:Hi All, Can anyone help with 'swamp_dead_tree' I want to be able to click on the hole in the tree to retrieve/place objects in or out of hole and have a connector
that will activate/deactivate door etc. I have set baseObject = "altar" on swamp_dead_tree defineObject and added class = "Surface", class = "Clickable" and
class = "Socket" but cannot get any item to be in the hole altering offset/size vec. Am I barking up the wrong tree here? Is there a better way PLS Help
Hey billb52,
here is a simple definition of swamp_dead_tree with added Surface and Clickable components
Add an item like long_sword to it in the editor - then change the offset/size vec etc
SpoilerShow

Code: Select all

defineObject{
	name = "swamp_dead_tree_new",
	baseObject = "base_obstacle",
	components = {
		{
			class = "Model",
			model = "assets/models/env/swamp_dead_tree.fbx",
			staticShadow = true,
		},
		-----------------------------cut pasted from asset pack 2 - base objects
		{
			class = "Surface",
			offset = vec(0, 0.85, 0.2),
			size = vec(1.3, 0.65),
			--debugDraw = true,
		},
		{
			class = "Clickable",
			offset = vec(0, 0.85+0.4, 0.2),
			size = vec(1.3, 0.8, 0.65),
			--debugDraw = true,
		},
		------------------------------
	},
	placement = "floor",
	editorIcon = 172,
	automapTile = "trees",
	minimalSaveState = true,
}
If you wanted to use a Socket component then change the Surface component for this Socket component
Again you will need to change the offset - this is straight from the asset pack Torch Holder
SpoilerShow

Code: Select all

{
			class = "Socket",
			offset = vec(0.05, 1.53, -0.25),
			rotation = vec(0, -20, -90),
			onAcceptItem = function(self, item)
				return (item.go.name == "...item_that_fits..." or item.go.name == "...another_item_that_fits...") and self:count() == 0
			end,
		},
Alternatively, to simply make an item retrievable from the swamp tree hole - dont add any components and just use:

Code: Select all

item_that_fits:setWorldPosition(vec(x, y ,z))
item_that_fits:setWorldRotationAngles(x, y ,z)
This - im fairly sure - is how the Island Master's letter is placed in the Forest Oak hole (in Grimrock 2's forest)