Help with Turret and AITurret classes resource in 1.4
by Jack Stone · in Torque Game Engine · 09/03/2005 (3:44 pm) · 10 replies
I am currently working in Torque 1.4, and I have a need for movable turrets in my game. This resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345 seems perfect for what im doing, but its only written for 1.2/1.3
I tried implementing it anyway, and it went fine until I got to this part:
void Trigger::consoleInit()
{
// Object level commands
// Manipulation commands
Con::addCommand("Trigger", "getNumObjects", cTriggerGetNumObjects, "[TriggerObject].getNumObjects()", 2, 2);
Con::addCommand("Trigger", "getObject", cTriggerGetObject, "[TriggerObject].getNumObjects(Object Index)", 3, 3);
// phdana aiobject ->
Con::addCommand("Trigger", "setOwner", cTriggerSetOwner, "[TriggerObject].setOwner(obj)", 3, 3);
// <- phdana aiobject
}
I have to add the Con::addcommand "setowner:" line to the void Trigger::consoleInit() functon, but there is no Trigger::consoleInit() function. It seems to be replaced by:
ConsoleMethod( Trigger, getObject, S32, 3, 3, "(int idx)")
{
S32 index = dAtoi(argv[2]);
if (index >= object->getNumTriggeringObjects() || index < 0)
return -1;
else
return object->getObject(U32(index))->getId();
}
This type of function.
I tried to make add a new ConsoleMethod function myself, but it didnt seem to work.
Also, I couldnt find this function in vehicle.cc:
static U32 sDirtySetMask = PlayerObjectType |
// phdana turrets ->
TurretObjectType |
// <- phdana turrets
VehicleObjectType;
so I couldnt add the TurretObjectType to it.
So anyway, I compiled, and got 105 errors. I then read that the change in gamebase.h should be in class gamebase:public scene object, rather than struct gamebase. I changed that, and im down to 37 errors.
Now, just to test, I removed the new .cc files from my project, the ones that were specific to the Turret code and not in torque 1.4, and im now down to ONE error:
c:\Torque\torque\engine\game\trigger.cc(520) : error C2248: 'GameBase::potentialEnterObject' : cannot access private member declared in class 'GameBase'
c:\Torque\torque\engine\game\gameBase.h(149) : see declaration of 'GameBase::potentialEnterObject'
c:\Torque\torque\engine\game\gameBase.h(145) : see declaration of 'GameBase'
Now I find this a little too good to be true, since I'm pretty sure you have to compile the turret.cc, turret.h and all those files with your project.
I was just wondering where do I go from here? Is 1.4 too different from 1.3 to use this resource, or is there a simple fix somewhere? I realise this is probably a complicated problem to fix, but I would really appreciate it if anyone could point me in the right direction.
Jack
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345 seems perfect for what im doing, but its only written for 1.2/1.3
I tried implementing it anyway, and it went fine until I got to this part:
void Trigger::consoleInit()
{
// Object level commands
// Manipulation commands
Con::addCommand("Trigger", "getNumObjects", cTriggerGetNumObjects, "[TriggerObject].getNumObjects()", 2, 2);
Con::addCommand("Trigger", "getObject", cTriggerGetObject, "[TriggerObject].getNumObjects(Object Index)", 3, 3);
// phdana aiobject ->
Con::addCommand("Trigger", "setOwner", cTriggerSetOwner, "[TriggerObject].setOwner(obj)", 3, 3);
// <- phdana aiobject
}
I have to add the Con::addcommand "setowner:" line to the void Trigger::consoleInit() functon, but there is no Trigger::consoleInit() function. It seems to be replaced by:
ConsoleMethod( Trigger, getObject, S32, 3, 3, "(int idx)")
{
S32 index = dAtoi(argv[2]);
if (index >= object->getNumTriggeringObjects() || index < 0)
return -1;
else
return object->getObject(U32(index))->getId();
}
This type of function.
I tried to make add a new ConsoleMethod function myself, but it didnt seem to work.
Also, I couldnt find this function in vehicle.cc:
static U32 sDirtySetMask = PlayerObjectType |
// phdana turrets ->
TurretObjectType |
// <- phdana turrets
VehicleObjectType;
so I couldnt add the TurretObjectType to it.
So anyway, I compiled, and got 105 errors. I then read that the change in gamebase.h should be in class gamebase:public scene object, rather than struct gamebase. I changed that, and im down to 37 errors.
Now, just to test, I removed the new .cc files from my project, the ones that were specific to the Turret code and not in torque 1.4, and im now down to ONE error:
c:\Torque\torque\engine\game\trigger.cc(520) : error C2248: 'GameBase::potentialEnterObject' : cannot access private member declared in class 'GameBase'
c:\Torque\torque\engine\game\gameBase.h(149) : see declaration of 'GameBase::potentialEnterObject'
c:\Torque\torque\engine\game\gameBase.h(145) : see declaration of 'GameBase'
Now I find this a little too good to be true, since I'm pretty sure you have to compile the turret.cc, turret.h and all those files with your project.
I was just wondering where do I go from here? Is 1.4 too different from 1.3 to use this resource, or is there a simple fix somewhere? I realise this is probably a complicated problem to fix, but I would really appreciate it if anyone could point me in the right direction.
Jack
#2
\Torque\torque\engine\game\trigger.cc(61) : error C2509: 'consoleInit' : member function not declared in 'Trigger'
../engine\game\trigger.h(38) : see declaration of 'Trigger'
Line of Trigger.h is "class Trigger : public Gamebase"
09/03/2005 (7:00 pm)
No, that just give me this:\Torque\torque\engine\game\trigger.cc(61) : error C2509: 'consoleInit' : member function not declared in 'Trigger'
../engine\game\trigger.h(38) : see declaration of 'Trigger'
Line of Trigger.h is "class Trigger : public Gamebase"
#3
09/03/2005 (8:37 pm)
I once noticed that the instructions for gameBase.h had you add the function to GameBaseData, instead of GameBase. This is an error in the resource. So, potentialEnterObject should be part of GameBase, and not GameBaseData. Double check that, or something like it. I got it to work with 1.3 just fine, as long as that error is corrected. I haven't touched 1.4 yet, but I ought to check it out sometime.
#4
09/04/2005 (8:07 am)
Yes, I fixed that, someone mentioned it towards the end of the resoure comments. Thanks anyway.
#5
09/08/2005 (4:23 pm)
Ok, just an FYI for anyone else. I got this working in 1.4 by changing a function in turret.cc from a "bool" to a "void" and it seems to be ok now. Havent tried it with the AI turret yet, but it should be ok.
#6
10/28/2005 (10:48 am)
@Jack - Which function did you change?
#7
Jack most likely changed the writepacketdata function definition (in vehicle.cc) and declaration (in vehicle.h) from a return type of 'bool' to 'void' in keeping with the original declaration i shapebase.cc
Clear as mud? =P
12/28/2005 (7:12 pm)
Hate to necro, but thought this could use some closure.Jack most likely changed the writepacketdata function definition (in vehicle.cc) and declaration (in vehicle.h) from a return type of 'bool' to 'void' in keeping with the original declaration i shapebase.cc
Clear as mud? =P
#8
JS
01/15/2006 (1:11 pm)
Yeah that sounds like what I did, sorry I didnt notice this thread had been updated. This resource works great in TSE too btw. JS
#9
I can't work out where my problem lies, whether it is in the Torque Script or in the engine code.
Thanks in advance.
09/11/2006 (12:24 pm)
Could anybody who has made this work successfully in the 1.4 head post a set of comments. I can't get it to work. I have it compiled but it doesn't activate.I can't work out where my problem lies, whether it is in the Torque Script or in the engine code.
Thanks in advance.
#10
Disabling ray casting seems to fix the problem, but i would like to keep in the build...
Any ideas?
Thank You in advance
06/27/2007 (1:19 pm)
Did anybody get a bug where weapons don't work properly in trigger area of the turrets?Disabling ray casting seems to fix the problem, but i would like to keep in the build...
Any ideas?
Thank You in advance
Associate Kyle Carter