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

Re: Ask a simple question, get a simple answer

Post by Isaac »

So... Auto use on equip?
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 »

I have a merchant who sells food. I gave two options; eat "on the spot" or "take away". If I can not use an item in the script, then I will have to remove the "on the spot" option, has it won't work for racial bonus food if I do not spawn an actual item and use it. So, is it possible ?
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

You make something with the onEquipItem hook [spawn item, and assign it (addConnector) a hooked function in a script entity, then add it to the Champion's inventory]; and use the equipmentItem component to manually check info and cause the desired effects.

*Speculation.
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 »

In this situation, the desired effects are : update the food level of the champion (done, it works), execute the onUseItem function if it exists (done, it works / example : rotten_pitroot_bread has 50% chance to cause the diseased condition), AND then there is also the racial bonus effects but I have zero control over this part. It seems to be hard-coded. I mean the bonus stats a champion can get when a ratling eats cheese, a lizardman eats turtle eggs or an insectoid eats horned fruits. I have no idea how to do the same thing without the item being actually used manually by the player!
User avatar
Duncan1246
Posts: 404
Joined: Mon Jan 19, 2015 7:42 pm

Re: Ask a simple question, get a simple answer

Post by Duncan1246 »

In my mod, I have some levels with several elevation. So I think that the automap isn't easy to read. I wonder if it is possible to script something to split the automap by elevation?
The Blue Monastery (LOG1)
download at:http://www.nexusmods.com/grimrock/mods/399/?

Finisterrae(LOG2)
download at:http://www.nexusmods.com/legendofgrimrock2/mods/61/?
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

AndakRainor wrote: I mean the bonus stats a champion can get when a ratling eats cheese, a lizardman eats turtle eggs or an insectoid eats horned fruits. I have no idea how to do the same thing without the item being actually used manually by the player!
I don't know what all of those bonuses are offhand, but you can change the PC quite a bit with the champion functions, as far as stats go.

*Have you considered spawning the item onto the mouse? The player has to do something with it, they will probably use it. Might very likely swap it for a weapon and use it; then return the weapon.
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 »

Hello! I would like to read the resistAll value from an EquipmentItemComponent in a script. It seems it has no get or set function ? I can't access it as I do for example with EquipmentItemComponent:getResistFire(). Also how does this stat work ? Is it additive with for example resist fire ? From the values returned by getResistFire() it seems completly disconnected.

If I don't find a solution I will have no choice but to remove this stat from all items definitions and replace it with readable elemental resistances.

Here is an example of an object with this stat:

Code: Select all

defineObject{
	name = "mirror_chestplate",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/mirror_armor_chestplate.fbx",
		},
		{
			class = "Item",
			uiName = "Mirror Chestplate",
			description = "Light reflected off the polished metal discs on this chest plate shimmers and dances around in a strange fashion.",
			armorSet = "mirror",
			armorSetPieces = 5,
			gfxIndex = 239,
			weight = 8.0,
			traits = { "light_armor", "chest_armor" },
		},
		{
			class = "EquipmentItem",
			protection = 8,
			resistAll = 5,
		},
	},
}
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

AndakRainor wrote:Hello! I would like to read the resistAll value from an EquipmentItemComponent in a script. It seems it has no get or set function ? I can't access it as I do for example with EquipmentItemComponent:getResistFire(). Also how does this stat work ? Is it additive with for example resist fire ? From the values returned by getResistFire() it seems completly disconnected.
I've not tried this, or looked into it yet, but what stops anyone from just reading all the resistances separately? Couldn't one even write a function in their script that returns all the resistance values for a given PC?
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 »

Yes the resistances of the champion are correctly modified by the resistAll stat. But as in this script I inspect the values of a given item, I don't think I should swap equipped items to look at champion's stats and try to get a value for resistAll this way. It would be better to directly get this value from the item itself (EquipmentItemComponent).
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

AndakRainor wrote:Yes the resistances of the champion are correctly modified by the resistAll stat. But as in this script I inspect the values of a given item, I don't think I should swap equipped items to look at champion's stats and try to get a value for resistAll this way. It would be better to directly get this value from the item itself (EquipmentItemComponent).
Ah... there is my answer. 8-)

** However... if it all happened mid-frame, I don't believe it would be noticeable to the player.

I'm interested in the solution to this, because I'll probably be doing this myself soon.
Post Reply