Game Development Community

A couple of quick questions

by Chris Harpan · in Torque Game Engine · 10/29/2007 (6:08 am) · 7 replies

I need a couple of questions answered and I'm hoping someone out there can help me.

First off is there any way to change the amount of damage of lava? I have tried changing the variables in player.cs but nothing has worked so far. I did find a thread about this doing a search, but it was rather old and it seems what worked before, does not work now. I was told there is a global variable some where, but the person I spoke to did not know exactly where.

Secondly, is there a good AI script resource available? I have tried Killer Kork, but it does not suit my needs and I'm still getting the hang of scripting, so changing it is still a bit of a task for me. I have been trying to adapt the AI scripts from Noon of the Dead (found here on the GG site), but so far I haven't been very succesful.

Thanks in advance for any help or suggestions you can give me.

#1
10/29/2007 (7:49 am)
Chris - you can try and change the damage done by lava via script by setting the global variables:

// Damage Rate for entering Liquid
$DamageLava = 0.01;
$DamageHotLava = 0.01;
$DamageCrustyLava = 0.01;
#2
10/29/2007 (7:55 am)
Andy, thanks very much for the quick reply. I have tried changing those variables in player.cs and it had no effect. I set them to 0.001, 0.0001, and 0.00001 and Kork still immeadately died upon entering the lava. I was told there might be another place where those variables are at, but it was unknown where, but the person I asked was unsure.

I'll try some other settings right now and see if that works.

Once again thanks for the quick reply. You wouldn't by chance know a place to find a good AI script would you? At this point I'm willing to pay someone for it.

Edit: I have tried playing with variations of the global vasriables in player.cs one again and still no luck. I've tried from 100 to 0.0000001 and it still does not effect damage. Kork dies as soon as he touches the lava. SO I'm hoping some one else has an idea.
I still need an AI too if anyone can help.
#3
10/30/2007 (4:15 am)
Chris - I've looked a little deeper into the lava code and there is a bug in the Torque scripts for certain, if you look at player.cs it uses the $DamageLava code to call setDamageDt function:

function Armor::onEnterLiquid(%this, %obj, %coverage, %type)
{
   switch(%type)
   {
      case 0: //Water
      case 1: //Ocean Water
      case 2: //River Water
      case 3: //Stagnant Water
      case 4: //Lava
         %obj.setDamageDt(%this, $DamageLava, "Lava");
      case 5: //Hot Lava
         %obj.setDamageDt(%this, $DamageHotLava, "Lava");
      case 6: //Crusty Lava
         %obj.setDamageDt(%this, $DamageCrustyLava, "Lava");
      case 7: //Quick Sand
   }
}

When you look at the function that then calls in shapebase.cs:

function ShapeBase::setDamageDt(%this, %damageAmount, %damageType)
{
   // This function is used to apply damage over time.  The damage
   // is applied at a fixed rate (50 ms).  Damage could be applied
   // over time using the built in ShapBase C++ repair functions
   // (using a neg. repair), but this has the advantage of going
   // through the normal script channels.
   if (%obj.getState() !$= "Dead") {
      %this.damage(0, "0 0 0", %damageAmount, %damageType);
      %obj.damageSchedule = %obj.schedule(50, "setDamageDt", %damageAmount, %damageType);
   }
   else
      %obj.damageSchedule = "";
}

It is using a local variable %obj that doesn't exist, it perhaps should be using %this instead but usually in TGE %obj is used for the object and %this for the datablock but without tracing it through I couldn't be sure. Certainly there is something not right with this.

As for AI it's really in a lot of cases very specific to what you want your AI to do, you could have a look at the Immersive AI engine here that's as good as I've seen, other than that there are forums and resources for more specific things but it's best to search for them. If you are new to Torque and AI then there's a section in the Advanced 3d Game programming all in one book that might be of use to you.
#4
10/30/2007 (5:27 am)
Thanks Andy. I did find that problem late last night while playing with those variables in the shapebase.cs. I even tried adjusting the 50 ms parameter, just to see if I could make a small difference and while it did work to some small degree(Kork didn't die right away, but he still died very quickly), it still does not solve the overall problem.

As far as the AI goes, I'm looking at the Immersive AI engine now, (Thank you very much for that). For now I'm looking at something simple, like the player comes within 20 meters and the NPC attacks.

I'll see if the Immersive AI is what I'm looking for and I've also found an AI example in the Advanced 3D Game Programming All in One book as well. Hopefully one of those should work for me, but I really wish that there was some sort of basic AI included in TGE, but I know that's alot ot ask of GG.
#5
10/30/2007 (6:51 pm)
Update: I've found a very simple AI that almost works. The script from Chapter 7 in the Advanced 3D Gaming Programming All in One book has a good resource, but unfortunately we can't get the bot to attack us.

For our next game I do plan on using the Immersive AI, but I just need something simple for now. If anyone can answer the problems with the AI script from the book, please let me know.
#6
10/30/2007 (7:10 pm)
@Chris

Have you taken a look at the AI Guard Resource?

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6773

I haven't used it in 1.5 or higher, but I guess it would work ok (I didn't take time to read the thread, but I've had it in 1.4 for a long time). It's pretty simple and will do what you have described you are looking for.
#7
10/31/2007 (5:13 am)
Thanks Alan, I had not seen this one and I'm already trying to implement it now. It's working to a point(just like the other one) but I haven't gone through all the comments yet.

I hope Torque 2 will include a module for AI, hopefully anyway and after going through all of this, I may be able to write the darn thing myself.

Edit: Alan I emailed you and posted a comment in the resource you recommended. I'm having a few issues and I wasn't sure if you had used that resource before.