PDA

View Full Version : Dice modification



Maspalio
December 17th, 2014, 11:54
Hello,

I am currently working on a ruleset adaptation. The basis is the Exalted 2.5 Ruleset.
I am a graphic designer for like 20 years, but my developers skills are low. Though i understand the way xml and lua works, i can't write programs by myself. At this point, i've already made all the graphic changes i wanted in xml files, and it works fine. Now, i need to change the dice behavior, and i'm standing in front of a 30 meters wall...

What i am trying to do : twink the way the botch and failure systems works. I would like to get that when you got a 1, it cancels a success. Got plenty examples with WOD or Exalted. But when you got 1's and no success either, then this leads to a Botch.

All i need really is someone who could throw an eye at the Exalted files, 'cause i think it's pretty close as the way it currently works.

The thing is i don't know how to implement or code that...

I'd be glad to help with graphic skills in return.

Cheers,

Maspalio

PS : sorry for my spelling, i'm from the old land, just like the fries.

Maspalio
December 17th, 2014, 23:21
Well, if someone could have a look, i'm pretty sur that all i need lies in this code. Thanks by advance.


function scriptRoll(draginfo)
for i = 1, draginfo.getSlotCount() do
draginfo.setSlot(i);
dicelist = draginfo.getDieList() or {};

for i = 1,#(initialRoll or {}) do
table.insert(dicelist, initialRoll[i]);
end

local tmp = {};
for i = negativemod + 1,#dicelist do
table.insert(tmp, dicelist[i]);
end
dicelist = tmp;

local entry = {};
entry.font = "systemfont";
entry.icon = "indicator_casterprep";

if dicelist and #dicelist > 0 then
local dicecount = table.maxn(dicelist);
local successes = 0;
local tens = {};
local nines = {};
local eights = {};
local sevens = {};
local sixes = {};
local fives = {};
local fours = {};
local threes = {};
local twos = {};
local ones = {};

local reform = {};
local tensDouble = not Input.isShiftPressed();
local target = ModifierStack2.getValue();

for c = 1, dicecount do
if dicelist[c].result == 10 then
if tensDouble then
successes = successes + 2;
else
successes = successes + 1;
end
table.insert(tens, c);
elseif dicelist[c].result == 9 then
successes = successes + 1;
table.insert(nines, c);
elseif dicelist[c].result == 8 then
if target <= 8 then
successes = successes + 1;
end
table.insert(eights,c);
elseif dicelist[c].result == 7 then
if target <= 7 then
successes = successes + 1;
end
table.insert(sevens, c);
elseif dicelist[c].result == 6 then
if target <= 6 then
successes = successes + 1;
end
table.insert(sixes, c);
elseif dicelist[c].result == 5 then
if target <= 5 then
successes = successes + 1;
end
table.insert(fives, c);
elseif dicelist[c].result == 4 then
if target == 4 then
successes = successes + 1;
end
table.insert(fours, c);
elseif dicelist[c].result == 3 then
table.insert(threes, c);
elseif dicelist[c].result == 2 then
table.insert(twos, c);
elseif dicelist[c].result == 1 then
table.insert(ones, c);
end
end

for c = 1, table.maxn(tens) do
table.insert(reform,dicelist[tens[c]]);
end
for c = 1, table.maxn(nines) do
table.insert(reform,dicelist[nines[c]]);
end
for c = 1, table.maxn(eights) do
table.insert(reform,dicelist[eights[c]]);
end
for c = 1, table.maxn(sevens) do
table.insert(reform,dicelist[sevens[c]]);
end
for c = 1, table.maxn(sixes) do
table.insert(reform,dicelist[sixes[c]]);
end
for c = 1, table.maxn(fives) do
table.insert(reform,dicelist[fives[c]]);
end
for c = 1, table.maxn(fours) do
table.insert(reform,dicelist[fours[c]]);
end
for c = 1, table.maxn(threes) do
table.insert(reform,dicelist[threes[c]]);
end
for c = 1, table.maxn(twos) do
table.insert(reform,dicelist[twos[c]]);
end
for c = 1, table.maxn(ones) do
table.insert(reform,dicelist[ones[c]]);
end

if successes > 0 then
entry.text = "Success: " .. successes;
else
if table.maxn(ones) > 0 and tensDouble then -- Botch; can't botch damage
entry.text = "BOTCH: "..table.maxn(ones);
else -- Simple fail
entry.text = "Failed";
end
end

if not tensDouble then
entry.text = "[Damage] " .. entry.text;
end

entry.text = entry.text .. " (target: " .. target .. ")";

entry.dice = reform;

if User.isHost() then
if ChatManager.getDieRevealFlag() then
entry.dicesecret = false;
end
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end
else
entry.text = "No dice left to roll.";
end

initialRoll = nil;
negativemod = 0;
deliverMessage(entry);
return true;
end -- end: for
end

damned
December 18th, 2014, 02:14
Hey Maspalio - welcome aboard.
Coding questions do take longer to get responses on typically as there are far less people with the expertise to help...

Unfortunately casting a quick eye over a ruleset by anyone other than the ruleset coder is usually ineffective as there are so many links between so many different files and functions - so it usually means someone needs to spend a good 30mins to even understand exactly what is going on.

FATE uses fudge dice with dice cancelling each other out. There is a FATE ruleset in your directory already (many thanks Valarian) - perhaps you can get some more clues there?

ianmward
December 18th, 2014, 07:18
Taking a punt...
In the middle there's a bit that checks the dice...
You could probably add something like..

elseif dicelist[c].result == 2 then
table.insert(twos, c);
elseif dicelist[c].result == 1 then
successes = successes - 1;
table.insert(ones, c);
end
end
if successes < 0 then
successes=0;
end

Just a wild guess, but worth a try...

Maspalio
December 21st, 2014, 11:03
Right, it worth a try, and i'll load a fate cimpaign as well to test the fudge dice. Thanks for your answers.

Maspalio
December 24th, 2014, 22:29
Just a wild guess, but worth a try...

Thanks a lot, it works !

I'm so close, i can smell it.

The last thing i really need to get for the all thing to works perfectly is :

if you got 1's, but successes > 0 (even if they have been cancelled by the 1's), then "failure"

Actually, it counts like botches. Botches are : 1's and no successes at all.



I wish you all a merry christmas.