Page 361 of 390

Re: Ask a simple question, get a simple answer

Posted: Tue Nov 10, 2020 7:13 am
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

Re: Ask a simple question, get a simple answer

Posted: Tue Nov 10, 2020 6:08 pm
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

Re: Ask a simple question, get a simple answer

Posted: Tue Nov 10, 2020 6:34 pm
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)

Re: Ask a simple question, get a simple answer

Posted: Tue Nov 10, 2020 7:14 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Tue Nov 10, 2020 11:43 pm
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.)

Re: Ask a simple question, get a simple answer

Posted: Wed Nov 11, 2020 2:25 am
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)

Re: Ask a simple question, get a simple answer

Posted: Wed Nov 11, 2020 7:27 am
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

Re: Ask a simple question, get a simple answer

Posted: Fri Nov 13, 2020 9:48 am
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.

Re: Ask a simple question, get a simple answer

Posted: Fri Nov 13, 2020 9:49 am
by IttaBitta
What kind of if then would I use to check for a certain item (a skull) placed into an alcove?

Re: Ask a simple question, get a simple answer

Posted: Sat Nov 14, 2020 5:07 am
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