Understanding Command Staff and Resolvers
Posted: Mon Feb 26, 2018 3:23 am
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 :
Steam staff code for base and 2 types :
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(),
}