non-turreted weapon?

non-turreted weapon?

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
thesleepless
Posts: 417
Joined: 24 Oct 2007, 04:49

non-turreted weapon?

Post by thesleepless »

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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: non-turreted weapon?

Post by KDR_11k »

Look at something like the KP Pointer or the S44 assault guns.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Re: non-turreted weapon?

Post by Guessmyname »

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.
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)

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.
User avatar
Strategia
Posts: 575
Joined: 06 Apr 2006, 18:32

Re: non-turreted weapon?

Post by Strategia »

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.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Re: non-turreted weapon?

Post by Nemo »

All of our weapons are turret = 1 using limited fire arc. it works pretty well.
Saktoth
Zero-K Developer
Posts: 2665
Joined: 28 Nov 2006, 13:22

Re: non-turreted weapon?

Post by Saktoth »

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. ;)
User avatar
thesleepless
Posts: 417
Joined: 24 Oct 2007, 04:49

Re: non-turreted weapon?

Post by thesleepless »

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

Code: Select all

weapons             = {

   {
      def                = [[EMG]],
      badTargetCategory  = [[FIXEDWING]],
      onlyTargetCategory = [[FIXEDWING LAND SINK SHIP SWIM FLOAT GUNSHIP HOVER]],
	  maxAngleDif		 = 35,
	  mainDir			 = [[0 0 1]],
    },

  },
Post Reply

Return to “Game Development”