PDA

View Full Version : 5E - Remove all foes with 0 HP



st4lk3r87
August 7th, 2017, 00:47
Lot of times during my adventures I need to remove from the battlegrounds all the enemies with 0hp. At the moment the combat tracker provide 2 options to: "Remove all the foes" and "Remove all the non-ally".
I added 2 more options:


Remove all the foes with 0 HP
Remove all the non-ally with 0 HP


What I changed is the ct_menu.lua but it looks like I'm forced to import a copy of template_ct.xml. Maybe I'm missing something, any advice? I'd like to avoid and keep the extension a bit more simple ( having only the ct_menu.lua )

Screenshot
20071

Extension
20072

Zacchaeus
August 7th, 2017, 01:00
There is the third option which is to click the little red delete button when an enemy is reduced to 0hp.

st4lk3r87
August 7th, 2017, 01:04
There is the third option which is to click the little red delete button when an enemy is reduced to 0hp.
Yes. That's the usual way of doing it. Unfortunately clicking 7 times and scrolling on the CT is sometimes tedious. That's why I came up with the extension :)

Zacchaeus
August 7th, 2017, 01:11
I was pretty sure that you knew that but I just wanted to be sure :D

Nickademus
August 7th, 2017, 01:28
I added a radial menu option to the token to remove it from the CT. Now I just remove them as they die. Don't even need the CT open.

MTS
August 8th, 2017, 20:12
I added a radial menu option to the token to remove it from the CT. Now I just remove them as they die. Don't even need the CT open.

That sounds cool. Did you create an extension to share it?

celestian
August 8th, 2017, 23:33
Lot of times during my adventures I need to remove from the battlegrounds all the enemies with 0hp. At the moment the combat tracker provide 2 options to: "Remove all the foes" and "Remove all the non-ally".
I added 2 more options:


Remove all the foes with 0 HP
Remove all the non-ally with 0 HP


What I changed is the ct_menu.lua but it looks like I'm forced to import a copy of template_ct.xml. Maybe I'm missing something, any advice? I'd like to avoid and keep the extension a bit more simple ( having only the ct_menu.lua )

Screenshot
20071

Extension
20072


Yoink! Thanks ;)

Nickademus
August 9th, 2017, 00:03
That sounds cool. Did you create an extension to share it?Um, sure. Not much there. OP might splice it in.

Slalom
October 20th, 2017, 19:37
Um, sure. Not much there. OP might splice it in.


Can you fix a minor bug that cant allow locked tockens move when you have your .ext enabled? The "remove" icon apear into "aprove movement" icon.

Nickademus
October 20th, 2017, 21:05
The southeast position is the only position open most of the time. As for approving movement, you can just click on the token or the end of the movement line with the middle mouse button to approve it.

Slalom
October 20th, 2017, 21:07
Tnx for the tip. Didnt knew that!

Gamerman
December 29th, 2017, 05:28
I like the extension, but it seem to doesn't work with High Templar's GAP theme (https://www.fantasygrounds.com/forums/showthread.php?35819-Extension-5E-Theme-FG-GAP).

Perhaps you can work together to get it compatible.

damned
December 29th, 2017, 05:52
I like the extension, but it seem to doesn't work with High Templar's GAP theme (https://www.fantasygrounds.com/forums/showthread.php?35819-Extension-5E-Theme-FG-GAP).

Perhaps you can work together to get it compatible.

Hi Gamerman. Most people make extensions to primarily meet their own needs. Why dont you crack open the two extensions and see if you can work out what/why they dont play nice together.

Gamerman
December 29th, 2017, 06:07
If I knew advanced LUA coding, and was as familiar with both extensions as either extensions' own developers, I'd give it a shot

But GAP theme looks like it makes massive changes that break something in the standard CT radial dial setup, since the extension works with everything else.

Considering the GAP developer often works with other extension developers to improve compatibility, suggesting two experts touch base makes perfect sense.

Frankly, it"s less than helpful for me to create yet another fork. The goal is to work together, and help everyone's extensions to work better together. If I can help out both developers improve their extensions for better inter-compatibility - so much the better.

Since you have suggested it - why not volunteer to teach a LUA development class on Fantasy Grounds College?

Gamerman
December 31st, 2017, 01:13
For what it's worth, it looks like you can hack the load order to get the Warrior-Priest's "5E - Remove all foes with 0 HP" extension to function with High Templar's theme extensions, by adding a <loadorder> tag after the <ruleset> tag inside the <properties> block of the the "extension.xml" file, and setting it higher than theme extension's load order.

For example:

<properties>
<name>Remove 0HP NPCs</name>
<version>1.0.0</version>
<author>st4lk3r87</author>
<description>Allows hosts to delete from combat tracker NPCs with 0HP</description>
<ruleset>
<name>5E</name>
</ruleset>
<loadorder>821</loadorder>
</properties>

That said - I'd also be curious about the answer to Warrior-Priest's original question about why he needs to include a copy of "template_ct.xml" in his extension, even though he only modifies the "ct_menu.lua" script.

From what I can see, the extension modifies the "onInit()" in the "ct_menu.lua" to add / register some additional menu items to the "Delete from Tracker" menu (e.g. "registerMenuItem") at initialization, tweaks the behavior of the existing menu selection function to support the new options (onMenuSelection), and overrides the "clearNPCs" function to implement the new options.

To do this, a full copy of the entire "ct_menu.lua" (with the above modifications) is included in the extension, as well, as full copy of the "template_ct.xml" (which is not changed at all).

How could this be tightened up, and duplicative script / template files removed from the extension?

For example - could some sort of "merge" be used?

Could a partial snippet of "Lua" script with just the extra changes be included and somehow invoke the normal ruleset script (since not everything in the base "ct_menu.lua" script needs to changed/over-ridden)?

And why does the current implementation require inclusion of another duplicate copy of the "template_ct.xml"?

Perhaps someone with more experience on Lua scripting under the FG architecture / object / ruleset model could weigh in and help explain how the script could be optimized and made simpler, and explain the reason for the current odd extra "template_ct.xml" dependency situation in the present implementaton.

damned
December 31st, 2017, 01:57
Good work Gamerman

I would thnk in most cases that a Full Theme (as the GAP theme is) would want to load before other items that change functionality and not appearance so the load order is a good idea. You would probably want to have both extensions have a load order specified so that there is a consistent behaviour.


For what it's worth, it looks like you can hack the load order to get the Warrior-Priest's "5E - Remove all foes with 0 HP" extension to function with High Templar's theme extensions, by adding a <loadorder> tag after the <ruleset> tag inside the <properties> block of the the "extension.xml" file, and setting it higher than theme extension's load order.

The more code that is included the more likely a future ruleset will break an extension so minimising included code is always a good idea. In many cases (especially first (second, third, fourth...) attempts at an extension/ruleset involve a lot of trial and error and learning and best practice is not yet understood so you may find superfluous code being used.


That said - I'd also be curious about the answer to Warrior-Priest's original question about why he needs to include a copy of "template_ct.xml" in his extension, even though he only modifies the "ct_menu.lua" script.

From what I can see, the extension modifies the "onInit()" in the "ct_menu.lua" to add / register some additional menu items to the "Delete from Tracker" menu (e.g. "registerMenuItem") at initialization, tweaks the behavior of the existing menu selection function to support the new options (onMenuSelection), and overrides the "clearNPCs" function to implement the new options.

To do this, a full copy of the entire "ct_menu.lua" (with the above modifications) is included in the extension, as well, as full copy of the "template_ct.xml" (which is not changed at all).

How could this be tightened up, and duplicative script / template files removed from the extension?

Test in two ways - use a coding tool to compare the two files and confirm they are the same - if they are the same comment out the include line in the extension and retest.


For example - could some sort of "merge" be used?

Could a partial snippet of "Lua" script with just the extra changes be included and somehow invoke the normal ruleset script (since not everything in the base "ct_menu.lua" script needs to changed/over-ridden)?

And why does the current implementation require inclusion of another duplicate copy of the "template_ct.xml"?

Perhaps someone with more experience on Lua scripting under the FG architecture / object / ruleset model could weigh in and help explain how the script could be optimized and made simpler, and explain the reason for the current odd extra "template_ct.xml" dependency situation in the present implementaton.

Merging works on XML files for windowclass and other named objects/definitions. They must have a name for you to merge on them. Not everything is always named (unfortunately). Merging doesnt (afaik) work on LUA files. In the past you always had to include the while LUA file and just change what you needed to but there was a discussion between Moon Wizard and Dulux_Oz (from memory) a year or so ago about being able to replace individual functions only.

Keep playing with it. You will find it both rewarding and frustrating as you go - sometimes in equal measure and sometimes not!

celestian
December 31st, 2017, 02:25
In the past you always had to include the while LUA file and just change what you needed to but there was a discussion between Moon Wizard and Dulux_Oz (from memory) a year or so ago about being able to replace individual functions only.


It is possible to replace specific function. I started doing it with the AdvancedEffects extension.



function onInit()
CombatManager.setCustomAddPC(addPC);
CombatManager.setCustomAddNPC(addNPC);

--CoreRPG replacements
ActionsManager.decodeActors = decodeActors;

-- 5E effects replacements
EffectManager5E.checkConditionalHelper = checkConditionalHelper;
EffectManager5E.getEffectsByType = getEffectsByType;
EffectManager5E.hasEffect = hasEffect;

-- used for 5E extension ONLY
ActionAttack.performRoll = manager_action_attack_performRoll;
ActionDamage.performRoll = manager_action_damage_performRoll;
PowerManager.performAction = manager_power_performAction;

-- option in house rule section, enable/disable allow PCs to edit advanced effects.
OptionsManager.registerOption2("ADND_AE_EDIT", false, "option_header_houserule", "option_label_ADND_AE_EDIT", "option_entry_cycler",
{ labels = "option_label_ADND_AE_enabled" , values = "enabled", baselabel = "option_label_ADND_AE_disabled", baseval = "disabled", default = "disabled" });
end


And the functions on the right of the equal are located in the script the above onInit() is called. For example ActionAttack.performRoll is replaced by the function manager_action_attack_performRoll.

There were some bits of this that were slightly hinky but for the most part it works. It just gets a bit burdensome if you are replacing a lot and might just be better to just replace the entire .lua script.

rob2e
September 5th, 2018, 10:26
This is really cool, but what about undead fortitude?

st4lk3r87
September 5th, 2018, 14:19
For what it's worth, it looks like you can hack the load order to get the Warrior-Priest's "5E - Remove all foes with 0 HP" extension to function with High Templar's theme extensions, by adding a <loadorder> tag after the <ruleset> tag inside the <properties> block of the the "extension.xml" file, and setting it higher than theme extension's load order.

For example:

<properties>
<name>Remove 0HP NPCs</name>
<version>1.0.0</version>
<author>st4lk3r87</author>
<description>Allows hosts to delete from combat tracker NPCs with 0HP</description>
<ruleset>
<name>5E</name>
</ruleset>
<loadorder>821</loadorder>
</properties>

That said - I'd also be curious about the answer to Warrior-Priest's original question about why he needs to include a copy of "template_ct.xml" in his extension, even though he only modifies the "ct_menu.lua" script.

From what I can see, the extension modifies the "onInit()" in the "ct_menu.lua" to add / register some additional menu items to the "Delete from Tracker" menu (e.g. "registerMenuItem") at initialization, tweaks the behavior of the existing menu selection function to support the new options (onMenuSelection), and overrides the "clearNPCs" function to implement the new options.

To do this, a full copy of the entire "ct_menu.lua" (with the above modifications) is included in the extension, as well, as full copy of the "template_ct.xml" (which is not changed at all).

How could this be tightened up, and duplicative script / template files removed from the extension?

For example - could some sort of "merge" be used?

Could a partial snippet of "Lua" script with just the extra changes be included and somehow invoke the normal ruleset script (since not everything in the base "ct_menu.lua" script needs to changed/over-ridden)?

And why does the current implementation require inclusion of another duplicate copy of the "template_ct.xml"?

Perhaps someone with more experience on Lua scripting under the FG architecture / object / ruleset model could weigh in and help explain how the script could be optimized and made simpler, and explain the reason for the current odd extra "template_ct.xml" dependency situation in the present implementaton.

This has been my first implemented extension. I must admit I'm not using it anymore and I'm pretty sure there's a better way to implement it as Celestian suggests.

arcanjl
September 11th, 2018, 16:59
I’m just curious. But is there a way to make it so If a creature reaches zero hit points it is automatically deleted and I don’t have to worry about it?

Zacchaeus
September 11th, 2018, 17:04
I’m just curious. But is there a way to make it so If a creature reaches zero hit points it is automatically deleted and I don’t have to worry about it?

Not without an extension. However not every creature dies when reduced to zero hit points, so you probably don't want such automatic removal.

Moon Wizard
September 11th, 2018, 17:54
There is also the situation where someone accidentally rolls damage twice; or drops a damage roll on incorrect target. If the accidental roll automatically removes the creature; you’ve lost all the information on the status and effects for that creature and have to re-add the creature.

JPG

st4lk3r87
September 16th, 2018, 17:17
There is also the situation where someone accidentally rolls damage twice; or drops a damage roll on incorrect target. If the accidental roll automatically removes the creature; you’ve lost all the information on the status and effects for that creature and have to re-add the creature.

JPG

And that's why I'm thinking of a new extension: "Undo". It would work so good! It's just an idea but it would be cool to have the DM undoing the last roll result ( remove damage mainly ).

arcanjl
September 18th, 2018, 17:41
Ok, all that makes sense... is there a way to make it a hotkey (shortcut) at the bottom? So I don't have to click, click, click?

Skillkoil
September 19th, 2018, 02:42
And that's why I'm thinking of a new extension: "Undo". It would work so good! It's just an idea but it would be cool to have the DM undoing the last roll result ( remove damage mainly ).

You can just hold [CTRL] while dragging the damage from chat to the token/combat tracker and it will already remove the damage done. No Extension Needed. :) For other cool tips check this (http://www.fantasygrounds.com/forums/showthread.php?45418-Useful-shortcuts-and-tips-to-use-in-Fantasy-Grounds) out. Happy Gaming!

arcanjl
September 19th, 2018, 03:20
You can just hold [CTRL] while dragging the damage from chat to the token/combat tracker and it will already remove the damage done. No Extension Needed. :) For other cool tips check this (http://www.fantasygrounds.com/forums/showthread.php?45418-Useful-shortcuts-and-tips-to-use-in-Fantasy-Grounds) out. Happy Gaming!

WHAAAAAAT????
Those are awesome!!!

Skillkoil
September 19th, 2018, 03:45
WHAAAAAAT????
Those are awesome!!!

Yeah I learned A LOT making that thread. So many cool things you can do on FG. I still learn new stuff all the time.

damned
September 19th, 2018, 04:35
that trick is very good but it wont be totally accurate for foes you have killed.
if the munster has 8 of 36hp remaining and you deal 20hp when you ctrl drag it back the munster will then have 20hp...

Skillkoil
September 19th, 2018, 04:43
that trick is very good but it wont be totally accurate for foes you have killed.
if the munster has 8 of 36hp remaining and you deal 20hp when you ctrl drag it back the munster will then have 20hp...

That is true, but you can use the modifier box and place in -12 and then ctrl drag drop it. I'm sure an extension would be useful for lots of reasons and I would be happy for someont to make one. Especially for things like effects like unconscious or prone etc.. that can be placed when things go to 0. I was just offering a quick alternative. Happy Gaming!

st4lk3r87
September 20th, 2018, 14:42
You can just hold [CTRL] while dragging the damage from chat to the token/combat tracker and it will already remove the damage done. No Extension Needed. :) For other cool tips check this (http://www.fantasygrounds.com/forums/showthread.php?45418-Useful-shortcuts-and-tips-to-use-in-Fantasy-Grounds) out. Happy Gaming!
That's the closest solution. It's good you're mentioning it as it looks lot of people don't know about that but as a UI/UX developer I must say that: Dragging something while holding ctrl to remove damage is not even close to an "Undo last action" button.

Skillkoil
September 20th, 2018, 15:26
Like I said before, I think someone much smarter than me should make an extension. I can't wait to see what you come up with!

rob2e
September 20th, 2018, 20:59
I put out a tip every Friday on Twitter and Facebook, so keep your eye out for those as well. Tips have gone out every week since December of 2017.

Here's the link to the Facebook version... https://www.facebook.com/search/str/%23fantasygroundsfriday/stories-keyword/stories-public

st4lk3r87
September 20th, 2018, 21:00
I put out a tip every Friday on Twitter and Facebook, so keep your eye out for those as well. Tips have gone out every week since December of 2017.

Here's the link to the Facebook version... https://www.facebook.com/search/str/%23fantasygroundsfriday/stories-keyword/stories-public

I learned a lot from those Rob! :D

aburnstorm
October 13th, 2018, 13:42
Nice! Thank you so much. Well-done.