setCauseCondition expects table

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!
Post Reply
User avatar
DaggorathMaster
Posts: 41
Joined: Thu Sep 08, 2022 7:29 pm

setCauseCondition expects table

Post by DaggorathMaster »

How does monsterAttack:setCauseCondition() work?
It expects a table.
But, of what?

I am interested in having monsters cause more than one condition,
e.g., spiders obviously poison, but IRL that poison causes paralysis,
so I would increase the base chance, and pick a condition randomly (weighted).

But the format for telling it a new condition, made its saving throw.
User avatar
7Soul
Posts: 205
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: setCauseCondition expects table

Post by 7Soul »

Looks like another oversight in the scripting interface :/ It does expect a table when it should've been a string

A way of making it work would be to use the `onAttackHit(self, champion)` hook to manually apply the random condition, ignoring the causeCondition property entirely
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
DaggorathMaster
Posts: 41
Joined: Thu Sep 08, 2022 7:29 pm

Re: setCauseCondition expects table

Post by DaggorathMaster »

I suppose I can settle for that if needed.
That approach does open the possibility of just reworking attack conditions entirely.
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: setCauseCondition expects table

Post by minmay »

To emulate causeCondition, use the onDealDamage hook rather than the onAttackHit hook; causeCondition only causes conditions for attacks that deal damage, whereas onAttackHit is called even if the attack deals no damage (it's called before damage calculation, in fact).
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
DaggorathMaster
Posts: 41
Joined: Thu Sep 08, 2022 7:29 pm

Re: setCauseCondition expects table

Post by DaggorathMaster »

OK. Actually now I see that that is just what Dark Acolytes do - causeCondition for poison, and a hook for paralysis.

The choice of whether to use onDealDamage or onAttackHit can be made based one whether late-game heavily-armored champions are god-mode or still too vulnerable (pending playtesting).

I have been eyeing a conditions rework anyway (because of things like monster vs. monster fighting, and making the mod a worthy challenge/mind$cr3w for people who know the game a little too well.)
So maybe ignoring most or all of the "normal" way of doing it is in order.
Post Reply

Return to “Mod Creation”