|
|
|
|
|
|
|
|
|
|
|
Re: Code Snippets[message #345837 is a reply to message #345708]
|
Sat, 04 June 2016 21:01 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
Interface Enhanced.cpp:
for (cnt = 0; cnt < 36; cnt++)
{
MSYS_DefineRegion( &gUDBFasthelpRegions[ iRegionsCreated ],
(INT16)(gItemDescGenSecondaryRegions[cnt].sLeft),
(INT16)(gItemDescGenSecondaryRegions[cnt].sTop),
(INT16)(gItemDescGenSecondaryRegions[cnt].sRight),
(INT16)(gItemDescGenSecondaryRegions[cnt].sBottom),
MSYS_PRIORITY_HIGHEST, MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemDescCallback );
MSYS_AddRegion( &gUDBFasthelpRegions[ iRegionsCreated ]);
SetRegionHelpEndCallback( &(gUDBFasthelpRegions[ iRegionsCreated ]), HelpTextDoneCallback );
MSYS_DisableRegion( &gUDBFasthelpRegions[ iRegionsCreated ] );
iRegionsCreated++;
}
should be
for (cnt = 0; cnt < 26; cnt++)
because
INV_DESC_REGIONS gItemDescGenSecondaryRegions[26]; // Secondary data regions, 3x5
Also in InitDescStatCoords, this code is suspicious:
memset(gItemDescAttachmentsXY, 0, MAX_ATTACHMENTS);
because gItemDescAttachmentsXY is defined as
INV_ATTACHXY gItemDescAttachmentsXY[MAX_ATTACHMENTS];
and INV_ATTACHXY is struct
typedef struct
{
INT16 sX;
INT16 sY;
INT16 sHeight;
INT16 sWidth;
INT16 sBarDx;
INT16 sBarDy;
} INV_ATTACHXY;
Left this community.Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Code Snippets[message #346741 is a reply to message #345867]
|
Thu, 25 August 2016 23:33 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
stable 7609:
Weapons.cpp, CalcNewChanceToHitGun
// silversurfer: this doesn't make sense. We always apply a penalty when we can see the target?
// invisible targets are already taken into account one step above in aimbonus from target
// VISIBILITY
/*if (iRange > 0 && iSightRange > iRange)
{
FLOAT fTempPenalty = (FLOAT)((FLOAT)iSightRange / (FLOAT)iRange);
fTempPenalty = (FLOAT)(100 / fTempPenalty);
fAimModifier += ((100-fTempPenalty) * gGameCTHConstants.AIM_VISIBILITY)/100;
fAimModifier = __max( gGameCTHConstants.AIM_TARGET_INVISIBLE, fAimModifier );
}*/
I think the idea was to take into account effective 'visual distance' to target which can be increased by grass and other obstacles.
Also, if scope gives some visibility bonus, effective 'visual distance' will be reduced, representing that we 'can see target better'.
Similar calculations are used in OCTH.
This code was removed in recent versions, but the option AIM_VISIBILITY still exists in CTHConstants.ini.
Also, in iSightRange calculation:
if (iSightRange == 0)
{ // Can't see the target but we still need to know what the sight range would be if we could so we can deal with cover penalties
iSightRange = SoldierToSoldierLineOfSightTest( pSoldier, MercPtrs[ubTargetID], TRUE, NO_DISTANCE_LIMIT, pSoldier->bAimShotLocation, false, true );
fCantSeeTarget = true;
}
ubTargetID = WhoIsThere2( sGridNo, pSoldier->bTargetLevel ); // Target ubID
ubTargetID can be NOBODY if we shoot at empty tile, but the code doesn't check that, passing wrong soldier pointer to SoldierToSoldierLineOfSightTest, this can result in crash in some situations (calc cth for shooting at invisible empty tile).
The same bug exists in CalcChanceToHitGun.
Left this community.Report message to a moderator
|
|
|
|
Re: Code Snippets[message #346743 is a reply to message #346741]
|
Fri, 26 August 2016 11:35 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
silversurfer |
![](http://thepit.ja-galaxy-forum.com/images/avatars/basterds_Inglourious-Basterds--2009-Christoph-Waltz3.jpg) ![](/images/ranks/liutenant.png) |
Messages:2791
Registered:May 2009 |
|
|
sevenfm wrote on Thu, 25 August 2016 22:33stable 7609:
Weapons.cpp, CalcNewChanceToHitGun
Toggle Spoiler// silversurfer: this doesn't make sense. We always apply a penalty when we can see the target?
// invisible targets are already taken into account one step above in aimbonus from target
// VISIBILITY
/*if (iRange > 0 && iSightRange > iRange)
{
FLOAT fTempPenalty = (FLOAT)((FLOAT)iSightRange / (FLOAT)iRange);
fTempPenalty = (FLOAT)(100 / fTempPenalty);
fAimModifier += ((100-fTempPenalty) * gGameCTHConstants.AIM_VISIBILITY)/100;
fAimModifier = __max( gGameCTHConstants.AIM_TARGET_INVISIBLE, fAimModifier );
}*/
I think the idea was to take into account effective 'visual distance' to target which can be increased by grass and other obstacles.
Also, if scope gives some visibility bonus, effective 'visual distance' will be reduced, representing that we 'can see target better'.
Similar calculations are used in OCTH.
This code was removed in recent versions, but the option AIM_VISIBILITY still exists in CTHConstants.ini.
The reason I commented this part of the code is that it doesn't make any sense to me.
iRange is the range to target.
iSightRange is the distance that we can see.
Now the above code says that if range to target is greater than zero and we can see further than the target we still get a penalty. What? It doesn't even take fCantSeeTarget into account.
fCantSeeTarget is used in function CalcNewChanceToHitAimTargetBonus and there it applies AIM_TARGET_INVISIBLE penalty.
Maybe I'm missing something here so if you still see a need for the above code we can always put it back but I would suggest to extend the if clause to:
if (iRange > 0 && iSightRange > iRange && fCantSeeTarget)
I prefer not to be penalized for seeing the target.
If there is no reason to put it back I agree that AIM_VISIBILITY should be removed from the code and CTHConstants.ini.
sevenfm wrote on Thu, 25 August 2016 22:33
ubTargetID = WhoIsThere2( sGridNo, pSoldier->bTargetLevel ); // Target ubID
ubTargetID can be NOBODY if we shoot at empty tile, but the code doesn't check that, passing wrong soldier pointer to SoldierToSoldierLineOfSightTest, this can result in crash in some situations (calc cth for shooting at invisible empty tile).
The same bug exists in CalcChanceToHitGun.
Simply changing the if clause to:
if (ubTargetID != NOBODY && iSightRange == 0)
should do the trick.
Wildfire Maps Mod 6.07 on SVN: https://ja2svn.mooo.com/source/ja2/branches/Wanne/JA2%201.13%20Wildfire%206.06%20-%20Maps%20MODReport message to a moderator
|
|
|
|
Re: Code Snippets[message #346781 is a reply to message #346743]
|
Thu, 01 September 2016 21:45 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
Quote:iSightRange is the distance that we can see.
It's not correct. sDistVis is the maximum visible distance.
sDistVis = pSoldier->GetMaxDistanceVisible(sGridNo, pSoldier->bTargetLevel, CALC_FROM_ALL_DIRS ) * CELL_X_SIZE;
iSightRange is effective visual distance to target.
If shooter can clearly see target, then iSightRange = iRange.
If there are some visual obstacles like grass or trees, then iSightRange will be greater than iRange, so some penalty will be applied because target cannot be seen clearly.
So I think that original code is ok.
[Updated on: Thu, 01 September 2016 21:51]
Left this community.Report message to a moderator
|
|
|
|
|
|
Re: Code Snippets[message #350370 is a reply to message #346805]
|
Fri, 21 July 2017 21:43 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
CalcThrownChanceToHit:
if ( Item[ usHandItem ].mortar )
{
if (HAS_SKILL_TRAIT( pSoldier, HEAVY_WEAPONS_NT ))
iChance += (gSkillTraitValues.sCtHModifierMortar * max( 0, ((100 - gSkillTraitValues.ubHWMortarCtHPenaltyReduction * NUM_SKILL_TRAITS( pSoldier, HEAVY_WEAPONS_NT ))/100)));
else
iChance += gSkillTraitValues.sCtHModifierMortar; // -60% for untrained mercs
}
Looks like this expression
iChance += (gSkillTraitValues.sCtHModifierMortar * max( 0, ((100 - gSkillTraitValues.ubHWMortarCtHPenaltyReduction * NUM_SKILL_TRAITS( pSoldier, HEAVY_WEAPONS_NT ))/100)));
not only has too many brackets but also is wrong because dividing integer 100 - gSkillTraitValues.ubHWMortarCtHPenaltyReduction * NUM_SKILL_TRAITS( pSoldier, HEAVY_WEAPONS_NT ) by integer 100 will always result in integer 0 or 1, so it should look like:
iChance += gSkillTraitValues.sCtHModifierMortar * max( 0, 100 - gSkillTraitValues.ubHWMortarCtHPenaltyReduction * NUM_SKILL_TRAITS( pSoldier, HEAVY_WEAPONS_NT )) / 100;
Also, in CalcBestThrow:
// this is try to minimize enemies wasting their (limited) toss attacks:
switch( ubDiff )
{
case 0:
case 1:
// don't use unless have a 70% chance to hit
if (pBestThrow->ubChanceToReallyHit < 70)
{
pBestThrow->ubPossible = FALSE;
}
break;
case 2:
case 3:
case 4:
// don't use unless have a 50% chance to hit
if (pBestThrow->ubChanceToReallyHit < 50)
{
pBestThrow->ubPossible = FALSE;
}
break;
default:
break;
}
AI soldier will not attack with grenade/GL/mortar if he has less than 50% CTH.
With default MORTAR_CTH_MODIFIER = -60 even perfect soldier with max stats (but without heavy weapons trait) will have CTH = 100% - 60% = 40% max, that means AI soldiers will never use mortars if someone decides to play with ASSIGN_SKILL_TRAITS_TO_ENEMY = FALSE.
[Updated on: Fri, 21 July 2017 21:58]
Left this community.Report message to a moderator
|
|
|
|
|
|
Re: Code Snippets[message #350511 is a reply to message #350507]
|
Tue, 08 August 2017 22:19 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
In _GermanText.cpp:
STR16 pMilitiaButtonsHelpText[] =
{
L"Zuordnung auflösen (|R|e|c|h|t|s |K|l|i|c|k)\Zuordnen (|L|i|n|k|s |K|l|i|c|k)\nGrüne Miliz", // button help text informing player they can pick up or drop militia with this button
L"Zuordnung auflösen (|R|e|c|h|t|s |K|l|i|c|k)\Zuordnen (|L|i|n|k|s |K|l|i|c|k)\nReguläre Miliz",
L"Zuordnung auflösen (|R|e|c|h|t|s |K|l|i|c|k)\Zuordnen (|L|i|n|k|s |K|l|i|c|k)\nElite Miliz",
L"Verteile Miliz gleichwertig über alle Sektoren",
};
compiler shows warning about unrecognized \ sequence, maybe it should look like:
L"Zuordnung auflösen (|R|e|c|h|t|s |K|l|i|c|k)\nZuordnen (|L|i|n|k|s |K|l|i|c|k)\nGrüne Miliz", // button help text informing player they can pick up or drop militia with this button
L"Zuordnung auflösen (|R|e|c|h|t|s |K|l|i|c|k)\nZuordnen (|L|i|n|k|s |K|l|i|c|k)\nReguläre Miliz",
L"Zuordnung auflösen (|R|e|c|h|t|s |K|l|i|c|k)\nZuordnen (|L|i|n|k|s |K|l|i|c|k)\nElite Miliz",
L"Verteile Miliz gleichwertig über alle Sektoren",
Left this community.Report message to a moderator
|
|
|
|
|
|
|
|
Re: Code Snippets[message #350785 is a reply to message #350779]
|
Tue, 29 August 2017 13:43 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Flugente |
![](/images/ranks/captain.png) |
Messages:3507
Registered:April 2009 Location: Germany |
|
|
Urgs. That was rather stupid of me. I'll commit the fix when i'm back home (unless you do it first).
Edit: Fixed in r8465.
[Updated on: Tue, 29 August 2017 20:57]
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.Report message to a moderator
|
|
|
|
|
Re: Code Snippets[message #350808 is a reply to message #350796]
|
Thu, 31 August 2017 11:24 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
Also it seems that fBuckshot is not initialized properly in UseGunNCTH except for throwing knives, this can potentially cause problems when shooting.
Easy fix:
[Updated on: Thu, 31 August 2017 11:24]
Left this community.Report message to a moderator
|
|
|
|
Re: Code Snippets[message #351487 is a reply to message #350808]
|
Wed, 15 November 2017 12:37 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
Looking at the code in Queen Command.cpp:
// HEADROCK HAM 3.2: enemy reinforcements arrive with 0 APs.
if (gGameExternalOptions.ubReinforcementsFirstTurnFreeze == 1 || gGameExternalOptions.ubReinforcementsFirstTurnFreeze == 2)
{
pSoldier->bActionPoints = 0;
// Flugente: due to a fix, also note here that the reinforcements get no APs.
pSoldier->usSoldierFlagMask |= SOLDIER_NO_AP;
// Flugente: campaign stats
if ( IsOurSoldier(pSoldier) )
gCurrentIncident.usIncidentFlags |= INCIDENT_REINFORCEMENTS_PLAYERSIDE;
else
gCurrentIncident.usIncidentFlags |= INCIDENT_REINFORCEMENTS_ENEMY;
}
Why we apply campaign stats only when reinforcements arrive with zero AP?
[Updated on: Wed, 15 November 2017 14:04]
Left this community.Report message to a moderator
|
|
|
|
Re: Code Snippets[message #351983 is a reply to message #351487]
|
Thu, 11 January 2018 02:00 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
in CalcBulletDeviation():
iRangeRatio = __max(1.0f, (FLOAT)(uiRange / sEffRange));
Since uiRange is UINT32 and sEffRange is UINT16, it will probably not work as intended.
[Updated on: Thu, 11 January 2018 02:23]
Left this community.Report message to a moderator
|
|
|
|
|
|
|
|