Author Topic: Projectile Directions (Sticking in fixed Directions)  (Read 756 times)

This is for testing my C4 Bomb, the code is copied and renamed to avoid over writing Space Guy's Demo Gun code.
The C4 are sticking to bricks in a fixed direction is there a way to make them stick in their normal direction when fired?

Code: [Select]
function Projectile::spawnC4Bomb(%obj,%col,%fade,%pos,%normal)
{
%type = %col.getType();
if((!(%type & $TypeMasks::fxBrickObjectType) && !(%type & $Typemasks::StaticObjectType) && !(%type & $TypeMasks::TerrainObjectType)))
return;

if(%col.getType() & $TypeMasks::StaticShapeObjectType && %col.getDatablock() == C4Static.getID())
return;

%player = %obj.client.player;
if(!isObject(%player))
return;

if(!isObject(%player.C4BombSet))
%player.C4BombSet = new SimSet();

%pos = vectorAdd(%pos,vectorScale(%normal,0.15));
%rot = rotFromTransform(%obj.getTransform());
%scaleFactor = getWord(%obj.getScale(),2);

%s = new StaticShape()
{
dataBlock = C4Static;
position = %pos;
rotation = %rot;
normal = %normal;

client = %obj.client;
sourceObject = %obj.sourceObject;
fireTime = %obj.fireTime;
};
MissionCleanup.add(%s);
%s.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);
%player.C4BombSet.add(%s);
%s.set = %obj.C4BombSet;

if(isObject(%player.client))
{
if(isObject(%player.client.minigame) && %player.client.tdmTeam != -1 && %player.client.tdmTeam !$= "")
%col = getColorIDTable(%player.client.minigame.teamCol[%player.client.tdmTeam]);
else
%col = %player.client.chestColor;
}
else
%col = "1 1 1 1";
%s.setNodeColor("ALL",%col);

%obj.schedule(33,delete);
}
« Last Edit: March 03, 2010, 08:54:57 PM by Tezuni »

there is no easy way. i also made c4 and am almost done. i am using a different method.

Set "%rot" to something different, perhaps dependant on the normal from the surface.

This is for testing my C4 Bomb, the code is copied and renamed to avoid over writing Space Guy's Demo Gun code.
The C4 are sticking to bricks in a fixed direction is there a way to make them stick in their normal direction when fired?

Code: [Select]
function Projectile::spawnC4Bomb(%obj,%col,%fade,%pos,%normal)
{
%type = %col.getType();
if((!(%type & $TypeMasks::fxBrickObjectType) && !(%type & $Typemasks::StaticObjectType) && !(%type & $TypeMasks::TerrainObjectType)))
return;

if(%col.getType() & $TypeMasks::StaticShapeObjectType && %col.getDatablock() == C4Static.getID())
return;

%player = %obj.client.player;
if(!isObject(%player))
return;

if(!isObject(%player.C4BombSet))
%player.C4BombSet = new SimSet();

%pos = vectorAdd(%pos,vectorScale(%normal,0.15));
%rot = rotFromTransform(%obj.getTransform());
%scaleFactor = getWord(%obj.getScale(),2);

%s = new StaticShape()
{
dataBlock = C4Static;
position = %pos;
rotation = %rot;
normal = %normal;

client = %obj.client;
sourceObject = %obj.sourceObject;
fireTime = %obj.fireTime;
};
MissionCleanup.add(%s);
%s.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);
%player.C4BombSet.add(%s);
%s.set = %obj.C4BombSet;

if(isObject(%player.client))
{
if(isObject(%player.client.minigame) && %player.client.tdmTeam != -1 && %player.client.tdmTeam !$= "")
%col = getColorIDTable(%player.client.minigame.teamCol[%player.client.tdmTeam]);
else
%col = %player.client.chestColor;
}
else
%col = "1 1 1 1";
%s.setNodeColor("ALL",%col);

%obj.schedule(33,delete);
}
Uuhhhh........I has dain bramage nao.

Uuhhhh........I has dain bramage nao.
Clearly, considering you can't type for stuff or make a useful post.

Also, you should probably be using %obj.sourceObject instead of %obj.client.player, so that it works with AIs.

I assumed that AIs wouldn't know how to detonate bombs so having them spammed around would be a bit useless.