Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Trying to make a simple auto-damage API

I've been studying other API's trying to build a simple damage script for 4e I simply want the damage roll to subtract from the targets hp after a successful macro roll I am having trouble on how to pass the target token information into the api I tried a simple script to test if something is marked for as hunter's quarry and roll damage for that as a test but it isn't going well on("chat:message", function(msg) { if(msg.type == "api" && msg.content.toLowerCase().indexOf('!quarry') !== -1) { var character = getObj('character', tgt.get('_represents')); if(character.get('status_archery-target', true)){ sendChat(msg.who, "/roll 1d8"); } } }); Any ideas on where to get started, I have read almost every thread but oddly nobody seems to talk about this you would think it would be a common idea.
1387522143
Alex L.
Pro
Sheet Author
Stephen H. said: I've been studying other API's trying to build a simple damage script for 4e I simply want the damage roll to subtract from the targets hp after a successful macro roll I am having trouble on how to pass the target token information into the api I tried a simple script to test if something is marked for as hunter's quarry and roll damage for that as a test but it isn't going well on("chat:message", function(msg) { if(msg.type == "api" && msg.content.toLowerCase().indexOf('!quarry') !== -1) { var character = getObj('character', tgt.get('_represents')); if(character.get('status_archery-target', true)){ sendChat(msg.who, "/roll 1d8"); } } }); Any ideas on where to get started, I have read almost every thread but oddly nobody seems to talk about this you would think it would be a common idea. First off i would use apicmd to handle command that will make it a lot easier. then you just have them pass the token name as part of the command, you could do this by have macros set up with the target variables in them. I will be totally honest with you, there is no such thing as a simple auto-damage script. I would guess that the sort of script you describe would do more harm than good, at some point over the next week or so I will be finishing my own auto damage stuff off (I am building it for a campaign) that will have a GM UI (if Riley ever fixes the bug with BIOs and stuff) for undoing things, if it works well and people enjoy it i will release it.
Well I have macros set up where they use their @to-hit vs the targets AC and it returns a success or not I figured I can try to into the api call into the macro, I do something similar for marking and it works ok. I am looking over that APICMD now it is a bit complicated.
1387525761
Alex L.
Pro
Sheet Author
Stephen H. said: Well I have macros set up where they use their @to-hit vs the targets AC and it returns a success or not I figured I can try to into the api call into the macro, I do something similar for marking and it works ok. I am looking over that APICMD now it is a bit complicated. Its very easy to say is this number bigger than that one but you will soon find out that there is a lot more to damaging than just does it hit, how do you do area attacks? what do you do if someone double clicks the macro, what do you do if someone's macro is just wrong, how do you haddle multi-attacks that happen only if the first hits.
I´m also very interested in a "press this to attack and apply damage" (since that connot be done with Macro, API is needed, however I+m not good at java at all.
Alex L. said: Stephen H. said: Well I have macros set up where they use their @to-hit vs the targets AC and it returns a success or not I figured I can try to into the api call into the macro, I do something similar for marking and it works ok. I am looking over that APICMD now it is a bit complicated. Its very easy to say is this number bigger than that one but you will soon find out that there is a lot more to damaging than just does it hit, how do you do area attacks? what do you do if someone double clicks the macro, what do you do if someone's macro is just wrong, how do you haddle multi-attacks that happen only if the first hits. Same way I do it now, for multi attacks I have one macro for damage and one for attack, they use the damage one once and the attack one multiple times for that I understand API might be hard to pull off. If they double click I'll just add the HP back we use that HP tracking script that puts all changes into the chat window so we can keep everyone on track for healing/damage. Other effects like sliding and the such will be done manually as they are now I just want to avoid me as the DM forgetting to hit "-10" on the mobs HP everytime someone attacks.
1387688868

Edited 1387689771
on("chat:message", function(msg) { if(msg.type == "api" && msg.content.toLowerCase().indexOf('!attack') !== -1) { var slice = msg.content.split(" "); // definining the enemy stats based on the first person named after the !attack var enemyname = slice[1]; var targetenemytoken = findObjs({_type: "graphic", name: enemyname})[0]; var targetenemycharacter = findObjs({_type: "character", name: enemyname})[0]; var ac = findObjs({ _type: 'attribute', name: 'AC', _characterid: targetenemycharacter.id })[0]; var fort = findObjs({ _type: 'attribute', name: 'Fort', _characterid: targetenemycharacter.id })[0]; var will = findObjs({ _type: 'attribute', name: 'Will', _characterid: targetenemycharacter.id })[0]; var reflex = findObjs({ _type: 'attribute', name: 'Reflex', _characterid: targetenemycharacter.id })[0]; // definining the player stats based on the second person named after the !attack var playername = slice[2]; var targetplayercharacter = findObjs({_type: "character", name: playername})[0]; var tohit = findObjs({ _type: 'attribute', name: 'tohit', _characterid: targetplayercharacter.id })[0]; var damage = findObjs({ _type: 'attribute', name: 'damage', _characterid: targetplayercharacter.id })[0]; // sets the target defense based on what the third entry was var targetdefensename = slice[3]; if(targetdefensename="AC"){ var targetdefensenumber = parseInt(ac.get("current")) }; if(randomInteger(20) + parseInt(tohit.get("current"))> parseInt(targetdefensenumber)){ targetenemytoken.set("bar1_value", parseInt(targetenemytoken.get("bar1_value"))-5); }; }; }); That script now works for basic attacks it will roll a d20 and add the tohit vs the targets ac it is basic and needs expanding but it is a good starting place.