here is some script I created. You can use it as a script_entity, or on a onDie, or whatever.
What it does is that when the action is called, the party members that succeed in a willpower check (custom stuff), willl gain a set random number of Exp.
I am a self taught modder/coder, and this piece of code is certainly improvable, I release it anyways, in the hope that other beginners can learn some stuff from it, or advanced coders can improve it (especially the iteration process of checking all party members).
Feel free to ask if questions.
Code: Select all
local willpower1 = party:getChampion(1):getStat("willpower")
local willpower2 = party:getChampion(2):getStat("willpower")
local willpower3 = party:getChampion(3):getStat("willpower")
local willpower4 = party:getChampion(4):getStat("willpower")
local name1 = party:getChampion(1):getName()
local name2 = party:getChampion(2):getName()
local name3 = party:getChampion(3):getName()
local name4 = party:getChampion(4):getName()
local randomnumber = math.random(25)
local experiencegained = math.random(10,25)
if willpower1 < randomnumber
then
hudPrint(name1.." doesn't learn anything.")
else
hudPrint(name1.." succeeds to understand what is going on and gain "..experiencegained.." XP." )
party:getChampion(1):gainExp(experiencegained)
end
local randomnumber = math.random(25)
local experiencegained = math.random(10,25)
if willpower2 < randomnumber
then
hudPrint(name2.." doesn't learn anything.")
else
hudPrint(name2.." succeeds to understand what is going on and gain "..experiencegained.." XP." )
party:getChampion(2):gainExp(experiencegained)
end
local randomnumber = math.random(25)
local experiencegained = math.random(10,25)
if willpower3 < randomnumber
then
hudPrint(name3.." doesn't learn anything.")
else
hudPrint(name3.." succeeds to understand what is going on and gain "..experiencegained.." XP." )
party:getChampion(3):gainExp(experiencegained)end
local randomnumber = math.random(25)
local experiencegained = math.random(10,25)
if willpower4 < randomnumber
then
hudPrint(name4.." doesn't learn anything.")
else
hudPrint(name4.." succeeds to understand what is going on and gain "..experiencegained.." XP." )
party:getChampion(4):gainExp(experiencegained)
end