Understanding Command Staff and Resolvers

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Nevuk
Thalore
Posts: 189
Joined: Thu Jul 27, 2006 2:50 am

Understanding Command Staff and Resolvers

#1 Post by Nevuk »

So I added a new type of staff to the game for one of my modules, a steam staff. The basic idea was to have it be a physical only type staff that had no access to channel staff but had cun modifier to offset that. I was able to make them and get them working, but somehow every staff wound up being physical at some point and I'm not sure when. I added a new superloading function to check for if a steamstaff/staff was equipped, but disabling that (and even disabling the steam staves) doesn't seem to make a difference.
So I traced back some more and decided to try adding elements to steam staves the same way as normal staves, to see if it would explain it. Then things got a little weird.

When I set the base staff to have the resolver.staff_element() function it would crash the game when attempting to load. I found the error report, but set it onto the second staff in the tree so I could experiment without crashing. Going to the resolver line where it throws the error talks about trying to get weight, and the pre init does reference a t value.

The error :

Code: Select all

error = "Lua Error: /loader/pre-init.lua:74: attempt to get length of local 't' (a nil value)\
  At [C]:-1 __len\
  At /loader/pre-init.lua:74 table\
  At /mod/resolvers.lua:971 \
  At /engine/Entity.lua:744 resolve\
  At /engine/Object.lua:44 resolve\
  At /engine/Zone.lua:574 finishEntity\
  At /mod/dialogs/debug/CreateItem.lua:82 fct\
  At /engine/ui/Dialog.lua:154 fct\
  At /engine/ui/Button.lua:63 fct\
  At /engine/Mouse.lua:58 receiveMouse\
  At /engine/Mouse.lua:98 delegate\
  At /engine/ui/Dialog.lua:765 mouseEvent\
  At /engine/ui/Dialog.lua:485 fct\
  At /engine/Mouse.lua:58 "
seen = true
reported = false


Steam staff code for base and 2 types :

Code: Select all

local Stats = require "engine.interface.ActorStats"
local Talents = require "engine.interface.ActorTalents"
local DamageType = require "engine.DamageType"

newEntity{
	define_as = "BASE_STEAMSTAFF",
	flavor_names = {"steamstaff", "steamingstaff", "steamerstaff", "meltingstaff"},
	slot = "MAINHAND",
	slot_forbid = "OFFHAND",
	type = "weapon", subtype="steamstaff",
	power_source = {steam=true, arcane=true},
	twohanded = true,
	add_name = " (#COMBAT_ELEMENT#)",
	display = "\\", color=colors.SLATE, image = "object/quarterstaff.png",
	moddable_tile = "right_hand_08",
	moddable_tile_big = true,
	randart_able = "/data/general/objects/random-artifacts/melee.lua",
	encumber = 5,
	rarity = 4,
	metallic = true,
	combat = {
		talented = "staff",
		physspeed = 1,
		damrange = 1.2,
		sound = {"actions/melee", pitch=0.6, vol=1.2}, sound_miss = {"actions/melee", pitch=0.6, vol=1.2},
	},
	command_staff = {inc_damage = 1,},
	desc = [[Steam staves are designed for those who wish to weld magic and steam. There are miniature machines embedded in them. They sacrifice the ability to change the damage type for mechanically and mystically enhanceable damage]],
	egos = "/data/general/objects/egos/staves.lua", egos_chance = { prefix=resolvers.mbonus(40, 5), suffix=resolvers.mbonus(40, 5) },
}

newEntity{ base = "BASE_STEAMSTAFF",
	name = "iron steamstaff", short_name = "iron",
	level_range = {1, 10},
	require = { stat = { mag=11,cun=11}, },
	cost = 5,
	material_level = 1,
	combat = {
		dam = 10,
		apr = 2,
		physcrit = 2.5,
		dammod = {mag=0.8,cun=0.8},
	},
	wielder = {
		combat_atk = 3,
		combat_steampower=3,
		combat_spellpower = 3,
		combat_spellcrit = 1,
	},
	
}
newEntity{ base = "BASE_STEAMSTAFF",
	name = "steel steamstaff", short_name = "steel",
	level_range = {10, 20},
	require = { stat = { mag=16, cun=16},},
	cost = 10,
	material_level = 3,
	combat = {
		dam = 15,
		apr = 3,
		physcrit = 3,
		dammod = {mag=0.8,cun=0.8},
	},
	wielder = {
		combat_atk = 6,
		combat_steampower=6,
		combat_spellpower = 6,
		combat_spellcrit = 2,
	},
	resolvers.staff_element(),
}

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Understanding Command Staff and Resolvers

#2 Post by HousePet »

Did you edit the staff_element resolver at all?
My feedback meter decays into coding. Give me feedback and I make mods.

Nevuk
Thalore
Posts: 189
Joined: Thu Jul 27, 2006 2:50 am

Re: Understanding Command Staff and Resolvers

#3 Post by Nevuk »

HousePet wrote:Did you edit the staff_element resolver at all?
Nope. Didn't touch resolvers in the slightest. Tried overloading with just a copy of the original resolvers file from tome4, that threw up even more errors. I've also tried reinstalling tome in case there was a corrupted file or something, but command staff works fine in different mods or with this one disabled.

Here's the section from resolver throwing an error (960-973)

Code: Select all

		local function get_weight(wt)
			local val = 0
			if type(wt) == "function" then
				wt = wt(e, tal, e) -- try to target self for effectiveness
			end
			if type(wt) == "number" then return wt
			elseif type(wt) == "table" then
				for _, n in pairs(wt) do
					val = math.max(val, get_weight(n))
				end
				if val == 0 then val = 2 end
			end
			return tonumber(val) or 0
		end
This is a smaller part of a larger function (927- 1088)

Code: Select all

function resolvers.calc.talented_ai_tactic(t, e)
btw, if you just create an alchemist in the mod the staves will still have command staff... but the dialogue doesn't offer any choices after you select mage/vile/etc.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Understanding Command Staff and Resolvers

#4 Post by HousePet »

I might have to disassemble your mod to work out where it went wrong.

I might have time tomorrow.
My feedback meter decays into coding. Give me feedback and I make mods.

Nevuk
Thalore
Posts: 189
Joined: Thu Jul 27, 2006 2:50 am

Re: Understanding Command Staff and Resolvers

#5 Post by Nevuk »

HousePet wrote:I might have to disassemble your mod to work out where it went wrong.

I might have time tomorrow.
Would be appreciated, as I've puzzled this over for a couple weeks and still really have no idea what's going on. Especially since a lot of the parts that I would think affect it most are also in the other, non EoR version, which doesn't have this issue.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Understanding Command Staff and Resolvers

#6 Post by HousePet »

I've located the exact line that causes the problem, but it makes no sense to me at all.

load.lua: line 9.

local PartyTinker = require 'mod.class.interface.PartyTinker'

I think you will need DarkGod to solve this one.
My feedback meter decays into coding. Give me feedback and I make mods.

Nevuk
Thalore
Posts: 189
Joined: Thu Jul 27, 2006 2:50 am

Re: Understanding Command Staff and Resolvers

#7 Post by Nevuk »

HousePet wrote:I've located the exact line that causes the problem, but it makes no sense to me at all.

load.lua: line 9.

local PartyTinker = require 'mod.class.interface.PartyTinker'

I think you will need DarkGod to solve this one.
That's ... huh. It does line up, that it happened around when I added a version of mana coil that could attach to steam coil. I was trying to superload mana coil to get it to attach to steamstaves, but it wound up being easier to just create a new version. It's honestly not even a big deal to just take it out, it only leaves them without an amazing tinker for their weapon, and instead merely some alright ones, until I get to the point of being able to superload the function (I tried to copy the behavior from the attach weapon tinkers to brawler gloves mod, but it's not quite a 1:1 case).

I'd actually tried taking out the portions that loaded the steam coil, but I never took out the local partytinker line because it never crossed my mind that it could be a problem.

I'd just rewritten steam staves to be a totally different category of weapon mastery from staves in case that would solve the problem lol, but it may make thematic sense to have the two staves use separate categories anyways. Not sure. Huge thanks for finding it

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Understanding Command Staff and Resolvers

#8 Post by HousePet »

After conferring with DarkGod and checking the Orcs DLC code, I've found a resolution.

Delete line 9: local PartyTinker = require 'mod.class.interface.PartyTinker'

Put local PartyTinker = require "mod.class.interface.PartyTinker" just before PartyTinker:loadDefinition('/data-steamchemist/tinkers.lua')
My feedback meter decays into coding. Give me feedback and I make mods.

Post Reply