Seeker projectile class
by Very Interactive Person · in Torque Game Engine · 10/13/2004 (12:54 am) · 15 replies
I'm using the seeker projectile class from the gamebeavers beaverpatrol demo.
I just added the seekerProjectile.cc and .h to the engine, and those changes alone don't seem to do much. Now I'm guessing I need to set the targets, so what I did is put a shedule on the projectile, and do a radius scan at regular intervals, then set the closest vehicle i find as the target. But, seeker.setTarget(%target) doesn't work. It says there's no such function setTarget(). In the code however i see:
Anyone who can help me? Do I need to change something to the engine code? I'm guessing I will have to change something to it, but i haven't got a clue what to do. The scripting part is no problem tough.
I just added the seekerProjectile.cc and .h to the engine, and those changes alone don't seem to do much. Now I'm guessing I need to set the targets, so what I did is put a shedule on the projectile, and do a radius scan at regular intervals, then set the closest vehicle i find as the target. But, seeker.setTarget(%target) doesn't work. It says there's no such function setTarget(). In the code however i see:
void SeekerProjectile::consoleInit()
{
Con::addCommand("SeekerProjectile", "setTarget", cSetTarget, "seeker.setTarget(obj)", 3, 3);
}Anyone who can help me? Do I need to change something to the engine code? I'm guessing I will have to change something to it, but i haven't got a clue what to do. The scripting part is no problem tough.
#2
Here's what i have on the script side of things btw:
Anyway, would you mind just passing your cc and h file to me? I could trade them for some artwork like skyboxes or something like that if you want.
10/14/2004 (4:03 am)
Hmmz no luck, it keeps saying it doesn't know any setTarget function, so i'm defenetly doing something wrong.Here's what i have on the script side of things btw:
function checkForTargets(%obj)
{
error(%obj SPC "is scanning for possible targets");
InitContainerRadiusSearch(%obj.getTransform(), 20, $TypeMasks::ShapeBaseObjectType);
%dist=50;
%target=0;
while ((%targetObject = containerSearchNext()) != 0) {
if(%targetObject != %obj.sourceObject){
%tempDist = vectorDist(%targetObject.getTransform(), %obj.getTransform());
if(%tempDist<%dist){
%dist=%tempDist;
%target=%targetObject;
}
}
}
%obj.setTarget(%target);
error("locked on to" SPC %target);
schedule(1000,%obj,"checkForTargets",%obj);
}Does this look like alright to you?Anyway, would you mind just passing your cc and h file to me? I could trade them for some artwork like skyboxes or something like that if you want.
#3
10/14/2004 (4:32 pm)
I don't see anything wrong with that function. Did you make sure that you replaced this function with the console method?static bool cSetTarget(SimObject *ptr, S32, const char **argv)
#4
10/15/2004 (2:57 am)
Yep, I did... that function is no longer there, and the new function was added. Compiled it, replaced the exe, but I still get console warnings there's no setTarget function available.
#5
The only thing with them is that my projectiles fly backwards (they're rockets, and they fly with the rocketengine to the front sometimes). I use the same models for regular projectiles and as far as I know it doesn't do that for regular projectiles.
Also, for some strange reason they sometimes stop in mid air (even tough they're locked on to a target nearby), and just hang there... till they fade out. Is this a problem with my settings, or are you experiencing similar things?
10/19/2004 (2:41 am)
Turns out it was just me... made a little mistake in the scripts. So its working now.The only thing with them is that my projectiles fly backwards (they're rockets, and they fly with the rocketengine to the front sometimes). I use the same models for regular projectiles and as far as I know it doesn't do that for regular projectiles.
Also, for some strange reason they sometimes stop in mid air (even tough they're locked on to a target nearby), and just hang there... till they fade out. Is this a problem with my settings, or are you experiencing similar things?
#6
10/25/2004 (11:17 pm)
I would be very interested in this.Why not make it a new resource?thanks.
#7
Get the files from gamebeavers, replace the console command function just like Josh said, and you can use the script I posted above for scanning.
10/26/2004 (2:46 am)
Everything you need to get them to work the same as they do in my game (wich isn't 100% flawless as you can see in my last post above) is in this thread.Get the files from gamebeavers, replace the console command function just like Josh said, and you can use the script I posted above for scanning.
#8
10/28/2004 (11:45 pm)
Thanks your reply.Is it put the scanning function in the MissileLauncherImage::onFire()?I try it for two days,but I could not make it work.
#9
10/29/2004 (2:40 am)
Putting a function inside a function? No, just add the function to your weapon script file... and in OnFire, after you created the projectile (%p in my example), you add this line: schedule(200,%p,"checkForTargets",%p);
#10
10/29/2004 (6:21 am)
Thanks,It works.But it is not easy to lock target,could other ways to fix it?
#11
And another ways? Sure there are other ways...
10/29/2004 (6:28 am)
Just play around with the settings of your seekerprojectile, and with the scan settings (change the 20 to 80 for example)...And another ways? Sure there are other ways...
#12
I notice a function "getLockedTarget",But I can't find it in engine.
10/29/2004 (6:43 am)
Thanks for quick reply.This is the function in the file MissileLauncher.cs that I used.function MissileLauncherImage::onFire(%this, %obj, %slot)
{
// %target = %obj.getLockedTarget(%slot);
%projectile = %this.projectile;
%obj.decInventory(%this.ammo,1);
%muzzleVector = %obj.getMuzzleVector(%slot);
%p = new (%this.projectileType)() {
dataBlock = %projectile;
initialVelocity = VectorScale(%muzzleVector, %projectile.muzzleVelocity);
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
// target = %obj.getLockedTarget(%slot);
};
schedule(200,%p,"checkForTargets",%p); //add
MissionCleanup.add(%p);
return %p;
}
function checkForTargets(%obj)
{
...
}I notice a function "getLockedTarget",But I can't find it in engine.
#13
Sorry for going on the main subject.
10/29/2004 (8:20 am)
Where can I download the beaverpatrol code?Sorry for going on the main subject.
#14
http://www.gamebeavers.org/modules.php?op=modload&name=Downloads&file=index&req=getit&lid=24
10/29/2004 (3:05 pm)
DOWNLOAD BEAVER PATROL 1.3 ALPHA:http://www.gamebeavers.org/modules.php?op=modload&name=Downloads&file=index&req=getit&lid=24
#15
I was frustrated with the difficulty in getting the Game Beaver's code so I made a resource for Guided or Seeker Projectiles.
It doesn't have all the bells and whistles of the GB code (i.e. it doesn't lose and find targets), but it is simple to implement.
Thanks.
12/10/2004 (8:53 am)
Greetings,I was frustrated with the difficulty in getting the Game Beaver's code so I made a resource for Guided or Seeker Projectiles.
It doesn't have all the bells and whistles of the GB code (i.e. it doesn't lose and find targets), but it is simple to implement.
Thanks.
Torque Owner Josh Moore
ConsoleMethod( SeekerProjectile, setTarget, bool, 3, 3, "ShapeBase Target") { ShapeBase* target; if (Sim::findObject(argv[2],target)) { object->setTarget(target); return true; } else object->setTarget(0); return false; }