2019-12-13 22:15 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000699Spring engineGeneralpublic2007-12-09 22:01
ReporterKDR_11k 
Assigned ToKDR_11k 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000699: [patch] limit weapon leading distance
DescriptionThis patch adds two weapon tags:
leadLimit: float, default -1
leadBonus: float, default 0

The weapon will never lead a target by more than leadLimit+experience*leadBonus elmos if leadLimit is non-negative (otherwise the lead distance is unlimited).

LeadLimit without leadBonus is useful for high arc weapons that tend to pretty much turn the other way and hit their own base when a fast target is moving towards them (and even if not a linear extrapolation rarely works if the shot is really slow).

It can also be used to simulate inexperienced units being bad at leading targets and getting better as they gain experience, especially in order to simulate the way leading worked in OTA.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon leadLimit.patch (3,113 bytes) 2007-12-04 19:16 -
    Index: Lua/LuaWeaponDefs.cpp
    ===================================================================
    --- Lua/LuaWeaponDefs.cpp	(revision 4926)
    +++ Lua/LuaWeaponDefs.cpp	(working copy)
    @@ -459,6 +459,8 @@
     	ADD_FLOAT("sprayAngle", wd.sprayangle);
     	ADD_FLOAT("movingAccuracy", wd.movingAccuracy);
     	ADD_FLOAT("targetMoveError", wd.targetMoveError);
    +	ADD_FLOAT("leadLimit", wd.leadLimit);
    +	ADD_FLOAT("leadBonus", wd.leadBonus);
     
     	ADD_BOOL("noSelfDamage", wd.noSelfDamage);
     	ADD_FLOAT("areaOfEffect", wd.areaOfEffect);
    Index: Sim/Weapons/Weapon.cpp
    ===================================================================
    --- Sim/Weapons/Weapon.cpp	(revision 4926)
    +++ Sim/Weapons/Weapon.cpp	(working copy)
    @@ -260,10 +260,14 @@
     			/* to prevent runaway prediction (happens sometimes when a missile is moving *away* from it's target), we may need to disable missiles in case they fly around too long */
     			predict = 50000;
     		}
    +		float3 lead = targetUnit->speed*predictSpeedMod*predict;
    +		if (weaponDef->leadLimit >= 0.0f && lead.Length() > weaponDef->leadLimit + weaponDef->leadBonus*owner->experience) {
    +			lead *= (weaponDef->leadLimit + weaponDef->leadBonus*owner->experience) / lead.Length();
    +		}
     		if(weaponDef->selfExplode){	//assumes that only flakker like units that need to hit aircrafts has this,change to a separate tag later
     			targetPos=helper->GetUnitErrorPos(targetUnit,owner->allyteam)+targetUnit->speed*(0.5f+predictSpeedMod*0.5f)*predict;
     		} else {
    -			targetPos=helper->GetUnitErrorPos(targetUnit,owner->allyteam)+targetUnit->speed*predictSpeedMod*predict;
    +			targetPos=helper->GetUnitErrorPos(targetUnit,owner->allyteam)+lead;
     		}
     		targetPos+=errorVector*(weaponDef->targetMoveError*30*targetUnit->speed.Length()*(1.0f-owner->limExperience));
     		float appHeight=ground->GetApproximateHeight(targetPos.x,targetPos.z)+2;
    Index: Sim/Weapons/WeaponDefHandler.cpp
    ===================================================================
    --- Sim/Weapons/WeaponDefHandler.cpp	(revision 4926)
    +++ Sim/Weapons/WeaponDefHandler.cpp	(working copy)
    @@ -229,6 +229,8 @@
     	wd.movingAccuracy = sin((movingAccuracy) * PI / 0xafff);
     
     	wd.targetMoveError = wdTable.GetFloat("targetMoveError", 0.0f);
    +	wd.leadLimit = wdTable.GetFloat("leadLimit", -1.0f);
    +	wd.leadBonus = wdTable.GetFloat("leadBonus", 0.0f);
     
     	// setup the default damages
     	const LuaTable dmgTable = wdTable.SubTable("damage");
    Index: Sim/Weapons/WeaponDefHandler.h
    ===================================================================
    --- Sim/Weapons/WeaponDefHandler.h	(revision 4926)
    +++ Sim/Weapons/WeaponDefHandler.h	(working copy)
    @@ -50,6 +50,8 @@
     	float sprayangle;						// inaccuracy of individual shots inside burst
     	float movingAccuracy;					// inaccuracy while owner moving
     	float targetMoveError;					// fraction of targets move speed that is used as error offset
    +	float leadLimit;                        // maximum distance the weapon will lead the target
    +	float leadBonus;                        // factor for increasing the leadLimit with experience
     
     	DamageArray damages;
     	float areaOfEffect;
    
    patch file icon leadLimit.patch (3,113 bytes) 2007-12-04 19:16 +

-Relationships
+Relationships

-Notes

~0001485

KDR_11k (reporter)

Committed in r4971 with some changes (works for flaks now).
+Notes

-Issue History
Date Modified Username Field Change
2007-12-04 19:16 KDR_11k New Issue
2007-12-04 19:16 KDR_11k File Added: leadLimit.patch
2007-12-09 21:32 KDR_11k Status new => assigned
2007-12-09 21:32 KDR_11k Assigned To => KDR_11k
2007-12-09 22:01 KDR_11k Status assigned => resolved
2007-12-09 22:01 KDR_11k Resolution open => fixed
2007-12-09 22:01 KDR_11k Note Added: 0001485
+Issue History