Page 155 of 396

Re: Ask a simple question, get a simple answer

Posted: Wed Sep 14, 2016 4:50 am
by minmay
THOM wrote:I've erased all additions I made to the party-object - no result.
You may think you've removed all the other party definitions, but I can almost guarantee that you haven't. If you had, then that hook would be called.
Are you importing assets/scripts/objects/generic.lua after defining the party? Because it will overwrite the party definition. Importing GrimTK? Overwrites the PartyComponent, so it will remove all your hooks. Using Skuggasveinn's winter tileset without fixing it first? It overwrites the entire party definition (for no reason!) too.
Have you done a grep for "party" in your entire dungeon folder, or shadowed defineObject() to print a special message when it encounters a definition named "party"? If not, then you shouldn't assume that you aren't redefining the party object somewhere else.

Just FYI, the hook function posted doesn't really accomplish the intended result - it gets the damage totally wrong, gets the damage type wrong if the champion is wearing an item with the "fire_gauntlets" trait, attacks HealthComponents that the party shouldn't be able to attack because they're blocked by a door, doesn't check the elevation of the HealthComponent so it can do a bunch of damage to monsters if the party's elevation doesn't match the HealthComponent's, and PartyComponent.onAttack doesn't get called for unarmed attacks at all so it won't detect those. It also probably "hits" the wrong square sometimes even when the elevations match.
There are many other possible problems with this approach as well; you should really temporarily remove the physical immunity instead of trying to use damageTile.

Re: Ask a simple question, get a simple answer

Posted: Wed Sep 14, 2016 8:37 am
by Isaac
minmay wrote:Have you done a grep for "party" in your entire dungeon folder, or shadowed defineObject() to print a special message when it encounters a definition named "party"?
Wouldn't searching for 'Party' be better?

Re: Ask a simple question, get a simple answer

Posted: Wed Sep 14, 2016 9:26 am
by minmay
Isaac wrote:
minmay wrote:Have you done a grep for "party" in your entire dungeon folder, or shadowed defineObject() to print a special message when it encounters a definition named "party"?
Wouldn't searching for 'Party' be better?
A defineObject() call that overwrites the entire party object is likely. As I mentioned, one exists in generic.lua (since it is the original party definition) and there's another one in The Winter Tileset. Anything that overwrites the PartyComponent will be part of a "party" definition so it will still be caught, though you could do a case-insensitive grep if you really need to see it twice.
Of course this still won't catch something silly like defineObject{name="p".."a".."r".."t".."y" [...]} but I doubt THOM has done anything like that.

Re: Ask a simple question, get a simple answer

Posted: Wed Sep 14, 2016 12:03 pm
by THOM
minmay wrote: Of course this still won't catch something silly like defineObject{name="p".."a".."r".."t".."y" [...]} but I doubt THOM has done anything like that.
I'm very relieved that you believe in me.... :mrgreen:

Actually it was GrimTK that blocked my onAttack hook. I've moved the script into the GrimTK party-object and now it works. :idea: Thank you Eburt for the code.

Concerning the doubts you mentioned, minmay: most of these circumstances can not become true in my case. I've also added a query and now the code only gets executed in case one specific object is attacked by the party. I hope that breaks the remaining possibilities.

Re: Ask a simple question, get a simple answer

Posted: Thu Sep 15, 2016 9:33 pm
by AndakRainor
I try to import files with a prefix path variable this way:

Code: Select all

path = "mod_assets/spells_pack/"
import path.."items/shaman_staff.lua" -- earth +20%
But it does not work. Using this prefix anywhere in the code works, but not with import. What am I doing wrong? Is it impossible?

Re: Ask a simple question, get a simple answer

Posted: Thu Sep 15, 2016 11:06 pm
by minmay
Unfortunately the import keyword only works with string literals, so you can't do that.

edit: I'm dumb

Re: Ask a simple question, get a simple answer

Posted: Fri Sep 16, 2016 1:40 am
by Isaac
Just encase the the entire string in parenthesis, like this:

Code: Select all

path = "mod_assets/spells_pack/"
import (path.."items/shaman_staff.lua") -- earth +20%

Re: Ask a simple question, get a simple answer

Posted: Fri Sep 16, 2016 2:36 am
by AndakRainor
Thanks a lot, it works :)
And something Minmay did not know :o ;)

Re: Ask a simple question, get a simple answer

Posted: Sun Sep 25, 2016 12:20 pm
by bongobeat
hey there,

I've got trouble with a custom spiketrap: I wanted a spiketrap to automatically activate itself, so I didn't had to use any trigger to activate the trap. I've added a floor_trigger component in the object definition, the trap activate itself when the party goes on but when when the party leave the trap the preview crashes and the editor gives me a warning message:
Image

the object definition
SpoilerShow

Code: Select all

defineObject{
	name = "floor_spike_trap_auto",
	baseObject = "base_floor_decoration",
	components = {
		{
			class = "Model",
			model = "assets/models/env/tomb_floor_spiketrap.fbx",
		},
		{
			class = "FloorTrigger",
			onActivate = function(self)
				self.go.animation:play("activate")
				self.go.tiledamager:enable()
			end,
		},
		{
			class = "Animation",
			animations = {
				activate = "assets/animations/env/tomb_floor_spiketrap_hit.fbx",
			},
		},
		{
			class = "TileDamager",
			attackPower = 50,
 			damageType = "physical",	-- TODO: change to "pure"
 			screenEffect = "damage_screen",
 			cameraShake = true,
			sound = "spike_trap",
			floorTrap = true,
			enabled = false,
			onHitObstacle = function(self, obstacle)
				if obstacle.go.name == "beach_thicket_01" then return false end
			end,
			onHitMonster = function(self, monster)
				if monster.go.name == "air_elemental" then return false end
			end,
		},
		{
			class = "Controller",
			onActivate = function(self)
				self.go.animation:play("activate")
				self.go.tiledamager:enable()
			end,
		},
	},
	editorIcon = 284,
}
any idea please?

Re: Ask a simple question, get a simple answer

Posted: Sun Sep 25, 2016 12:32 pm
by AndakRainor
I did not test it, but it seems you are missing a definition for onDeactivate and a default one is messing with your animations.