Using datablocks and different models
by Dave · in Torque Game Engine Advanced · 03/01/2006 (5:41 am) · 1 replies
Hi,
I've been trying to figure out how to make my NPCs have different models from the player and from each other. I'm using the Orc from realm wars as the player model and want to use the space orc for various NPCs for now. I can get the player and all NPCs using either one of the two models, but can't seem to figure out how to get them all to use different models from each other.
I've tried creating a different datablock and setting the model in that. I wanted to inherit from lightmalehumanarmor so that I would have all the standard stuff that is in that datablock. So what I did was this
datablock PlayerData(OrcMaleHumanArmor : lightmalehumanarmor)
{
classname = "Armor";
shapeFile = "~/data/shapes/spaceOrc/player.dts";
debrisShapeName = "~/data/shapes/spaceOrc/debris_player.dts";
};
I'm apllying it to my NPC in the mission file as follows
new AIPlayer(Bob) {
position = "1121.2 451.103 259.86";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "OrcMaleHumanArmor";
enemy = "1";
};
At first it kept giving me the following errors
Object 'OrcMaleHumanArmor' is not a member of the 'GameBaseData' data block class
game1/data/missions/atlas.mis (0): Register object failed for object Bob of class AIPlayer.
And of course my NPC failed to appear. I thought maybe it was because the cs file with the datablock wasn't being exec'ed early enough in the load so I moved it up above the point where the error was ocurring. That got rid of the error, but now the game gets as far as "Engine initialised" and just hangs with no errors.
I've also tried leaving the datablock as LightMaleHumanArmor and just overriding the shape and debris_shape params when I "new" my NPCs, but that doesn't work either. The NPCs just end up with the player model
If anyone can explain or point me at a resource that shows how to give different characters different models and/or datablocks I would be very grateful.
Thanks a lot,
Dave.
I've been trying to figure out how to make my NPCs have different models from the player and from each other. I'm using the Orc from realm wars as the player model and want to use the space orc for various NPCs for now. I can get the player and all NPCs using either one of the two models, but can't seem to figure out how to get them all to use different models from each other.
I've tried creating a different datablock and setting the model in that. I wanted to inherit from lightmalehumanarmor so that I would have all the standard stuff that is in that datablock. So what I did was this
datablock PlayerData(OrcMaleHumanArmor : lightmalehumanarmor)
{
classname = "Armor";
shapeFile = "~/data/shapes/spaceOrc/player.dts";
debrisShapeName = "~/data/shapes/spaceOrc/debris_player.dts";
};
I'm apllying it to my NPC in the mission file as follows
new AIPlayer(Bob) {
position = "1121.2 451.103 259.86";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "OrcMaleHumanArmor";
enemy = "1";
};
At first it kept giving me the following errors
Object 'OrcMaleHumanArmor' is not a member of the 'GameBaseData' data block class
game1/data/missions/atlas.mis (0): Register object failed for object Bob of class AIPlayer.
And of course my NPC failed to appear. I thought maybe it was because the cs file with the datablock wasn't being exec'ed early enough in the load so I moved it up above the point where the error was ocurring. That got rid of the error, but now the game gets as far as "Engine initialised" and just hangs with no errors.
If anyone can explain or point me at a resource that shows how to give different characters different models and/or datablocks I would be very grateful.
Thanks a lot,
Dave.
About the author
Torque Owner Dave
Found the problem. I tracked it down to the computeCRC line in the LMHA datablock. Discovered that I was executing the datablock inheritance BEFORE I had executed the player.cs file in the space orc directory. I guess this meant the client had no CRC available to check for the DTS so just hung. Executing the player.cs file in the space orc directory *before* the datablock inheritance cleared up the problem and I can now use different shapes for the NPCs.
I suspect this is a bug (in the exception handling sense) as the problem should be caught and a console log error message should be produced rather than a hang. Will stick it up on the TSE bug forum.