RPTools.net

Discussion and Support

Skip to content

It is currently Tue May 23, 2017 7:28 pm 






Reply to topic  [ 14 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Sat Nov 19, 2016 12:52 am
Posts: 18
 Post subject: Can anyone help me please
PostPosted: Fri Mar 03, 2017 3:47 pm 
Ok,

I have tried figuring this out, how do I get a macro to give a list of possible enemy targets so a player can select which target to attack?

Next once I get this how do I get a defense number from said target?

Thanks for the help guys, this will also help with a couple of other questions but the second question will answer enough so I can figure out coding for other things.

I am creating a campaign based on the anime "Is it wrong to try to pick up girls in a dungeon".
Players won't know any of the bonus's their stats get and am trying to automate most things so they can't figure it out.

ralstad


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7696
Location: Bay Area
 Post subject: Re: Can anyone help me please
PostPosted: Fri Mar 03, 2017 9:44 pm 
There are several examples for targeting (here is one: viewtopic.php?f=3&t=25860&p=257652#p257652)

To get data from a token I recommend using Wiki: switchToken() and getProperty.

Quote:
I am creating a campaign based on the anime "Is it wrong to try to pick up girls in a dungeon".


Fun anime. Second season airs in April, but not sure when English sub/dub will come out to US though.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Nov 19, 2016 12:52 am
Posts: 18
 Post subject: Re: Can anyone help me please
PostPosted: Sat Mar 04, 2017 4:25 am 
Ya, I loved the anime it was fantastic.
I thought it might be fun to play a D&D type game in that world.
The only thing the characters are going to know is just like in the anime they are going to know their ranking in their stats and any special abilities they gain over time and magic but not what anything really does.
The biggest problem is none of the frameworks I have seen work anywhere with this type of game, so building from the ground up.
I did a lot of VB programming and have a good hold on that and it seems a decent amount of the coding is similar but just not quite enough to truly start coding.

I have a quick question for anyone that will answer here is the formula I use to figure the number of attack a character will have

[R: (floor(if((Agility>799),round(Agility/200),floor(Agility/200))+if((Dexterity>799),round(Dexterity/200),floor(Dexterity/200))/6)+1)]

Now to explain in this formula you take the agility and dexterity modifiers, the ifs figure this part out, and add them together then divide them by 6 and add the starting 1 attack everyone starts with but for some reason on one character I tested it on with a dexterity of 300 and an agility of 400 it is totaling it out to 3 attacks but it should only be one, rounded down of course.

Thanks


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7696
Location: Bay Area
 Post subject: Re: Can anyone help me please
PostPosted: Sat Mar 04, 2017 7:38 am 
How about something like this:

Code:
[H: agilityMod = if(Agility >= 800,round(Agility/200)/6,floor(Agility/200)/6)]
[H: dexterityMod = if(Dexterity >= 800,round(Dexterity/200)/6,floor(Dexterity/200)/6)]
[H: numberOfAttacks = floor(agilityMod + dexterityMod + 1)]


So, dex 300 gives 1/6, agility 400 gives 2/6 and you add 1 which is 1.5 and floors to 1. Your formula didn't 1/6th the agility.

I like to break complex formulas up on multiple lines for an easy read and if needed, convert it to a single formula if speed seems to be a factor.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Nov 19, 2016 12:52 am
Posts: 18
 Post subject: Re: Can anyone help me please
PostPosted: Tue Mar 07, 2017 7:49 pm 
Thanks for the help. I took your parts and used them to correct what was wrong. I couldn't use it the way you set it up because it is on each token as a property.

I do have another question, I went to the page you suggested for targeting and used that macro but all it does is pop up a picture in the chat window and next to the token picture it gives the name of the token like it is trying to type something.

Code:
<!-- getSeenTokens(options,source): json array or object

options (strprop or json object)
   pc - 0 any token, 1 - PC only
   npc - 0 any token, 1 - NPC only
   range - upto this distance in grid units (ie feet, and not grid squares); 0 - any range
   self - 0 do not include self, 1 include self
source = source token, defaults to currentToken
   
This function will get a list of tokenIds based on the current tokens vision
-->

[H, if(argCount()): options = lower(arg(0)); options = "{}"]
[H, if(argCount() >= 2): sourceToken = arg(1); sourceToken = currentToken()]

<!-- verify token is on current map -->
[H: sourceToken = findToken(sourceToken)]

[H: assert(! json.isEmpty(sourceToken),"<b>getSeenTokens(options,source):</b> Token not found on current map.",0)]

<!-- define options locally -->
[H: defaults = json.set("{}","pc",0,"npc",0,"range",0,"self",0)]
[H, if(json.type(options) == "UNKNOWN" && ! json.isEmpty(options)): options = json.fromStrProp(options)]
[H, if(json.isEmpty(options)): options = defaults; options = json.merge(defaults,options)]
[H: varsFromStrProp(json.toStrProp(options))]

<!-- get token ids -->
[H: conditions = "{}"]
[H, if(npc && ! pc): conditions = json.set(conditions,"npc",npc)]
[H, if(! npc && pc): conditions = json.set(conditions,"pc",pc)]
[H, if(range): conditions = json.set(conditions,"range",json.set("{}","token",sourceToken,"upto",range,"distancePerCell",1))]
[H, if(! json.isEmpty(conditions)): tokenIds = getTokens("json",conditions); tokenIds = getTokens("json")]

<!-- exclude self if set -->
[H, if(self), code: {
   [H, if(! json.isEmpty(tokenIds)): tokenIds = json.union(tokenIds,json.append("",sourceToken)); tokenIds = json.append("",sourceToken)]
};{
   [H, if(! json.isEmpty(tokenIds)): tokenIds = json.difference(tokenIds,json.append("",sourceToken)); tokenIds = "[]"]
}]

<!-- check each id for name and visible -->
[H: targets = "[]"]
[H: hasSight = hasSight()]
[H, if(! hasSight()): setHasSight(1)] <!-- this works for NPC tokens too -->
[H, foreach(tokenId,tokenIds), code: {
   [H: canSee = ! json.isEmpty(canSeeToken(tokenId))]
   [H, if(canSee): targets = json.append(targets,tokenId)]
}]
[H, if(hasSight != hasSight()): setHasSight(hasSight)]

[H: macro.return = targets]


Is there something I need to change to make this work?


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9225
Location: Netherlands
 Post subject: Re: Can anyone help me please
PostPosted: Wed Mar 08, 2017 3:33 am 
this is a function macro. That means that you can use it in your code, however in order to do that you first need to create a userdefinedfunction: "getSeenTokens" in the onCampaignLoad macro. When you've done that you can do e.g.:

Code:
[h:me getSelectedNames()]
[
h:assert(listCount(me)==1,"Make sure (only) one token is selected",0)]
[
h:seenTokens getSeenTokens('["pc=0;npc=1;self=0;range=30"]')]

The NPC you can see in a vicinity of 30 is [r:seenTokens


untested.

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II and onMouseOverEvent
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Nov 19, 2016 12:52 am
Posts: 18
 Post subject: Re: Can anyone help me please
PostPosted: Thu Mar 09, 2017 7:47 pm 
So I create a new macro called onCampaignLoad then put
Code:
[h:me = getSelectedNames()]
[h:assert(listCount(me)==1,"Make sure (only) one token is selected",0)]
[h:seenTokens = getSeenTokens('["pc=0;npc=1;self=0;range=30"]')]

in the command box and that will allow me to use it?


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9225
Location: Netherlands
 Post subject: Re: Can anyone help me please
PostPosted: Fri Mar 10, 2017 1:24 am 
Unless your leaving out stuff, I'm guessing: no. Read this first: http://www.lmwcs.com/rptools/wiki/Calli ... d_Function

Did you do that?

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II and onMouseOverEvent
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Nov 19, 2016 12:52 am
Posts: 18
 Post subject: Re: Can anyone help me please
PostPosted: Fri Mar 10, 2017 5:52 am 
I think I understand. Lets see.
Ok, I placed a token on my map called "Lib:Token" then
in the token I created 2 macros

1st being "onCampaignLoad"
Code:
[defineFunction("getSeenTokens", "getSeenTokens@Lib:Token")]


2nd being "getSeenTokens"
with the code above

then i created a macro to call the "getSeenTokens" called "target" in my campaign macrosusing your code
Code:
[h:me = getSelectedNames()]
[h:assert(listCount(me)==1,"Make sure (only) one token is selected",0)]
[h:seenTokens = getSeenTokens('["pc=0;npc=1;self=0;range=30"]')]

The NPC you can see in a vicinity of 30 is [r:seenTokens]


is that correct?

ok tested what i did above and get an error of
Code:
   Error in body of roll.
Statement options (if any): h
Statement Body : seenTokens = getSeenTokens('["pc=0;npc=1;self=0;range=30"]')


What am I missing?


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9225
Location: Netherlands
 Post subject: Re: Can anyone help me please
PostPosted: Fri Mar 10, 2017 7:21 am 
Did you run oncampaignload once or saved and restarted the campaign?

And I think it's

getSeenTokens("pc=0;npc=1;self=0;range=30")]

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II and onMouseOverEvent
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7696
Location: Bay Area
 Post subject: Re: Can anyone help me please
PostPosted: Fri Mar 10, 2017 7:33 am 
I prefer

Code:
[H: options = json.set("{}","pc",0,"npc",1,"self",0,"range",30)]
[H: seenTokens = getSeenTokens(options)]


json formatting uses : and not =. You should almost always use the constructor to build your json.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Nov 19, 2016 12:52 am
Posts: 18
 Post subject: Re: Can anyone help me please
PostPosted: Fri Mar 10, 2017 1:00 pm 
ok, saved reloaded.

then ran the "target" macro from my campaign macros with the following code

Code:
[H: options = json.set("{}","pc",0,"npc",1,"self",0,"range",30)]
[H: seenTokens = getSeenTokens(options)]


and I get.

Code:
Error in body of roll.
Statement options (if any): H
Statement Body : seenTokens = getSeenTokens(options)


What am I messing up?

I am looking at the "target" macro does this call the "getSeenTokens" macro?
Code:
[H: seenTokens = getSeenTokens(options)]

I don't see where it calls that macro to run is this where my problem is coming in at?


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7696
Location: Bay Area
 Post subject: Re: Can anyone help me please
PostPosted: Fri Mar 10, 2017 11:18 pm 
Make sure getSeenTokens has the allow players to edit unchecked (preferences of macro). Unfortunately, the default is to always have it on. That's one reason why I use RPEdit because it turns it off by default.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Nov 19, 2016 12:52 am
Posts: 18
 Post subject: Re: Can anyone help me please
PostPosted: Sat Mar 11, 2017 4:18 am 
Thanks for your guys help on the function I tried to use but couldn't get it to work right.
I found a macro that will give me what I want.
I used the targeting macro from

http://lmwcs.com/rptools/wiki/Forms_tutorial#Click-based_Target_selection

Now the question I have is changing the button in this code
Code:
<input type="submit" name="btn_submit" value="Perform action">


To a button that used the image of a d20 in the default resources folder.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 14 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman