Little bug in entrenchment function when negative value is set(editor and game)

Post bug reports and ask for help with other issues here.
Post Reply
User avatar
welk
Posts: 1309
Joined: Sun Sep 17, 2006 6:41 pm
Location: France

Little bug in entrenchment function when negative value is set(editor and game)

Post by welk »

Working in my mod, I noticed that : When you set a negative value in the "defense bonus data" parameters (-1) for a hex (example : village), editor does accept this value.

But in game and in editor, if you place a unit on the concerned hex, you see that this unit has the benefit of a super-gigantic entrenchment value : 255 :mrgreen:
Due to this ultra high entrenchement value, the concerned unit is almost invulnerable in combat when attacked

If you set the parameter = 0 or > 0, no any problem, the entrenchment value of units is correct

So, to set -1 as value for entrenchment in a hex (malus) gives to units a gigantic entrenchement capacity of 255 (the exact contrary of what it is wanted)

Capture image here :
(don't take in mind the little blank point that is displayed on some hex, it's "invisible supply" (tip) I place on roads to adapt the supply system to tactical scale)

I report this concerning a value = -1 for entrenchement, but in my opinion, it would be necessary to verify if a similar problem does occur when we set a -1 value for all other bonus/malus in the defense bonus data windows => example : what will happends if I set a malus of -1 for village in defense vs tanks ?, etc (entrenchment bug is easy to verify in game, because all is displayed on screen, but it's not so evident for other bonus/malus of the list because nothing can be displayed in details => By example, if I set a -1 value for units in villages for defense vs tanks, perhaps it does cause a invisible bug that gives more wrong resistance to the attacked unit in village (same like entrenchment bonus), etc


BUG_ENTRENCHMENT.jpg
BUG_ENTRENCHMENT.jpg (405.17 KiB) Viewed 326 times
BUG ENTRENCHEMENT 2.jpg
BUG ENTRENCHEMENT 2.jpg (269.88 KiB) Viewed 322 times
User avatar
welk
Posts: 1309
Joined: Sun Sep 17, 2006 6:41 pm
Location: France

Re: Little bug in entrenchment function when negative value is set(editor and game)

Post by welk »

I did a new test concerning problems above, and I discovered a second little problem :

In bonus defense data windows (see images first post above), if you set a -1 value by example for defense in villages vs infantry, you should normally have -1 in defense vs infantry for units that are on villages hex.

But in game, you see in "details" of concerned units that no any thing is changed in their defense parameters : the -1 value you have given for defense in villages vs infantry is not displayed by the program


If the unit has a defense vs infantry = 3, it should have in village a reduced defense vs infantry => 3-1 = 2

Even not displayed, is this value reduction taken in mind by the program during combats ? Impossible to know that, a clarification would be usefull about this.

It's not so important, because we can detect this problem in "details display" of concerned unit. But it does risk to create difficulties if this problematic -1 value does cause a invisible bug in combat calculation

I think some verification and clarifications would be needed and usefull in this matter
For the present time, seems better to avoid to use this -1 value in defense bonus data parameters
User avatar
welk
Posts: 1309
Joined: Sun Sep 17, 2006 6:41 pm
Location: France

Re: Little bug in entrenchment function when negative value is set(editor and game)

Post by welk »

In addition, 2 another questions, please : in editor, a second windows does exist, to set bonus/Malus => this windows is named EDIT/PENALTIES BONUS DATA
EDIT PENALTIES BONUS DATA.jpg
EDIT PENALTIES BONUS DATA.jpg (740.45 KiB) Viewed 291 times
I did a quick test, and I did set that values I entered in this windows are not displayed in "details" parameters of units (same like for DEFENSE BONUS DATA above posts)

1°/ Even theses values are not displayed, how to be sure they are really taken in mind by the program ? Could this be
officially confirmed ?

2°/ These values may be set as positive or negative values. Are these eventual negative values realy taken in mind by the program ?
Ever since I noticed the bug described in the first post with the -1 value for 'entrenchment', I've become paranoid about every -1 value. :twisted: In informatic matter, value = -1 are sometimes highly dangerous devils :mrgreen:
EDIT PENALTIES BONUS DATA 2.jpg
EDIT PENALTIES BONUS DATA 2.jpg (688.8 KiB) Viewed 291 times
User avatar
welk
Posts: 1309
Joined: Sun Sep 17, 2006 6:41 pm
Location: France

Re: Little bug in entrenchment function when negative value is set(editor and game)

Post by welk »

Another sight that negative values are problematics in game :

Here, to do a test, I have set rough terrains for -2 strikes concerning armored assault guns (malus for armored assault guns that are in this type of terrain).

See image in editor :
BUG STRIKES 2.jpg
BUG STRIKES 2.jpg (651.89 KiB) Viewed 271 times
And what happends in game ?
A really curious situation : I have a armored assault gun on a rough terrain, with 254 strikes, and the "details" windows does display a malus of -1 in place of the malus of -2 I have set in editor.

See image in game :
BUG STRIKES.jpg
BUG STRIKES.jpg (911.53 KiB) Viewed 271 times
the armored assault gun is on a rough terrain and should fuffer -2 in number of strikes
But the "details" windows of the unit does display only a malus -1
And... the concerned assault gun has 254 strikes :mrgreen:

Don't know how has abused of whisky, me, Hubert or the chief of this armor unit :twisted: , but something seems be wrong with these negative values.

Would perhaps be better to verify these negative values, they does create curious situations, and I have heavy doubts about their fiability.

My armored assault gun is set with 1 strike in editor, it's stays on a rough terrain that does reduce it's strike (-2), and program display a reduction of -1, giving at the same time to this unit a capacity of 254 strikes... Where is the error ? :?

When I use only positive values in parameters, no any problem. But using negatives values, I see they conduct to situation that are not coherent.

EDIT : I think that the little bug I reported in the first post (long cycle of attacks) here :
https://forums.matrixgames.com/viewtopic.php?t=418666
does come ( with high probability) from a negative value set for a terrain : if a unit is on this kind of terrain set with a malus -1 in number of strikes, the bugs does give to the unit a great number of strikes, and that causes these long cycles of repetitive attacks I reported in the first post of this thread.

My conclusion : It will probably be prudent to not use negative values in the editor, to set parameters
Last edited by welk on Sun Sep 20, 2026 10:22 am, edited 2 times in total.
User avatar
welk
Posts: 1309
Joined: Sun Sep 17, 2006 6:41 pm
Location: France

Re: Little bug in entrenchment function when negative value is set(editor and game)

Post by welk »

At final step, and after some other tests, I think I found the origin of the bug :

1/ Supposing a unit is set with "x" strikes in editor
2/ Supposing a terrain is set with a penalty of "y" in number of strikes for unit that are on this terrain

If the reduction of strikes number (x - y) is > 0 or = 0 : all works ok in game
If the reduction of strike number (x - y) is < 0 , the programm has a bug and give 255 strike to the concerned unit

I tested :
If I give 2 strikes to armored assault guns and if at the same time I give them a penalty of -2 strike on rough terrains : in game, they display 0 strikes = all is ok

But if I give only 1 strike to armored assault guns and if at the same time I give them a penalty of -2 strikes, the result is that 1 - 2 = -1 and in this case program has a bug and give them 255 strikes

Conclusion : somewhere in the code, a function is missing : this function should "say" to the program this instruction : if the final result of number of strikes for a unit, considering penalties of terrains that reduce this number of strikes, is < 0, consider that 0 has to be applied in place of the real negative result

The problem does not come from negative values themselves, it comes from the lack of this needed instruction : if the difference between basic capacity and penalty become negative, the program should consider that 0 has to be applied in place of this negative result.

So, I think that the bug I reported in the first post here (long and repetitive attacks cycle):
https://forums.matrixgames.com/viewtopic.php?t=418666
does come from this instruction that is missing in the code : the unit is on a terrain that does reduce his strike capacity under 0 (example : 1-2=-1, etc), and in this case the program "bugs" : it gives 255 strikes to the unit, and that does cause the long attack cycles I reported.

I think this analyse should probably work for all negative parameters in the editor : when the difference between basic capacity of unit and reduction caused by penalty is < 0, the program "bugs" because it has no any instruction to take 0 as result in place of the negative result.

Conclusion : Users of editor have to take care when they set the parameters : Never set a negative penalty that is superior (in absolute values) to the basic capacity of the concerned unit, because the goal is to have a result = 0 or > 0, and never a negative result that does cause the reported bug.

Each time you have as final result of the below operation a negative result, you will have a problem.

Total "vanilla" capacity of a unit (for any matter) - total of penalties for this unit in a certain terrain = x
If x is < 0, you have a risk of bug because the program don't know it should ignore this negative result and that it should in place apply 0


The practical problem is that : it's easy to take care to set a penalty inferior or equal to the basic capacity of a unit, but it's more difficult to do the synthetic/global analysis of all different penalties we set for a unit, that may conduct this unit to have a negative value at final step

If the program would have the instruction to replace the eventual negative result by 0, all things would work ok.

EDIT : Another practical solution could also be that : To implement in editor an alert when settings choiced by users in COUNTRY DATA, DEFENSE BONUS DATA, MOVEMENT COST DATA and PENALTIES-BONUS DATA, etc) conduct to a final negative value for the concerned capacity (number of strikes, entrenchment, etc)
User avatar
welk
Posts: 1309
Joined: Sun Sep 17, 2006 6:41 pm
Location: France

Re: Little bug in entrenchment function when negative value is set(editor and game)

Post by welk »

Hubert or Bill : Please, could you say if you plane to solve this problem in next update ?

I need to use negative values and the bug blocks the use of these values : each time you set negatives values in BONUS DEFENSE DATA or in BONUS PENALTIES DATA, if the total of negative penalties for a precise parameter (number of strike, entrenchment, etc) makes that capacity of unit for the concerned parameter becomes < 0, the program bugs and give to the unit a gigantic capacity or 255

Example (see please capture images above in the thread) : try to give to a terrain a penality of -2 in strikes (number of strikes) and set a unit with 1 strike in COUNTRY DATA : each time this unit will be on the concerned hex, it will have 255 strikes

Why ?
Because the -2 penality makes that his "number of strikes" (that is basically 1) below < 0 (1 - 2 = -1)

And same for entrenchment, etc

It's really a problem : if editor does allow negative values, the program in game should manage these negative values, it's not actually the case => these negative values are very usefull to configure a scenario and should work :roll:
User avatar
Hubert Cater
Posts: 6118
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Little bug in entrenchment function when negative value is set(editor and game)

Post by Hubert Cater »

Thanks Welk, I'll look into this and fix this
Post Reply

Return to “Tech Support”