[SDK] //Does unit have promtion & Combining bars

phungus420

Deity
Joined
Mar 1, 2003
Messages
6,296
OK, so I've been working on improving the new awesome Advanced Combat Modcomp by PieceOfMind. Yesterday I was able to get a function working where it would shift between advanced and default display by holding down shift with some help of a friend on IRC. Yesterday was the first time I've coded in C++, and just in general I don't know much coding (I can only do some simple stuff in Python, but I have written some working code for it modding CIV).

Anyway I have two goals at this point:
1st, Get the XP calculation to take into account the Leadership promotion. Keeping in mind it needs to be specific, and apply only to the attacker if that attacker has it, and vice versa for the defender. So far ally my attempts have resulted in ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========. Basically I've been trying to find instances in the code where Promotions are called and use that as a reference, it has not worked.

Here is the code found in the Advanced Combat Mod:

Calculated:
Code:
                float AttXP = 4.0f/CombatRatio;
                float DefXP = 2.0f*CombatRatio;
Minimum:
Code:
                int iExperience;
                if (pAttacker->combatLimit() < 100)
                {
						iExperience        = GC.getDefineINT("EXPERIENCE_FROM_WITHDRAWL")			
                }
                else
                {
                    iExperience        = (pDefender->attackXPValue() * iDefenderStrength) / iAttackerStrength;
                    iExperience        = range(iExperience, GC.getDefineINT("MIN_EXPERIENCE_PER_COMBAT"), GC.getDefineINT("MAX_EXPERIENCE_PER_COMBAT"));
                }

                int iDefExperienceKill;
                    iDefExperienceKill = (pAttacker->defenseXPValue() * iAttackerStrength) / iDefenderStrength;
                    iDefExperienceKill = range(iDefExperienceKill, GC.getDefineINT("MIN_EXPERIENCE_PER_COMBAT"), GC.getDefineINT("MAX_EXPERIENCE_PER_COMBAT"));

I thought I could figure it out, but no dice. Just keep getting error messages such as "Undeclared Identifier" when I try to compile:

Oh And here is where it the XP is displayed on screen, in case it's easier to attack it there:
Code:
						if(pAttacker->combatLimit() == (pDefender->maxHitPoints() )) {
							szTempBuffer.Format(SETCOLR L"Victory" ENDCOLR L": " SETCOLR L"%.2f%%"ENDCOLR L" for " SETCOLR L"%dXP" ENDCOLR L"  (" SETCOLR L"%.1fHP" ENDCOLR L")",
                                                TEXT_COLOR("COLOR_POSITIVE_TEXT"),TEXT_COLOR("COLOR_POSITIVE_TEXT"),100.0f*AttackerKillOdds,TEXT_COLOR("COLOR_POSITIVE_TEXT"),iExperience,TEXT_COLOR("COLOR_POSITIVE_TEXT"), E_HP_Att_Victory/AttackerKillOdds);



OK, now for the next issue: Combining displayed bars. Explanation, in the mod currently if there are many combat outcomes (such as occures in drastically different strength units), the pane becomes too large, and the top gets choped off by the top of the screen. To fix this, need to combine items that are under 0.01% probably of occuring, so that instead of having a list of 12 different values from 5 to 50 HP at 0.00% (as is currently displayed), it'll just list of a single bar of with a 5-50HP at 0.01%. This one I have no idea of even how to start going about it.
Code:
                   if (tmpDetail > 2)//everything detail
                    {

                        for (int n_D = iNeededRoundsAttacker-1; n_D >= 0; n_D--)
                        {

                            float prob = 100.0f*(getCombatOddsSpecific(pAttacker,pDefender,iNeededRoundsDefender,n_D)+(getCombatOddsSpecific(pAttacker,pDefender,iNeededRoundsDefender-1,n_D)));
                            szTempBuffer.Format(SETCOLR L"%dHP" ENDCOLR L" %.2f%%",
                                                TEXT_COLOR("COLOR_NEGATIVE_TEXT"),((pDefender->currHitPoints()) - n_D*iDamageToDefender),prob);
                            szString.append(NEWLINE);
                            int pixels = (int)(Scaling_Factor*prob + 0.5)+2;  // 1% per pixel
                            int fullBlocks = (pixels-2) / 10;
                            int lastBlock = (pixels-2) % 10;
{
                                szString.append(L"<img=Art/ACO/red_bar_left_end.dds>");
                                for (int iI = 0; iI < fullBlocks; ++iI)
                                {
                                    szString.append(L"<img=Art/ACO/red_bar_10.dds>");
                                }
                                if (lastBlock > 0)
                                {
                                    szTempBuffer2.Format(L"<img=Art/ACO/red_bar_%d.dds>", lastBlock);
                                    szString.append(szTempBuffer2);
                                }
                                szString.append(L"<img=Art/ACO/red_bar_right_end.dds>");
                            //}
                            szString.append(L" ");
                            szString.append(szTempBuffer.GetCString());

                        }
                    }
 
Back
Top Bottom