[h,macro("Base_Stats@TOKEN"):"base initiative"]
[h:bonus=macro.return]
[h:init_list=getInitiativeList()]
[h:init_list=json.get(init_list,"tokens")]
[h:temp=init_list]
[h:init_list=""]
[h,FOREACH(n,json.fields(temp)):init_list=init_list+","+json.get(json.get(temp,n),"initiative")]
[h:init_list=replace(init_list,",","",1)]
[h:abort(input("temp|0|Temporary modifiers to initiatve"))]
[h:mod=floor(Dexterity/2-5)+bonus+temp]
[h:mod=mod/100]
[h:duplicate=1]
[h:n=0]
[r,while(duplicate&&10>n,""),CODE:{
initiative: [t:init=1d20+floor(Dexterity/2-5)+bonus+temp+mod+(1d20)/10000]
[h,if(0==listContains(init_list,init)):duplicate=0]
[r,if(duplicate):"Duplicate initiative, rerolling.<br>"]
[h:n=n+1]
}]
[h,if(!duplicate),CODE:{
[h:addToInitiative()]
[h:setInitiative(init)]
}]
[r,if(duplicate):"Too many rerolls, giving up."]
Pro:
Automatic
resolves initiative order disputes
Doesn't sort the initiative list
con:
overly large and complex awesome
produces 5+-digit initiatives
not quite official method because only one party rerolls.
Doesn't sort the initiative list.
Is not mouted into a macro that automatically creates this macro on all selected tokens.
Doesn't work if you have "Allow Players to Edit Macro" checked and cannot be edited by players if it works.
Requires the following macro to be on the same token:
[h,switch(macro.args):
case "base HP":macro.return=4+4+4;
case "hit dice":macro.return=3;
case "base initiative":macro.return=0;
case "abilities":macro.return="8,18,13,14,10,17";
case "BAB":macro.return=1;
case "CL":macro.return=3;
case "base fort":macro.return=1;
case "base ref":macro.return=1;
case "base will":macro.return=3;
default: macro.return="error"]
[h,switch(macro.args):
case "base initiative":macro.return=0;
default: macro.return="error"]
Well, really, you could just replace the macro call with setting the value for bonus, but because you can edit Base_Stats but cannot edit the initiative macro it makes sense to keep them separate...