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!
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Disable the ItemComponent.
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
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Oh yeah - that was a good idea. :idea:
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Echoplex
Posts: 63
Joined: Tue Nov 04, 2014 10:59 pm

Portrait Not Working After Upload

Post by Echoplex »

Hello. I have a script that changes the 1st champion portrait. It works fine in the editor however once I have uploaded the mod to steam workshop it no longer fires off. Everything else in the script works except the portrait change.

Code: Select all

function picture1()
	party.party:getChampion(1):setPortrait("mod_assets/portraits/21_human_female.tga")
	end
Is the location wrong? Format? Again it fires off in the editor but not once uploaded to steam.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Only files that end with .dds, .lua, .model, .animation, .wav, .ogg, or .ivf will be exported. If the actual file in your mod_assets folder ends with .tga instead of .dds, then it won't be exported so it won't work.
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.
Echoplex
Posts: 63
Joined: Tue Nov 04, 2014 10:59 pm

Re: Ask a simple question, get a simple answer

Post by Echoplex »

Min I appreciate the help as always however this one isn't solved yet. So I downloaded paint.net and converted the file to DDS and changed the file path accordingly in the script. It is still not firing off when exported. Works fine in the editor but not export. I tried searching more on the issue and came across a post stating that the .dds file must still be referenced as .tga in the script so I also tried that as well and it didn't work either. So now im back at square one. Thoughts?

Code: Select all

function yysara()
    party.party:getChampion(1):setName("Yysara")
	party.party:getChampion(1):setSex("female")
	party.party:getChampion(1):setPortrait("mod_assets/portraits/21_human_female.tga") --also did .dds  to no avail.
	party.party:getChampion(1):trainSkill("athletics",1,true)
	party.party:getChampion(1):trainSkill("alchemy",1,true)
	party.party:getChampion(1):trainSkill("firearms",1,true)
	party.party:getChampion(1):trainSkill("armors",-1,false)
	party.party:getChampion(1):removeTrait("tough")
	party.party:getChampion(1):removeTrait("agile")
	party.party:getChampion(1):addTrait("weapon_specialization")
	party.party:getChampion(1):setBaseStat("strength",14)
	party.party:getChampion(1):insertItem(4,spawn("tattered_shirt").item)
	party.party:getChampion(1):insertItem(5,spawn("torn_breeches").item)
	party.party:getChampion(2):setEnabled(false)
	party.party:getChampion(3):setEnabled(false)
	party.party:getChampion(4):setEnabled(false)
	end
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

You're being so vague about your problem that I can't really help you...for me, a .dds portrait, named with the .dds extension, and referred to in strings as if it had a .tga extension (like all textures in Grimrock) works fine both in the editor and in the main game after being exported.
Did you save it ending in '.DDS' or '.Dds' or '.dDS' or something? It has to be .dds, lowercase, like I said.
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.
Echoplex
Posts: 63
Joined: Tue Nov 04, 2014 10:59 pm

Re: Ask a simple question, get a simple answer

Post by Echoplex »

I was able to fix the issue by moving the portraits folder from mod_assets/portraits to mod_assets/textures/portraits. Thanks for helping with the dds
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, looking for a quick easy solution....

I have a Skill that reduces the amount of weight of Ammo carried in a champs Offhand
When there is Ammo in 1 hand + a missile weapon in the other hand - the weight reduction bonus will go off
(Reduces weight of carried ammo by Skill Level ... so every level in this Skill effectively lets you carry 10 weightless arrows (weight 0.1), for example)

I would like to know the best simplest method to do this
Ive tried running something like this:
SpoilerShow

Code: Select all

local item1 = champion:getItem(ItemSlot.Weapon)
			local item2 = champion:getItem(ItemSlot.OffHand)
			if item1 and item2 then
				if (item1 and item1:hasTrait("ammo") 
				and item2 and item2:hasTrait("missile_weapon")) then
					local w = item1:getWeight()
					local wT = item1:getTotalWeight()
					print("yes1", w, wT)
					if item2.go.rangedattack:getAmmo() == item1.go.ammoitem:getAmmoType() then
						print("yes2")
						local count = 0
						local w = item1:getWeight()
						local stack = item1:getStackSize()
						local weightT = w * stack
						
						repeat 
							count = count + 1
							
						until (count * w) >= level
						item1:setWeight(wT - (count * w))
						
						print("yes3", w, wT, stack, count)
					end
					
				elseif (item2 and item2:hasTrait("ammo") 
				and item1 and item1:hasTrait("missile_weapon")) then
					local w = item2:getWeight()
					local wT = item2:getTotalWeight()
					print("yes1", w, wT)
					if item1.go.rangedattack:getAmmo() == item2.go.ammoitem:getAmmoType() then
						print("yes2")
						local count = 0
						local w = item2:getWeight()
						local stack = item2:getStackSize()
						local weightT = w * stack
						
						repeat 
							count = count + 1
							
						until (count * w) >= level
						item2:setWeight(wT - (count * w))
						print("yes3", w, wT, stack, count)
					end
				end
			end
through the onRecomputeStats hook for the SKill...

Ive also tried running this:
SpoilerShow

Code: Select all

onEquipItem = function(self, champion, slot)
			---------------------------------------------reduce ammo weight
				if slot == 1 or slot == 2 then
					local stack = self:getStackSize()
					local lvl = champion:getSkillLevel("missile_weapons")
					local w = self:getWeight()
				--local wT = self:getTotalWeight()
					local count = 0
					local sAmmo = slot
					local sBow = 2
					if sAmmo == 2 then
						sBow = 1
					end
					local item1 = champion:getItem(sAmmo)
					local item2 = champion:getItem(sBow)
					if item1 and item1:hasTrait("ammo") and item2 and item2:hasTrait("missile_weapon") then
						if item1.go.ammoitem:getAmmoType() == item2.go.rangedattack:getAmmo() then
							while (count * w) < lvl do
								count = count + 1
							end
							item1:setWeight((stack*w) - (count*w))
							print(stack, w, count, lvl)
						end
					end
				end
			end,
			onUnequipItem = function(self, champion, slot)
				if self:getWeight() == 0 then
					self:setWeight(0.1)
				end
			end,
through the ammo items equip hooks...

No luck, spent too much time on this, Im about to throw my pc out of a window - pls help!
(I know its simple so feel free to laugh all u like) ;)
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

It's not clear to me what you're trying to do. Do you mean that the weight should be reduced by 1 kg for each skill level, or that the weight should be reduced by the weight of 10 ammo items per skill level?
In any case, you are pretty much going to have to check every frame - I suppose onRecomputeStats works as a hack for that, provided you never remove the skill. You need to change the weight of the ammo back to normal after it is fired, picked up (remember that the player can pick up only part of a stack), destroyed, etc. Just retrieving a piece of ammo after it is fired by the party is both non-trivial, and required for this to work. I genuinely cannot think of a way to cleanly implement the skill you are describing; I assure you that if a working solution exists at all, it will require a lot of hacks and easily-breakable assumptions. This is probably the least "simple" question that has ever been asked in this thread.

Considering that this skill would be completely useless, I don't think it's worth the complexity of implementing it. If you really want to have a skill that increases carrying capacity for ammo, why not just have the skill increase carrying capacity, like the Pack Mule trait? It will have the same end result without the complexity.
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 »

Ahh yes - Total Offhand Ammo weight reduced by up to 1 kg per level of (Missile Weapons) Skill
I thought it might be nice touch seemings tonnes of ammo tends to use up the Max Load
(I already have Max Load + 4kg for each level of Athleticism Skill + Pack Mule gives you Immunity to Burdened now)

You do make a compelling argument minmay... its not essential material and it aint worth it the complexity and time :)
Thankyou for replying so quickly!
Akroma
Post Reply