file Custom PowerUp Tutorial

  • HiGuy
  • HiGuy's Avatar Topic Author
  • Offline
  • Lead Developer
  • Lead Developer
  • PQ Developer Emeritus
  • Posts: 1333
  • Thank you received: 604
13 May 2011 02:55 #1
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

This signature is real code
Code:
function clientcmd12dothepq() { commandToClient(LocalClientConnection, '34onthedancefloor'); }

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
13 May 2011 03:21 #2
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.

  • Posts: 139
  • Thank you received: 0
13 May 2011 03:32 #3
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.

  • Posts: 321
  • Thank you received: 10
13 May 2011 06:51 #4
[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
  • Posts: 719
  • Thank you received: 188
13 May 2011 06:51 #5
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.

  • Posts: 394
  • Thank you received: 0
13 May 2011 11:52 #6
awesome tutorial!

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

  • Posts: 227
  • Thank you received: 0
13 May 2011 12:57 #7
Nice, I was hoping you would do something like that

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

  • Posts: 1949
  • Thank you received: 18
13 May 2011 13:50 #8
Great guide. Sticked.

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

  • Posts: 1638
  • Thank you received: 15
13 May 2011 16:02 #9
Excellent guide!

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

  • dobrakmato
  • dobrakmato's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 134
  • Thank you received: 0
13 May 2011 17:09 #10
Amazig tutorial Higuy!

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
13 May 2011 21:42 #11
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
  • Lead Developer
  • Lead Developer
  • PQ Developer Emeritus
  • Posts: 1333
  • Thank you received: 604
13 May 2011 22:56 #12
May use.

This signature is real code
Code:
function clientcmd12dothepq() { commandToClient(LocalClientConnection, '34onthedancefloor'); }

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

  • HiGuy
  • HiGuy's Avatar Topic Author
  • Offline
  • Lead Developer
  • Lead Developer
  • PQ Developer Emeritus
  • Posts: 1333
  • Thank you received: 604
17 May 2011 23:55 #13
May 12, 2011, 11:51pm, helpme wrote:[code[[*/code]

Use it.
...


I've discovered that using [code] and

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


This signature is real code
Code:
function clientcmd12dothepq() { commandToClient(LocalClientConnection, '34onthedancefloor'); }

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

  • Posts: 219
  • Thank you received: 1
27 May 2011 21:53 #14
Thanks! This will be very helpful to MBElite.

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
28 May 2011 17:19 #15
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
  • Lead Developer
  • Lead Developer
  • PQ Developer Emeritus
  • Posts: 1333
  • Thank you received: 604
29 May 2011 03:21 #16
@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.

This signature is real code
Code:
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
  • Posts: 444
  • Thank you received: 261
19 Jun 2011 21:01 #17
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: Doomblah
Time to create page: 0.881 seconds
We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.