Skip to content

Instantly share code, notes, and snippets.

@7H3LaughingMan
7H3LaughingMan / clear-temporary.js
Last active December 22, 2024 02:02
Clear Temporary Items
Hooks.on("combatTurnChange", async (encounter) => {
if (encounter.combatant.isOwner) {
encounter.combatant.actor.itemTypes.weapon
.filter((item) => item.system.temporary && item.system.quantity === 0)
.forEach((item) => item.delete());
}
});
ui.notifications.info("Created Clear Temporary Items Hook");
@7H3LaughingMan
7H3LaughingMan / quick-vial.js
Last active December 22, 2024 01:16
Alchemist Quick Vial
if (!actor || !item) {
return;
}
const versatileVial = await fromUuid(
"Compendium.pf2e.equipment-srd.Item.ljT5pe8D7rudJqus"
);
const createdItem = await actor.createEmbeddedDocuments("Item", [
versatileVial,
@7H3LaughingMan
7H3LaughingMan / dirty-trick.js
Last active December 20, 2024 05:00
Dirty Trick Macro
const actor = canvas.tokens.controlled[0]?.actor;
const targetActor = game.user.targets.first()?.actor;
if (!actor || !targetActor || game.user.targets.size !== 1) {
return ui.notifications.warn("Please select one actor and one target");
}
if (!actor.isOfType("character")) {
return ui.notifications.warn("Controlled actor must be a player-character");
}
@7H3LaughingMan
7H3LaughingMan / Treat Wounds and Battle Medicine v2.js
Last active January 2, 2025 19:10
PF2e Treat Wounds / Battle Medicine Macro
/**
* @param {ActorPF2e} actor
* @param {string} slug
* @returns {boolean}
*/
function checkFeat(actor, slug) {
return actor.itemTypes.feat.some((feat) => feat.slug === slug);
}
/**
@7H3LaughingMan
7H3LaughingMan / alchemist-exploration.js
Last active December 24, 2024 00:57
Alchemist Exploration
let cumulativeDelta = 0;
Hooks.on("updateWorldTime", (worldTime, delta) => {
if (game.combat || !game.user.character) {
cumulativeDelta = 0;
return;
}
if (delta < 0) {
cumulativeDelta = 0;
@7H3LaughingMan
7H3LaughingMan / Impossible-Class-Playtest-v2.0.json
Created December 9, 2024 21:00
Impossible Class Playtest - Pathbuilder 2e
{
"customPackID": "04c6fc20-3deb-4e41-a278-a6bcb9ecad6c",
"customPackName": "Impossible Class Playtest v2.0",
"listCustomEquipment": [
{
"databaseID": 1,
"uniqueIdentiier": "227bc591-0b9f-4832-baa5-36885e450524",
"category": 8,
"name": "Aiuen, the Elf-gate Key",
"itemLevel": 17,
@7H3LaughingMan
7H3LaughingMan / treat-wounds.js
Created December 5, 2024 20:01
Alchemist - Treat Wounds
/* Get DamageRoll */
const DamageRoll = CONFIG.Dice.rolls.find((R) => R.name === "DamageRoll");
async function applyChanges(token, $html) {
const mod = parseInt($html.find('[name="modifier"]').val()) || 0;
const requestedProf = parseInt($html.find('[name="dc-type"]')[0].value) || 1;
const skill = token.actor.skills["crafting"];
if (!skill?.proficient) {
ui.notifications.warn(`${token.actor.name} is not trained in Crafting.`);
@7H3LaughingMan
7H3LaughingMan / draw_quad.rs
Created November 20, 2024 15:08
Rust - Draw Quad
#[wasm_bindgen(js_name = drawQuad)]
pub fn draw_quad(&self, gl: WebGl2RenderingContext) {
let current_program: WebGlProgram = gl.get_parameter(WebGl2RenderingContext::CURRENT_PROGRAM).unwrap().into();
let target_texture = gl.create_texture().unwrap();
gl.bind_texture(WebGl2RenderingContext::TEXTURE_2D, Some(&target_texture));
let _ = gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_u8_array(
WebGl2RenderingContext::TEXTURE_2D,
0,
WebGl2RenderingContext::RGBA as i32,
@7H3LaughingMan
7H3LaughingMan / point.rs
Created November 19, 2024 03:20
Rust - Quadtree
#[derive(Clone, Copy, Debug)]
pub struct Point {
pub x: f64,
pub y: f64,
}
impl Point {
pub fn new(x: f64, y: f64) -> Self {
Self { x, y }
}
{
"key": "ItemAlteration",
"itemType": "armor",
"mode": "override",
"predicate": [
"item:equipped"
],
"property": "ac-bonus",
"value": 3
}