ok, i've made my unit model and texture and now i'm trying to script it to make it work in game.
it moves fine, and looks great, except it since it doesn't have a turret for its weapon it can't aim.
when its weapon has turret = false it just refuses to fire at anything that isn't in its tolerance, so you have to manually change its direction then tell it to fire infront of it. this is no good.
when set to turret = true it rotates to face its target correctly, but it fires during turning with the projectiles always going in the direction of its target even though the gun isnt facing that direction.
so my question is, how do you get a weapon that only fires forward and will cause the whole unit to rotate when it needs to aim at something?
thanks.
non-turreted weapon?
Moderator: Moderators
Re: non-turreted weapon?
Look at something like the KP Pointer or the S44 assault guns.
- Guessmyname
- Posts: 3301
- Joined: 28 Apr 2005, 21:07
Re: non-turreted weapon?
Use wait-for-turn <piece> in the AimWeaponX script, and it will wait until it has the proper orientation (you can use a dummy piece for this if you want, just have it turn as fast as the unit itself can turn, and viola)thesleepless wrote:when set to turret = true it rotates to face its target correctly, but it fires during turning with the projectiles always going in the direction of its target even though the gun isnt facing that direction.
Another way you could do it is with a second, turret=0; dummy weapon with the same range: the unit would turn to the correct orientation per the described behaviours, and - in theory - when it reaches the correct orientation, the dummy would try to fire as well. Use this to set up the actual weapon to only be able to fire when the dummy is firing, via a while(dummyWeaponIsFiring==FALSE) sleep loop the unit's script (dummyWeaponIsFiring being a static-var set to TRUE when the dummy weapon is, well, firing).
One fun thing you could do is make the dummy weapon a visible red beamlaser (that does no damage), making it look like a targetting laser and the unit is locking on ^_^
That second approach is entirely theoretical, though. I've only just thought it up; no idea how well it would actually work.
Re: non-turreted weapon?
I don't know about coding, but S44's predecessor in OTA had non-turreted vehicles (tank destroyers, artillery) work by using the entire vehicle model as a turret, so the model turned but the selection box on the ground didn't. It's a hacky, somewhat ugly workaround and I don't know how or even if it'd work with Spring, but it might be a stopgap until you get ^ the proper code to work.
Re: non-turreted weapon?
All of our weapons are turret = 1 using limited fire arc. it works pretty well.
Re: non-turreted weapon?
For your missile skimmer deal, either turret the entire unit or give it a fixedlauncher.
Or just let us script it, we have people who can do this.
Or just let us script it, we have people who can do this.

- thesleepless
- Posts: 417
- Joined: 24 Oct 2007, 04:49
Re: non-turreted weapon?
got it working using fixed angle, the reason it wasn't working before is the syntax has changed for the lua unit defs.
need to do
need to do
Code: Select all
weapons = {
{
def = [[EMG]],
badTargetCategory = [[FIXEDWING]],
onlyTargetCategory = [[FIXEDWING LAND SINK SHIP SWIM FLOAT GUNSHIP HOVER]],
maxAngleDif = 35,
mainDir = [[0 0 1]],
},
},