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!
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Holy moly, that looks nice :)

I guess I will keep the flat waterfall walls from zimber as placeholder for now until I can obtain these :)
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

THOM wrote: Tue Aug 14, 2018 10:57 am The waterfall of Skuggs will come with ORRR3. 8-)
Ahhh good to know :D
Cheers THOM!
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Is it possible to detect a "bad object" without crashing the game? Let's say the bad object is an item inside a container component, can I detect it then remove the item from its slot inside this container?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

The "bad object" error message means that either you passed the completely wrong type of argument to a function, or you tried to do something with a reference to a GameObject/Component/etc. that has been destroyed.
Presumably you're talking about the second case, and the answer is no, not really. Merely indexing an object that has already been destroyed will cause an error. The solution is to keep better track of your objects.

The example you're giving seems odd to me. If the game tries to destroy a GameObject that's inside a container, it should cause an error anyway because you're destroying an object that's not on a map. I guess you could cause some havoc by removing just the ItemComponent while it's in a container and leaving the parent GameObject intact...but the only time that would happen is in a user script, which means you have a reference to the ItemComponent anyway and can remove it from the container before destroying it.
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
Huff
Posts: 18
Joined: Fri Jun 22, 2012 9:47 pm

Re: Ask a simple question, get a simple answer

Post by Huff »

Is there a way to interrupt a monster's action or immediately set it to idle?

I'm trying to make it so that when the monster:knockback() method from weapons like the Maul will always trigger a knockback, regardless of the monster's current action. The current implementation only allows you to knock back monsters if the monster:getCurrentAction() returns nil, which appears to be the idle state.

Some sample code of what I've tried:

Code: Select all

onHitMonster = function(self, monster)
	monster.go.animation:stop()
	monster:performAction("idle")
	print(monster:getCurrentAction())
	monster:knockback(party.facing)
end,
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Try this:

Code: Select all

onHitMonster = function(self, monster)
	if monster:isAlive() and not monster:isFalling() and monster:getCurrentAction() ~= "knockback" then
		monster.go:setPosition(monster.go.x,monster.go.y,monster.go.facing,monster.go.elevation,monster.go.level)
		monster:knockback(party.facing)
	end
end,
Setting a monster's position is the easiest way to interrupt monster actions.
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
Huff
Posts: 18
Joined: Fri Jun 22, 2012 9:47 pm

Re: Ask a simple question, get a simple answer

Post by Huff »

Great work minmay, thank you!
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

Hey All,
I have 2 questions re animated textures drawn over the champion menus....

1. When wounded / injured, the corresponding Inventory (menu) slot is outlined in bold red, but also there is a red transparent tint than fades out as the tint comes closer to the middle of the injured slot. This tint seems to wax and wane (ever so slightly) every few seconds (is spose to imply throbbing pain? :geek: ) This kind of thing ive been replicating by experimenting with gametime and sin / cos / tan.... with varying degrees of tears and boredom as the usual result.
EG

Code: Select all

local txtV = party.animatetexturecounter:getValue()
local gt = party.gametime:getValue()
local alpha = (90 * math.sin(gt * 0.65) + 160)
context.color(255, 255, 255, alpha )
-------------------------------------------------------------------------------------------------------------menu glass
context.drawImage2("mod_assets/textures/gui/loopSkyAnimated2Spots.tga", w-f*554,  f*291,  txtV,  (90 * math.sin(fc *0.65)+260),		115, 60, 	f*517, f*317)
My question is: Does anyone have an exact or similar Math Formula for the fading red inventory slot tint seen if injured???

2. What would be the best way to replicate the blue sparkling 'heal_party' Fx animated over the Attack Panel portraits when a champion is healed?? Ive looked for the thread where Isaac has demonstrated 2D animations by using a particle effect atlas (each frame draws the next version of the particle) ... but I cant find it :| :oops: ... is this the best way to redo the heal party sparkle???

Admittedly, I am hoping someone can help me cut corners here... as Im trying to not sink loads of time into these small nagging things... any help would be marvellous :D 8-)
Cheers folks
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

For the injury, context.color(0, 0, 215+math.sin(Time.currentTime()*4)*40, 255) before drawing the overlay.

You can't replicate the healing effect exactly because it uses additive blending, which is not available in GraphicsContext. Even if you're willing to settle for alpha blending, it would not be fun to code, or very efficient. If at all possible, I recommend you just use the real healing effect.
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
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

minmay wrote: Fri Aug 24, 2018 10:28 am For the injury, context.color(0, 0, 215+math.sin(Time.currentTime()*4)*40, 255) before drawing the overlay.
Absolutely fantastic, many many thanks :P :D
minmay wrote: Fri Aug 24, 2018 10:28 am You can't replicate the healing effect exactly because it uses additive blending, which is not available in GraphicsContext. Even if you're willing to settle for alpha blending, it would not be fun to code, or very efficient. If at all possible, I recommend you just use the real healing effect.
Ahh I see, I see.. unfortunately I cant use almost all of the vanilla effects shown in menus or attack panels.... reason being
Ive redrawn all attack panels and menus... hence my recent posts asking for the best ways to re-implement features, fx and other hard coded stuff....
Hopefully the below images should demonstrate my dilemma :roll: :x
SpoilerShow
Image
SpoilerShow
Image
SpoilerShow
Image
But all good! I wont try to replicate the vanilla heal effect, ill create a diff one instead - Thankyou again kind sir for steering me away from the fruitless time trap of replicating it :D
Post Reply