Stupid weapon range issues

Stupid weapon range issues

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Stupid weapon range issues

Post by aGorm »

Right, so I have a missile tank. It also has a laser for extra defense. its missiles only fire when its deployed and it dont move when deployed. So far so good, as that all works.

Here's the problem though. When its not deployed (and cant fire missiles) it wont move to attack with its laser (with its shorter range) as the missles (which cant fire) are in range and it seems to think thats enough.

So I thought, hay I'll swap the weapons around so the laser is the primary, as it wont be able to move into range with the laser anyway when its deployed it wont matter.

However this had an advers side effect in that it won't shoot the missiles now unless you aim only within the range of the laser. It's like its waiting for the laser to be in range befor it cheacks the secondary weapon.

So basicly, I'm wondering is there a way to switch a weapon off properly (IE ignore it compleatly) instead of just blocking it in script, or does anyone know of any work arounds?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Stupid weapon range issues

Post by knorke »

I think primary weapon is always used for the move-into-range behavior.
Maybe changing weapon range via script and Spring.SetUnitWeaponState might work but not sure if it works at all?
workaround:
The deployable gun could be an invisible fake unit that gets created on deploying and deleted on undeploying. The invisible fake unit talks to the real unit and tells it how to animate the turret etc.
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: Stupid weapon range issues

Post by aGorm »

Workaround sounds like a lot of work for somthing so trivial...

Im thinking maybe swap the unit when deployed with a differn't unit, but then again, that seems stupid seeing as how I cant think of a reason why the engin would want to limit the range of all weapons to that of the lowest range weapon (effectivly what its done). Feels like a rather stupid bug in the engin that we should have to work around. I fact I'm kinda surpirsed no ones noticed it before... there must be similar units...
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Stupid weapon range issues

Post by smoth »

unit switch is probably your cleanest bet man
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: Stupid weapon range issues

Post by aGorm »

Bothers... OK anyone point me to some example code :-( and I'll give it a go (I see this one little thing taking more than 1 lunch break to fix... dam it all. How does everyone else seem to get so much done...)
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Stupid weapon range issues

Post by smoth »

Probably can cannibalize the morph gadget..
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Stupid weapon range issues

Post by FLOZi »

In the second case, did you test the missiles attacking ground or against enemy units? I suspect they will still properly target enemies even if they won't attack ground.

I might consider doing unit swapping directly in the LUS for something like this if its the only way
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Stupid weapon range issues

Post by bobthedinosaur »

if he is doing lus he can also adjust the range. so maybe doing a longer range but still block the laser might help? or a 0 range for the missiles being mobile?
User avatar
Deadnight Warrior
Posts: 183
Joined: 08 Jun 2009, 17:59

Re: Stupid weapon range issues

Post by Deadnight Warrior »

In a proof-of-concept game I made I used

Code: Select all

if factory_buttons[factories[UnitDefs[factDefID].name]].turret_cmdDesc.params[curFactory.turret+2]:find("Radar",1,true) then
	Spring.SetUnitSensorRadius(unitID, "radar", Spring.GetUnitSensorRadius(unitID, "radar") * sensors)
	Spring.SetUnitWeaponState(unitID, 0, "range", 1)
else
	Spring.SetUnitWeaponState(unitID, curFactory.turret, "range", Spring.GetUnitWeaponState(unitID, curFactory.turret, "range") * sensors)
	Spring.SetUnitWeaponState(unitID, 0, "range", Spring.GetUnitWeaponState(unitID, curFactory.turret, "range"))
end
Long story short, I check which turret I enabled on a chasis and adjust weapon[0] to the range of the chosen weapon, or set it to 1 if I attached radar turret instead. Variable sensors ranges from 1 to 1.25 and allows for extended range of a turret (option when building a unit with long-range targeting sesors), factory turrets range from 0 to 3 (4 for radar) and enable one of the predefined weapons in a unitDef.

I do this in gadget:UnitFromFactory and not in LUS
Post Reply

Return to “Game Development”