-
Notifications
You must be signed in to change notification settings - Fork 3
/
Development Notes.txt
147 lines (110 loc) · 6.68 KB
/
Development Notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
MacroPass Documentation:
On Use Macro: on
off
ItemMacro (workflow):
preItemRoll: Called before the item is rolled (*)
templatePlaced: Only callled once a template is placed
preambleComplete: Called after all targeting is complete
preAttackRoll: Called before the attack roll is made
preCheckHits: Called after the attack roll is made but before hits are adjudicated
postAttackRoll: Called after the attack is adjudicated
preDamageRoll: Called before damage is rolled
postDamageRoll: Called after the damage roll is made
preSave: Called before saving throws are rolled
postSave: Called after saves are rolled
preDamageApplication: Called before Damage Application
preActiveEffects: Called before applying active effects
postActiveEffects: Called after applying active effects
all: Called at each of the above
CUSTOM: 0
MULTIPLY: 1
ADD: 2
DOWNGRADE: 3
UPGRADE: 4
OVERRIDE: 5
Special Durations
1Attack 1 Attack: Expires on the next spell/weapon attack by the character
turnStartSource Turn Start: Expires at the start of the source actor's next turn (in combat)
turnEndSource Turn End: Expires at the end of the source actor's next turn (in combat)
COMMON LOG TESTS
- console.log("MACRO TEST | ARGS %O Macropass %s",args[0],args[0].macroPass);
- console.log("MACRO TEST | PC ACTOR %O",pcActor);
DAE/MIDI NOTES:
This gives advantage to an attack if placed on a monster
Guiding Bolt
flags.midi-qol.grants.advantage.attack.all Custom 1
Adding a flag to your character for latter use in a script
Elemental Adept (Cold)
flags.dae Custom flagName value
Triggering an ItemMacro with an effect at a specific time in the workflow
flags.midi-qol.onUseMacroName Custom ItemMacro.Name of Macro,workflow (ex preDamageRoll)
data.details.attunedItemsCount
data.details.attunedItemsMax
FOUNDRY VTT NOTES:
The data layout can be a bit confusing, the whole document piece is to facilitate the data base management and most of the time you can ignore it.
The one case where it can bite you is when you do fromUuid(uuid) you get back the document version of the object.
For tokens the tokens document class is TokenDocument, for actors and items it is Actor and Item - hence the special casing for token documents (sometimes).
Foundry store lots of references from one thing to another to make navigation easy.
So actor.items.getName("Longsword").parent will get you back to where you started.
It's generally not copies but references to the object and there is only one copy of the object.
actor.data, item.data is the actual data for the object and actor.data._source is the information stored in the database.
[Some of the data in the actor/item is always calculated when the actor/item is updated and never store in the data base]
The labels are not a great thing to match on, since they are localised to the language the game is run in and hence can change.
CONSOLE NOTES:
For the console _token refers to the currently selected token.
So you can do _token.actor to look at the actor data, then navigate through _token.actor.data.data to get to what you want, so
_token.actor.data.data.details.type will get the actor type field.
GIT COMMANDS:
- VIDEO: https://www.youtube.com/watch?v=raM_Z0e7ov8
> git branch -M master
> git pull
> git add .
> git commit -a -m'comments here'
> git push -u origin master
SETTING UP ITEMS INFO DROPDOWN
<p> </p>
<details>
<summary><strong>USEAGE: </strong> <span style="color: #169179;">ACTIVATE ANYTIME</span></summary>
<p>This is a utility Maneuver and can be used whenever your character can take an action. This will setup any bonuses and effects on the TARGET actor. A <span style="text-decoration: underline; color: #236fa1;">Superiority Die </span>will be expended immediately.</p>
</details>
<p> </p>
<details>
<summary><strong>SETUP:</strong></summary>
<p>Please remember to link the use of this ability to a character sheet resource under the item details Resource Consumption dropdown.</p>
<img width="569" alt="image" src="https://user-images.githubusercontent.com/76136571/161775726-fb67bb97-5fd1-45c5-8301-bbb17e2d0f1d.png">
</details>
<p> </p>
<details>
<summary><strong>VERSION INFO</strong></summary>
<p>v0.1 March 15 2022</p>
<p>jbowens #0415 (Discord)</p>
<p>https://github.com/jbowensii/More-Automated-Spells-Items-and-Feats.git</p>
</details>
JAVASCRIPT NOTES:
There is a javascript shorthand that is very useful for such things ternary operator at https://www.javascripttutorial.net/javascript-ternary-operator/
(!([creatureType?.value.toLowerCase(), creatureType?.subtype.toLowerCase()].includes(activationCondition?.toLowerCase()))) {
console.log ("MACRO TEST | REMOVE TARGET: %O %s", target, creatureType);
workflow.targets.delete(target);
}
you don't need the if/else construction.
The ? short circuits the lookup and the result ends up being [undefined, undefined].includes(string) which is false, which is what you want,
since it then takes the not of that expression, so the if(expr) evaluates to true.
Array iterators are very powerful, the if else chain for the crDestroy can be replaced with a one liner
crDestroy = [{level: 17, cr: 4}, {level: 14,cr: 3}, {level: 11., cr:2}, {level: 8, cr: 1}, {level: 5, cr: 0.5}].find(l => actorClass.levels >= l.level).cr;
also worth looking at
.map https://www.w3schools.com/jsref/jsref_map.asp for each element in the array do something
.filter https://www.w3schools.com/jsref/jsref_filter.asp create new array of all elements of the original array that pass a test
.reduce https://www.w3schools.com/jsref/jsref_reduce.asp goes through an array and performs a function resulting in a singular value for the whole array
The normal route to access actor data from a token would be: token.actor.data.data (avoid going via _source)
if you change workflow.damageRoll, you need to also update workflow.damageTotal and workflow.damageHTML.
You should not be changing any _fields in the roll.
damageHTML is set via workflow.damageHTML = await workflow.damageRoll.render().
Fiddling with the dice results is not a good solution, since you end up with a "bad" state in the roll,
which is likely to cause problems. The way I'd recommend is to reroll the damage roll
(behind the scenes with the correct formula - they player will never know) - you can fiddle with the roll
before it is rolled, but not really after.
const newRoll = workflow.damageRoll.clone();
newRoll.dice.forEach(t=>t.modifiers.push("min2"));
workflow.damageRoll = await newRoll.roll();
workflow.damageTotal = newRoll.total;
workflow.damageHTML = await newRoll.render();