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
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

But it's non-specific. It returns true for anyone in the party with the item; not the caster's personal inventory.

*I suppose it depends upon what the designer intends. It's sure a lot easier though. ;)
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

Isaac wrote: Mon Apr 25, 2022 6:49 pm But it's non-specific. It returns true for anyone in the party with the item; not the caster's personal inventory.

*I suppose it depends upon what the designer intends. It's sure a lot easier though. ;)
PartyComponent:isCarrying(string) returns true even for disabled champions

So if champion 1 is the only champion carrying a "red_gem"
and you disable champion 1 with Champion:setEnabled(false)
then party.party:isCarrying("red_gem") still returns true.

But in most mods, the party doesn't change once you've started the game, so this little bug usually doesn't matter.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

hi, can anyone help me with that script?
SpoilerShow

Code: Select all

-- this is added to an item, an armor
			onEquipItem=function(self,champion,slot)
				if slot==4 then
					champion:trainSkill("water_magic", 1,false)
					champion:trainSkill("earth_magic", 1,false)
					champion:trainSkill("air_magic", 1,false)
					champion:trainSkill("fire_magic", 1,false)
					playSound("level_up")
				end
			end,
			onUnequipItem=function(self,champion,slot)
				if slot==4 then
					champion:trainSkill("water_magic", -1,false)
					champion:trainSkill("earth_magic", -1,false)
					champion:trainSkill("air_magic", -1,false)
					champion:trainSkill("fire_magic", -1,false)
				end
			end]]
I wanted to add the 4 skillpoins in each magic schooll, it works only if you haven't reach the maximum skill (5 pts)
The problem here is if you already got 5 in any magic, then when removing the item, it removes 1 pt of the corresponding magic, even if you maxed the skill before puting the item. So basically, you loose one or more skill points
My asset pack: viewtopic.php?f=22&t=9320

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

Re: Ask a simple question, get a simple answer

Post by minmay »

This is quite complicated to do in a way that works. The skillModifiers field may be relevant.
You'll need to manage skill traits by hand no matter what approach you use (because adding skill traits can be automatic, but removing them when skill levels decrease is not). If you use skillModifiers, you'll need to do some fix-up any time the player trains the skill in the character sheet. If you use this trainSkill() approach, you'll need to store whether the skill level was actually increased and only decrease it on unequip if it was, and of course it won't be able to raise the skill past 5.
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: Ask a simple question, get a simple answer

Post by bongobeat »

ok, this is quite complicated to do then.

thank you for your answer.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

Hello, guys! I have encountered another problem :?
I am using this tileset made by Phitt: https://www.nexusmods.com/legendofgrimrock2/mods/35 wich is really a masterpiece. But recently I've discovered an unpleasant surprise: all doors in this mod (normal and secret ones) are transparent for projectiles. Is there a right way to fix it? Sadly, I have no experience using model editors, so I have no idea what to do with all that models and nodes :roll:
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Door component has a 'sparse' option that allows projectiles to pass through, and for the party to pick up items on the floor just inside the doorway.

DoorComponent:setSparse(boolean)

You can set the component's sparse flage to false in the individual door object definition(s), or in the object they inherit the door component from, if there is one.

*I have not looked at the mod resource yet, but am downloading it as I type.
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

Isaac wrote: Sun May 29, 2022 7:51 am Door component has a 'sparse' option that allows projectiles to pass through, and for the party to pick up items on the floor just inside the doorway.
Thank yor for reply!
AFAIK, 'sparse' option only allows to put/pick up items, not throw.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

You are probably right; It's been a [long] while since I've used any of it... I am re-familiarizing. ;)

(Looking at the resource scripts...)
SPARSE:
Items can be picked up and dropped through sparse doors. Monsters can also see through sparse doors, and the Poison Cloud spell can be cast through sparse doors.
It's definitely not the sparse flag. :(

I see what you mean about projectiles passing through the doors.

_____________

There are differences with the doors from the regular/official doors...

**Minmay has likely seen this problem before, and already knows. :lol:

It seems like it must be the script; swapping with an official door model solves nothing.
The Asian gate model is unusual; with assimp import lib nodes, but it seems to work visually well enough.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

DoorComponent uses the bounding box of the gate node (for normal doors) or the door_left and door_right nodes (for double doors) for projectile and FirearmAttackComponent collision.
The problem here is that two of the door models in that asset pack have empty gate nodes. You can fix this by shuffling around the nodes; this was quick enough for me to do so here's a download link to fixed versions of those models.
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.
Post Reply