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

Macro assistance needed

Right, I´v recently changed from Maptools to this, mainly due to the ease of use. However I´m messing with some macros thats really fouling my mood by now! I´l look around the forum to no avail. 1st Marco. A damage macro. I want it to Roll a "to hit" vs the skills of the selected token. Then a "dodge" by the target. (and this is do) I´d like it NOT to post futher if the attack fails to hit or is dodged. // I dont know how to do that On Hit I want it to roll damage and add a single modifyer minus the enemies passive PD. (This ia also do) I just CANT make it effect the other tokens HP at all... #lof /em @{selected|token_name} makes their attacks: For Talasero!! /r d20>@{selected|melee} /r d20>@{target|Dodge}) /roll 2d10+ @{selected|Total dam bonus} - @{target|pd} = "XX" // some sort of way to store this number is really needed!! @{target|hp} - "XX" // should reduce the targets hp bar 2nd Macro is very simply a check to see if the spell is off //would insert appropriate damage mechanic from above macro Fireball! set(@{selected|Mana} -16) /r d20>@{selected|Spell skill} I getting grayhaired (more then I am) messing with this for 2 days now! Anyone please help!
A macro can't actually change another token's stats. Since you're a mentor, you'll have to go into the API for this. This is all fairly easily doable in the API and would include the ability to break the run if you missed.
So i´d need to make a API script doing the above (in jave though) and call "Meleeattack" or something Then make a macro that could be placed as a token action with the !Meleeattack or what?
Yes. The easiest way would be a script that takes {target|token_id} as an input so you can grab the correct target token and call/modify it's attributes.
hmm heres a Macro from Maptools I made, how big is the jump to make it work here? <a href="https://gist.github.com/Raazorfiend/8055576" rel="nofollow">https://gist.github.com/Raazorfiend/8055576</a>
Hitting a macro sends the selected token with the API. You can pass the target's token id. From those two, you can cycle through to grab the top/left points of the tokens and math them to get a distance and call the attribute Aim. You can then do rolls/damage/etc. and directly alter the HP attribute or bar1 value. Then set the status icons.
Hmm Thanks, I´ll try to mess with it some.
Brandon W. said: A macro can't actually change another token's stats. Since you're a mentor, you'll have to go into the API for this. This is all fairly easily doable in the API and would include the ability to break the run if you missed. Is there an e ample of this somewhere I've seen several posts about how easy it is but can't find any api scripts meant to handle attack\damage rolls and attribute changing.
If you do I´d love a link m8- API is not far from Maptools codeing, but far enough to be very uphill for me lol
Here you go, something quick, dirty, and just for experience. This actually does 2d6+ an attribute's current value to the selected target, but you can probably figure it out from here. API command: !Attack It then pulls the represents field from the token to get to it's sheet, looking for two Attributes. Note, everything on the sheet is normally stored as strings, so ParseInt is used to convert numbers back to actual numbers for mathing. Otherwise you get some really strange damage off of this. Finds Attr1 which represents the damage modifier. Finds Attr2 which represents current and max health. Creates a variable for 2d6+ Attr1 damage. Creates a variable for current HP minus damage. Then resets current HP to the new health variable. <a href="https://gist.github.com/Kamanar/8070970" rel="nofollow">https://gist.github.com/Kamanar/8070970</a>
That seems to be in the right direction but it seems like it is pulling the damage attribute and HP attribute from the same token, wouldn't it have to pull the damage from one token and the hp from another or am I looking at it wrong?
1387660232

Edited 1387660469
It would. Like I said, it was quick and dirty. You'd have to do a bit with splitting the input, and doing !Attack @{target|token_id} var slice = msg.contect.split(" "); //Splits the message input based off spaces. slice[0] is !Attack. var enemy_token = slice[1]; //Enemy Token ID. var enemy_HP = enemy_token.get("bar1") //This assumes that the enemy doesn't have a sheet and only gets the HP Then you could do: enemy_token.set("bar1",enemy_HP-Damage); --Edit I don't promise the above works exactly, as I didn't test that code.
Oh awesome thank you that is the piece of the puzzle I was missing on how to handle the multiple tokens at once I will work on this tonight and have something in here tonight for people to try.
1387665420

Edited 1387665692
Ok so I tried pasting something together here, not a full complicated auto damage script but a simple one where you send it !Quarry and it then checks for achery-target status and if it detects it rolls damage, on("chat:message", function(msg) { if(msg.type == "api" && msg.content.toLowerCase().indexOf('!quarry') !== -1) { var slice = msg.contect.split(" "); //Splits the message input based off spaces. slice[0] is !Attack. var enmy_token = slice[1]; //Enemy Token ID. if(enmy.token.get('status_archery-target', true)){ enmy.token.set("bar1_value", parseInt(enmy.token.get("bar1_value"))-5); }; }; }); However I get the following error TypeError: Cannot call method 'split' of undefined at Sandbox. (evalmachine.:4:32) at eval ( It seems to not like the split, I've been looking up the syntax and it seems right don't understand what's upsetting it. edit, had a conteCt instead of conteNt and a _ instead of a . my bad but now I am getting Unexpected token . I've gotten this before it feels like the system isn't making the leap from a token-name to the actual token, from the wiki it seems like getobjs is the right command to start at playing with it nowl
Ok it has been done before I'm sure but I've managed to make a working script here, you do "!quarry name" it checks for archery-target marker on the named token and rolls 1d8 damage that it takes from it's HP, it isn't a full hit - damage script yet but it's the start of one from here I can try to add in attack rolls and the such. on("chat:message", function(msg) { if(msg.type == "api" && msg.content.toLowerCase().indexOf('!quarry') !== -1) { var slice = msg.content.split(" "); //Splits the message input based off spaces. slice[0] is !Attack. var enemyname = slice[1]; var toke = findObjs({_type: "graphic", layer:"objects", name: enemyname})[0]; if(toke.get('status_archery-target', true)){ toke.set("bar1_value", parseInt(toke.get("bar1_value"))-randomInteger(8)); sendChat(enemyname, " Takes 1d8 Quarry Damage"); }; }; });
Looking good, baby steps. That's what I've had to do.
1387686884

Edited 1387689792
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"))&gt; 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.
wow you guys work fast ^^ I´v been away 2 days lol and already you give me a lot of good stuff to work with :D Thanks truely!