bratch9
September 25th, 2020, 16:10
I've noticed that overrides of functions only work from 'external' functions, while functions in the super class(es) still use the original super version of the functions and not the overridden version of the functions.. This forces you to search out all usages of these functions in the super class and also override all those functions and extra code to make it work....
( these are tested in FGC in ruleset 5E, but its the same in FGU. I dont think its ruleset specific, this is just the functions I used.. )
Attached is a zip with 3 campaigns and 3 extensions, and a 'patch' file for and unzipped '5E-rulesets' ( which adds debug chat output on 5 functions.. )
camp1,
uses ext1 which overrides,
onDamageAction,onDamageChanged,onInit,onClose
Open character 'bob', and swap to 'actions' tab. This will run the onInit sequence,
s'onInit start'
s'onInit start - ruleset'
s'onDataChanged start - ruleset'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDataChanged end - ruleset'
s'onInit end - ruleset'
s'onInit end'
You can see the extension 'onInit' is called and this calls the super.onInit from the ' - ruleset' functions.
It also shows that ONLY the ruleset version of 'onDamageChanged' is called... which should have been overridden.
When you 'double click' on the 'longsword' damage box,
s'onDamageAction start'
s'onDamageAction start - ruleset'
s'onDamageAction end - ruleset'
s'onDamageAction end'
bob: [DAMAGE (M)] Longsword [TYPE: slashing (1d8=2)]
You can see that 'onDamageAction' from the extension correctly calls and flows into the super version in the ruleset it calls. ( Called from external to the scrips and rule set script.. )
Using the 'damage edit' button you will get this output,
s'onDataChanged start - ruleset'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDataChanged end - ruleset'
Showing again that the extension version of 'onDamageChanged' was not called.
camp2, uses ext2 which add override for 'onDataChanged', as its clear from above that this is called by the ruleset to sequence the update.
If you do the damage action sequences above you will get exactly the same 3 output blocks as above as this extra 'onDataChanged' is also never called just like the 'onDamageChanged'
camp3, uses ext3 which brings the 'contents' of the 'super' function for 'onInit' and 'onDataChanged' into the extension from the 5e rule set code base,
On open of 'bob' and 'actions' tab,
s'onInit start'
s'onDataChanged start'
s'onDamageChanged start'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDamageChanged end'
s'onDataChanged end'
s'onInit end'
You can see, now I dont call the 'super' version of the function but just used the 'contents' for these 2 functions, the 'onDamageChanged' in the extension is used and correctly call the super version.
Also when you use the 'damage edit' button you will now see,
s'onDataChanged start'
s'onDamageChanged start'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDamageChanged end'
s'onDataChanged end'
You can see again that the extension version are now called by the correct 'DB.addHandler' in the exension 'onInit'
The issue with this is that all the extensions override 'onDamageChanged' but the ruleset 'super' still called ONLY the rule set version of this function.
You have to check in the original ruleset file and add all functions that also call 'onDamageChanged' to make the override work because the merge has not extended the base class functions.. It only does this for 'external' calls to these functions.
I would expect the ruleset ( or super ) version to call the new exteneded override function, and assume that if needed the new extended function would call the 'super' version of the function to pass down to the original ruleset code.
I dont expect to have to 'hunt' around in the code and end up having to override extra functions and move the code from those function into my extension to make this work.
This is not how inheritance/function overrides should work. ( Well in c++ you would virtual the 4 functions and the base class would call your inherited functions.. )
Thanks, Pete
( these are tested in FGC in ruleset 5E, but its the same in FGU. I dont think its ruleset specific, this is just the functions I used.. )
Attached is a zip with 3 campaigns and 3 extensions, and a 'patch' file for and unzipped '5E-rulesets' ( which adds debug chat output on 5 functions.. )
camp1,
uses ext1 which overrides,
onDamageAction,onDamageChanged,onInit,onClose
Open character 'bob', and swap to 'actions' tab. This will run the onInit sequence,
s'onInit start'
s'onInit start - ruleset'
s'onDataChanged start - ruleset'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDataChanged end - ruleset'
s'onInit end - ruleset'
s'onInit end'
You can see the extension 'onInit' is called and this calls the super.onInit from the ' - ruleset' functions.
It also shows that ONLY the ruleset version of 'onDamageChanged' is called... which should have been overridden.
When you 'double click' on the 'longsword' damage box,
s'onDamageAction start'
s'onDamageAction start - ruleset'
s'onDamageAction end - ruleset'
s'onDamageAction end'
bob: [DAMAGE (M)] Longsword [TYPE: slashing (1d8=2)]
You can see that 'onDamageAction' from the extension correctly calls and flows into the super version in the ruleset it calls. ( Called from external to the scrips and rule set script.. )
Using the 'damage edit' button you will get this output,
s'onDataChanged start - ruleset'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDataChanged end - ruleset'
Showing again that the extension version of 'onDamageChanged' was not called.
camp2, uses ext2 which add override for 'onDataChanged', as its clear from above that this is called by the ruleset to sequence the update.
If you do the damage action sequences above you will get exactly the same 3 output blocks as above as this extra 'onDataChanged' is also never called just like the 'onDamageChanged'
camp3, uses ext3 which brings the 'contents' of the 'super' function for 'onInit' and 'onDataChanged' into the extension from the 5e rule set code base,
On open of 'bob' and 'actions' tab,
s'onInit start'
s'onDataChanged start'
s'onDamageChanged start'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDamageChanged end'
s'onDataChanged end'
s'onInit end'
You can see, now I dont call the 'super' version of the function but just used the 'contents' for these 2 functions, the 'onDamageChanged' in the extension is used and correctly call the super version.
Also when you use the 'damage edit' button you will now see,
s'onDataChanged start'
s'onDamageChanged start'
s'onDamageChanged start - ruleset'
s'onDamageChanged end - ruleset'
s'onDamageChanged end'
s'onDataChanged end'
You can see again that the extension version are now called by the correct 'DB.addHandler' in the exension 'onInit'
The issue with this is that all the extensions override 'onDamageChanged' but the ruleset 'super' still called ONLY the rule set version of this function.
You have to check in the original ruleset file and add all functions that also call 'onDamageChanged' to make the override work because the merge has not extended the base class functions.. It only does this for 'external' calls to these functions.
I would expect the ruleset ( or super ) version to call the new exteneded override function, and assume that if needed the new extended function would call the 'super' version of the function to pass down to the original ruleset code.
I dont expect to have to 'hunt' around in the code and end up having to override extra functions and move the code from those function into my extension to make this work.
This is not how inheritance/function overrides should work. ( Well in c++ you would virtual the 4 functions and the base class would call your inherited functions.. )
Thanks, Pete