-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customizable disguised target evaluation behaviour in new ScriptType attack actions #1169
base: develop
Are you sure you want to change the base?
Changes from 1 commit
757f67c
3d265ff
f42b2eb
fbc3035
16042b9
1b0a658
1484010
950823d
d8b71d5
e3e4d9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c | |
bool agentMode = false; | ||
bool pacifistTeam = true; | ||
auto pTeamData = TeamExt::ExtMap.Find(pTeam); | ||
std::vector<double> disguiseDetection = {}; | ||
|
||
if (!pScript) | ||
return; | ||
|
@@ -136,6 +137,19 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c | |
if ((pTypeInf->Agent && pTypeInf->Infiltrate) || pTypeInf->Engineer) | ||
agentMode = true; | ||
} | ||
|
||
auto pTechnoData = TechnoTypeExt::ExtMap.Find(pTechnoType); | ||
if (pTechnoType->DetectDisguise) | ||
{ | ||
auto const AIDifficulty = static_cast<int>(pFoot->Owner->GetAIDifficultyIndex()); | ||
double detectionValue = 1.0; | ||
|
||
if (pTechnoData->DetectDisguise_Percent.size() == 3) | ||
detectionValue = pTechnoData->DetectDisguise_Percent[AIDifficulty]; | ||
|
||
detectionValue = detectionValue > 0.0 ? detectionValue : 1.0; | ||
disguiseDetection.push_back(detectionValue); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -194,7 +208,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c | |
enemyHouse = HouseClass::Array->GetItem(pLeaderUnit->Owner->EnemyHouseIndex); | ||
|
||
int targetMask = scriptArgument; | ||
selectedTarget = GreatestThreat(pLeaderUnit, targetMask, calcThreatMode, enemyHouse, attackAITargetType, idxAITargetTypeItem, agentMode); | ||
selectedTarget = GreatestThreat(pLeaderUnit, targetMask, calcThreatMode, enemyHouse, attackAITargetType, idxAITargetTypeItem, agentMode, disguiseDetection); | ||
|
||
if (selectedTarget) | ||
{ | ||
|
@@ -399,7 +413,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c | |
} | ||
} | ||
|
||
TechnoClass* ScriptExt::GreatestThreat(TechnoClass* pTechno, int method, int calcThreatMode = 0, HouseClass* onlyTargetThisHouseEnemy = nullptr, int attackAITargetType = -1, int idxAITargetTypeItem = -1, bool agentMode = false) | ||
TechnoClass* ScriptExt::GreatestThreat(TechnoClass* pTechno, int method, int calcThreatMode = 0, HouseClass* onlyTargetThisHouseEnemy = nullptr, int attackAITargetType = -1, int idxAITargetTypeItem = -1, bool agentMode = false, std::vector<double> disguiseDetection = {}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass the value of |
||
{ | ||
TechnoClass* bestObject = nullptr; | ||
double bestVal = -1; | ||
|
@@ -492,6 +506,29 @@ TechnoClass* ScriptExt::GreatestThreat(TechnoClass* pTechno, int method, int cal | |
&& object->Owner != pTechno->Owner | ||
&& (!pTechno->Owner->IsAlliedWith(object) || IsUnitMindControlledFriendly(pTechno->Owner, object))) | ||
{ | ||
if (object->IsDisguised()) | ||
{ | ||
if (disguiseDetection.size() == 0) | ||
continue; | ||
|
||
bool detected = false; | ||
|
||
for (double item : disguiseDetection) | ||
{ | ||
int dice = ScenarioClass::Instance->Random.RandomRanged(0, 99); | ||
int detectionValue = std::round(item * 100.0); | ||
|
||
if (detectionValue > dice) | ||
{ | ||
detected = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!detected) | ||
continue; | ||
} | ||
|
||
double value = 0; | ||
|
||
if (EvaluateObjectWithMask(object, method, attackAITargetType, idxAITargetTypeItem, pTechno)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,8 @@ class TechnoTypeExt | |
Nullable<Leptons> SpawnDistanceFromTarget; | ||
Nullable<int> SpawnHeight; | ||
|
||
ValueableVector<double> DetectDisguise_Percent; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is only use based on |
||
|
||
struct LaserTrailDataEntry | ||
{ | ||
ValueableIdx<LaserTrailTypeClass> idxType; | ||
|
@@ -359,6 +361,7 @@ class TechnoTypeExt | |
|
||
, SpawnDistanceFromTarget {} | ||
, SpawnHeight {} | ||
, DetectDisguise_Percent {} | ||
{ } | ||
|
||
virtual ~ExtData() = default; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont do this every time function called, fix this on
INIReading
moment instead.