CameronC's items/scripts (NEW: the socketSystem)

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!
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: CameronC's items/scripts (NEW: the socketSystem)

Post by cameronC »

Woopsies, I moved it to its own repo and didn't update some links. https://github.com/camcallahan/log2-socketSystem

That is the most recent version, minus the multiple gameffect bug fixed above. When I'm back home I'll go through and update everything.
User avatar
melierax
Posts: 29
Joined: Sat Oct 27, 2012 2:08 am
Location: Quebec, Canada

Re: CameronC's items/scripts (NEW: the socketSystem)

Post by melierax »

Hello again :)
I see you've made changes to your site but I'm missing it's two files that are not there (socketSystem.lua and socketItems.lua). ;)
Could you put on the forum.
Thanks :D
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: CameronC's items/scripts (NEW: the socketSystem)

Post by cameronC »

melierax wrote:Hello again :)
I see you've made changes to your site but I'm missing it's two files that are not there (socketSystem.lua and socketItems.lua). ;)
Could you put on the forum.
Thanks :D
Those two files are no longer needed so that is why they are not included anymore. Here is how you install socketSystem:

1. Get the newest code:
If you have LordYigs models/gfxIndex stuff already you can copy/paste the individual scripts from github: https://github.com/camcallahan/log2-soc ... er/scripts
OR download the zip from github: https://github.com/camcallahan/log2-soc ... master.zip
OR download the zip from MediaFire link: http://www.mediafire.com/download/c2vxz ... 1-4-15.zip
(I've made some minor changes to some of the gems, mostly standardizing how the ability gems create components and removing blank lines added to gem descriptions)

2. Copy the main folders into your mod_assets folder for the dungeon (Do NOT overwrite init.lua, as you will want to just add these import lines to your file instead of losing anything you've added to yours).

The import lines that go into your init.lua are these:

Code: Select all

-- Cameron Callahan's SocketSystem Base Items
import "mod_assets/scripts/socketSystem/socketBaseItems.lua"
--[[ LordYig's Gem Collection for LOG1 (definitions for GEMS converted by Cameron for LOG2)
Alcoves in this pack have not been converted for use. Download LordYig's 
original LOG1 asset pack here: http://www.nexusmods.com/grimrock/mods/177/
--]]
import "mod_assets/scripts/socketSystem/alcoves_and_gems_collection.lua"
-- Cameron Callahan's SocketSystem Gem Sets
import "mod_assets/scripts/socketSystem/socketElementGems.lua"
import "mod_assets/scripts/socketSystem/socketAbilityGems.lua"
import "mod_assets/scripts/socketSystem/socketPassiveGems.lua"
import "mod_assets/scripts/socketSystem/socketSkullGems.lua"
socketBaseItems.lua MUST be imported before the socketSystem gem set files, as they all grab some base code from items in that first file.

Optionally, if you want to have any item have sockets added to it when you pick it up, you can add this onPickUpItem hook to your party definition in init.lua:

Code: Select all

onPickUpItem = function(self, item)
		-- General Triggers Below (Skill/Trait triggers, etc)
			local theGameEffect = item.go.item:getGameEffect()
			local beforeGE = ""
			if theGameEffect ~= nil then beforeGE = "\n" end
			if theGameEffect == nil then theGameEffect = "" end
			beforeGE = theGameEffect .. beforeGE
			if item.go.item:hasTrait("shield") and not item.go:getComponent("sockets") then
				local shieldSockets = math.random(1, 2)
				item.go:createComponent("Counter", "sockets")
				item.go.sockets:setValue(shieldSockets)
				item.go:createComponent("Counter", "gemcount")
				item.go.gemcount:setValue(shieldSockets)
				item.go.item:setGameEffect(beforeGE.."- Free Sockets ("..tostring(item.go.gemcount:getValue()).."/"..tostring(item.go.sockets:getValue())..").")
			elseif item.go.item:hasTrait("chest_armor") and not item.go:getComponent("sockets") then
				local chestSockets = math.random(2, 4)
				item.go:createComponent("Counter", "sockets")
				item.go.sockets:setValue(chestSockets)
				item.go:createComponent("Counter", "gemcount")
				item.go.gemcount:setValue(chestSockets)
				item.go.item:setGameEffect(beforeGE.."- Free Sockets ("..tostring(item.go.gemcount:getValue()).."/"..tostring(item.go.sockets:getValue())..").") 
			elseif (item.go:getComponent("meleeattack") or item.go:getComponent("rangedattack") or item.go:getComponent("firearmattack")) and not item.go:getComponent("sockets") then
				if item.go.item:hasTrait("two_handed") then
					local weaponSockets = math.random(2, 4)
					item.go:createComponent("Counter", "sockets")
					item.go.sockets:setValue(weaponSockets)
					item.go:createComponent("Counter", "gemcount")
					item.go.gemcount:setValue(weaponSockets)
					item.go.item:setGameEffect(beforeGE.."- Free Sockets ("..tostring(item.go.gemcount:getValue()).."/"..tostring(item.go.sockets:getValue())..").")
				else
					local weaponSockets = math.random(1, 2)
					item.go:createComponent("Counter", "sockets")
					item.go.sockets:setValue(weaponSockets)
					item.go:createComponent("Counter", "gemcount")
					item.go.gemcount:setValue(weaponSockets)
					item.go.item:setGameEffect(beforeGE.."- Free Sockets ("..tostring(item.go.gemcount:getValue()).."/"..tostring(item.go.sockets:getValue())..").")
				end
			end
			return
		end,
		},
socketSystem.lua is no longer needed because that function is now built in to the gem items themselves. Instead of a single, large script entity that modifies the items based on the gem used that code is now stored in the gems themselves via a Script component. This means that as long as you import that socketBaseItems file, you can very easily add or remove gems from your dungeons and gem sets can be created and shared super easily.

the SocketItems.lua file is now split up into the multiple gem files imported after that base file and lordyigs models (the ELEMENT, PASSIVE, ABILITY, SKULL files). Splitting them up was just for convenience. I hope this is enough to get this working for you.
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.

Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
User avatar
melierax
Posts: 29
Joined: Sat Oct 27, 2012 2:08 am
Location: Quebec, Canada

Re: CameronC's items/scripts (NEW: the socketSystem)

Post by melierax »

Thank you very much :D
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: CameronC's items/scripts (NEW: the socketSystem)

Post by Pompidom »

Is there a LoG 2 mod out there that actually uses this socket system?
Post Reply