Help with weapon attack macro

If you have searched the other User Creations subforums and an answer to your question has not been found, please post here!

Moderators: dorpond, trevor, Azhrei, Gamerdude

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Help with weapon attack macro

Post by aliasmask »

Most of it is what I created for standard lib tokens. It has some debugging tools and utility functions I use. onCampaignLoad makes all the macros on the lib token in to UDF or user defined functions. (see Wiki: defineFunction()) So, the macro "addWeapon" can be called with a prefix which I defined as "am.sg." which are my initials and sg for sg1 so I can make sure the functions are unique to this lib token. So, to call the addWeapon macro insteald of using [macro:] I just referenced it by am.sg.addWeapon(). That's all you really need to know about onCampaignLoad.

The debug functions pause, watch and label help to look at variables as you are running the macros to see if you are dealing with the proper data. pause() pauses the execution when it hits the line where it's inserted, watch() prints a frame but continues with execution and label prints a frame with a label you specify. The format to use is am.sg.pause("varName1","varName2"), am.sg.watch("varName"), am.sg.label("label") and am.sg.label(1). The varNames must be in quotes and the labels just print to screen so you know the last executed line in code before a crash.

The output function allow you to send output to the chat screen. This is needed because all output is suppressed in the functions. It also adds another layer of control adding "owner" and "other" as options for output targets. owner is anyone with token ownership and other is everyone else. Good for having output only the gm can see while showing everyone else different output. For me, I usually have a gm tooltip that the players can't see. By specifying other for a second output, the gm doesn't have to see double the output.

deferFunction is just a utility function I came up with to break in the middle of a macro to run another macro.

Function for this lib will include
addWeapon() - adds the weapon data to a json array so you can have an unlimited number of weapons
editWeapon() - allows you to change any weapon in the list of weapons. I'll probably include a delete option here.
setMainWeapon() - takes a weapon from the weapon list and makes it your primary. So, when you click attack it uses the main weapon. I'm not sure of the mechanics of your game and using multiple weapons so we'll just start off with having only 1 active weapon.
weaponAttack() - uses the main weapon for an attack. Again, don't know the mechanics, so it'll do a full weapon attack, but it's easy to add an option to only make the first attack when there are multiple attacks.

I'm not going to go any further beyond this with the coding. It should give a nice base to build your own functions. I do recommend using notepad++ or similar editor in conjunction with my RPEdit drop-in token to quickly edit macros on a token. I have some mods specifically for notepad++ in my signature that makes the IDE easier to read, gives tooltips on functions and copies single macro blocks easily for use with RPEdit.

You learn best by figuring this stuff out on your own, so I don't want to do all the work for you.

Post Reply

Return to “Requests for HELLLLP!”