height dependant range

height dependant range

Requests for features in the spring code.

Moderator: Moderators

ohooli
Posts: 3
Joined: 29 Apr 2007, 07:52

height dependant range

Post by ohooli »

towers and cannons and units and such should have height dependent ranges, so it would make it more strategic to place a gun turret on a tall hill.
User avatar
Ishach
Posts: 1670
Joined: 02 May 2006, 06:44

Post by Ishach »

they already do i think
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Depends on the weapon, ballistics fly further I think but e.g. lasers obviously don't get a boost (and can disappear before reaching the target if the height difference is too big). Of course there's no logical reason for a laser to get more range from a higher location, all they get is less chance that terrain or features block their line of fire.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

height has a huge effect on range.
User avatar
Fanger
Expand & Exterminate Developer
Posts: 1509
Joined: 22 Nov 2005, 22:58

Post by Fanger »

Im pretty sure that range functions on a cylinder capped with a sphere at the top.. could be wrong but it has always seemed to me that when a unit is up on a hill it can still fire out to its max range in the flat, even though looking at it in 3d you can see that it has actually surpassed its max range, this conveys a massive advantage to units up on high ground with a medium difference in height as they can essentially fire as though they were on perfectly flat ground, but they arent, where as units attack up the hill are acting as they they are firing up and thus are limited by their max range..
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

It sounded like he wanted the actual delta between shooter and target in relationship to maximum range limits to be influenced by the height delta.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Post by yuritch »

Part of the problem of units firing up and not hitting is that targetting code uses a cylinder, but actual projectile is limited by a sphere (at least by upper half of a sphere, I haven't tested firing down). This can be seen easily by giving an aircraft a high CruiseAlt (like 1000) and then flying it over some enemy ground units so they shoot at it. The units will shoot even if their max range is something like 500. They won't actually hit the plane (projectiles will exceed max range and disappear/fall back, depending on projectile type), but targetting code doesn't account for that.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

MadRat wrote:It sounded like he wanted the actual delta between shooter and target in relationship to maximum range limits to be influenced by the height delta.
You're using fancy words to say "the unit on the hill shoots farther". Did you realize between pulling out all these words like delta that that's not a counterargument as the unit on the hill can already shoot farther?

yuritch: Strange, I'm fairly sure units in Gundam won't shoot until the com is pretty much right above them and some can't even shoot that high (try flying gunperries over Zakus). However, the com will shoot back even at ranges twhere its shots just disappear. The projectile is always limited to a sphere (well, line of sight projectiles, ballistics are limited to a parable) but the aim is limited to a sphere only when aiming up, to a cylinder when aiming down. I.e. I second Fanger's observations.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

I've noticed that too, height doesn't seem to exist for flying units with LOS weapons.
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post by LathanStanley »

its conical on the lower end. The top end is is a semicircle.

make a map to test on, with a ramp and a flat distance on the other side (parallel to the ramp)

make the map small, and play with TAB view, direct down.

measure as the unit walks up the ramp.

its circle off the ramp ALWAYS gets bigger. thus, it meets a tangental line on the semicircle up top, and continues in a straight line down.

(the degree it is tangental at, I do not know.)

here is a graphic to show the info:
Image
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

If this applies to fliers as well then we know the reason.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Post by TradeMark »

Would be nice to have realistic height dependent range...
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Post by yuritch »

KDR_11k wrote:yuritch: Strange, I'm fairly sure units in Gundam won't shoot until the com is pretty much right above them and some can't even shoot that high (try flying gunperries over Zakus). However, the com will shoot back even at ranges twhere its shots just disappear. The projectile is always limited to a sphere (well, line of sight projectiles, ballistics are limited to a parable) but the aim is limited to a sphere only when aiming up, to a cylinder when aiming down. I.e. I second Fanger's observations.
My test was made witn Spring 0.74b3, maybe it's different in latest svn. The plane had CruiseAlt=1000, ground units had range=750, they constantly fired at the plane and no projectiles actually reached it. The weapon on those units was of non-beam laser type.
Thing with the Gundam com is probably that it's very large. AFAIK wepon ranges are calculated relative to target's center, so while a part of that flying fortress may be over a unit, its center is still out of range.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Try it with a Gundam epic com and aqua GMs. Those guys won't shoot unless they are under the exact center of the com and the stars align JUST right.
User avatar
Fanger
Expand & Exterminate Developer
Posts: 1509
Joined: 22 Nov 2005, 22:58

Post by Fanger »

I call for someone with some knowledge of coding (IE who can read the crap, as I cant or I would do it myself) go into the source code, and look up the aiming weapon stuff to confirm or deny our theories..
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

KDR_11k wrote:
MadRat wrote:It sounded like he wanted the actual delta between shooter and target in relationship to maximum range limits to be influenced by the height delta.
You're using fancy words to say "the unit on the hill shoots farther". Did you realize between pulling out all these words like delta that that's not a counterargument as the unit on the hill can already shoot farther?
If you understood the fancy stuff then you'd of realized its different than what you believed it to be saying. If you don't understand the terminology you could ask me to explain. The terms are pretty standard in the phyics world and I can assume you didn't take any class on the subject matter. Whenever you see delta its a difference in relative measurement between two objects. The measurements could be most anything, but in this example its the difference in positions measured in all three dimensions. The original poster was in my opinion asking for units to be able to exploit their longer potential range if they enjoy a height advantage relative to the target. It is not just about shooting farther, its about being able to actually aim on those targets because it has that advantage. Otherwise you have to use a kludge like manually forced fire to get the desired result. So before you're a smart ass with someone try not to be ignorant.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

You said the height difference influences the range difference. "Influences" says jack shit about the kind of relation. For all we know you could have said that the higher unit has less range.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Post by yuritch »

Fanger wrote:I call for someone with some knowledge of coding (IE who can read the crap, as I cant or I would do it myself) go into the source code, and look up the aiming weapon stuff to confirm or deny our theories..
I looked into weapon code and found this:

Code: Select all

bool CWeapon::TryTarget(const float3 &pos,bool userTarget,CUnit* unit)
{
	if(unit && !(onlyTargetCategory&unit->category))
		return false;

	if(weaponDef->stockpile && !numStockpiled)
		return false;

	float3 dif=pos-weaponPos;

	float r=range+(owner->pos.y-pos.y)*heightMod;
	if(dif.SqLength2D()>r*r)
		return false;

	if(maxMainDirAngleDif>-0.999f){
		dif.Normalize();
		float3 modMainDir=owner->frontdir*mainDir.z+owner->rightdir*mainDir.x+owner->updir*mainDir.y;

//		geometricObjects->AddLine(weaponPos,weaponPos+modMainDir*50,3,0,16);
		if(modMainDir.dot(dif)<maxMainDirAngleDif)
			return false;
	}
	return true;
}
Take note of

Code: Select all

	if(dif.SqLength2D()>r*r)
		return false;
part. If that is what I think it is, then it uses 2D distance. SqLength2D() is defined as "return x*x+z*z;", so it ignores y coordinate. I'm not sure what

Code: Select all

r=range+(owner->pos.y-pos.y)*heightMod;
does, though.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Multiplies the difference in height between the shooter and the target with heightMod, some multiplier and adds that to the unit's range.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Post by yuritch »

I understand what it does, I don't understand why it does that. The multiplier seems to be 0.8 for cannons (ballistic weapons), 0.2 for everything else (look in WeaponDefHandler.cpp). Any ideas as to why this is needed?
Post Reply

Return to “Feature Requests”