Ask a simple question, get a simple answer

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!
User avatar
akroma222
Posts: 1024
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 » Mon Feb 15, 2016 11:05 pm

Hey folks,
Just a quick question - has anyone attempted to make a Cloud object/spell - that causes the Sleep condition??
As in a cloud / damageTile that Sleeps monsters whenever it deals damage (yes I realise damage wakes up monsters)
Just wondering if anyone has a work around for this?

Ive tried the basics like this:
SpoilerShow

Code: Select all

{
			class = "TileDamager",
			attackPower = 1,
			repeatCount = 5,
			repeatDelay = 1,
			onHitMonster = function(self, monster)
				monster:setCondition("sleep", 10)
				if monster:hasCondition("sleep") then
					monster:setConditionValue("sleep", 10)
				end
			end,
		},
and also tried delayed calling other functions to Sleep the monster
SpoilerShow

Code: Select all

{
			class = "TileDamager",
			attackPower = 1,
			--sound = "dark_bolt_hit",
			--screenEffect = "dark_bolt_screen",
			repeatCount = 5,
			repeatDelay = 1,
			onHitMonster = function(self, monster)
				delayedCall("trapSpellScripts", 0.2, "setSleepingMonster", monster.go.name)
			end,
		},


function setSleepingMonster(mon)
	local m = findEntity(mon)
	if m and m.monster then
		print("monster")
		m.monster:setCondition("sleep", 10)
		if m.sleeping then
			print("sleeping monster")
		end
	end
end
No joy... any hints or tips!? :) :roll:
Akroma

minmay
Posts: 2657
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Mon Feb 15, 2016 11:27 pm

onHitMonster executes before damage is dealt, not after. So if you don't return false (which cancels the damage), the monster is going to wake up immediately.
I do not have the time to test it right now but I'm pretty sure it would be easiest to just not do any damage with the TileDamager:

Code: Select all

{
         class = "TileDamager",
         attackPower = 1,
         repeatCount = 5,
         repeatDelay = 1,
         onHitMonster = function(self, monster)
            if monster:isAlive() then
              monster:setCondition("sleep", 10)
            end
            return false
         end,
         onHitObstacle = function() return false end,
         onHitChampion = function() return false end,
},
If you want to do damage as well, just use two TileDamagers:

Code: Select all

{
         class = "TileDamager",
         attackPower = 1,
         repeatCount = 5,
         repeatDelay = 1,
},
{
         class = "TileDamager",
         name = "sleeper",
         attackPower = 1,
         repeatCount = 5,
         repeatDelay = 1,
         onHitMonster = function(self, monster)
            if monster:isAlive() then
              monster:setCondition("sleep", 10)
            end
            return false
         end,
         onHitObstacle = function() return false end,
         onHitChampion = function() return false end,
},
Just make sure the TileDamager that inflicts sleep is after the TileDamager that does damage in the object definition. (Components generally initialize in the same order they are in the component table, and TileDamagers deal damage in the same order they are in the component table.)

Using delayedCalls for something like this is a bad idea imo, especially using delayedCalls with delays greater than 0. You want the sleep to happen as soon as possible after the damage; if you wait a frame (or, god forbid, multiple frames like you were doing...) you risk the monster moving, being dead, etc.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
akroma222
Posts: 1024
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 » Tue Feb 16, 2016 7:44 am

Ahh such a silly error on my part, I knew I was messing up the timing somehow!!
Thanks heaps minmay :D
Last edited by akroma222 on Tue Feb 16, 2016 4:21 pm, edited 1 time in total.

User avatar
Modraneth
Posts: 95
Joined: Thu Aug 27, 2015 8:27 pm
Location: Portugal

Re: Ask a simple question, get a simple answer

Post by Modraneth » Tue Feb 16, 2016 10:44 am

someone know about a dungeon floor filled with water and some cave with lava?
i want to place this on my mod, if possible and if already exist can u show me the link?
Mods:
Isle of Gunger
The Bloody Path Dropped
A World of Power work in progress

User avatar
THOM
Posts: 1130
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM » Tue Feb 16, 2016 11:27 am

Dungeon with water is included in the main-game.
And Lava can be found by the search-function:

viewtopic.php?f=22&t=9141&hilit=lava
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download

User avatar
Modraneth
Posts: 95
Joined: Thu Aug 27, 2015 8:27 pm
Location: Portugal

Re: Ask a simple question, get a simple answer

Post by Modraneth » Tue Feb 16, 2016 2:33 pm

THOM wrote:Dungeon with water is included in the main-game.
And Lava can be found by the search-function:

viewtopic.php?f=22&t=9141&hilit=lava
i want a dungeon floor with water on the floor, not the main game floor
its like just water on the floor with a "spash" sound when u move over it

EDIT: and thanks for the link to lava
Mods:
Isle of Gunger
The Bloody Path Dropped
A World of Power work in progress

User avatar
2Four
Posts: 18
Joined: Fri Mar 09, 2012 9:55 pm

Re: Ask a simple question, get a simple answer

Post by 2Four » Wed Feb 17, 2016 4:53 am

Is there simple way to re-create the wooden/plank bridges in the sewers of LOG2 in the editor?
I've searched the item list for items such as 'wooden', 'bridge', 'plank' and 'platform'.
I just can't seem to find it! is there a way to lay those plank bridges down on a map?
TIA!

minmay
Posts: 2657
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Wed Feb 17, 2016 5:40 am

2Four wrote:Is there simple way to re-create the wooden/plank bridges in the sewers of LOG2 in the editor?
I've searched the item list for items such as 'wooden', 'bridge', 'plank' and 'platform'.
I just can't seem to find it! is there a way to lay those plank bridges down on a map?
TIA!
Here is a dungeon editor file that will load Isle of Nex. You can then look at how all the levels in the game were made and find the name of any object you want.

The bridges in question are 'forest_bridge'.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
2Four
Posts: 18
Joined: Fri Mar 09, 2012 9:55 pm

Re: Ask a simple question, get a simple answer

Post by 2Four » Wed Feb 17, 2016 5:13 pm

Holy cow!
That's neat, thanks a bunch minmay!!
:D

User avatar
THOM
Posts: 1130
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM » Mon Feb 22, 2016 2:43 am

I need a socket to hold it's item forever. The player should insert a specific item which shoudn't be able to be picked up again.

But whatever I try, I can't get it to work. The item stays pickable. Anyone an idea?

What I tried:
- add in the object-definition a function which sets onRemoveItem to false after something is inserted
- disable the socket.component after something is inserted
- destroying the item in the mouse and recreate it in the socket

In my particular case the socket can be reached from behind and it seems, that it doesn't act like a socket anymore from this direction. Maybe items are always grapable from behind?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download

Post Reply