Page 145 of 396

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 19, 2016 9:54 pm
by minmay
GameObject isn't a Component. GameObject is the container that contains Components. All Components have a "go" field that points to their parent GameObject, but the GameObject does not have a field that points to itself; your hook assumes it does, which it doesn't, so it crashes.
Use

Code: Select all

villageMummy1Lantern:destroy()
Also there should still be an error message, you just aren't seeing it because you aren't running the game from the command line so stdout goes nowhere.

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 19, 2016 10:04 pm
by Isaac
brzrkr wrote:2. Why does it say that "gameobject" or "go" doesn't exist?
Because it doesn't. All of the gameobject methods are accessible as object:method()

Code: Select all

 Try this in the hook:

function smotherLantern(monsta)
	print(monsta.go.id, unpack{monsta.go:getPosition()})
	for monster in monsta.go.map:entitiesAt(monsta.go.x, monsta.go.y) do
	
		if monster.monster and not monster.go then  -- notice that the condition FAILS if there is a value for monster.go
		
			print(monster.id, unpack{monster:getPosition()})   -- notice that this is not monster.go.id
		end
	end

end
The .go field is used when accessing the script object; which is generally the first argument passed to your function. In function(self), self.go.id gives the id of the script. [monsta is the script, and needs to be monsta.go.id]
And the wall lantern has that same exact ID.
No two objects [existing concurrently] on the map should have the exact same id. That will crash it.
[Except in the dangerous case where of one of them is in a container on the map].
How am I supposed to destroy the lantern or disable one of its components when the monster dies, if this is not the correct way?
If its id is 'Lantern' then the way is: Lantern:destroy()
3. About the commented part, since the dying monster's ID is villageMummy, I was wondering if I could take his id, append "Lantern" to it in a string (thus creating the lantern's ID), and then use the string variable as if it were the lantern ID itself, to destroy the lantern directly. If not, how can I turn that string into the actual lantern entity?
.
You could set it up this way by manually naming the objects. When you have a concatenated string and need to use it as an ID, use the function findEntity() in place of the id, and pass to it the string.
Examples:

findEntity("my_object_1"):destroy()

local obj = "my_object_"..x --where x == 1
findEntity(obj):destroy()

Know that findEntity will return nil, if it cannot find the object ~that can crash your script if unexpected. So if there is a chance of it returning nil, you can first check that it's not nil.
Example:
if findEntity("my_object_1") then findEntity("my_object_1"):destroy() end

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 12:18 am
by zimberzimber
How can a condition manipulate a champions cool down?
It's definitely possible because there's a condition that does that already. (Haste)
I've added this to the conditions definition but it did nothing:

Code: Select all

	onComputeCooldown = function(champion, weapon, attack, attackType, level)
		if level > 0 then return 90 end
	end,

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 12:29 am
by brzrkr
Riight. I expected it to be something so stupid that I overlooked it. I'm even more stupid than it.

Thank you for the tips also.

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 12:39 am
by minmay
zimberzimber wrote:How can a condition manipulate a champions cool down?
It's definitely possible because there's a condition that does that already. (Haste)
I've added this to the conditions definition but it did nothing:

Code: Select all

	onComputeCooldown = function(champion, weapon, attack, attackType, level)
		if level > 0 then return 90 end
	end,
The builtin conditions don't really work like custom conditions. Anyway, there's no onComputeCooldown hook for conditions, only skills and traits. You'll need to add a trait to all champions that checks for the presence of your custom condition.

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 12:41 am
by zimberzimber
minmay wrote:The builtin conditions don't really work like custom conditions. Anyway, there's no onComputeCooldown hook for conditions, only skills and traits. You'll need to add a trait to all champions that checks for the presence of your custom condition.
Into the hidden mother-of-all-not-simply-added-stats trait it goes :D

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 4:54 pm
by AndakRainor
How do I get the height of a monster ?

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 5:59 pm
by Isaac
AndakRainor wrote:How do I get the height of a monster ?
The elevation? [-7 to 6?]
monster.elevation

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 6:43 pm
by minmay
MonsterComponent:getCapsuleHeight()

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 20, 2016 9:28 pm
by AndakRainor
I tried MonsterComponent:getCapsuleHeight(), and used the value in world coordinates. It appears to be very low, near the ground. I am trying to set a good starting position for a particle effect moving from the "center" of a monster to the party (for the drain life spell).

Currently I am using monster:getCapsuleHeight() + monster:getCapsuleRadius()/2, it feels ok, I tested if in the arena of orrr3, but it was still a little too low for the mosquitos!