PDA

View Full Version : Removing the Static 10 for AC



Whaley
September 13th, 2015, 23:16
Does anyone have or know where I can get rid of the static 10 on the AC for Pathfinder? I want it to be a D20 variable AC instead of static 10.

Trenloe
September 13th, 2015, 23:39
The default of 10 is set in a number of template calculations in campaign\template_char.xml in the 3.5E ruleset:

number_chartotalac
number_charflatfootedac
number_chartouchac
number_charcmd

Have a look at the onUpdate code within each of these templates. They all have code to set the value to 10 + the various modifiers: setValue(10 + ...

Felix Montmorency
June 6th, 2016, 09:10
Hello,

I'm new to the forum, and started to use FG a few weeks ago. Actually this is may first post.
I'm just browsing the forum for information what kind of possibilities available in FG. When I've found this thread and since we are using dynamic AC, I thought that this topic is about to change static (+10) AC to dynamic d20. Based on your guide I was able to remove the +10 modifier, the next step would be to replace it with a random d20. I'm not sure if it is possible, so please tell me if I shouldn't search for a solution, otherwise if this is possible please tell me how to proceed.

Thank you in advance

Trenloe
June 6th, 2016, 17:29
Now that I know how people want this to work (random 1d20 to AC instead of the base 10 on each attack), it will be best to do the modification of AC in the FG attack action.

Look at the 3.5E ruleset scripts\manager_action_attack.lua. In the onAttack function the target AC is stored in nDefenseVal. A simple way to modify this would be to subtract 10 and add 1d20:

nDefenseVal = nDefenseVal - 10 + math.random(20);

Do this after nDefenseVal has been returned from the ActorManager2.getDefenseValue function call.

You won't see a d20 rolling to apply to the AC (this would be waaaaay too complicated in the asynchronous 3d dice rolling model), but it does add a random number between 1 and 20.

Felix Montmorency
June 6th, 2016, 20:58
Excellent,

Thank you for the quick answer, it seems to work.
If I understood correctly it is difficult to make the visualization of the roll. Such as in case of the saving throws.
What do you think is it possible to show somehow at least the result of the random d20?
It would be nice to know what was the actual AC. eg if we fail to set the modification before the roll, we can "manually" make the damage, or restore the lost hp.

Thank you in advance

Trenloe
June 6th, 2016, 21:33
rAction.aMessages is a table that contains text entries that are added into the attack notification message in the onAttack function. You could extract the math.random(20) calculation into a variable and then store that in into the messages table with a suitable text descriptor.

Felix Montmorency
June 6th, 2016, 22:37
Thanks,
I did it partially, I created a local variable at the declaration part of the function (dynamicAC), and give it a value with the math.random(20) inmediately there.
It seems OK, 'cos the function running well (I tested several rolls, in one case roll 14 miss, in the other roll 14 hit - so I think its OK)

I make the AC calculation in the section starting with the "-- If we have a target, then calculate the defense we need to exceed" comment in the else part where not the "critconfirm" happen.
I've just written "table.insert(rAction.aMessages, dynamicAC);" just before the original "table.insert(rAction.aMessages, string.format(sFormat, nAtkEffectsBonus));" line, but it is not visible in the text output.
Perhaps this is not the way to add line in the table, or it is not the right place to make it happen.

Could you please give me more specific info about this table.
Actually I'm not so good in coding, just do it on hobby level.

Thank you in advance

Trenloe
June 6th, 2016, 23:07
I've just written "table.insert(rAction.aMessages, dynamicAC);" just before the original "table.insert(rAction.aMessages, string.format(sFormat, nAtkEffectsBonus));" line, but it is not visible in the text output.
That is within a If statement that only gets executed if there are some effects active on the attack - I'm guessing there aren't in your testing.

Put it immediately after the ActorManager2.getDefenseValue command for your initial testing.

You can see if your code is getting executed by using Debug.console("String to send to console") commands within the code - open the console using /console and then you can see the results of these commands. Info on Debug.console here:https://www.fantasygrounds.com/refdoc/Debug.xcp#console Adding these in when you are adding your code will help to determine if your code is actually being executed.

Trenloe
June 6th, 2016, 23:13
Another place you could put it (which might be easier) is the rRoll.sDesc string. Make sure you concatenate your values, as this is slowly built up during the dice rolling process.

e.g. rRoll.sDesc = rRoll.sDesc .. " [Dynamic AC:" .. dynamicAC .. "]";

Felix Montmorency
June 7th, 2016, 05:42
Excellent, it is working properly, I used, the first solution, before I realized, you posted another one.
Actually rRoll.sDesc solution is not clear for me. Just adding "rRoll.sDesc = rRoll.sDesc .. " [Dynamic AC:" .. dynamicAC .. "]";" instead of the table.insert exactly in the same place doesn't result any text out.
Maybe it is just giving a value to rRoll.sDesc and overwritten somewhere else in the code. I wasn't able to locate where to text out rRoll.sDesc
I'm just curious about this, maybe somewhere else it would be beneficial to know this method.
I started to enjoy modifying the code, it opens a lot of potential.

The other problem I wasn't able to use the Debug Console command I've inserted a line Debug.Console(dynamicAC); just before the table.insert line, and in runtime I open the console with /console, and it returns an error message: "Script Error: [string "scripts/manager_action_attack.lua"]:416: attempt to call field 'Console' (a nil value)"

Thank you in advance

damned
June 7th, 2016, 08:29
Hola Felix Montmorency - please post your finished solution so that others can use it or learn from it :)

Trenloe
June 7th, 2016, 13:49
Lua is case sensitive, use Debug.console (lower case c).

Trenloe
June 7th, 2016, 15:00
Maybe it is just giving a value to rRoll.sDesc and overwritten somewhere else in the code. I wasn't able to locate where to text out rRoll.sDesc
I'm just curious about this, maybe somewhere else it would be beneficial to know this method.
You're right, the 3.5E ruleset doesn't appear to do anything with the rRoll.sDesc string for the attack action. Sorry for the misinformation, I've been using that in another ruleset and so was used to it.

Felix Montmorency
June 7th, 2016, 18:29
No problem. In this case I will use the table.insert solution. Thank you very much for your support. I'd like to ask two more things:
- is it possible to create alternative ruleset pak to use it beside the original 3.5E?
- Is it enough to install it to the host computer, or the players also need a copy?

Thank you in advance

Felix Montmorency
June 7th, 2016, 18:34
Hola Felix Montmorency - please post your finished solution so that others can use it or learn from it :)

Of course, I'm more than happy to support the community. How should I do it?
Attach the modified 3.5E pak (am I allowed to it), or copy only the modified section of the code to the forum?

Trenloe
June 7th, 2016, 18:34
- is it possible to create alternative ruleset pak to use it beside the original 3.5E?
You're best doing ruleset modifications as an extension that makes the changes only on top of the ruleset.

Extension info here: https://www.fantasygrounds.com/modguide/extensions.xcp

And plenty of examples here: https://www.fantasygrounds.com/forums/showthread.php?15925-List-of-Extensions

You'll just need to include the whole modified manager_action_attack.lua in your extension - and a reference to it in the <base> section of extension.xml


- Is it enough to install it to the host computer, or the players also need a copy?
All ruleset (and extension) info is passed from the GM to the players, so only the GM needs the modified code.

Felix Montmorency
June 7th, 2016, 18:35
Hola Felix Montmorency - please post your finished solution so that others can use it or learn from it :)

Of course, I more than happy to support the community. How should I do it.
Attach the modified 3.5E pak (am I allowed to it), or copy only the modified section of the code to the forum?

Felix Montmorency
June 7th, 2016, 21:14
Lua is case sensitive, use Debug.console (lower case c).

Thank you, it is working now. It will be very useful in the future

Felix Montmorency
June 7th, 2016, 21:52
You're best doing ruleset modifications as an extension that makes the changes only on top of the ruleset.

Extension info here: https://www.fantasygrounds.com/modguide/extensions.xcp

And plenty of examples here: https://www.fantasygrounds.com/forums/showthread.php?15925-List-of-Extensions

You'll just need to include the whole modified manager_action_attack.lua in your extension - and a reference to it in the <base> section of extension.xml


All ruleset (and extension) info is passed from the GM to the players, so only the GM needs the modified code.

I've created a folder "Dynamic AC" and copied the manager_acton_attck.lua, created an extension.xml from one of the examples (replacing all info) and in the <base> section I entered:<includefile source="manager_action_attack.lua" />

On starting I recive an error message: Database Error: A XML parse error occurred processing file manager_action_attack.lua - Error on line 0: Error document empty.
Ruleset Error: Local extension (Dynamic AC) unable to be loaded : invalid XML


Do you have any idea, what is the problem?

Thank you in advance

Felix Montmorency
June 7th, 2016, 21:59
OK, I think I found the problem, I should use <script name="manager_action_attack.lua" file="Scripts/manager_action_attack.lua" />, instead of <includefile source="manager_action_attack.lua" />

Felix Montmorency
June 7th, 2016, 22:19
You're best doing ruleset modifications as an extension that makes the changes only on top of the ruleset.

Extension info here: https://www.fantasygrounds.com/modguide/extensions.xcp

And plenty of examples here: https://www.fantasygrounds.com/forums/showthread.php?15925-List-of-Extensions

You'll just need to include the whole modified manager_action_attack.lua in your extension - and a reference to it in the <base> section of extension.xml


All ruleset (and extension) info is passed from the GM to the players, so only the GM needs the modified code.

I've just tried another idea, combined the original "how to remove the static 10 AC" problem with the dynamic d20 AC idea.
I've managed to remove the static 10 AC from PC-s, but it is not remove it form the NPC/Encounter's AC.
Is there a solution for this, or it should be manually removed from the NPC/Encounter AC?

It is not a big deal for me, 'cos I haven't populated, the NPC roster yet, but if someone else would like to use it eg. with the Monsters Library it would be a problem.

Thank you in advance

Trenloe
June 7th, 2016, 23:22
NPC records are stored differently to PC records and hence displayed with different FG GUI windowclass XML. Assuming you're talking about removing it from the actual NPC sheet?

Can you clarify what you're looking to do?

damned
June 8th, 2016, 01:49
Of course, I more than happy to support the community. How should I do it.
Attach the modified 3.5E pak (am I allowed to it), or copy only the modified section of the code to the forum?

When you have it all finished and working as an extension - upload it here as an attachment :)

Moon Wizard
June 8th, 2016, 01:56
You probably want to catch the AC result in the applyAttack call chain right after AC is calculated, whether PC or NPC; and before it is compared to attack roll. Then, it shouldn't matter whether target is PC or NPC.

Cheers,
JPG

Felix Montmorency
June 8th, 2016, 04:38
NPC records are stored differently to PC records and hence displayed with different FG GUI windowclass XML. Assuming you're talking about removing it from the actual NPC sheet?

Can you clarify what you're looking to do?


You probably want to catch the AC result in the applyAttack call chain right after AC is calculated, whether PC or NPC; and before it is compared to attack roll. Then, it shouldn't matter whether target is PC or NPC.

Cheers,
JPG

The idea is not to substract 10 from AC and then add a random d20 in the manager_action_attack.lua, but remove the static 10 from AC on the character sheet.
It was the original solution Trenloe provided. I did it in the campaign\template_char.xml (see post #2).
In this case it is not confusing the player that on the character sheet he can see eg.: an AC 14, but FG calculates with AC 4. (substracting 10 from total AC)
It is OK, and working based on the solution provided in post #2 The problem is that, if you drag a monster eg.: Skeleton, human from the Library (open the Monster Library, and drag it to combat tracker or NPC list), then the AC of the monster in the Library is including the static +10.
So if the template_char.xml has been changed, then I can't substract the static AC (10) in the onAttack function (now it is just adding the random d20) because in this case I will reduce the AC twice. But if I don't sustract it, then the monster AC won't reduced, 'cos the modification in the template_char.xml won't affect the encounter AC from the Library (I guess monsters' AC is not stored in the template_char.xml).
So I'm looking for a solution, where I can modify the AC on character sheet, it is OK using the template_char.xml
But I'd like to modify the AC of the added monsters form the Library also -and I'm afraid so it is only possible manualy when it has been added to the NPC roster, or to the combat tracker.
Sorry for the long explanation, I hope I could clarify my idea.

Than you in advance

damned
June 8th, 2016, 04:47
Hi Felix Montmorency - Moon Wizard wrote the 3.5e ruleset and based on the extra info/needs that have come out of this thread I think he is suggesting that because you want to apply it to PCs and NPCs doing it the applyAttack instead might simplify what you are trying to achieve.

Ahhh - I just re-read again. Because you want to display the AC as (example) 4 you cant wait till the attack rolls to make the change. You could display the AC on the Charsheet like: 14/4 where the 4 is not editable but changes onUpdate of the 14...?

Moon Wizard
June 8th, 2016, 05:26
Given that all the NPCs are going to have data written assuming the base 10, it's actually easier to leave it in place and add the variability when the AC check is made. In that way, you can use the NPCs and PCs as is, without all the complexity of changing everywhere.

All that you are really doing in your game is adding a random -9 to +10 modifier to AC with every hit check. I was just suggesting to code it that way for simplicity and ease of long term maintenance.

Regards,
JPG

Felix Montmorency
June 8th, 2016, 05:45
Hi Felix Montmorency - Moon Wizard wrote the 3.5e ruleset and based on the extra info/needs that have come out of this thread I think he is suggesting that because you want to apply it to PCs and NPCs doing it the applyAttack instead might simplify what you are trying to achieve.

Ahhh - I just re-read again. Because you want to display the AC as (example) 4 you cant wait till the attack rolls to make the change. You could display the AC on the Charsheet like: 14/4 where the 4 is not editable but changes onUpdate of the 14...?


Given that all the NPCs are going to have data written assuming the base 10, it's actually easier to leave it in place and add the variability when the AC check is made. In that way, you can use the NPCs and PCs as is, without all the complexity of changing everywhere.

All that you are really doing in your game is adding a random -9 to +10 modifier to AC with every hit check. I was just suggesting to code it that way for simplicity and ease of long term maintenance.

Regards,
JPG

Damned: Thank you, it is a great idea, to display the AC on the character sheet in that way eg.: 14 (4+d20), the question arisen how it could be done, because in the tempate_char.xml I just change the value of the AC, and I can't display a string, I guess B]14 (4+d20)[/B] would be a string

Moon Wizard: Thank you, I was assuming that, there is no easy way to change the NPCs AC, but now I know it for sure, and looking for a solution. I will do as you suggested, the only question, is based on damned comment, how should I display it on the char sheet, not to confuse the players.

Regards,
Felix

Trenloe
June 8th, 2016, 05:54
Just display it as normal and tell them that is the average "take 10" AC. You'll need to explain the d20 variability anyway (at least you will for anyone familiar with the usual AC system), I'm sure your players will get used to it pretty quickly.

I only mentioned in post #2 changing it on the character sheet because I wasn't clear at that point what you were actually trying to accomplish. Since then I've recommended just subtracting 10 and adding the d20 to the AC in the attack action as that will cover both PCs and NPCs.

Whereas tinkering with code can be a good challenge and very satisfying trying to make your modifications completely amazing, you'll soon discover that maintaining complex code over time can become a complete PITA as FG updates change the files you've used and you need to re-code your extension to keep version compatibility. Try to keep your modifications simple and to as few files as possible and your extensions will be much easier to maintain in future and you (and others) will be using them for years to come.

Felix Montmorency
June 8th, 2016, 07:01
NPC records are stored differently to PC records and hence displayed with different FG GUI windowclass XML. Assuming you're talking about removing it from the actual NPC sheet?

Can you clarify what you're looking to do?

Yes I tought, that maybe there is an "onDrag" event or function, when adding it to the combat tracker or NPC list, where I can reduce the NPCs AC by 10

Moon Wizard
June 8th, 2016, 07:30
There is, but the NPC record will still not show it. Also, you'll still end up having to modify more files, than the simpler capture only in comparison.

You could add a (Take 10) label to the PC sheet to notify the players as suggested, or do something more elaborate visually. If you do something more elaborate, I would just hide the current AC field so it maintains the same value, but show a value less 10 in new control.

Regards,
JPG

Moon Wizard
June 8th, 2016, 07:33
Also, you technically don't need to change the CT, since only the GM ever sees it and you mentioned you were only concerned with what the players see.

Regards,
JPG

Felix Montmorency
June 9th, 2016, 06:09
When you have it all finished and working as an extension - upload it here as an attachment :)

I guess I've reached the point, when I can say it is the first version.

Felix Montmorency
June 9th, 2016, 06:13
There is, but the NPC record will still not show it. Also, you'll still end up having to modify more files, than the simpler capture only in comparison.

You could add a (Take 10) label to the PC sheet to notify the players as suggested, or do something more elaborate visually. If you do something more elaborate, I would just hide the current AC field so it maintains the same value, but show a value less 10 in new control.

Regards,
JPG

How can I hide the AC field, and insert a new control?
Thank you in advance

damned
June 9th, 2016, 06:16
Well done - I just gave it a test run :)

Felix Montmorency
June 9th, 2016, 13:53
Well done - I just gave it a test run :)

Thank all of you for the support.