It can certainly be done, but biggest question is what you want the process like, and how much input you want people to have at which stages. I think the hardest part of most scripts is the interface, if you can nail that, the script writing becomes much easier. At it's simplest, it sounds like an outline would be: Player executes command, passing the attack roll, target, and damage. API loads the target API compares the attack roll to the target's AC On Success, deduct damage from target's HP On Failure, do nothing. So, the command might look like (Roll Queries for simplicity): !apply-attack ?{Roll} @{target|token_id} ?{Damage} on the API side, it would look something like (pseudocode): /* on chat message */
let token = getObj('graphic', <targetid> );
let character = getObj('character',token.get('represents'));
if(character){
let ac = getattrbyname(character.id,'AC');
if(ac < <roll> ){
let hp = findObjs({ type: 'attribute', name: 'HP', characterid: character.id})[0];
if(hp){
hp.set('value', (hp.get('value') - <damage> ) );
}
}
}
Not too complicated. Complication comes from wanting to provide feedback about what happened, wanting to choose different stats to check an apply to, wanting the DM to be able to override, etc. That's really all interface stuff though, the actual code is still pretty simple. Hope that helps, and of course feel free to ask more questions!!