PDA

View Full Version : Need some guidance - extension to change encounter window



spite
September 10th, 2019, 02:22
So I'm wanting to make up an extension that changes how the level modification box on encounters works (namely, changing the values it adds, potentially based on role), and am wondering what area of the ruleset this is handled in so I can try figure it out. Does anyone know where to start?

Trenloe
September 10th, 2019, 02:43
I don't think the 4E ruleset does any auto calculation of encounter XP or level based off the creatures in the encounter window. I can't see any code in the ruleset that does this, and using the ruleset itself doesn't do any auto-calc.

So, are you saying you want to add in such functionality? In which case I recommend looking at the 5E or 3.5E rulesets - these have calculation buttons in the encounter window that perform various calculations on the encounter. For example, in 3.5E there are two buttons in campaign\record_encounter.xml (button_enc_refreshcr and button_enc_refreshxp) that trigger challenge rating and XP calculations for the encounter.

spite
September 10th, 2019, 02:46
I am referring to the box (pictured here at the end of the line to the left of the ID) that you can put in a value, and it adjusts the creatures level when added to the combat tracker. By default it adds 10hp, +1 ATK, +1 DEF, and +0.5 DMG (rounding down) per level. It also reduces by the same values if negative value there.

I'm wanting to make an extension that adjusts what those values are, and if possible, add a check that chooses the value based on the creatures type (skirmisher, controller, brute, lurker, artillery, soldier etc)
https://puu.sh/Efqcx/e25fe305bc.jpg

Trenloe
September 10th, 2019, 02:55
Ah, right - gotcha.

Have a look at the 4E ruleset, scripts\manager_combat2.lua - addNPC function - the nLevelAdj variable comes from that field. This function is ran when the NPC is added to the combat tracker.

spite
September 10th, 2019, 03:23
Alrighty, found what I need, just need to figure out how to make an extension now that changes it.
Thanks Trenloe :)

Trenloe
September 10th, 2019, 03:37
Alrighty, found what I need, just need to figure out how to make an extension now that changes it.
If you look at the top of the manager_combat2.lua script, you'll see that there is a command: CombatManager.setCustomAddNPC(addNPC);

This is a way that FG uses in key areas allowing layered rulesets (and extensions) to easily add in single functions to override the lower level code (base ruleset -> layered ruleset -> extension).

So, you can use this in your own extension to override the 4E addNPC script. Just copy out the addNPC code from the 4E ruleset into a script file in your extension, have an onInit function with CombatManager.setCustomAddNPC(addNPC); to override the 4E custom function with your own, and then customize addNPC as needed.


Thanks Trenloe :)
No worries.

spite
September 10th, 2019, 05:06
I think I broke it. Hahhaha

This is an experience

Trenloe
September 10th, 2019, 05:07
I think I broke it. Hahhaha
Well played!

spite
September 10th, 2019, 05:15
I've edited the manager_combat2.lua to have the correct values etc, and have made the extension call upon it (I think) but it hasnt adjusted anything in the actual ruleset. Do you perhaps have a moment for me to pick your brains on discord?

Trenloe
September 10th, 2019, 05:42
I've edited the manager_combat2.lua to have the correct values etc, and have made the extension call upon it (I think) but it hasnt adjusted anything in the actual ruleset. Do you perhaps have a moment for me to pick your brains on discord?
Sorry, I'm not really on Discord.

You don't modify the 4E manager_ combat.lua file - you leave that as is.

Extract the addNPC function from that file and put it in your own LUA file that you will have in your extension.

Then, in that LUA file, add an onInit() function that overrides the base addNPC function: CombatManager.setCustomAddNPC(addNPC);

Then load this script in your extension.xml file.

See the LUA file in the attached ZIP file - I've done this for you. Add this file to your extension, and load it with a <script> command in your extension.xml file.

Then make your custom changes to the addNPC function in this file. Don't touch any of the base 4E files.

spite
September 10th, 2019, 05:51
No worries. I'll try your instructions now and see how I get on.
Thanks for your time, again, Trenloe

spite
September 10th, 2019, 05:53
YES IT WORKS!
Woohoo!

Trenloe
September 10th, 2019, 06:07
YES IT WORKS!
Woohoo!
Cool!