Now, some of you may know about the command .applyImpulse(). This self-explanatory command can be very useful to mod makers. Basically, it will apply an impulse, or push, to any object with a start point and a vector of impulse. Basic command syntax is as follows:
Code:%object.applyImpulse(%start, %vector);
Here's an example with values:
Code:%object.applyImpulse(0 0 -1 0 0 3);
This snippet here will apply an impulse to the object from 1 block below the object's center, with an upwards force of 3.
You're probably thinking, that's how the blast works, but there is another hidden step there. See, if you try to impulse the marble, it will reset camera direction, movement speed, and any other input factors affecting the marble. As well, normal impulses applied to the marble will stack up, meaning that if you apply later impulses, they will also re-apply the previous impulses. Basically, don't impulse LocalClientConnection.player.
But fear not! Jeff and I found a solution to this while working on PR. The solution can be found in blast.cs and it is in most of my recent codes. The basic concept is that you have to find the client-side marble. LocalClientConnection.player is server-side, as you can find it in MissionCleanup. Jeff and I discovered that you can scour the contents of ServerConnection (yes, a GameConnection object) for the marble, although none of the objects in ServerConnection have names or custom values. All that they have is datablocks and classnames, so we used classnames to find the marble. Here is the basic syntax for finding the client-side marble:
Code://Snip from blast.cs
function findRealMarble() {
//Iterate through all objects in client-side server connection
for (%i = 0; %i < ServerConnection.getCount(); %i ++) {
//Get the object from the iteration
%obj = ServerConnection.getObject(%i);
//Check for ID. The marble ID will *always* be higher.
//Analysis shaped by using tree();
//tree(); is one of those hidden-but-useful functions
if (%obj.getId() < LocalClientConnection.player.getId())
continue;
//If it's a marble, then we're good!
//This is *guarenteed* to be the client-side marble, 100%
//of the time, if you are playing single player
if (%obj.getClassName() $= Marble) {
return %obj;
}
}
}
From there, you can simply run:
Code:findRealMarble().applyImpulse(0 0 -1, 0 0 10000);
And shoot your marble out into space with no side-effects (besides being in space).
HiGuy
Code:%object.applyImpulse(%start, %vector);
Here's an example with values:
Code:%object.applyImpulse(0 0 -1 0 0 3);
This snippet here will apply an impulse to the object from 1 block below the object's center, with an upwards force of 3.
You're probably thinking, that's how the blast works, but there is another hidden step there. See, if you try to impulse the marble, it will reset camera direction, movement speed, and any other input factors affecting the marble. As well, normal impulses applied to the marble will stack up, meaning that if you apply later impulses, they will also re-apply the previous impulses. Basically, don't impulse LocalClientConnection.player.
But fear not! Jeff and I found a solution to this while working on PR. The solution can be found in blast.cs and it is in most of my recent codes. The basic concept is that you have to find the client-side marble. LocalClientConnection.player is server-side, as you can find it in MissionCleanup. Jeff and I discovered that you can scour the contents of ServerConnection (yes, a GameConnection object) for the marble, although none of the objects in ServerConnection have names or custom values. All that they have is datablocks and classnames, so we used classnames to find the marble. Here is the basic syntax for finding the client-side marble:
Code://Snip from blast.cs
function findRealMarble() {
//Iterate through all objects in client-side server connection
for (%i = 0; %i < ServerConnection.getCount(); %i ++) {
//Get the object from the iteration
%obj = ServerConnection.getObject(%i);
//Check for ID. The marble ID will *always* be higher.
//Analysis shaped by using tree();
//tree(); is one of those hidden-but-useful functions
if (%obj.getId() < LocalClientConnection.player.getId())
continue;
//If it's a marble, then we're good!
//This is *guarenteed* to be the client-side marble, 100%
//of the time, if you are playing single player
if (%obj.getClassName() $= Marble) {
return %obj;
}
}
}
From there, you can simply run:
Code:findRealMarble().applyImpulse(0 0 -1, 0 0 10000);
And shoot your marble out into space with no side-effects (besides being in space).
HiGuy
This signature is real code
Code:
function clientcmd12dothepq() {
commandToClient(LocalClientConnection, '34onthedancefloor');
}