2025-08-01 19:08 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001148Spring engineGeneralpublic2009-01-15 12:33
Reporterlurker 
Assigned Tolurker 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001148: [PATCH] Target Generation Magic
DescriptionMake it so GenerateTargets generally doesn't have access to information the team using it doesn't have, such as unit health, unitdef, etc.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • diff file icon generatetargetsmagic.diff (2,630 bytes) 2008-10-15 12:39 -
    Index: rts/Game/GameHelper.cpp
    ===================================================================
    --- rts/Game/GameHelper.cpp	(revision 6750)
    +++ rts/Game/GameHelper.cpp	(working copy)
    @@ -420,9 +420,10 @@
     					}
     					float3 targPos;
     					float value = 1.0f;
    -					if (unit->losStatus[attacker->allyteam] & LOS_INLOS) {
    +					short unitLos = unit->losStatus[attacker->allyteam];
    +					if (unitLos & LOS_INLOS) {
     						targPos = unit->midPos;
    -					} else if (unit->losStatus[attacker->allyteam] & LOS_INRADAR) {
    +					} else if (unitLos & LOS_INRADAR) {
     						const float radErr = radarhandler->radarErrorSize[attacker->allyteam];
     						targPos = unit->midPos + (unit->posErrorVector * radErr);
     						value *= 10.0f;
    @@ -432,27 +433,32 @@
     					const float modRange = radius + (aHeight - targPos.y) * heightMod;
     					if ((pos - targPos).SqLength2D() <= modRange * modRange){
     						float dist2d = (pos - targPos).Length2D();
    -						value *= (secDamage + unit->health);
     						value *= (dist2d * weapon->weaponDef->proximityPriority + modRange * 0.4f + 100.0f);
    -						value *= (0.01f + unit->crashing);
    -						value /= weapon->weaponDef->damages[unit->armorType]
    -										 * unit->curArmorMultiple
    -						         * unit->power * (0.7f + gs->randFloat() * 0.6f);
    -						if (unit == lastTarget) {
    -							value *= weapon->avoidTarget ? 10.0f : 0.4f;
    +						if (unitLos & LOS_INLOS) {
    +							value *= (secDamage + unit->health);
    +							if (unit == lastTarget) {
    +								value *= weapon->avoidTarget ? 10.0f : 0.4f;
    +							}
    +							if (paralyzer && unit->health-unit->paralyzeDamage < unit->maxHealth * 0.09f) {
    +								value *= 4.0f;
    +							}
    +							if (weapon->hasTargetWeight) {
    +								value *= weapon->TargetWeight(unit);
    +							}
    +						} else {
    +							value *= (secDamage + unit->maxHealth);
     						}
    -						if (unit->category & weapon->badTargetCategory) {
    -							value *= 100.0f;
    +						if (unitLos & LOS_PREVLOS) {
    +							value /= weapon->weaponDef->damages[unit->armorType]
    +											 * unit->curArmorMultiple
    +									 * unit->power * (0.7f + gs->randFloat() * 0.6f);
    +							if (unit->category & weapon->badTargetCategory) {
    +								value *= 100.0f;
    +							}
    +							if (unit->crashing) {
    +								value *= 1000.0f;
    +							}
     						}
    -						if (paralyzer && unit->health-unit->paralyzeDamage < unit->maxHealth * 0.09f) {
    -							value *= 4.0f;
    -						}
    -						if (unit->crashing) {
    -							value *= 10.0f;
    -						}
    -						if (weapon->hasTargetWeight) {
    -							value *= weapon->TargetWeight(unit);
    -						}
     						targets.insert(std::pair<float, CUnit*>(value, unit));
     					}
     				}
    
    diff file icon generatetargetsmagic.diff (2,630 bytes) 2008-10-15 12:39 +

-Relationships
+Relationships

-Notes

~0002918

lurker (reporter)

Just noticed it should probably use 'unsigned short' instead of 'short'. Not really worth uploading a new version, just stick that in when applying.

~0003037

lurker (reporter)

Committed, passed a while of testing, but it does make some changes, leaving open for a while.
+Notes

-Issue History
Date Modified Username Field Change
2008-10-15 12:39 lurker New Issue
2008-10-15 12:39 lurker File Added: generatetargetsmagic.diff
2008-10-15 12:45 lurker Note Added: 0002918
2008-10-26 11:57 lurker Note Added: 0003037
2008-10-26 11:57 lurker Assigned To => lurker
2008-10-26 11:57 lurker Status new => assigned
2009-01-15 12:33 lurker Status assigned => resolved
2009-01-15 12:33 lurker Resolution open => fixed
+Issue History