how to make ProxMine to a frag_grenade
by Harrie Laversma · in Torque 3D Professional · 04/03/2013 (2:28 am) · 8 replies
thus any one now how to make the ProxMine to a fraggrenade its almost done the throwing is very nice
only it must explode immediately or with delay
only it must explode immediately or with delay
#2
function Grenade::Explode( %data, %obj, %col )
{
%obj.setDamageState(Destroyed);
%obj.schedule(999, "explode");
}
04/03/2013 (8:13 am)
just like this, I am not a great coder more art stufffunction Grenade::Explode( %data, %obj, %col )
{
%obj.setDamageState(Destroyed);
%obj.schedule(999, "explode");
}
#3
but nothing happens
game\scripts\server\proximityMine.cs
function ProxMineImage::onFire( %this, %obj, %slot )
{
// To fire a deployable mine is to throw it
%obj.throw( %this.item );
%obj.schedule(5555, "explode");
}
04/03/2013 (10:46 am)
I did this on the onfire looks a good place for %obj.schedule(5555, "explode");but nothing happens
game\scripts\server\proximityMine.cs
function ProxMineImage::onFire( %this, %obj, %slot )
{
// To fire a deployable mine is to throw it
%obj.throw( %this.item );
%obj.schedule(5555, "explode");
}
#4
%obj is the player throwing the mine, by that logic, you're telling the player to explode after five seconds.
What you need to do is attain the object ID of the "grenade" via the throw command (check item.cs), and use the explode schedule on that.
EDIT:
Some digging gives me this:
This calls the onThrow method:
So, you need to overload the onThrow method with your "grenade" item datablock, and call the explode schedule on the %obj declared in your overloaded function.
04/03/2013 (1:39 pm)
Well, we need to look closely at the calls here.%obj is the player throwing the mine, by that logic, you're telling the player to explode after five seconds.
What you need to do is attain the object ID of the "grenade" via the throw command (check item.cs), and use the explode schedule on that.
EDIT:
Some digging gives me this:
function ShapeBase::throw(%this, %data, %amount)
{
// Throw objects from inventory. The onThrow method is
// responsible for decrementing the inventory.
if (%this.getInventory(%data) > 0)
{
%obj = %data.onThrow(%this, %amount);
if (%obj)
{
%this.throwObject(%obj);
serverPlay3D(ThrowSnd, %this.getTransform());
return true;
}
}
return false;
}This calls the onThrow method:
function ItemData::onThrow(%this, %user, %amount)
{
// Remove the object from the inventory
if (%amount $= "")
%amount = 1;
if (%this.maxInventory !$= "")
if (%amount > %this.maxInventory)
%amount = %this.maxInventory;
if (!%amount)
return 0;
%user.decInventory(%this,%amount);
// Construct the actual object in the world, and add it to
// the mission group so it's cleaned up when the mission is
// done. The object is given a random z rotation.
%obj = new Item()
{
datablock = %this;
rotation = "0 0 1 "@ (getRandom() * 360);
count = %amount;
};
MissionGroup.add(%obj);
%obj.schedulePop();
return %obj;
}So, you need to overload the onThrow method with your "grenade" item datablock, and call the explode schedule on the %obj declared in your overloaded function.
#5
04/03/2013 (1:55 pm)
Quote:by that logic, you're telling the player to explode after five seconds.It is a feature, not a bug. ;) That is just awesome.
#6
maybe the grenade launcher is a better thing to make it a frag grenade
04/04/2013 (3:42 am)
oke thanks for the information cannot get it to work I will try more things and here is one to http://www.garagegames.com/community/forums/viewthread/23892maybe the grenade launcher is a better thing to make it a frag grenade
#7
04/04/2013 (5:26 am)
function ProxMine::onAdd(%this, %obj)
{
// 4 seconds after you throw it, boom!
%obj.schedule(4000, explode);
}
#8
it works very nice and so simple script now I can make a handgrenade
thanks all
04/04/2013 (6:11 am)
Michael thank you so much saves me allot of brain damage of scriptingit works very nice and so simple script now I can make a handgrenade
thanks all
Associate Michael Hall
Distracted...