With NutJob's script removed, I built my own. It's a lot lot less versatile than what I've seen of NutJob's, but it serves my needs. Crappy weapons, basic clothing, some food, other miscellaneous items. Because of the dungeon I'm working on, it also gives a shovel to the first 2 champions.
I launch the script via a 0 second timer that starts when the game starts.
Code: Select all
function equipChampions()
if party ~= nil then
for i=1,4 do
if party.party:getChampion(i) ~= nil then
local skill = findPrimarySkill(party.party:getChampion(i))
giveEquipment(party.party:getChampion(i), skill, i)
end
end
end
end
function findPrimarySkill(champ)
local skill_list = { "armors", "missile_weapons", "throwing", "firearms", "light_weapons", "heavy_weapons", "concentration", "alchemy" }
if champ == nil then
--hudPrint("nil champion")
return
end
--local scroll = spawn("scroll",party.level, party.x, party.y, party.elevation, party.facing)
local text = ""
local primary = ""
local maxskill = 0
for _,skill_name in ipairs(skill_list) do
if champ:getSkillLevel(skill_name) == nil then
text = text .. skill_name .. " is nil\r\n"
else
text = text .. skill_name .. " = " .. champ:getSkillLevel(skill_name) .. "\r\n"
end
if champ:getSkillLevel(skill_name) >= maxskill then
primary = skill_name
maxskill = champ:getSkillLevel(skill_name)
end
end
--scroll.scrollitem:setScrollText(text)
--scroll.scrollitem:setTextAlignment("left")
if maxskill == 0 then
return "none"
else
return primary
end
end
function giveEquipment(champ, skill, ord)
--hudPrint(champ:getName() .. " " .. skill)
local inv = {}
local right
local left
local armor = {}
for i=1,32 do
local old
if champ:getItem(i) ~= nil then
old = champ:getItem(i)
champ:removeItemFromSlot(i)
--delayedCall(self.go.id, 0.2, "delayedDestroy", old.go.id);
--old.go:setPosition(1,1,1,1,1)
end
end
if skill == "armors" then
armor[#armor+1] = spawn("leather_brigandine")
armor[#armor+1] = spawn("leather_cuisse")
armor[#armor+1] = spawn("leather_boots")
else
armor = randomClothes()
end
if skill == "missile_weapons" then
right = spawn("sling")
left = spawn("rock")
left.item:setStackSize(5)
inv[#inv+1] = spawn("potion_healing")
elseif skill == "throwing" then
right = spawn("throwing_knife")
right.item:setStackSize(5)
inv[#inv+1] = spawn("potion_healing")
elseif skill == "firearms" then
right = spawn("flintlock")
left = spawn("pellet_box")
left.item:setStackSize(10)
inv[#inv+1] = spawn("potion_healing")
elseif skill == "light_weapons" then
right = spawn("hand_axe")
inv[#inv+1] = spawn("potion_healing")
elseif skill == "heavy_weapons" then
right = spawn("bone_club")
inv[#inv+1] = spawn("potion_healing")
elseif skill == "concentration" then
right = spawn("whitewood_wand")
inv[#inv+1] = spawn("potion_energy")
elseif skill == "alchemy" then
right = spawn("mortar")
left = spawn("torch")
inv[#inv+1] = spawn("blooddrop_cap")
inv[#inv+1] = spawn("etherweed")
else
-- No useful skill
right = spawn("torch")
left = spawn("compass")
inv[#inv+1] = spawn("rope")
end
if ord == 1 or ord == 2 then
if left == nil then
left = spawn("shovel")
else
inv[#inv+1] = spawn("shovel")
end
end
if ord == 3 then
inv[#inv+1] = spawn("sack")
end
if ord == 4 then
if left == nil then
left = spawn("torch")
else
inv[#inv+1] = spawn("torch")
end
end
for _,food in ipairs(randomFood()) do
table.insert(inv, food)
end
-- Armor
for _,item in ipairs(armor) do
local slot = findArmorSlot(item.item)
champ:insertItem(slot, item.item)
end
-- Right hand
if right ~= nil then
champ:insertItem(2, right.item)
end
-- Left hand
if left ~= nil then
champ:insertItem(1, left.item)
end
-- Inventory
for i,item in ipairs(inv) do
champ:insertItem(12+i, item.item)
if item.item:hasTrait("herb") then
item.item:setStackSize(3)
end
end
end
function findArmorSlot(item)
if item:hasTrait("chest_armor") then
return 4
elseif item:hasTrait("cloak") then
return 7
elseif item:hasTrait("helmet") then
return 3
elseif item:hasTrait("necklace") then
return 8
elseif item:hasTrait("gloves") then
return 9
elseif item:hasTrait("boots") then
return 6
elseif item:hasTrait("leg_armor") then
return 5
elseif item:hasTrait("bracers") then
return 10
end
return 13
end
function randomClothes()
local shirt_list = { "tattered_shirt", "tattered_shirt", "peasant_tunic", "xafi_robe" }
local pants_list = { "loincloth", "torn_breeches", "peasant_breeches", "torn_breeches", "peasant_breeches", "xafi_khakis", "silk_hose" }
local shoe_list = { "sandals", "shoes", "sandals", "shoes", "pointy_shoes", "nomad_boots" }
local list = {}
list[#list+1] = spawn(shirt_list[math.random(1, #shirt_list)])
list[#list+1] = spawn(pants_list[math.random(1, #pants_list)])
list[#list+1] = spawn(shoe_list[math.random(1, #shoe_list)])
return list
end
function randomFood()
local food_list = { "rat_swarm_shank", "rat_shank", "rat_jerky", "horned_fruit", "boiled_beetle", "borra", "lizard_stick", "silver_roach", "smoked_bass", "cheese", "fjeld_warg_meat", "baked_maggot", "sausage", "mole_jerky", "pitroot_bread", "turtle_eggs", "bread" }
local list = {}
local nut = 500
while nut > 0 do
local food = spawn(food_list[math.random(1, #food_list)])
list[#list+1] = food
nut = nut - food.usableitem:getNutritionValue()
end
return list
end