I have the following script, I'm trying to use to create an NPC. It creates the NPC fine, but doesn't upload the stats, when I check in my game, it prompts with charactermancer. Is there any way
on('ready', function() {
// Check if the NPC statblock already exists to avoid duplicates.
var existingNPC = findObjs({
type: 'character',
name: 'Fighter (Tier 1)'
})[0];
if (!existingNPC) {
// Create the Fighter NPC
var fighter = createObj('character', {
name: 'Fighter (Tier 1)',
avatar: '', // Add a link to an image if you have one
bio: 'Medium or Small humanoid, any alignment.',
gmnotes: '', // Any notes for the GM only
});
// Set the attributes
var attributes = [
{name: 'sheet_type', current: 'npc'}, // This is the crucial attribute to set the sheet to NPC mode
{name: 'npc_ac', current: 14},
{name: 'npc_hpformula', current: '4d10 + 12'},
{name: 'npc_speed', current: '30 ft.'},
{name: 'strength', current: 16},
{name: 'dexterity', current: 13},
{name: 'constitution', current: 16},
{name: 'intelligence', current: 12},
{name: 'wisdom', current: 10},
{name: 'charisma', current: 14},
// ... add more attributes specific to the NPC statblock
];
_.each(attributes, function(attr) {
createObj('attribute', {
characterid: fighter.id,
name: attr.name,
current: attr.current,
max: attr.max || ''
});
});
// Set abilities (skills, special moves, etc.)
var abilities = [
{
name: 'Action Surge',
action: 'The fighter can take one additional action. (1/Short or Long Rest)',
istokenaction: true
},
{
name: 'Maneuvers',
action: 'When the fighter takes the attack action, they can choose one weapon attack to deal an extra 1d8 damage (same damage type as the attack) and cause Distraction.',
istokenaction: true
},
// ... add more abilities as needed
];
_.each(abilities, function(abil) {
createObj('ability', {
characterid: fighter.id,
name: abil.name,
action: abil.action,
istokenaction: abil.istokenaction || false
});
});
}
});