Hiring party member(s) script - SOLVED
Hiring party member(s) script - SOLVED
huge thanks to JKos, who invented this wonderful GUI for hiring new members. all credits to him please
download here:
https://github.com/JKos/log2doc/archive/master.zip
with it you can do following:
- define new champions to hire
- define starting items for hired champions
- replace old party members with new champions in case no free slots
download here:
https://github.com/JKos/log2doc/archive/master.zip
with it you can do following:
- define new champions to hire
- define starting items for hired champions
- replace old party members with new champions in case no free slots
Last edited by Drakkan on Thu Mar 05, 2015 10:50 am, edited 3 times in total.
Re: Huge script request - new party member(s)
just up in case somebody have free Saturday evening
- QuintinStone
- Posts: 72
- Joined: Sat Nov 01, 2014 9:58 pm
Re: Huge script request - new party member(s)
Drakkan, I might take a look at this this weekend.
Crypt of Zulfar
Re: Huge script request - new party member(s)
hm... universe would be gratefufull if you check it I alraedy managed to set lots of champion statistics with setting it manualy (like:
and also just simply enabling / disabling party members
party.party:getChampion(4):setEnabled(true)
however the sccript need to work with champion names and also need some other clever checks. And the most important part of course the "swapping" for new party members...
anyway keeping my fingers if you try something !
Code: Select all
party.party:getChampion(4):setPortrait("")
party.party:getChampion(1):setClass("")
party.party:getChampion(1):setName("")
party.party:getChampion(2):setName("")
party.party:getChampion(2):setRace("")
party.party:getChampion(2):removeTrait("")
etc...
party.party:getChampion(4):setEnabled(true)
however the sccript need to work with champion names and also need some other clever checks. And the most important part of course the "swapping" for new party members...
anyway keeping my fingers if you try something !
Re: Huge script request - new party member(s)
Well here is a start so you don't have to begin from scratch:
usage example:
define champion named 'Test Man'
store champion 2
replace champion 2 with 'Test Man'
Feel free to improve and develop it further.
Code: Select all
champions = {}
skills = {
"accuracy","athletics", "armors", "critical", "dodge", "missile_weapons",
"throwing", "firearms", "light_weapons", "heavy_weapons", "concentration", "alchemy",
"fire_magic","earth_magic","water_magic","air_magic"
}
stats = {'strength','dexterity','vitality','willpower'}
conditions = {}
traits = {
"fighter","barbarian","knight","rogue","wizard","battle_mage","alchemist","farmer","human",
"minotaur","lizardman","insectoid","ratling","skilled","fast_learner","head_hunter","rage",
"fast_metabolism","endure_elements","poison_immunity","chitin_armor","quick","mutation","athletic",
"agile","healthy","strong_mind","tough","aura","aggressive","evasive","fire_resistant","cold_resistant",
"poison_resistant","natural_armor","endurance","weapon_specialization","pack_mule","meditation",
"two_handed_mastery","light_armor_proficiency","heavy_armor_proficiency","armor_expert","shield_expert",
"staff_defence","improved_alchemy","bomb_expert","backstab","assassin","firearm_mastery","dual_wield",
"improved_dual_wield","piercing_arrows","double_throw","reach","uncanny_speed","fire_mastery","air_mastery",
"earth_mastery","water_mastery","leadership","nightstalker"
}
function storeChampion(champ)
champions[champ:getName()] ={
baseStats = getBaseStats(champ),
class = champ:getClass(),
dualClass = champ:getDualClass(),
energy = champ:getEnergy(),
evasion = champ:getEvasion(),
experience = champ:getExp(),
food = champ:getFood(),
health = champ:getHealth(),
level = champ:getLevel(),
load = champ:getLoad(),
maxEnergy = champ:getMaxEnergy(),
maxHealth = champ:getMaxHealth(),
maxLoad = champ:getMaxLoad(),
name = champ:getName(),
protection = champ:getProtection(),
race = champ:getRace(),
sex = champ:getSex(),
skillLevels = getSkillLevels(champ),
traits = getTraits(champ),
skillPoints = champ:getSkillPoints()
}
end
function defineChampion(def)
champions[def.name] = def
end
function loadChampion(name,replaceChamp)
local data = champions[name]
setBaseStats(replaceChamp,data.baseStats)
replaceChamp:setRace(data.race)
replaceChamp:setSex(data.sex)
replaceChamp:setClass(data.class)
--replaceChamp:setCondition(name)
--replaceChamp:setConditionValue(name, value)
replaceChamp:setEnergy(data.energy)
replaceChamp:setFood(data.food)
replaceChamp:setHealth(data.health)
replaceChamp:setName(data.name)
if data.portrait then
replaceChamp:setPortrait(data.portrait)
end
local toTargetXp = data.experience - replaceChamp:getExp()
replaceChamp:gainExp(toTargetXp)
setSkillLevels(replaceChamp,data.skillLevels)
replaceChamp:setSkillPoints(data.skillPoints)
setTraits(replaceChamp,data.traits)
end
function getSkillLevels(champ)
local result = {}
for _,skill in ipairs(skills) do
result[skill] = champ:getSkillLevel(skill)
end
return result
end
function setSkillLevels(champ,champSkills)
for _,skill in ipairs(skills) do
local value = champSkills[skill] or 0
local currentLevel = champ:getSkillLevel(skill)
local trainToTarget = value - currentLevel
champ:trainSkill(skill,trainToTarget)
end
end
function getBaseStats(champ)
local result = {}
for _,stat in ipairs(stats) do
result[stat] = champ:getBaseStat(stat)
end
return result
end
function setBaseStats(champ,stats)
for stat,value in pairs(stats) do
champ:setBaseStat(stat,value)
end
end
function getTraits(champ)
local result = {}
for _,trait in ipairs(traits) do
result[trait] = champ:hasTrait(trait)
end
return result
end
function setTraits(champ,champTraits)
for _,trait in ipairs(traits) do
if champTraits[trait] then
champ:addTrait(trait)
else
champ:removeTrait(trait)
end
end
end
define champion named 'Test Man'
store champion 2
replace champion 2 with 'Test Man'
Code: Select all
local champ = {
name = 'Test Man',
race = 'ratling',
class = 'farmer',
sex='male',
portrait='assets/textures/portraits/human_male_02.tga',
experience=6000,
baseStats = {
strength=20,
dexterity=1,
vitality=18,
willpower=1
},
skillLevels = {
accuracy=1,
light_weapons=4
},
energy=110,
food=1000,
health=100,
level=4,
skillPoints=0,
traits={
human=true,
}
}
champions.script.defineChampion(champ) -- define new champion
champions.script.storeChampion(party.party:getChampion(2)) --store champion 2
champions.script.loadChampion('Test Man',party.party:getChampion(2)) -- replace champion 2 with ''Test Man'
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
- QuintinStone
- Posts: 72
- Joined: Sat Nov 01, 2014 9:58 pm
Re: Huge script request - new party member(s)
thats really nice, hope QuintinStone will be able to extend it a little
- Mysterious
- Posts: 226
- Joined: Wed Nov 06, 2013 8:31 am
Re: Huge script request - new party member(s)
Hi Jkos I was wondering if you could supply a demo dungeon on how your script works it look so awesome, but my script understanding is limited so thxs in advance
EDIT: I sort of understand how the script works and can see how to create additional Champs for slot 2, but how do I activate the champ in the game eg: A monster that you click on becomes champ 2? I don't know how to get the new champ to activate and help please I really want to use this and I hope it comes with a GUI interface soon thxs Jkos
EDIT: I sort of understand how the script works and can see how to create additional Champs for slot 2, but how do I activate the champ in the game eg: A monster that you click on becomes champ 2? I don't know how to get the new champ to activate and help please I really want to use this and I hope it comes with a GUI interface soon thxs Jkos
- Mysterious
- Posts: 226
- Joined: Wed Nov 06, 2013 8:31 am
Re: Huge script request - new party member(s)
Sorry guys: Bump up.
Re: Huge script request - new party member(s)
create two scripts - first script name will be -- champions -- and copy inside whole first code. then copy second code (where you define new champion) inside second script (no particular name required).Mysterious wrote:Hi Jkos I was wondering if you could supply a demo dungeon on how your script works it look so awesome, but my script understanding is limited so thxs in advance
EDIT: I sort of understand how the script works and can see how to create additional Champs for slot 2, but how do I activate the champ in the game eg: A monster that you click on becomes champ 2? I don't know how to get the new champ to activate and help please I really want to use this and I hope it comes with a GUI interface soon thxs Jkos
when you start the game in the editor, chosen default champion will be automatically replaced with defined champion. As I was making some tries, I found out that if you make some changes inside scripts, just reloading the dungeon does not help, you need to exit and start editor again.