nwn2fixes / player

Fixes for the casual NwN2 player
27 stars 11 forks source link

SOZ : Enemies do not run away correctly on the overland map #19

Open Question2 opened 5 years ago

Question2 commented 5 years ago

The fearsome roster teamwork feat says :

Specifics: Hostiles on the Overland Map will run from the party if their CR is 3 levels or more below the party level (without this benefit, enemies will run away if they are 4 levels or more below the party).

The problem is, enemies do not check for total levels, they check for levels in a single player. So for example, a level 13 barbarian/fighter 2 is level 15, so EL 10 enemies (monstrous band) should run away from you. However, they do not, because the script only sees a level 13 barbarian and doesnt take the fighter levels into account.

Edit : The problem may be something else, i added a level 9 wizard/level 8 cleric to my party and suddenly EL 10 encounters were running away. But they do not run if its just my level 13 barbarian/fighter 2.

kevL commented 5 years ago

The code calculates average level of the Party and compares it to the CR that's been assigned to an OL encounter blueprint.

the code is poorly written but looks mechanically okay ```c++ // 'ginc_overland' int GetPartyChallengeRating() { object oPartyMember = GetFirstFactionMember(GetFirstPC(), FALSE); int nHD; int nTotalPartyLevels; int nPartySize; float fPartyCR; while (GetIsObjectValid(oPartyMember)) { nHD = GetTotalLevels(oPartyMember, FALSE); nTotalPartyLevels = nTotalPartyLevels + nHD; nPartySize++; oPartyMember = GetNextFactionMember(GetFirstPC(), FALSE); } fPartyCR = IntToFloat(nTotalPartyLevels) / IntToFloat(nPartySize); return FloatToInt(fPartyCR); } // 'ginc_overland_ai' int GetIsEncounterScared(object oEnc = OBJECT_SELF) { if (GetLocalInt(oEnc, "NX2_ENC_NO_FEAR")) return FALSE; else if (GetLocalInt(oEnc, "nAfraid")) return TRUE; else { object oPC = GetFactionLeader(GetFirstPC()); float fCR = GetChallengeRating(oEnc) + 5; if (GetHasFeat(FEAT_TW_FEARSOME_ROSTER, oPC)) fCR = GetChallengeRating(oEnc) + 4; if (GetHasFeat(FEAT_TW_IMPROVED_FEARSOME_ROSTER, oPC)) fCR = GetChallengeRating(oEnc) + 3; if (FloatToInt(fCR) < GetPartyChallengeRating()) { SetEncounterFlagAfraid(oEnc); return TRUE; } } return FALSE; } ```


note Familiars/AnimalCompanions/etc will drop the party's average level - i consider it poor design that creatures on the OL consider the party weaker when the party actually gets stronger - but not a bug per se

Question2 commented 5 years ago

I had no familiars or animal companions, i was playing solo.

kevL commented 5 years ago

oh ... it could be a rounding error