Item that can take damage : DamagableItemObjectType
by Charles B · in Torque Game Engine · 08/18/2005 (11:03 am) · 9 replies
Does anyone know how to use the DamagableItemObjectType or dynamicType variable from item.cc or itemdata.
I want to have crate items that will take damage from flying bullets and it would seem that marking only these items as damagable is the performance way to go - if someone knows how to change an item to a damagable item.
I know you can add ItemObjectType to ( engine/game/projectile.cc ) Projectile::csmDynamicCollisionMask but that would add all items to the collision check?
I want to have crate items that will take damage from flying bullets and it would seem that marking only these items as damagable is the performance way to go - if someone knows how to change an item to a damagable item.
I know you can add ItemObjectType to ( engine/game/projectile.cc ) Projectile::csmDynamicCollisionMask but that would add all items to the collision check?
About the author
#2
Do you mean like this ( it doesn't seem to work ) :
########### /Torque/example/starter.fps/server/scripts/crate.cs = execed from game.cs ###
function ItemData::create( %data )
{
echo( "ItemData::create - make a crate we can kill with projectile --------------------------" );
%obj = new Item()
{
dataBlock = %data;
rotate = false;
static = true;
dynamicType = DamagableItemObjectType;
};
return %obj;
}
##############################################################################
Ben - Thanks for responding.
08/18/2005 (3:06 pm)
Ben,Do you mean like this ( it doesn't seem to work ) :
########### /Torque/example/starter.fps/server/scripts/crate.cs = execed from game.cs ###
function ItemData::create( %data )
{
echo( "ItemData::create - make a crate we can kill with projectile --------------------------" );
%obj = new Item()
{
dataBlock = %data;
rotate = false;
static = true;
dynamicType = DamagableItemObjectType;
};
return %obj;
}
##############################################################################
Ben - Thanks for responding.
#3
You will need to have a $ before any globals, incidentally.
08/18/2005 (10:31 pm)
I've no idea what the script interface is for that stuff, unfortunately.You will need to have a $ before any globals, incidentally.
#4
Thanks for helping.
I guess no one knows about this or uses it.
I searched the forums before posting and there was only 1 other reference to DamagableItemObjectType.
I'll try to mess around some more...
08/19/2005 (8:24 am)
Ben,Thanks for helping.
I guess no one knows about this or uses it.
I searched the forums before posting and there was only 1 other reference to DamagableItemObjectType.
I'll try to mess around some more...
#5
You need to have
for it to even assign a value to that field.
08/19/2005 (12:49 pm)
This line, just to be clear, doesn't work:dynamicType = DamagableItemObjectType;
You need to have
dynamicType = $DamagableItemObjectType;
for it to even assign a value to that field.
#6
What I did was edit the /home/me/.garagegames/torqueDemo/starter.fps/data/missions/stronghold.mis
and in the
new Item() {
pos/rot/scale
rotate = "0";
....
dynamicType = $TypeMasks::DamagableItemObjectType;
collideable = "1"; // but this nevers seems to make any difference
};
^^^ This seems to be the correct way but alas it doesn't make projectiles hit my crate.
08/20/2005 (12:47 pm)
Ben,What I did was edit the /home/me/.garagegames/torqueDemo/starter.fps/data/missions/stronghold.mis
and in the
new Item() {
pos/rot/scale
rotate = "0";
....
dynamicType = $TypeMasks::DamagableItemObjectType;
collideable = "1"; // but this nevers seems to make any difference
};
^^^ This seems to be the correct way but alas it doesn't make projectiles hit my crate.
#7
what I got to work was to create a new c++ class called damagableItem
and force it's type to DamagableItemObjectType at the end of it's constructor.
this works - projectiles hit the crate and blow up.
08/20/2005 (1:24 pm)
^^^ although that didn't work....what I got to work was to create a new c++ class called damagableItem
and force it's type to DamagableItemObjectType at the end of it's constructor.
this works - projectiles hit the crate and blow up.
#8
08/20/2005 (2:58 pm)
There ya go! Glad to hear it's working.
#9
10/27/2008 (10:11 am)
What does the code look like for that? I'm trying to do the same thing but... alas..
Associate Ben Garney