Before we go, I will say that some parts of this may be hackish and could possibly glitch, particularly the parts involving the function mouseFire.
This code requires additions to the following source files:
-
client/scripts/default.bind.cs
client/scripts/playgui.cs
server/scripts/item.cs
server/scripts/powerUps.cs
server/scripts/marble.cs
So let's get started!
You will need to definitely know coding skills here, and I'm not going to elaborate too much. So here goes!
marble/client/scripts/default.bind.cs
Find:
function mouseFire(%val)
After:
{
Add:
$mouseFireOn = !$mouseFireOn;
marble/client/scripts/playGui.cs
Find:
function PlayGui::updateTimer(%this, %timeInc)
After:
%this.elapsedTime += %timeInc;
Add:
if ($mouseFireOn)
LocalClientConnection.player.doThePowerUpThing();
marble/server/scripts/item.cs
Find:
function ItemData::onPickup(%this,%obj,%user,%amount)
After:
if (%user.client && !%this.noPickupMessage)
messageClient(%user.client, 'MsgItemPickup', '\c0You picked up %1', %this.getPickupName(%obj));
Add any code required on item pickup here. The datablock is %this, the object itself is %obj, %user is most likely the marble, and %user.client is LocalClientConnection. %amount is the amount picked up (1).
marble/server/scripts/marble.cs
Find:
function Marble::setPowerUp(%this,%item,%reset)
After:
PlayGui.setPowerUp(%item.shapeFile);
Add:
if (%item.powerUpId > 5) {
%this.CPpowerUpId = %item.powerUpId;
%this.setPowerUpId(0, true);
%this.hasCustomPowerup = true;
return;
}
%this.hasCustomPowerup = false;
%this.CPpowerUpId = 0;
Also, add this function:
function Marble::doThePowerUpThing(%this) {
if (%this.hasCustomPowerup == true) {
switch (%this.CPpowerUpId) {
case insert PowerUpId here:
handler code here
}
%this.setPowerUp(0, true);
%this.CPpowerUpId = 0;
%this.hasCustomPowerup = false;
}
}
Obviously, you will need to change the boldfaced values.
The code in italics can be duplicated and used for different values.
marble/server/scripts/powerUps.cs
This is where you will define all your custom powerups. I will give an example with the LoGravPowerUp and the HiGravPowerUp:
datablock ItemData(LoGravPowerUp) {
category = Powerups;
className = PowerUp;
pickupName = a Lo-Grav Powerup!;
useName = Lo-Grav!;
shapeFile = ~/data/shapes/powerUps/LoGrav.dts;
mass = 1;
powerUpId = 6;
friction = 1;
elasticity = 0.3;
emap = true;
maxInventory = 1;
};
datablock ItemData(HiGravPowerUp) {
category = Powerups;
className = PowerUp;
pickupName = a Hi-Grav Powerup!;
useName = Hi-Grav!;
shapeFile = ~/data/shapes/powerUps/HiGrav.dts;
mass = 1;
powerUpId = 7;
friction = 1;
elasticity = 0.3;
emap = true;
maxInventory = 1;
};
That's the first bit. Now in marble.cs, I'll add to that doThePowerUpThing function I just made above:
function Marble::doThePowerUpThing(%this) {
if (%this.hasCustomPowerup == true) {
switch (%this.CPpowerUpId) {
case 6:
defaultmarble.gravity = 2;
case 7:
defaultmarble.gravity = 100;
}
%this.setPowerUp(0, true);
%this.CPpowerUpId = 0;
%this.hasCustomPowerup = false;
}
}
Like so! If this guide doesn't work for you, please tell me on the MB forums and post your console.log file. Thanks!
This code was originally programmed for MarbleBlast Opal, and revised (with all the funny comments removed) to be more accessible and free of anti-hack junk.
HiGuy
This signature is real code