CameronC's items/scripts (NEW: the socketSystem)
Posted: Sun Dec 07, 2014 9:10 am

---------- Ascension Item Pack ------------------------------
Github: https://github.com/camcallahan/general- ... nsion_pack
This is a small collection of items that I hope will give people some ideas on the types of unique weapons and armor that this game engine can create with mix and matching its components around. This consists of two parts.
A Party definition with some specific code in each of the party hooks. Basically, the new Party definition, whenever any of the PartyComponent hooks are ran, scan the champions equipped items (Or the entire parties equipped items, depending on the hook) and
looks for a specifically named component. This component is a script component with a function in it. The function is ran. This lets you isolate and contain items that would otherwise have abilities you would have to check for in the party definition itself. I think it's much cleaner this way, and I seemingly have it working pretty well so far (Though I haven't tested EVERY trigger yet, and I don't think an item can return false to cancel anything YET...). The best, probably, example of this is to give armor an effect that triggers onDamage or onReceiveCondition, but it is pretty useful, I think. Now, if only I can get delayedCall to trigger a Script component on a weapon or armor, things get could really cool...
The second part is the items themselves. There are only 7 right now and they were hardly balanced with anything in mind. I just wanted to create a few interesting items, some stuff with more than just raw stat bonuses as the only way to define an item (I like the concept of items that evolve over time, that change as you use them, myself -- maybe a set of weapons that 'level up' will be next). I've got some descriptions/comment in the lua files themselves, which I'll put in the CODE tags below, and links to the actual files and an album of random screenshots taken during testing at the bottom of the post.
PSA: Due to the items having embedded scripts, if you are editing the triggerOn_____ scripts for items if you save the items lua file and restart the editor, any items in the editor will have the old scripts, so just delete and re-place the item while you are testing any embedded scripts in items.
-- Summary of Items.
Code: Select all
The Collector - A sword with a secondaryAction spell that adds charges as it deals damage to enemies.
Ceremonial Daggers - A pair of Daggers with a secondary function that requires both daggers to be equipped. Each dagger reduces the EnergyRegenerationRate but also give the champion energy when they hit a monster.
Charm of the Thief - A necklace that glows when near a trap. By default, it detects mimic chests and checks for an istrap Counter component to check for arbitrary trapped entities.
Cloak of Phasing - Cloak that has a chance to adds a temporary boon to the entire part on damage.
Heavy Shield of Bashing - Shield with meleeattack and secondaryaction components.
Travelers Cloak - Cloak that counts the steps taken while worn and adds stat bonuses the longer it is equipped.
Simple Backpack - Equippable conatineritem that grants an increase in the weight the champion can carry when equipped.
Staff of Energy Shield - Staff with secondaryaction that casts a shield on the champion that redirects all damage to his Energy pool instead. Recasting removes the effect and his energy dropping to 0 also removes the effect. If it blocks a particularly strong attack the shield has a chance to shatter as well.
Gift from Elsewhere - A bag that onInit runs a script to populate itself with various potions.
The socketSystem is a simple setup that lets champions discover magical gems that can be inserted into sockets on their equipment and modify their attributes.
The basics: There is a base_object that the gems are based off of with an onUseItem hook that checks if the gem is in a champions hand and, if it is, what item is in the champions other hand. That item is then passed to a Script component inside the gem item. The script then, depending on the purpose of the gem, modifies the item being held (Or maybe it doesn't, because the champion is holding a sword and this gem only modifies shields, for example).
The system is now entirely item based and self contained. There is no massive gem check function in your dungeon.
You import the base item file and then, after that, import any gem files you want included.
If someone else ever makes a set of socketable gems, you simple put their definition file in your scripts folder and import it. Very simple.
Below is a more in depth write up on what it currently does now and a description of the 64 gems included in this current release.
Most Recent Code:
Mediafire zip: http://www.mediafire.com/download/c2vxz ... 1-4-15.zip
Github link: https://github.com/camcallahan/log2-socketSystem
Installation instructions:
SpoilerShow
1. Get the newest code from above.
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:
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:
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"
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,
},
Code: Select all
general-log2-assets/socketSystem
===================
A D2-style weapon/armor system that allows for gems to be placed into sockets on items to alter their abilities.
The init.lua has an onPickUpItem hook that will
add the required component to allow them to be modified. This can easily be changed to only alter items
some percentage of the time instead of always.
The gem models and GfxIndex icons are from LordYig's gem/alcove pack for Grimrock 1. I converted the gem
definition to be usable in Grimrock 2 and those models/icons/descriptions/names are used as a base for
a lot of the gems in here. I have not gone through and converted any of the alcoves in his pack.
LordYig's Grimrock 1 pack can be found on NexusMods: http://www.nexusmods.com/grimrock/mods/177/
The converted gem definitions are included and imported in this if you want to use those as is or
modify them into more socket gems. Filtering in the editor for itm_ should bring up all of the gems.
The order of the import lines in init.lua is important.
The socketBaseItems.lua MUST come first, as it has an item in there that others use as a base_object.
The other import lines bring in the gems by "type". There are a few types included so far.
The system works by having a base_object all the gems are based on that has an onUseItem hook that does
the various checks to determine if the gem can be used, what item is it being used on, etc. Then, the
onUseItem function calls a Script component within the gem (passing it some information on the item
the gem will be used on) and that function is what actually alters the items. This means, chiefly, there
is no gigantic script entity to place in your dungeon anywhere. It also means that if you want to change
the behaviour of a gem you go to the object definition of the gem and that has every piece of information
you need in one place to change or troubleshoot it. It also lets the gems be separated out across different
files. If you don't want the Skull gems then just comment out that one import line and they won't show up in
the editor and there won't be any code anywhere relating to them. It also means that if someone one makes a
set of gems, as long as you import the base item file you don't have to do anything other than import their
gem file. Super simple, super easy.
Look at the base item and included gems on how to create your own. Basically, all the GEM needs is a Script
component named "triggers" and a function named "insertGem" that accepts the variable itemToEnchant.
Whatever you put in that script will be ran when the gem is right clicked in a champion ahnd while holding
another item. Return true and the gem will be used, return false and it will remain.
Current gems available:
A base set of ELEMENT gems that increase stats/provide resistances. These have a specific effect depending
what type of item they are socketed in. Weapons gain attack power and elemental damage. Shields gain
resistances. Armor gain minor and major stat bonuses.
The SKULL gems switch and change the lower-level properties of an item, like baseDamageStat and
skill requirements. There is a skull for each of the four major stats that will change the stat
used to scale damage up (So maybe a new found hammer can be wielded fiercely by a willpower mage, for
instance). There are also gems to converted heavy_armor requirements to light_armor, and other similar
effects.
The PASSIVE gems are similar to the ELEMENT gems but with less restrictions. They increase stats by a
more limited amount but can be inserted into any type of item with slots. So, while a high level SAPPHIRE
will only provide willpower when put into a chest_armor, one of these willpower gems will give you the
bonus even when put into a shield or weapon. These mostly provide stat bonuses, but there are a few other
things that they can alter as well.
ABILITY gems provide secondary actions. Currently, there is only a small pool of them. There is one for the
base Bolt-type spells for weapons and ones that provide shields with the elemental shield-type spells. There
is also one that provides the ability MUG to a dagger. This allows a champion with a dagger to shake down the
enemy and has a small chance to drop items for the party.
To manually create an item with the ability to accept gems, the weapon/armor requires two components:
- A Counter component named "sockets", set to the max amount of gems the item can accept.
- A Counter component named "gemcount", initially set to the same value as "sockets". This is decreased
when enchanting an item and prevents gems from being used when at 0.
Currently shields, chest pieces, and non-RunePanel weapons can be enchanted. Shields are given 1-2 slots,
chest pieces are given 2-4, and weapons are given 1-2 slot each (Except weapons with the "two_handed" trait
are given 2-4 slots).
To modify an item, place one of the gems into a champion's hand along with the item to enchant in the
other hand. Right-click the gem to enchant the other item being held. The gem will vanish and print out
the effect of the gem.
If the other item being held does not have the correct components to be enchanted then it will print out
that fact and the gem will remain in the champion's hand. Similarly, if the item has no more free sockets
then the gem will have no effect and remain in hand.
To-do/Fixes needed:
- Find a better way to display the amount of free sockets in items. Currently, an item with a gameEffect
will have it erased and replaced with the free socket count. Perhaps a simple gameEffect/description
manager needs to be implemented so that -lines- of information can be retrieved/modified without hurting
other lines of information in the strings.
- secondaryAction spells have charges that DO work, but are not displayed when hovered over the item. Unsure
what is causing this.
- Determine if it is possible to script a sort of setPowerAttackTemplate to dynamically add the predefined
power attacks to weapons... or at least reverse-engineer some of the more interesting ones to use.
NOTE: The gems currently have another Counter component in them named "treasureclass" that is unrelated to
the socketSystem.