Game Development Community

Turrets in TGE 1.5.2

by Aleksander Elvemo · in Torque Game Engine · 04/21/2009 (7:10 am) · 8 replies

Hi there.

I have tried over some time to get the turret resource to work
in tge 1.5.2. I have used the 1.20 update posted, and i have no compile
errors, and no console errors.

The problem lies in the ai turret behavior. It doesn't react to anything. It stays still. I have changed the RifleExplosion and RifleProjectile to CrossbowExplosion and CrossbowProjectile. This is what i get from the console:

ACTIVATE sequence found
TurretData::onNewDataBlock
AITurretData::onNewDataBlock
AnotherAITurret::onAdd()
ACTIVATE sequence found

Anyone got any idea what could be the problem?

#1
04/22/2009 (1:06 pm)
I've narrowed it down to the command setOwner. I'm getting this error.

game/server/scripts/Turret/aiTurret.cs (44): Unknown command setOwner.
Object (2357) Trigger -> GameBase -> SceneObject -> NetObject -> SimObject

However, in trigger.cc i have this ConsoleMethod

ConsoleMethod( Trigger, setOwner, void, 3, 3, "(obj)")
{
if (argc > 2)
{
GameBase* owner = NULL;
if (Sim::findObject(argv[2], owner) == false)
return;

object->setOwner(owner);
}
}

Anyone got an idea? =)
#2
04/22/2009 (1:33 pm)
I just implemented the 1.20 version last week and had a few compile errors, but after reading through the comments got them sorted out. It all works fine for me.

Did you get any compile errors at all? or did it just work? Because you should have got errors. Also did you merge the files or just copy over the complete files over your other ones?
#3
04/22/2009 (1:39 pm)
I have no compile errors! The only error i get is ingame in the console:
game/server/scripts/Turret/aiTurret.cs (44): Unknown command setOwner.
Object (2357) Trigger -> GameBase -> SceneObject -> NetObject -> SimObject

I merged the files together. When i place out the example turret AnotherAiTurret i get no console errors, but it wont do anything as described in my first post. When i place GenericAIturret, then i get the console error and no reaction. Hmm, its strange.

any thougths? thanks for replying btw =)
#4
04/22/2009 (2:18 pm)
I'm not sure what your using to compile, but I remember having a funky error in Visual Studio 2005 where sometimes I would Just click build solution and I wouldn't get errors but stuff didn't work correct. But if I would click Rebuild Torque Demo then stuff would work.

If you haven't, try to rebuild the whole project and see if maybe that works.
#5
04/22/2009 (2:42 pm)
Tried to rebuild now. Closed everything, checked that it was the right project with right output directory, nada! Rawr!

My only clue is the setOwner command. It can't find it. It is the ConsoleMethod it is looking for, right? Because that one i have in trigger.cc, and from the consoleerror we see that it is indeed the trigger that is causing all this fuzz.

Hmm.
Thanks again ;)
#6
04/22/2009 (2:55 pm)
I have a few things in both trigger.cc and trigger.h either called setOwner, or reference setOwner. Do you have all of these?

In Trigger.cc I have these. . .
Around line 74
// phdana aiobject ->
ConsoleMethod( Trigger, setOwner, void, 3, 3, "(obj)")
{
     if (argc > 2)
     {
          GameBase* owner = NULL;
          if (Sim::findObject(argv[2], owner) == false)
               return;
          
          object->setOwner(owner);
     }
}
// <- phdana aiobject


Around line 126
// phdana turrets ->
void cTriggerSetOwner(SimObject* obj, S32 argc, const char** argv )
{
   AssertFatal(dynamic_cast<Trigger*>(obj) != NULL, "Error, how did a non-trigger get here?");
   Trigger* trigger = static_cast<Trigger*>(obj);

   if (argc > 2)
   {
      GameBase* owner = NULL;
      if (Sim::findObject(argv[2], owner) == false)
         return;

      trigger->setOwner(owner);
   }

}
// <- phdana turrets


Around line 550
// phdana turrets ->
void Trigger::setOwner(GameBase *owner)
{
  mOwner = owner;
}
// <- phdana turrets


In Trigger.h I have this
Around line 100
// phdana aiobject ->
   void setOwner(GameBase *owner);
// <- phdana aiobject
#7
04/22/2009 (3:04 pm)
I had all three of them, swapped them with yours just to be safe. They were identical. I dont understand. I must be doing something very strange.
#8
04/22/2009 (3:06 pm)
I'm out of ideas, maybe someone that knows C++ better will come along and figure it out for you. Sorry I can't be of anymore help.