Game Development Community

StaticShape playthread problem

by David Horn · in Artist Corner · 12/03/2007 (5:48 am) · 19 replies

In my game, I'm creating an audience.
Many of the audience members are simply TSStatic shapes, however in the front row, I want them to have some ambient, yet dynamic bones animation.

I did some research and after reading this...
http://tdn.garagegames.com/wiki/DTS/Scripting/AddingObjects

I tried the following:
I created an audiencemember.cs in the server folder...
datablock StaticShapeData(audiencemember)
{
category = "Items";
shapeFile = "~/data/shapes/ring/audiencemember.dts";
};

function audiencemember::create(%block){ 

%obj = new StaticShape() 
{ 
dataBlock = %block; 
}; 
return(%obj);
}
I add the audience member to the world in world editor from the Misc folder and he shows up fine. I give him a name of "aud1"

When something "good" happens, I want him to clap. so I created an animation sequence named clap. Saved it as audiencemember_clap.dsq and saved it in the same folder as audiencemember.dts. Works fine in show tool.

I assumed that when I hit ' and type:
aud1.playThread(0,"clap");

... he'd start to clap. Is this not so?

Please, any help would be appreciated. I'm finding it very hard to search for invoking animations on StaticShapes, Players, or Aiplayers that aren't the typical run, strafe, walk, jump animations.

Thank you

#1
12/03/2007 (5:55 am)
Reexport the DTS with the "clap" animation in the DTS and not a DSQ and try it. Also check the console. Does it give you an error when you type that?
#2
12/03/2007 (7:35 am)
The problem is I need to have many more animations - booing, standing, different ambients, etc. I just started with the clapping animation just to see if I could have the dts file recognize the dsq animation on command.

So I really need external files. Plus when it comes time to do the fighters (they will more than likely be aiplayers - not StaticShapes), they will have many more animations than I can fit inside the DTS file... probably over 100. Plus, since I'm having different fighters which will need different dts files, I want to keep the animations seperate. Then create some type of "fighter" object that will allow different dts model definitions (in the datablocks i assume) while still being able to access shared dsq files. At least that's how I did it before in the last engine i used - not sure how I'm going to do that in Torque just yet, but baby-steps :)

I will try it though, just to see if that works for the purposes of troubleshooting.

No, when I type aud1.playThread(0,"clap"); - the console gives me no errors at all. It just doesn't evoke the animation.

Thanks so much for helping me out with this by the way. evoking dsq animations to aiplayers and staticshapes, other than the standard player hard-coded animations, is critical to my game. And I just can't seem to find any tutorials on evoking custom dsq animations.
#3
12/03/2007 (8:20 am)
@David, I'm not sure you can do this with StaticShapes, but it's worth a try. To add your animation you could perhaps put something like this in your datablock:
sequence0 = "./audiencemember_clap.dsq clap";

Below your "shapeFile" line in your datablock.
#4
12/03/2007 (10:31 am)
I'll try that when I get home.

Is that the same kind of technique I'd use on an aiPlayer? because I'll definitely be ahving to do that for the fighters as well. I can always make the audience members aiplayers at worst case. But it seemed like from that wiki that i sited, this can be done with StaticShapes.

I mean, theoretically, shouldn't you be able to have a piece of machinery like a mechanical arm with bones, and load in various dsq animations to it without having it be a "player" class or subclass?
#5
12/03/2007 (10:44 am)
I believe you can do that for an AIPlayer, yeah.
#6
12/03/2007 (11:47 am)
For "player" class/subclass try using %obj.setActionThread(%slot, %name);
I don't have sources at hand, so I may misspell it, but it's there, names something like that.
#7
12/03/2007 (4:55 pm)
That didnt seem to work, Ross
I tried both...
datablock StaticShapeData(audiencemember)
{
   category = "Items";
   shapeFile = "~/data/shapes/ring/audiencemember.dts";
   sequence0 = "~/data/shapes/ring/audiencemember_clap.dsq clap";

};

   function audiencemember::create(%block){   
  
      %obj = new StaticShape()   
      {      
         dataBlock = %block;   
         };   
         return(%obj);
   }

and i tried...
datablock StaticShapeData(audiencemember)
{
   category = "Items";
   shapeFile = "~/data/shapes/ring/audiencemember.dts";
   

};

   function audiencemember::create(%block){   
  
      %obj = new StaticShape()   
      {      
         dataBlock = %block;   
         };   
         return(%obj);
   }
   
   datablock TSShapeConstructor(audiencememberDts)
{
   baseShape = "~/data/shapes/ring/audiencemember.dts";
   sequence0 = "~/data/shapes/ring/audiencemember_clap.dsq clap";
}
Now I'll have to try to embed the animations into the dts file as well as using an aiplayer...
#8
12/03/2007 (5:09 pm)
Why not make your audience members AI? Then you can use the existing ai player class to make them work. Plus, I don't know if object in the item class can do extra animations.
Look at player.cs in the server/scripts folder, and the player.cs in data/shapes/player for examples.
#9
12/03/2007 (5:18 pm)
David:
datablock TSShapeConstructor(audiencememberDts)
{
   baseShape = "~/data/shapes/ring/audiencemember.dts";
   sequence0 = "~/data/shapes/ring/audiencemember_clap.dsq clap";
}
datablock StaticShapeData(audiencemember)
{
   category = "Items";
   shapeFile = "~/data/shapes/ring/audiencemember.dts";
};
   function audiencemember::create(%block){   
  
      %obj = new StaticShape()   
      {      
         dataBlock = %block;   
         };   
         return(%obj);
   }
See the difference with your code?
I've moved TSShapeConstructor to be loaded BEFORE the datablock for StaticShape is created, as I'm not sure if it's possible to "modifiy" DTS after the datablock is loaded.

If you look at ~/server/scripts/player.cs - that' the place where the tsShapeConstructor is called (before the player datablock description).
Move the code a bit up (before the shape datablock or move it to another and at top of your script add:
exec(""~/data/shapes/ring/audiencemember.cs");
and that called file contains:
datablock TSShapeConstructor(audiencememberDts)
{
   baseShape = "./audiencemember.dts";
   sequence0 = "./audiencemember_clap.dsq clap";
}
This "could" be the issue why you don't have it working.
Btw, have you tried loading your DTS and DSQ into ShowTool to see if it's working :) just in case.

I don't see any other reasons that block this from working.
#10
12/03/2007 (5:19 pm)
Mike: ai objects are "heavier" comparing to StaticShape objects in a question of processor time being spent on calculating the moves/physics (even they don't move at all).
#11
12/03/2007 (5:48 pm)
Yes bank, It works in show tool

I've had some success since you posted that.

I am able to evoke the animation by using
aud1.playThread(0,"clap");
ONLY IF the clap animation is embedded into the dts file - not using the external dsq file.

So really, I've narrowed the problem down to somehow me incorrectly coding the dsq files. Unless StaticShapes cannot use external dsq files, but I cannot imagine that is so.

I'll try the code that you just posted...
#12
12/03/2007 (6:49 pm)
Actually when I put the TSShapeConstructor at the top of the audience.cs file as you suggested, the shape does not appear in the Items folder in world editor. Should I put it inside another cs file perhaps?

Is it possible that TSShapeConstructor doesn't work for StaticShapes? In which case, StaticShapes cannot access external dsq files?
#13
12/03/2007 (6:55 pm)
Can you send me the files to www.afterworld.ru/gmail.png? I can check it as have some spare time, as now I can't even imagine what could be wrong there
#14
12/03/2007 (7:45 pm)
I got a bounceback from the email

here...

http://www.homebrewwrestling.com/HBW2.zip

Thank you i really appreciate it
#15
12/03/2007 (7:56 pm)
I think your adding your shape to the Items catagory may be hindering you.

Here is the AIElf from the demo:

datablock StaticShapeData(ElfDance)
{
   category = "Misc";
   shapeFile = "~/data/shapes/tge_elf/elf.dts";
};

function ElfDance::onAdd(%this,%obj)
{
   %obj.playThread(0,"celmirror");
   %obj.repeatFlag = true;
}
You may need to switch your catagory.
#16
12/03/2007 (8:00 pm)
Ohh.. how I missed it. The solution is.......
datablock TSShapeConstructor(audiencememberDts){   
   baseShape = "~/data/shapes/ring/audiencemember.dts";   
   sequence0 = "~/data/shapes/ring/audiencemember_clap.dsq clap";
   sequence1 = "~/data/shapes/ring/audiencemember_yell.dsq yell";
};
Noticed the ";" at the end?

At the end of every datablock description you need to put the semicolon. It works now :)

Btw, if you hit Ctrl+F7 in torsion while the script if open it will try to compile and if there are any problems if would point you exactly where is a problem.

Nice stuff btw! :)

edit: pasted the corrected code from your script

edit2: google does not like the attachments with EXE files in it.
#17
12/04/2007 (10:21 am)
HA! that's it bank! Thank you.

So many thanks to everyone!

here is my final code as reference...

datablock TSShapeConstructor(audiencememberDts){   
      baseShape = "~/data/shapes/ring/audiencemember.dts";   
      sequence0 = "~/data/shapes/ring/audiencemember_clap.dsq clap";
      sequence1 = "~/data/shapes/ring/audiencemember_yell.dsq yell";
      };
   

   datablock StaticShapeData(audiencemember){   
      category = "Audience";   
      shapeFile = "~/data/shapes/ring/audiencemember.dts";
      };   
      

   function StaticShapeData::create(%block){           
         %obj = new StaticShape()         
         {               
            dataBlock = %block;            
            };            
            return(%obj);   
         }

I can now trigger aud1.playThread(0,"clap"); and aud1.playThread(0,"yell"); etc. at will
#18
12/14/2007 (7:45 am)
I'm having a similar problem, despite having everything set up as described above. I've noticed my Windmill::onAdd() isn't called, so I suspect this has to do with the item being a TSStatic in the mission. However, if I remove it and try to re-add it to the mission from the Shapes->Buildings->Windmill section, verses the Static Shapes section, I get "Register object failed for object (null) of class StaticShape.

I've tried changing the type in the .mis file from TSStatic to Windmill, and WindmillDts and they all give me "Unable to instantiate non-conobject class Windmill"

I've tried changing the type in the .mis file from TSStatic to StaticShape and that gives me "Register object failed for object Windmill of class StaticShape"

David, how is your audience member defined in the mission file?
#19
12/14/2007 (8:11 am)
Okay, I figured it out!

In the mission file, I changed the type to StaticShape and had to add the datablock:

new TSStatic(Windmill) {
   ...
}

new version with correct type and datablock:
new [b]StaticShape[/b](Windmill) {
   ...
   [b]dataBlock = "Windmill";[/b]
}