timer question and gameModeFadeOut

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!
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

timer question and gameModeFadeOut

Post by bongobeat »

Hello gentlemen,

Just want to now if what I'm doing isn't wrong:
Please, somebody can confirm me that this will not make any issue?

this is a timer that I've put in the init.lua
it has to start when one champion (or more) is wearing a complete armor set, and play a breathing sound.
SpoilerShow

Code: Select all

--- timer hev suit
		{
			class = "Timer",
			name = "breathetimer",
			timerInterval = 5,
			onActivate = function(self)
				playSound("breathe")
			end,
			enabled = false,
		},
then the armor item:
when the full suit is equipped, the timer is activated in the onRecomputeStats function.
when this item is removed (or one of the other item of the set), it stop the timer and remove the waterbreathing condition, in the onUnequipItem function.
SpoilerShow

Code: Select all

defineObject{
	name = "hev_cuirass",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "mod_assets/models/hev_chest.fbx",
			offset = vec(0, 0.1, 0),
		},
		{
			class = "Item",
			uiName = "HEV Body MK3",
			description = "Nothing can tell what is the use of this mysterious stuff.",
			armorSet = "hev",
			armorSetPieces = 5,
			gfxIndex = 150,
			gfxAtlas = "mod_assets/textures/oliveitem.tga",
			weight = 4.0,
			traits = { "chest_armor" },
			onUnequipItem=function(self,champion,slot)
				if slot==4 then
				party.breathetimer:disable()
				champion:removeCondition("water_breathing")
				end
			end
		},
		{
			class = "EquipmentItem",
			protection = 5,
			onRecomputeStats = function(self, champion)
				if champion:isArmorSetEquipped("hev") then
					champion:addStatModifier("resist_cold", 200)
					champion:addStatModifier("resist_poison", 200)
					champion:addStatModifier("resist_fire", 200)
					champion:addStatModifier("resist_shock", 200)
					champion:setConditionValue("water_breathing", 600)

					party.breathetimer:enable()

--GameMode.fadeOut(0x00CC00,600)
				end
			end,
		},
	},
}
Also, is it possible to use the GameMode.fadeOut with an alpha parameter? or anything that can modify the opacity of the color used in the GameMode.fadeOut?

I want something, like green, transparent, that comes in fullscreen when the set is equipped.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: timer question and gameModeFadeOut

Post by Isaac »

Is this a dive suit? :roll: [I'm, almost done; had a couple snags, but they are fixed.]

For effects:
Xanthar's room in the ORRR2 is the one you want to look at. He implemented his awesome multi~colored lens goggles and hallucinogenic mushroom visual effects.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: timer question and gameModeFadeOut

Post by minmay »

GameMode.fadeOut() and GameMode.fadeIn() are not appropriate for the effect you want. However, neither are any of the PartyComponent.onDraw hooks; while it is easy to draw a transparent green rectangle over the view, it will completely disappear whenever the party uses free-look (or does anything else that hides the GUI). This is what Xanathar did, so looking at ORRR2 won't help bongobeat at all with this.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: timer question and gameModeFadeOut

Post by bongobeat »

It is not realy a diving suit, it is some kind of nbc suit. it is used in one level to avoid all magical damage, where I put a timer that give insta damage of each magic, each demi second, if you don't wear the suit, you are killed (very hostile place :mrgreen: ). I added the waterbreathing because there is some water to dive in. Maybe I put too much value of the waterbreathing time.
(Anyway, this has nothing to do with the diving helmet stuff)

I though of the mod of Xanathar (the sunset gate, not the orr2, but I guess he uses it the same way), hum, so there isn't any way to do that? Or just draw some particle ? even if it is not entirely green?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: timer question and gameModeFadeOut

Post by minmay »

I don't recommend trying to do this visual effect at all. The 2d methods are no good because of free look, and attaching a ModelComponent or extra ParticleComponent to the party would require reverse engineering the entire default camera (otherwise the model/particle will be in the wrong place whenever the party moves, free looks, falls, etc.). You could make a particle system and apply it with PartyComponent:playScreenEffect(), of course, which will follow the camera perfectly - but then you will have to disable all other screen effects.

Also, it's going to hurt the framerate obviously.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: timer question and gameModeFadeOut

Post by Isaac »

minmay wrote:I don't recommend trying to do this visual effect at all. The 2d methods are no good because of free look, and attaching a ModelComponent or extra ParticleComponent to the party would require reverse engineering the entire default camera (otherwise the model/particle will be in the wrong place whenever the party moves, free looks, falls, etc.).
Since it's not meant as a legible Hud, what about a low-poly translucent sphere assigned to the model component?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: timer question and gameModeFadeOut

Post by minmay »

Again, you will run into problems when the camera moves.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: timer question and gameModeFadeOut

Post by Isaac »

I experimented with this; here is proof of concept: https://www.dropbox.com/s/h09b4azhxz36i ... t.zip?dl=0

It has the caveat that torches to the immediate side of the party, lose the tint effect on the flames, but otherwise it looks great. 8-)
(And the loss of tint doesn't really detract.)
Image
*GIF image: reduced to 256 colors.

*This also seems to hold great potential for more than just a full screen tint 8-); as the model can have any contour, and be placed in any location. It's basically like colored glass;(and presumably able to be animated).

**Uses emissiveColor in this version, so the tint doesn't show up in low quality render mode; but there is likely a workaround for that.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: timer question and gameModeFadeOut

Post by bongobeat »

this looks very cool! :shock:

do you have any example on how removing / activating that effect?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: timer question and gameModeFadeOut

Post by Isaac »

bongobeat wrote:this looks very cool! :shock:

do you have any example on how removing / activating that effect?
In the editor console, type party.greeneffect:disable() [or enable()].
Post Reply