Game Development Community

Homing Missiles

by Martin Schultz · in Torque Game Engine · 10/29/2002 (4:03 am) · 43 replies

Hi there,

did anyone get homing missiles working? Script oder C++ based? Any experience would be great :)

Thanks in advance,

Martin
Page «Previous 1 2 3 Last »
#1
10/29/2002 (5:13 am)
Luigi Rossi posted one he wrote a while back on his website. Check here...

http://cirrus.realityslip.com/index.php
#2
10/30/2002 (2:23 am)
Thanks!
#3
10/31/2002 (2:05 pm)
Hi,

I tried the resource from luigi. the copy & paste code from the site didn't work on the latest head (after spending some hours on it :)

Is there any other source for homing/seeking projectiles known that work with the current head?

Martin
#4
10/31/2002 (2:12 pm)
Muerte What problems are you having? I added the homing missiles to the Head yesterday and got all but the textures to work. You can't just cut and paste you have to add a getHead function AND a lockObjecType variable, also you have to add to ClientTargetSet. . . . basically tell me your errors and I will explain how to fix them as best I can, I had posted the fixes on his site but my comments are gone, once I get the textures to work I 'll have everything ready for a full head merge.
#5
10/31/2002 (3:03 pm)
I can now totally impliment the homing missile with HUD iss youy want to know how post here so it can be a resource for others
#6
11/01/2002 (5:05 am)
Anthony,
Could you post your fixes here? I've added that homing code and had problems with it using the HEAD engine as well.
#7
11/01/2002 (5:19 am)
Hi there,

I will post the errors I had this evening when I'm back at home. Seems like there's a demand for clearing this issue up :)

Would be cool if we can get this working together and make it available for others, like written above.

Best,
Martin
#8
11/01/2002 (5:20 am)
Anthony,

I was about to try this soon with the head version, so if you could post the fix, I'd appreciate also.

Thanks !
#9
11/01/2002 (8:31 am)
Alright Here it is, First off I didn't not figure this out a very Smart Kind person by the name of Ice helped me with this, also it is Not 100 percent working due to the fact the Heating managment system was ripped out I am trting to figure out how to get the code to read my heat variables from the scripts but right now it only reads from the constuctor. So all Shapebase objects that are added to the targetset will be detected. If this sounds confusing well it did for me too.
First
In shapeBase.h
in the ShapeBaseImageData struct
in public add a new variable
U32 lockObjectType;
goto shapeimage.cc
add and set the variable in the contructor to 0
lockObjectType = 0;
in the funtion
ShapeBaseImageData::initPersistFields()
add a new field
addField("lockObjectType",   TypeS32, Offset(lockObjectType, ShapeBaseImageData));
back to shapbase.h

in shapeBase struct
in protected add variable
F32 mHeat
in public add new function
F32  getHeat() { return mHeat; }
In ShapeBase.cc
in the constuctor for ShapeBase
set mHeat = 0;
Also to add items to the target list go to player.cc or wheeledvehicle .cc and in the Player::onadd function right after the line
scriptOnAdd();
make sure both of these calls are there
Sim::getServerTargetSet()->addObject(this);
Sim::getClientTargetSet()->addObject(this);
OK now we have vehicles/players with heat that is set to 0.0 and those type of object will be in the target set. We need to do one last thing that is missing from the tutorial , initalized the seek/lockReticleName to Texture
Open up shapeimage.cc go to the preload function
right before the line

TSShapeInstance* pDummy = new TSShapeInstance(shape, !server);

add this code
//initalize textures for Missile_launcher Hud
if(lockReticleName && lockReticleName[0] != '[[62815f407fa73]]')
lockReticleTexture.set(lockReticleName);
if(seekReticleName && seekReticleName[0] != '[[62815f407fa73]]')
seekReticleTexture.set(seekReticleName);

Finally in your missile_launcher.cs file in the
datablock ShapeBaseImageData(MissileLauncherImage)

add a varible like this
lockObjectType = $TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType ;

That Should Work. It will determine possible targets then lock on to them after a bit of time. W/o the Heat management system working all the objects on the target list will be selected also it will render the minHeat varible useless until it gets fixed. So if you have a heat managemtn system please explain what we need. This is an excellent tutorial that Luigi have given the community I sure many others will benifit greatly if we can get it totally done.
#10
11/01/2002 (11:38 am)
Hi there,

Anthony: Big thanks for the lines you wrote.

I did again a step-by-step going through Luigi's tutorial and wrote down each error I got in a textfile (pasted in a bit down). I was able to fix all errors and got it working with your help!!!

One question is left, about the right character comparison, if I did it right (the stuff with the "casingShapeName"). Anthony, may you answer this too (very bottom of this message)? :)

But nevertheless, for all others, who might try to get in homing weapons at a later stage, it should give now a full insight about all the troubles one might went through (like me ;)

Ok, here's my experience:

------------------------------------------------------------

Small typo found at "shapeBase.cc " around line 2301:

"lMatrixMode" should be "glMatrixMode"

Page 6 in Luigi's tutorial. Complete original line is:
lMatrixMode(GL_MODELVIEW);

------------------------------------------------------------

Typo at shapeImage.cc:

ShapeBaseImageData::ShapeBaseImageData()
{
lockReticleName = NULL;
seekReticleName = NULL

Missing semicolon in the second line, so:

ShapeBaseImageData::ShapeBaseImageData()
{
lockReticleName = NULL;
seekReticleName = NULL;

would be correct. Typo is in page 3 on the very top in Luigi's tutorial.

------------------------------------------------------------

Missing declaration in shapeImage.cc:

"lockObjectType"

See Anthony's answer above for that.

------------------------------------------------------------

Missing method in shapeImage.cc:

getHeat

See Anthony's answer above for that.
(by the way: mHeat variable is already in there in my HEAD release)

------------------------------------------------------------

seekerProjectile.cc

Take care of the line breaks! The text of the "dSprintf(errorBuffer,..." and "Con::errorf..." functions are line wrapped. You need to concatenate them back to the line before. (maybe a browser problem on my side? ie6?!?). Ok, not a hard problem, just some times pressing the backspace key :)

------------------------------------------------------------

Typo on page 15 - function

void SeekerProjectile::launchDebris()
{

The line:

mObjBox.getCenter(
#11
11/01/2002 (11:58 am)
First off
[quote]
Typo on page 15 - function

void SeekerProjectile::launchDebris()
{

The line:

mObjBox.getCenter(
#12
11/01/2002 (12:35 pm)
Quote:
Im not sure where you are talking about casingShapeName, but the variable set in the scripts tells the turret what possible types to aim at of those added to targetList example if you wanted flares you would add the server/clientTargetList in Item.cc then in the script make the variable lockObjectType to include ItemObjectType;

Found it. I referred in the text to the missileLauncher.cs:

datablock SeekerProjectileData(MissileProjectile)
{
casingShapeName= "~/data/shapes/projectile.dts";
projectileShapeName = "~/data/shapes/projectile.dts";

The casing shape is the one when the missile gets straight up in the air. When it then faces the target, the projectileShape is used. I tested it with replacing the casingShapeName path with the one of the buggy. Looks funny! :)

Quote:
Finally we need the heat working it is really similar to the energy managment I'll work on it as soon as I know I got some time to do so or YOU, please!!!!

Well :-) I definately WILL spend some time hopefully finding this stuff out. Let's wait and see ;-)

Anyway, so far I'm totally happy that seeking missiles work now pretty cool! Thanks!
#13
11/01/2002 (12:41 pm)
LOL I know the feeling but until it works it'll target everything or nothing, I think I got the solution, but I got called in to work, NEVER FEAR I'll be off tomorrow and hope to impliment a full system, want a start, look at repairRate, rechargeRate and how they are used in both the scripts and the code
#14
11/01/2002 (3:30 pm)
Yeah well I got off of work and Guess what I finished the code. All this really done is take the variable from the dataBlocks and stores it dynamically
in ShapeBase.h
under our getHeat function add this function
void setHeat(F32 heatRate) { mHeat = heatRate; }
in the ShapeBasedata struct add public section a new variable
F32 heat;
next in Shapebase.cc
in the shapebasedata constructor initalize the variable
heat = 0;
In void ShapeBaseData::initPersistFields()
add
addField("heat",           TypeF32,        Offset(heat,           ShapeBaseData));

in void ShapeBase::consoleInit()
add
Con::addCommand("ShapeBase", "setHeat", cSetHeat, "obj.setHeat(value)", 3, 3);
   Con::addCommand("ShapeBase", "getHeat", cGetHeat, "obj.getHeat()", 2, 2);
these are console functions
add these with the rest of the console function
static void cSetHeat(SimObject *ptr, S32, const char **argv)
{
   ShapeBase* obj = static_cast<ShapeBase*>(ptr);
   F32 rate = dAtof(argv[2]);
   if(rate < 0)
      rate = 0;
   obj->setHeat(rate);
}

static F32 cGetHeat(SimObject *ptr, S32, const char **)
{
   ShapeBase* obj = static_cast<ShapeBase*>(ptr);
   return obj->getHeat();
}


Finally in player.cs look for the Armor::0nAdd(%this,%obj)
add
%obj.setHeat(%this.heat);
Now when a player is added the heat in their datablock will be set. You can use this command with all the vehicles just make sure the variable names match those in the function I'll work on flares next to get some more advanced stuff.
#15
11/01/2002 (4:42 pm)
wow, you're pretty fast! :-)

I'll try this tomorrow - looks promising!

Martin
#16
11/01/2002 (8:34 pm)
Wow, you guys rocks ! I'm stuck doing other stuff but I will sure try all this really soon. Was really happy to see my mail filled with "Homing missile" topic tonight :) Thanks for your time and tips with this.
#17
11/02/2002 (3:40 am)
Hi,

it works fine with just one exception: when I climb with my car a rock and the "nose" of the car looks in the air, it sometimes locks on something in the air. When I try to shoot it, the rocket comes back to me. :-) I will take later some time to find out what there happens.

About the heat variables: In my head the "heat" variable was already in there. Anthony, did you have this too in your build?

Important note: I experienced, if you switch back from a weapon image WITH homing projectiles back to weapons WIHTOUT home projectiles, I noticed a white square image around my crosshair. I found out, when I add to all non-seeking weapons in the datablock

datablock ShapeBaseImageData(MFRLImage)
{
lockReticle = "~/data/shapes/mfrl/lockReticle";
seekReticle = "~/data/shapes/mfrl/seekReticle";

with those images as purely transparent (so nothing in in these images), the white square bitmap disappears due to the transparency. Uhm, strange sentence I wrote... is it understandable? :)

Seems like the seek/lock images also appear on the screen also with non-seeking weapons.

So far my newest experiences.

Martin :)
#18
11/02/2002 (5:58 am)
Sorry I've been gone for the past few weeks due to conferences and a beast load of work. I lost a big chunk of the database due a mysql crash and had to revert to an older snapshot.

I had the fixes posted on the forum but I fear most of the important ones were lost.

Quote:
if (casingShapeName && casingShapeName[0] != 'seekerProjectile.cc continuation...')

should be:

if (casingShapeName && casingShapeName[0] != NULL)

The casing is the little box that the missile should appear to be in before it gets launched (before acceleration kicks in) then the casing should appear to be blown to bits (with the debris). The projectile is then rendered with its normal shape. I used the Tribes 2 shapes and it looked right :) you just need to tweak the delay times so things look right.

I'm going to be reimplementing all this code into the latest head as soon as I get a weekend free and I'll be updating both of the tutorials (plus finishing off a couple other ones).

I had to reimplement the heat management but I didn't add it all to the tutorial as lots of it was jetpack and turret dependent and those makes up two new tutorials (turrets and jetpacks) :)

The lock and seek reticles create a targeter over your current target. The seek reticle is used while the you are attempting to acquire target lock and the lock one is used when the target has been locked.

Quote:
it works fine with just one exception: when I climb with my car a rock and the "nose" of the car looks in the air, it sometimes locks on something in the air. When I try to shoot it, the rocket comes back to me. :-) I will take later some time to find out what there happens.

I haven't looked at the vehicle physics much but it's possible that you're locking on yourself due to a sudden jolt of position (client and server may not be synched in that instant)... do some tracing to get the id of the target you've locked.

Let me know if you still have questions.
#19
11/07/2002 (6:37 am)
The site seems down? Is this a resource now?
#20
11/07/2002 (7:55 am)
Anthony Rosenbaum wrote:
Quote:
You can't just cut and paste you have to add a getHead function

I wish there was such a function..I would surely add it.
Page «Previous 1 2 3 Last »