Page 140 of 396

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 13, 2016 8:46 pm
by zimberzimber
Is it possible to have the game perform an autosave without forcing the player to heal at a healing crystal?
Was thinking about self disabling floor triggers that autosave the game. If possible, into a different slot/name. (Not the default "Autosave" slot)

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 13, 2016 9:13 pm
by minmay
Isaac wrote:
Connectors pass all the arguments that the hook has. A SurfaceComponent onInsertItem connector passes the SurfaceComponent and the ItemComponent.
Anytime a hook fires, its arguments are passed [afaik], but what's an example of a connector triggering a hook? (~besides onInsertItem /acceptItem, or script assigned.)
What on earth are you talking about? Connectors are triggered by hooks, not the other way around. Every time a hook triggers and doesn't return false, all connectors for that hook are triggered in order. All of these connectors receive the same arguments as the hook. PartyComponent.onDrawGui connectors pass the PartyComponent and the GraphicsContext, MonsterComponent.onProjectileHit connectors pass the MonsterComponent, ItemComponent, damage, and damageType, etc.

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 13, 2016 9:24 pm
by Howl3r
Is there a way to fiddle with timers and stuff so that I can make an enemy respawn in case it is not killed in given time?

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 14, 2016 1:22 am
by Eleven Warrior
Hi all.

Has or can anyone help me make a spell of Healing? When the spell is casted it checks to see if the champ(s) is wounded if not hudPrint Champ is not hurt, if wounded hudPrint Trynadore is healed,

It need to check if the caster is a certain level, has a certain trait, and requires eart or something else.

Also need the Scroll item to show the player gestures.

Thxs for the help on this.

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 14, 2016 4:58 am
by Isaac
minmay wrote:
Isaac wrote:
Connectors pass all the arguments that the hook has. A SurfaceComponent onInsertItem connector passes the SurfaceComponent and the ItemComponent.
Anytime a hook fires, its arguments are passed [afaik], but what's an example of a connector triggering a hook? (~besides onInsertItem /acceptItem, or script assigned.)
What on earth are you talking about? Connectors are triggered by hooks, not the other way around. Every time a hook triggers and doesn't return false, all connectors for that hook are triggered in order. All of these connectors receive the same arguments as the hook. PartyComponent.onDrawGui connectors pass the PartyComponent and the GraphicsContext, MonsterComponent.onProjectileHit connectors pass the MonsterComponent, ItemComponent, damage, and damageType, etc.
I wasn't talking about that, you seemed to be; so I asked for an example.

The original question was asking how to pass arguments with connectors [likely meaning plates and buttons, rather than user scripts]... and (erroneously) to hooks; unless I misread it.

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 14, 2016 8:37 am
by zimberzimber
Howl3r
Howl3r wrote:Is there a way to fiddle with timers and stuff so that I can make an enemy respawn in case it is not killed in given time?
If you need it as part of a custom monster, add this component:

Code: Select all

{
	class = "Timer",
	name = "respawnTimer",
	timerInterval = 10,
	disableSelf = true,
	onActivate = function(self)
	end,
},
And this to the monster component:

Code: Select all

onDie = function(self)
	if not self.go.respawnTimer:isEnabled() then
		self:setExp(0) --Preventing infinite xp (or don't)
		spawn(self.go.name, self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
	end
end,
The monster will not respawn if it is killed within 10 seconds after it spawned, so be sure to spawn it (rather than placing it) when the party should encounter it. (or activate via script)
Since the monster object has a short delay before destroying itself, you could add another initially disabled timer and set its interval to something like 0.5 or 1, have it activate when the monster dies, and upon it activating, it'll spawn the new monster. Don't forget to add a fancy particle effect ;)


If you need it on a single monster, do the following:
Add a timer, name it "respawn_timer_1", make it disable self, and have the interval set to the time for the party to kill the monster.
Add a monster, name it "myMonster_1", and have it trigger the scripts "respawn" function on death.
Add a script entity, name it "respawn_script_1", and add this to it:

Code: Select all

function respawn(monster)
	if not respawn_timer_1.timer:isEnabled() then 
		if monster.go.id == "myMonster_1" then
			if not myMonster_2 then
				local m = spawn(monster.go.name, monster.go.level, monster.go.x, monster.go.y, monster.go.facing, monster.go.elevation, "myMonster_2")
				m.monster:addConnector("onDie", "respawn_script_1", "respawn")
				respawn_timer_1.timer:enable()
			else
				print("error")
			end
		elseif monster.go.id == "myMonster_2" then
			if not myMonster_1 then
				local m = spawn(monster.go.name, monster.go.level, monster.go.x, monster.go.y, monster.go.facing, monster.go.elevation, "myMonster_1")
				m.monster:addConnector("onDie", "respawn_script_1", "respawn")
				respawn_timer_1.timer:enable()
			else
				print("error")
			end
		else
			print("wrong ID")
		end
	else
		print("The monster died")
	end
end
Make sure the interval is not too small(higher than 5), so the monster object will be deleted by the time he is ready to respawn.
If you still want to the interval to be lower than 5, you could make then "myMonster_2" checker spawn a ""myMonster_3", and have its checker spawn a "myMonster_1".

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 14, 2016 8:48 am
by zimberzimber
Eleven Warrior
Eleven Warrior wrote:Hi all.

Has or can anyone help me make a spell of Healing? When the spell is casted it checks to see if the champ(s) is wounded if not hudPrint Champ is not hurt, if wounded hudPrint Trynadore is healed,

It need to check if the caster is a certain level, has a certain trait, and requires eart or something else.

Also need the Scroll item to show the player gestures.

Thxs for the help on this.
Here: (not sure what you meant by "eart")

Code: Select all

defineSpell{ -- Heals the caster based on their life magic skill and concentration
	name = "heal",
	uiName = "Heal",
	gesture = 258,
	manaCost = 30,
	skill = "concentration",
	icon = 60,
	spellIcon = 1,
	description = "Heal your own wounds. \nHealth restored: concentration * 10 + 30",
	
	onCast = function(champion, x, y, direction, skill)
		local reqLv = 5
		local reqTrait = "wizard"
		if champion:getLevel() >= reqLv and champion:hasTrait(reqTrait) then
			if champion:getHealth() == champion:getMaxHealth() then
				hudPrint(champion:getName().." was healed")
			else
				hudPrint(champion:getName().." is not wounded")
			end
		end
	end,
}
From what I saw, scroll items are generated automatically.

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 14, 2016 9:59 am
by Isaac
zimberzimber wrote:Here: (not sure what you meant by "eart")
Earth

**Requires Earth [magic] or something**

BTW: Howl3r is posting questions in both the LoG1 and LoG2 threads; but which game? (It affects the answers)

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 14, 2016 11:39 am
by Howl3r
Isaac wrote:
zimberzimber wrote:Here: (not sure what you meant by "eart")
Earth

**Requires Earth [magic] or something**

BTW: Howl3r is posting questions in both the LoG1 and LoG2 threads; but which game? (It affects the answers)
Oh f**k. Yeah thanks for noting me. I have been looking just through the internet for guides and haven't even noticed that a part of them are LoG 2 forums. Sorry about that :d

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 14, 2016 12:18 pm
by zimberzimber
Isaac wrote:
zimberzimber wrote:Here: (not sure what you meant by "eart")
Earth

**Requires Earth [magic] or something**
Derp :?
Just need to replace concentration with earth_magic then