Skip to content

Instantly share code, notes, and snippets.

@SCPRedMage
Last active January 19, 2024 20:25
Show Gist options
  • Save SCPRedMage/5b9c8d7c55c53ee38cdb to your computer and use it in GitHub Desktop.
Save SCPRedMage/5b9c8d7c55c53ee38cdb to your computer and use it in GitHub Desktop.
on("add:character", function(obj) {
// If there aren't any ability objects to grab, then we're probably in the middle of a sandbox spin-up
if (findObjs({ _type: "ability"}).length === 0)
return;
var abil = findObjs({ _type: "ability", _characterid: obj.id});
if (abil.length === 0) // Only create the abilities if the character doesn't have any
{
createObj("ability", {
name: "Init",
characterid: obj.id,
action: "&{template:pf_generic} {{character_name=@{selected|token_name}}} {{character_id=@{character_id}}} {{name=Initiative}} {{check=[[ (1d20 + [[ @{init} ]][init] + [[ abs(0.01 * @{init}) ]][tie-breaker]) &{tracker} ]]}} {{header_image=@{header_image-pf_generic}}}",
istokenaction: true
});
createObj("ability", {
name: "Fort",
characterid: obj.id,
action: "&{template:pf_defense} {{character_name=@{selected|token_name}}} {{character_id=@{character_id}}} {{name=Fort}} {{Save=[[ 1d20 + [[ @{Fort} ]] ]]}} @{save_options} {{header_image=@{header_image-pf_defense}}}",
istokenaction: true
});
createObj("ability", {
name: "Ref",
characterid: obj.id,
action: "&{template:pf_defense} {{character_name=@{selected|token_name}}} {{character_id=@{character_id}}} {{name=Reflex}} {{Save=[[ 1d20 + [[ @{Ref} ]] ]]}} @{save_options} {{header_image=@{header_image-pf_defense}}}",
istokenaction: true
});
createObj("ability", {
name: "Will",
characterid: obj.id,
action: "&{template:pf_defense} {{character_name=@{selected|token_name}}} {{character_id=@{character_id}}} {{name=Will}} {{Save=[[ 1d20 + [[ @{Will} ]] ]]}} @{save_options} {{header_image=@{header_image-pf_defense}}}",
istokenaction: true
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment