file Custom PowerUp Tutorial

  • HiGuy
  • HiGuy's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
  • Rewrite it in Rust
More
13 May 2011 02:55 #1 by HiGuy
Custom PowerUp Tutorial was created by HiGuy
Hey everybody! As I have noticed, the most asked question on these code forums is how to make a Custom PowerUp. This has been rejected by Jeff and I both numerous times, but I have decided to release the code to the public now, so here we go!

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

PQ in a nutshell
function clientcmd12dothepq() {
    commandToClient(LocalClientConnection, '34onthedancefloor');
}

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
13 May 2011 03:21 #2 by Jeff
Replied by Jeff on topic Custom PowerUp Tutorial
thanks for following through with this higuy, i think mod owners owe u respect now, because as of now, only u and seiz (maybe phil or spy) could have actually done that.

*This was an mbopal code*

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

More
13 May 2011 03:32 #3 by Sim_Nine
Replied by Sim_Nine on topic Custom PowerUp Tutorial
Thank you for this, sometime I may getting around to actually using it, I hope...

Please Log in or Create an account to join the conversation.

More
13 May 2011 06:51 #4 by Don.Gato
Replied by Don.Gato on topic Custom PowerUp Tutorial
[code[[*/code]

Use it.

Anyway, thanks for this. I don't understand it but it's still very generous of you...

Please Log in or Create an account to join the conversation.

  • RDs.The-dts-guy
  • RDs.The-dts-guy's Avatar
  • Offline
  • Developer
  • Developer
  • Blender pls
More
13 May 2011 06:51 #5 by RDs.The-dts-guy
Replied by RDs.The-dts-guy on topic Custom PowerUp Tutorial
Nice tutorial. I may use it for MBR.


May 12, 2011, 8:21pm, jeff wrote:thanks for following through with this higuy, i think mod owners owe u respect now, because as of now, only u and seiz (maybe phil or spy) could have actually done that.

*This was an mbopal code*

Spy left long time ago.

Some guy that does DTS shapes and levels.

AWESOME time HINT : When making PQ level place your custom interiors and textures in platinum/data/interiors_pq/custom
makes life easier for you and everyone else :)

Please Log in or Create an account to join the conversation.

More
13 May 2011 11:52 #6 by Xuan
Replied by Xuan on topic Custom PowerUp Tutorial
awesome tutorial!

Please Log in or Create an account to join the conversation.

More
13 May 2011 12:57 #7 by Stal
Replied by Stal on topic Custom PowerUp Tutorial
Nice, I was hoping you would do something like that

Please Log in or Create an account to join the conversation.

More
13 May 2011 13:50 #8 by Pablo
Replied by Pablo on topic Custom PowerUp Tutorial
Great guide. Sticked.

Please Log in or Create an account to join the conversation.

More
13 May 2011 16:02 #9 by Andrew
Replied by Andrew on topic Custom PowerUp Tutorial
Excellent guide!

Please Log in or Create an account to join the conversation.

  • dobrakmato
  • dobrakmato's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
More
13 May 2011 17:09 #10 by dobrakmato
Replied by dobrakmato on topic Custom PowerUp Tutorial
Amazig tutorial Higuy!

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
13 May 2011 21:42 #11 by Jeff
Replied by Jeff on topic Custom PowerUp Tutorial
May 12, 2011, 11:51pm, rdsempire wrote:Nice tutorial. I may use it for MBR.


May 12, 2011, 8:21pm, jeff wrote:thanks for following through with this higuy, i think mod owners owe u respect now, because as of now, only u and seiz (maybe phil or spy) could have actually done that.

*This was an mbopal code*

Spy left long time ago.

I know that..... that prob. explains why seizure22 is pq's programmer

anyways, I think this will ern higuy more respect around here, since not to many people are a genious like this kid is. Higuy, u are the next Albert Einstine

Higuy, ur the man keep it up!


Quote:
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, the other two? I have no clue.


marble/server/scripts/marble.cs


I think that %user would be the player who is using the powerup and %amount would be the amount of that powerup you picked up (kinda like your inventory, even though you can only have 1)

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • HiGuy
  • HiGuy's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
  • Rewrite it in Rust
More
13 May 2011 22:56 #12 by HiGuy
Replied by HiGuy on topic Custom PowerUp Tutorial
May use.

PQ in a nutshell
function clientcmd12dothepq() {
    commandToClient(LocalClientConnection, '34onthedancefloor');
}

Please Log in or Create an account to join the conversation.

  • HiGuy
  • HiGuy's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
  • Rewrite it in Rust
More
17 May 2011 23:55 #13 by HiGuy
Replied by HiGuy on topic Custom PowerUp Tutorial
May 12, 2011, 11:51pm, helpme wrote:[code[[*/code]

Use it.
...


I've discovered that using and [quote] make the font unbearably small and hard to read, so I just typed it out.[code] and

make the font unbearably small and hard to read, so I just typed it out.


PQ in a nutshell
function clientcmd12dothepq() {
    commandToClient(LocalClientConnection, '34onthedancefloor');
}

Please Log in or Create an account to join the conversation.

More
27 May 2011 21:53 #14 by Explode
Replied by Explode on topic Custom PowerUp Tutorial
Thanks! This will be very helpful to MBElite.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
28 May 2011 17:19 #15 by Jeff
Replied by Jeff on topic Custom PowerUp Tutorial
I am happy to hear you are planning to use this, even though I am not higuy

What could the communnity do without programmers? lol

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • HiGuy
  • HiGuy's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
  • Rewrite it in Rust
More
29 May 2011 03:21 #16 by HiGuy
Replied by HiGuy on topic Custom PowerUp Tutorial
@Explode: You're welcome!

Edited first post to clarify on %user and %amount. Also lengthened the example to show better usage of the switch statement and multiple PowerUps.

PQ in a nutshell
function clientcmd12dothepq() {
    commandToClient(LocalClientConnection, '34onthedancefloor');
}

Please Log in or Create an account to join the conversation.

  • whirligig
  • whirligig's Avatar
  • Offline
  • Professional Marbler
  • Professional Marbler
More
19 Jun 2011 21:01 #17 by whirligig
Replied by whirligig on topic Custom PowerUp Tutorial
Well, I'll be darned. I was so sure that custom inventory powerups were impossible without modifying the executable.

Please Log in or Create an account to join the conversation.

Moderators: AayrlKalle29Regislian