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
Lorial
Posts: 91
Joined: Sat Dec 29, 2018 12:27 pm

Re: Ask a simple question, get a simple answer

Post by Lorial »

I am looking for a way to add a turokesque hudPrint("Get to the surface!") for the extended waterbreathing condition.
How can I add this on a specific tick/time before the end of the duration, say at 190 seconds.

Code: Select all

defineCondition{
	onStart = function(self, champion)
		self:setDuration(200)
	end,
	onRecomputeStats = function(self, champion)
		champion:setCondition("water_breathing")
	end,
	onTick = function(self, champion)
		if not champion:isAlive() then
		champion:removeCondition("water_breathing")
		end
	end,
	onStop = function(self, champion)
		champion:removeCondition("water_breathing")
	end,
}
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Pompidom wrote: Mon Sep 16, 2019 5:25 pm Weapons and objects don't have unique names in my mod, they're simply bought from shops.
You can for instance blow all your money on 8 lightning staffs with 4 dual staff wielding mages. (Just an example)

So it has to be implemented directly in the define object code of the staff if that's possible
The id ~staff~, was simply an example name. In the charging function you would examine the object to determine whether to set charges.

There are many ways to determine if it should be charged; the fact that it HAS any charge is one of them. You could inspect the UIname, or the GameEffect strings (for identifying information—that you have put there). You could name the item component, and check for that. You could define a custom trait, and check for it.
Lorial wrote: Mon Sep 16, 2019 6:22 pm I am looking for a way to add a turokesque hudPrint("Get to the surface!") for the extended waterbreathing condition.
How can I add this on a specific tick/time before the end of the duration, say at 190 seconds.

Code: Select all

-- inside onTick
		if math.floor(self:getDuration()) ==  190 then
			hudPrint("Get to the surface!")
		end
Last edited by Isaac on Mon Sep 16, 2019 7:02 pm, edited 2 times in total.
User avatar
Lorial
Posts: 91
Joined: Sat Dec 29, 2018 12:27 pm

Re: Ask a simple question, get a simple answer

Post by Lorial »

Isaac wrote: Mon Sep 16, 2019 6:31 pm

Code: Select all

-- inside onTick
if self:getDuration() >189 then
	hudPrint("Get to the surface!")
end
Great, thanks for the quick response.
Now since the party might not be under water anymore, is there a way to check whether the party is submerged at that exact moment and show the message only then?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Essentially no. The easiest way is a hack. :(

You check for the water automap tile, but you also need to check the party elevation, because they could be on a bridge.
User avatar
Lorial
Posts: 91
Joined: Sat Dec 29, 2018 12:27 pm

Re: Ask a simple question, get a simple answer

Post by Lorial »

Isaac wrote: Mon Sep 16, 2019 7:04 pm Essentially no. The easiest way is a hack. :(

You check for the water automap tile, but you also need to check the party elevation, because they could be on a bridge.
Well..., not gonna bother with that. Guess I'll rather use my grammar hack then and rephrase it to "The water breathing spell is starting to fade." or some such. ;)
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Notice that the script was updated. ;)
User avatar
Lorial
Posts: 91
Joined: Sat Dec 29, 2018 12:27 pm

Re: Ask a simple question, get a simple answer

Post by Lorial »

Isaac wrote: Mon Sep 16, 2019 9:22 pm Notice that the script was updated. ;)
Due to the hud spam I came to that same conclusion right away, but the == did not get recognized, for whatever reason - works that way for all my equip/unEquips. Now that I think of it, I had trouble with time and timers in general trying to get an event to start exactly at a given moment.

Instead I fiddled around a bit and ended up with this makeshift version which blocks 3 of the 4 visible lines with empty lines.
It also seems like the duration is counting down, not up. The code below gives a warning message 10 seconds before the spell runs out.

Code: Select all

	onTick = function(self, champion)
		if self:getDuration() >= 9.9 and self:getDuration() < 10 then
		hudPrint("")
		hudPrint("")
		hudPrint("Get to the surface!")
		hudPrint("")
		end
	end,
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Lorial wrote: Tue Sep 17, 2019 6:07 am
Isaac wrote: Mon Sep 16, 2019 9:22 pm Notice that the script was updated. ;)
Due to the hud spam I came to that same conclusion right away
That's what the update fixed. There is no longer hud-spam; it flashes once, at 190 seconds. ;)
It also seems like the duration is counting down, not up.
It is counting down.

*Note, though it's very unlikely, it is possible that a different hudPrint() could get cleared by your expiring condition, before the player has a chance to read the message.
User avatar
Eleven Warrior
Posts: 746
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

How do I add exp to the party in coding I cant remember how to do it ty. oh and with huprint eg: Party gains 100 exp etc... and plus a sound fx added into the code ty again mb :)
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Code: Select all

function champXP()
for i=1,4 do
	local ch = party.party:getChampion(i)
	if ch:isAlive() then
		ch:gainExp(50)
		hudPrint(" "..ch:getName().." gained 50 XP.")
	end
end
playSound("level_up")
end
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Post Reply