Hey guys,
I'm wondering if anyone can help me out with deciphering the files for this.
I'm trying to modify the skills in the game (skills.txt, skills.lua) to add a few more things or fix some issues I feel don't make much sense.
Modifying the existing values is pretty easy, but it's another to try to add something that wasn't in the skill to begin with.
I've found that "TheRider" has already done this a bit with his equilibrium mod, so I downloaded that to take a look and to see if I could learn how he did it. Unfortunately, I can't seem to figure out what exactly is going on with the code. I would ask him directly, but he hasn't checked this forum since before Christmas, so I'm not sure if he'd get around to answering.
So far I have found out that he had added a few custom scripts into certain skills that he modified to point to his own functions to add the new abilities (for example, adding "Attack +1" to a skill that didn't have it before.)
Code:
blood_lust {
pos=2,4
deps=dark_force
pic=skillicon1_17_
name=skill_blood_lust_caption
hint_header=skill_blood_lust
hint_text=skill_blood_lust_hint
script=skill_bloodx (Originally script=skill_rush)
I assume that the scripts are being defined in skills.lua where there are functions for various other skills. Looking through it, I find his custom function.
PHP Code:
function skill_bloodx(name,level)
local bonus = skill_power(name,2,level-1)
if level >1 then bonus=bonus-skill_power(name,2,level-2) end
local cur_rage=Logic.hero_lu_item("rage","limit")
Logic.hero_lu_item("rage","limit",cur_rage+bonus)
local bonus2 = skill_power(name,3,level-1)
if level >1 then bonus2=bonus2-skill_power(name,3,level-2) end
local cur_attack=Logic.hero_lu_item("attack","count")
Logic.hero_lu_item("attack","count",cur_attack+bonus2)
return true
end
Comparing to the original function, it looks like he copied the function to retain its original bonuses, but added a second part to deal with the new bonus he added to the skill.
PHP Code:
function skill_rush(name,level)
local bonus = skill_power(name,2,level-1)
if level >1 then bonus=bonus-skill_power(name,2,level-2) end
local cur_rage=Logic.hero_lu_item("rage","limit")
Logic.hero_lu_item("rage","limit",cur_rage+bonus)
return true
end
Unfortunately, this is where I get completely confused, because I have no idea where the "skill_power" function is getting its parameters from, nor what all the various numbers are supposed to mean. They look arbitrary to me, since I can't match them up with any other parameters, and they seem to be the only thing different between the two functions before it calls the value to change.
Looking further up in the skills.lua file, I see that there is a definition for the function skill_power, but its first parameter is 'skillname,' which unfortunately, is simply declared as "name" in the above mentioned functions, which doesn't help me at all in locating which function is attached to which skill/statistic/attribute.
PHP Code:
function skill_power(skillname,param,level)
level = tonumber(level)
if param==nil then param = 1 end
if level == nil then level=Logic.hero_lu_skill(skillname)-1 end
if level<0 then return 0 end
--local skillname=Logic.skill_name()
local par_end=0
local par_string=Logic.skill(skillname,level)
local par=""
if par_string~="" and par_string~=nil then
par_string=string.gsub(par_string, "/", "")
par=text_dec(par_string, param)
if par~="" and par~=nil then
local par_e=string.gsub(par, "%D", "")
par_end=tonumber(par_e)
end
end
return par_end
end
Any help in deciphering this would be greatly appreciated.
Thanks!