Place in a script entity on the map. Alter the character values to suit. You can change the enabled value to 'disable', and enable them later, as the PCs are recruited. For custom portraits, you must ensure the .dds image files are present, and named correctly; using the same naming convention as the the others in the game.
Code: Select all
--Set a Custom Party: version 0.9a
--By Isaac
function setCustomPC()
local function rnd(min,max) if max then return math.random(min,max) else return math.random(min) end end
local characters = {
{--PC #1
enabled = true,
name = "test1",
race = "minotaur",
sex = "male",
class = "farmer",
portrait = "minotaur_male_02",
isCustomPortrait = false,
stats = {strength = rnd(15), dexterity = rnd(15), vitality = 56, willpower = rnd(15)}, --remember to account for racial Stat Bonuses!
traits = {"head_hunter",},
skills = {
alchemy=0, accuracy=1, athletics=3, critical=0,
concentration=0, light_weapons=0, heavy_weapons=2,
missile_weapons=0, throwing=0, firearms=0, armors=2,
earth_magic=0, water_magic=0, fire_magic=0, dodge=0,
air_magic=0,
},
equipped = {
"hand_axe", --Weapon
"", -- OffHand
"peasant_cap", --Head
"leather_brigandine", --Chest
"", --Legs
"", --Feet
"", --Cloak
"", --Necklace
"leather_gloves", --Gloves
"", --Bracers
"fire_bomb", --Weapon2
"", --Offhand2
},
Backpack = {"dagger", "pitroot_bread","dagger", "pitroot_bread","dagger", "pitroot_bread",
"dagger", "pitroot_bread","dagger", "pitroot_bread","dagger", "pitroot_bread",
"dagger", "pitroot_bread","dagger", "pitroot_bread","dagger", "pitroot_bread",
"dagger", "potion_healing",}, -- 20 comma separated items max
},
{--PC #2
enabled = true,
name = "test2",
race = "minotaur",
sex = "male",
class = "fighter",
portrait = "minotaur_male_11",
isCustomPortrait = true,
stats = {strength = 20, dexterity = rnd(6,20), vitality = rnd(15,22), willpower = rnd(20)},
traits = {"head_hunter",},
skills = {
alchemy=0, accuracy=0, athletics=2, critical=1,
concentration=0, light_weapons=2, heavy_weapons=1,
missile_weapons=0, throwing=0, firearms=1, armors=2,
earth_magic=0, water_magic=0, fire_magic=0, dodge=0,
air_magic=0,
},
equipped = {
"dagger", --Weapon
"", -- OffHand
"peasant_cap", --Head
"", --Chest
"", --Legs
"", --Feet
"", --Cloak
"", --Necklace
"", --Gloves
"", --Bracers
"", --Weapon2
"", --Offhand2
},
Backpack = {"dagger", "pitroot_bread", "potion_healing",},-- 20 comma separated items max
},
{--PC #3
enabled = true,
name = "test3",
race = "insectoid",
sex = "female",
class = "rogue",
portrait = "insectoid_female_03",
isCustomPortrait = false,
stats = {strength = rnd(16), dexterity = rnd(6,20), vitality = 16, willpower = rnd(16,20)},
traits = {},
skills = {
alchemy=3, accuracy=3, athletics=0, critical=1,
concentration=4, light_weapons=0, heavy_weapons=0,
missile_weapons=0, throwing=0, firearms=0, armors=2,
earth_magic=0, water_magic=0, fire_magic=0, dodge=1,
air_magic=0,
},
equipped = {
"dagger", --Weapon
"", -- OffHand
"peasant_cap", --Head
"", --Chest
"", --Legs
"", --Feet
"", --Cloak
"", --Necklace
"", --Gloves
"", --Bracers
"", --Weapon2
"", --Offhand2
},
Backpack = {"dagger", "pitroot_bread", "potion_healing",},-- 20 comma separated items max
},
{--PC #4
enabled = true,
name = "test4",
race = "human",
sex = "female",
class = "wizard",
portrait = "human_female_03",
isCustomPortrait = false,
stats = {strength = 20, dexterity = rnd(6,20), vitality = 16, willpower = rnd(15,20)},
traits = {},
skills = {
alchemy=1, accuracy=3, athletics=1, critical=0,
concentration=4, light_weapons=0, heavy_weapons=0,
missile_weapons=0, throwing=0, firearms=0, armors=0,
earth_magic=1, water_magic=0, fire_magic=2, dodge=1,
air_magic=1,
},
equipped = {
"dagger", --Weapon
"", -- OffHand
"peasant_cap", --Head
"", --Chest
"", --Legs
"", --Feet
"", --Cloak
"", --Necklace
"", --Gloves
"", --Bracers
"", --Weapon2
"", --Offhand2
},
Backpack = {"dagger", "pitroot_bread", "potion_healing",},-- 20 comma separated items max
},
}
--**************************************************************************************
local function setEnabledPCs()
for x,PC in pairs(characters) do
local champ = party.party:getChampion(x)
champ:setEnabled(PC["enabled"])
end
end
setEnabledPCs()
local function setSkills(champ, skills)
for k,v in pairs(skills) do
champ:trainSkill(k,champ:getSkillLevel(k)*-1, false)
champ:trainSkill(k,v)
end
champ:upgradeBaseStat("health", champ:getMaxHealth()-champ:getHealth())
champ:upgradeBaseStat("energy", champ:getMaxEnergy()-champ:getEnergy())
champ:setSkillPoints(0)
end
local function setStats(champ, stats)
for k,v in pairs(stats) do
champ:setBaseStat(k,v)
end
end
for pos,PC in pairs(characters) do
local champ = party.party:getChampion(pos)
if champ:getEnabled() then
champ:setRace(PC["race"])
champ:setName(PC["name"])
champ:setSex(PC["sex"])
local filepath = iff(characters[pos]["isCustomPortrait"],"mod_","").."assets/textures/portraits/"..characters[pos]["portrait"]..".tga"
champ:setPortrait(filepath)
champ:setClass(PC["class"])
setStats(champ, PC["stats"])
setSkills(champ, PC["skills"])
if #PC["traits"] > 0 then
for x = 1, #PC["traits"] do
champ:addTrait(characters[pos]["traits"][x])
end
end
for x = 1,12 do
if #PC["equipped"][x] > 0 then
champ:insertItem(x,spawn(PC["equipped"][x]).item)
end
end
if #PC["Backpack"] then
for x = 1, #PC["Backpack"] do
champ:insertItem(x+12,spawn(PC["Backpack"][x]).item)
end
end
end
end
for x=1,5 do hudPrint("") end
delayedCall(self.go.id, .2, "fixHealth")
end
function fixHealth()
for x = 1, 4 do
local champ = party.party:getChampion(x)
if champ:getEnabled() then
champ:setHealth(champ:getMaxHealth())
champ:setEnergy(champ:getMaxEnergy())
end
end
end
delayedCall(self.go.id, .1, "setCustomPC")
It is a really good (and polite) idea to make it very clear in the mod's description, (where the player selects it to play), that you warn them that the mod overwrites a pre-made party; so not to bother making a party of their own.