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
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

@IttaBitta I think you need to have a script object named "zim_functions" in your dungeon, then you set it to "external" and point to the script file, and be sure to add it to your init.lua as well
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

Hi, folks!
May be someone know, is there an easy way to make item:trowItem() function deal actual damage to the party? Changing AttackPower of projectile does nothing, as well as setting CastByChampion. May be there is a hidden flag, that tells that the projectile was cast by a monster? I'm really don't want to rewrite onProjectileHit() function, with my noobish scripting skills that would be a disaster :D
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Adrageron wrote: Tue Nov 10, 2020 6:08 pm May be someone know, is there an easy way to make item:trowItem() function deal actual damage to the party? Changing AttackPower of projectile does nothing, as well as setting CastByChampion. May be there is a hidden flag, that tells that the projectile was cast by a monster?
Could you describe this in more detail?

Is this for a weapon or item thrown at the party by a monster?
Or is it a weapon that damages a party member when it is thrown? (by them?)

The monster component has a throwItem function.

Code: Select all

MonsterComponent:throwItem(item, height, attackPower)
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

It is for an item (dart or arrow) trown at the party by a trap. I can emulate it by placing invisible monster there, but it looks like an ugly solution :)

Code: Select all

class = "Controller",
			{
			class = "Spawner",
			name = "missile",
			spawnedEntity = "dart",
			},
			{
			class = "Controller",
			onActivate = function(self)			
				self.go:playSound("dark_bolt_launch")
				local dir = self.go.facing-2
				if dir<0 then dir = dir+4 end
				local missile = self.go:spawn(self.go.missile:getSpawnedEntity())
				missile:setWorldPositionY(missile:getWorldPositionY()+1.5)
				missile.item:setFragile(true)
				missile.item:throwItem(dir,20)
				missile.projectile:setAttackPower(100)
			--	missile.projectile:setCastByChampion(1)
				return false
			end,
			},
This projectile hits party for 1-3 damage.
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

IttaBitta wrote: Tue Nov 10, 2020 6:54 am Thanks for all your help, btw

More mod mishaps - I tried to use Zimber's assets and I've had a lot of trouble
Trouble one:
Image
things lead me to think it wants me to 'merge' zim_party with my party definition... but I don't know where or WHAT that definition is.
Do you have a different asset pack with a party definition in it? Or did you remember to put the 'zimscripts' object in your dungeon?

Now my own question: How would I make it so when I press a button it checks if there is certain items on an alcove and if so then it destroys them and spawn a different one? (Like a stick and a rock would turn into a cudgel.)
User avatar
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

ratman wrote: Tue Nov 10, 2020 11:43 pmNow my own question: How would I make it so when I press a button it checks if there is certain items on an alcove and if so then it destroys them and spawn a different one? (Like a stick and a rock would turn into a cudgel.)
SurfaceComponent triggers script that loops through contents, checks their names, then surface:addItem(spawn("cudgel").item)
Join the LoG discord server: https://discord.gg/ArgAgNN :D

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

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

ratman wrote: Tue Nov 10, 2020 11:43 pm Now my own question: How would I make it so when I press a button it checks if there is certain items on an alcove and if so then it destroys them and spawn a different one? (Like a stick and a rock would turn into a cudgel.)
If you want code, Isaac will provide it :D

Here's just the functions you need:

1)
https://github.com/JKos/log2doc/wiki/Co ... -component --> SurfaceComponent:contents()

Code: Select all

-- Iterate over all items on the surface
for index, item in surface:contents() do
	print(index, item.go.id)
end
2)
GameObject:destroyDelayed()
http://www.grimrock.net/forum/viewtopic ... 66#p121766
IttaBitta
Posts: 19
Joined: Thu Oct 22, 2020 12:14 am

Re: Ask a simple question, get a simple answer

Post by IttaBitta »

ScroLL wrote: Wed Oct 29, 2014 9:12 pm Is there a way to make the dungeon floor entity not appear invisible when looking up from under it?
there's just no model there. it's invisible because there is no bottom. so no.
IttaBitta
Posts: 19
Joined: Thu Oct 22, 2020 12:14 am

Re: Ask a simple question, get a simple answer

Post by IttaBitta »

What kind of if then would I use to check for a certain item (a skull) placed into an alcove?
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Technically the material is one-sided by default. One can define a two-sided material, and it will show from both sides...However the shadows generated for a single sided model will not look right.

The real question is how are you planning to use it? Is it merely ceiling decoration... where the player will not walk on the top side? If that's the case, you can use a script to flip the models 180 degrees.

Example; start a new project/map, and place a dungeon_floor_01 object on elevation level 1 so that you can look upwards at it. Type the following into the console.

Code: Select all

dungeon_floor_01_1.model:setRotationAngles(0,0,180)
If you are only using a few of these, then it makes sense to just script the change in a script _entity. If you want to place a bunch of these, or if they must look like stone from both sides, then you should define a new asset, and include a duplicate model component, with the necessary flip included in the definition.

Like this:

Code: Select all

defineObject{
	name = "dungeon_floor_01_flipped",
	baseObject = "dungeon_floor_01",
	components = {
		{
			class = "Model",
			name = 'flipped',
			model = "assets/models/env/dungeon_floor_01.fbx",
			staticShadow = true,
			offset = vec(0,-0.015),
			onInit = function(self) self.go.flipped:setRotationAngles(0,0,180) end,
		},
	},
}
Image
Post Reply