As a wondered for some time now i have launched an old school 2nd edition framework but i am currently working on the initiative panel
- Already experience issues with sorting and find solution here is the code
In the Campagin panel i launch the following macro from a token lib
Code: Select all
[MACRO("StartCombat2@Lib:Combat"):""]
1) a little text into the chat
Code: Select all
[H: "<!--Declarations-->" ]
[h: Titred='<table border="0", width="250px"><tr bgcolor="#1924FF"><td style="padding:0px 5px;" align=center ><span style="color:white">']
[h: Titred2='<table border="0", width="250px"><tr bgcolor="#0C98FF"><td style="padding:0px 5px;" align=center ><span style="color:white">']
[h: Titref="</td></tr></table>"]
[h: setLibProperty("Initcount", 1, "Lib:combat")]
[h: Contenu= "Nouveau Combat"]
[h: Contenu2= " Round " + " " + getLibProperty("Initcount", "lib:combat") + " "+" Initiative Nouveau round !" + ]
[r: declaration = Titred + Contenu +Titref]
[r: declaration2 = Titred2 + Contenu2 +Titref]
Code: Select all
[h: removeAllFromInitiative()]
[r: declaration3="All Token removed sucessfully"]
This is achieved via the storage of the current round into a token lib
Code: Select all
[h: round0=getLibProperty("Initcount", "lib:combat")]
[h: setInitiativeRound(round0)]
[r: declaration4="Round set to 1 "]
in this case only add NPC and Non dead (based on statement)
Code: Select all
[h, CODE:{
[h: cond = '{"npc":1, "unsetStates":["Dead"]}']
[h: jsonpions.liste = getTokens("json",cond)]
[h: jsonNPC = jsonpions.liste]
[h: jsonInit = '[]']
}]
[h: "<!--Definit l initiative: Force + 1d500-->" ]
[h, foreach(id, jsonNPC), CODE:
{
[h: selectTokens(id,0)]
[h: genre1 = getProperty('strength',id)]
[h: genre1 =genre1+1d500]
[h: "<!--Definit le Json pour les PNJ a ajouter dans initiative-->" ]
[h: jsonInsert = json.set('{}', "id", id, "init", genre1)]
[h: jsonInit = json.append(jsonInit, jsonInsert)]
}]
[H: "<!--transfert vers token lib-->" ]
[h: setLibProperty("json.init", jsonInit, "Lib:combat")]
[h: json.libb=getLibProperty("json.init", "lib:combat")]
<pre>[r: json.indent(json.libb)]</pre>
[
{
"id": "C0A8010ABF4EFCF0AAA10400C0A8000A",
"init": 335
},
{
"id": "C0A8010ABF4EFCF096A10400C0A8000A",
"init": 433
},
{
"id": "C0A8010ABF4EFCF094A10400C0A8000A",
"init": 451
}
]
After that the intent is where the issues are coming
My project is
1) to be able for every single token listed before to add into a Json annother occurence based on the number of attack for every token
2) to check into token property to retreive informations related to the number of attack and sequence of attack in order to adjust their initiative
3) add these new occurrence to the JSON
4) Use the Json to sort by initiative
5) Add the content to the init panel
let's take an exemple :
Token 1 : Orc with one attack and
Token 2 : Dragon with three attacks
The "json.libb" contains the first occurence for each token
Token 1 : init 10
Token 2 : Init 12
But i would like t o have at the end
Token 1 : init 10 first strike
Token 2 : Init 12 first strike
Token 2 : Init 12+ adj second strike
Token 2 : Init 12+ adj + adj third strike
Is is possible ?