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
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

bongobeat wrote: Sat Mar 28, 2020 1:39 pm It worked perfectly for a while, then it's power attack don't work anymore. Don't know if the script has an error or if it's something other related to the rest of the mod.
The script works for me, as long as I

a) Comment out this line:
party.berserkerScript.weaponUnequip(self,champion,slot)

b) Change this line:
requirements = { "critical", 2, "epic_weapons", 3 },
to
requirements = { "critical", 2 },

c) Change this line:
spell = "darkburst",
to
spell = "fireburst",

The power attack works until it runs out of charges.
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 »

Well, with the custom spell and custom skill, the thing worked great for the first few hours I used it, since I got the sword.
The power attack recharges itself when hitting a monster.

Then after a few reload, the power attacks cannot be used anymore.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

bongobeat wrote: Sun Mar 29, 2020 12:37 am Well, with the custom spell and custom skill, the thing worked great for the first few hours I used it, since I got the sword.
The power attack recharges itself when hitting a monster.

Then after a few reload, the power attacks cannot be used anymore.
If you've used up all charges, and then call CastSpellComponent:setCharges(number) to set the charges to 1 (or any other number > 0), the power attack won't work anymore.
You have to call CastSpellComponent:recharge() first.

Code: Select all

if self.go.collection:getValue() >= 100 then
	local currentCharges = self.go.Dfire:getCharges()
	if currentCharges < self.go.Dfire:getMaxCharges() then
		if doDebug then print("Charge added, resetting count.") end
		self.go.Dfire:recharge()
		self.go.Dfire:setCharges(currentCharges + 1)
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

Zo Kath Ra wrote: Sun Mar 29, 2020 9:43 am
bongobeat wrote: Sun Mar 29, 2020 12:37 am Well, with the custom spell and custom skill, the thing worked great for the first few hours I used it, since I got the sword.
The power attack recharges itself when hitting a monster.

Then after a few reload, the power attacks cannot be used anymore.
If you've used up all charges, and then call CastSpellComponent:setCharges(number) to set the charges to 1 (or any other number > 0), the power attack won't work anymore.
You have to call CastSpellComponent:recharge() first.

Code: Select all

if self.go.collection:getValue() >= 100 then
	local currentCharges = self.go.Dfire:getCharges()
	if currentCharges < self.go.Dfire:getMaxCharges() then
		if doDebug then print("Charge added, resetting count.") end
		self.go.Dfire:recharge()
		self.go.Dfire:setCharges(currentCharges + 1)
I suppose you could call CastSpellComponent:recharge() only if currentCharges == 0
But I think it doesn't hurt to call CastSpellComponent:recharge() every time you add a charge.
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 »

Zo Kath Ra wrote: Sat Mar 28, 2020 6:44 pm
bongobeat wrote: Sat Mar 28, 2020 1:39 pm Please can somebody check the attached script of this item?
I haven't checked the script yet, but...

"The rapier of Jean Bart, the legendary pirate. It is said that he has slayed 13 drakes with this sword during the Dragon's War. A succesful hit replenishes its power attack."

has slayed -> slew
succesful -> successful
Thanks! :lol:
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
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 »

Zo Kath Ra wrote: Sun Mar 29, 2020 9:45 am
Zo Kath Ra wrote: Sun Mar 29, 2020 9:43 am
bongobeat wrote: Sun Mar 29, 2020 12:37 am Well, with the custom spell and custom skill, the thing worked great for the first few hours I used it, since I got the sword.
The power attack recharges itself when hitting a monster.

Then after a few reload, the power attacks cannot be used anymore.
If you've used up all charges, and then call CastSpellComponent:setCharges(number) to set the charges to 1 (or any other number > 0), the power attack won't work anymore.
You have to call CastSpellComponent:recharge() first.

Code: Select all

if self.go.collection:getValue() >= 100 then
	local currentCharges = self.go.Dfire:getCharges()
	if currentCharges < self.go.Dfire:getMaxCharges() then
		if doDebug then print("Charge added, resetting count.") end
		self.go.Dfire:recharge()
		self.go.Dfire:setCharges(currentCharges + 1)
I suppose you could call CastSpellComponent:recharge() only if currentCharges == 0
But I think it doesn't hurt to call CastSpellComponent:recharge() every time you add a charge.
thanks! I will give it a try.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
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 »

Is "fitContainer = false," necessary to a container item?

I've accidentaly omitted the line "fitContainer = false," in a custom container item. So you can put the container into another container, and you can open it from there. I've noticed that during the test of my mod.

I found that practicall, but I don't know if this is safe and cannot do some issues later with the inventory
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

bongobeat wrote: Wed Apr 01, 2020 12:35 pm Is "fitContainer = false," necessary to a container item?

I've accidentaly omitted the line "fitContainer = false," in a custom container item. So you can put the container into another container, and you can open it from there. I've noticed that during the test of my mod.

I found that practicall, but I don't know if this is safe and cannot do some issues later with the inventory
I've never had any problems with containers that fit inside other containers, such as
- keyring
- shotgun (reload it by manually putting shells inside)
- sword (increase its attack power by putting gems inside)

It just looks weird, because only one container UI can be open at any time.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

If you allow the player to place containers inside other containers, it immediately introduces two problems. First, they can put a container inside itself and crash the game:
1. Open container A
2. Put container B inside container A
3. Open container B
4. Put container A inside container B, causing an immediate stack overflow

Second, they can put items in and out of a container they aren't carrying:
1. Open container A
2. Put container B inside container A
3. Open container B
4. Drop container A
5. Container B's interface remains open, so now the player can put items in it even though they aren't carrying it anymore - effectively letting them teleport items across the dungeon, drink potions they aren't carrying, modify the weight of the container they aren't carrying, all sorts of mayhem.



That said, I think you could prevent these with a careful PartyComponent.onClickItemSlot hook.
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 »

Ah yes, it's definetely not good. :lol:

I found that funny, but it's better if I don't mess with that. Beside this becomes too hard scripting.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply