question-circle How Can I Create A Special Challenge For A Custom Level?

  • thebourret
  • thebourret's Avatar Topic Author
  • Offline
  • Beginner Marbler
  • Beginner Marbler
More
24 Jan 2016 04:07 #1 by thebourret
Hello Everyone, I was playing Marble Blast Powered Up a lot recently, and I saw that a lot of levels had a special challenge for it. I have some questions about it. For example, on the level called "Learn The Super Bounce (Beginner Level 11)", you are afraid of the green, and yellow. How did they make the marble go out of bounds for touching these specific colours? How did they make the camera go mad on Beginner level 24? How do you make bumpers swarm at you on Beginner Level 17? How do you make the fans wind suck you up on Beginner Level 18? Is is possible to create your own special challenges for your own custom levels?

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

  • whirligig
  • whirligig's Avatar
  • Offline
  • Professional Marbler
  • Professional Marbler
More
24 Jan 2016 05:09 #2 by whirligig
Glad to hear you're interested in this! MBPU's challenges use TorqueScript, which is the scripting language used for most of the game logic in Marble Blast. The code is in .chl files, which are located in the marble/data/challenges directory. Let's take a look into some of these.

Here's bounce_parallax.chl, the first challenge you mention:
new ScriptObject(ChallengeInfo) {
	artist = "Whirligig231";
	name = "Parallax";
	mission = "beginner/bounce.mis";
	desc = "You're afraid of green ... and yellow too ...";
	diff = 3;
};
 
banGreen();
 
function onUnload() {
	resetBan();
}

The new ScriptObject bit is just to give the name, author, level, and difficulty of the challenge. The meat of the code is the banGreen and resetBan functions. The former will disallow you from touching any green textures; this is done by giving those textures ridiculously large negative friction (similar to the Random Force in MBP). The latter restores the friction to normal.

Now, here's windingroad_madness.chl, the Winding Madness challenge:
new ScriptObject(ChallengeInfo) {
   artist = "Whirligig231";
   name = "Winding Madness";
   mission = "beginner/windingroad.mis";
   desc = "The camera has gone a bit ... mad ... Try an isometric view!";
   diff = 2;
};
 
function onSpawn() {
	schedule(100,0,"resetCamThing");
}
 
function resetCamThing() {
	defaultmarble.cameraDistance = 100;
	defaultmarble.cameraMaxFov = 10;
	defaultmarble.cameraMinFov = 10;
}
 
$tempEffects = $pref::disablePowerupEffects;
$pref::disablePowerupEffects = 1;
%smat = MatrixMultiply("0 0 0" SPC getWords(StartPoint.rotation,0,2) SPC mDegToRad(getWords(StartPoint.rotation,3)), "0 0 0 0 0 -1 0.78539816229745");
%emat = MatrixMultiply("0 0 0" SPC getWords(EndPoint.rotation,0,2) SPC mDegToRad(getWords(EndPoint.rotation,3)), "0 0 0 0 0 -1 0.78539816229745");
StartPoint.rotation = getWords(%smat,3,5) SPC mRadToDeg(getWords(%smat,6));
EndPoint.rotation = getWords(%emat,3,5) SPC mRadToDeg(getWords(%emat,6));
disable("turnleft");
disable("turnright");
disable("turnup");
disable("turndown");
 
function onUnload() {
	defaultmarble.cameraDistance = 2.5;
	defaultmarble.cameraMaxFov = 90;
	defaultmarble.cameraMinFov = 90;
	enableAll();
	$pref::disablePowerupEffects = $tempEffects;
}

The onSpawn function just schedules resetCamThing to take place 100 ms after you spawn, as it has to wait until the camera is properly initialized and all. The resetCamThing function then zooms the camera out and decreases the field of view, simulating an orthographic view. Then the next two lines, outside the function, make sure powerup effects are disabled, remembering whether they were previously on so they can be re-enabled if necessary. After that, the next four lines, with matrices, rotate the start and end pads 45 degrees so they face a different direction. This involves a lot of complicated math. The next four lines disable all of the camera rotation controls. Finally, the onUnload function resets everything back to normal.

Here's the bumper swarm code:
new ScriptObject(ChallengeInfo) {
	artist = "Whirligig231";
	name = "Bumper School";
	mission = "beginner/bumpers.mis";
	desc = "You might be a bit ... swarmed.";
	diff = 1;
};
 
schedule(3000,0,"withAll","Bumpers","%this.approachObject(p(),5);");

Apart from the challenge info, this can actually be done in one line! This uses three functions at a time. The first is schedule(), which waits three seconds before the bumpers start to move. The second is withAll, which executes the code "%this.approachObject(p(),5);" for each of the bumpers in the level. The third is the approachObject method, which automatically sets up a loop causing the bumper to slowly approach the marble at a speed of 5. The function p() is shorthand for LocalClientConnection.getControlObject(), which gets the marble.

Here's the fan sucking code:
new ScriptObject(ChallengeInfo) {
	artist = "Whirligig231";
	name = "This Challenge Sucks!";
	mission = "beginner/ductfan.mis";
	desc = "Dude, it really sucks!";
	diff = 2;
};
 
DuctFan.forceStrength[0] = -100;

Again, this is one line: we change the strength of the DuctFan to be negative, so that it pulls you in instead of blowing you away. We don't need to reset this in onUnload, because properties of level objects get re-initialized every time you load a new level.

You can make your own challenges simply by making more .chl files. You'll need to know some amount of TorqueScript (or beg someone to do the code for you). The important part is the ChallengeInfo object. artist is the author's name, name is the name of the challenge, mission is the path to the level file you want the challenge to work with, beginning from the marble/data/missions directory, desc is the description of the challenge, and diff is the number of difficulty stars. Let me know if you have any issues or questions.
The following user(s) said Thank You: Weather

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

  • thebourret
  • thebourret's Avatar Topic Author
  • Offline
  • Beginner Marbler
  • Beginner Marbler
More
24 Jan 2016 19:33 #3 by thebourret
Hello whirligig, Which folder do I find the TorqueScript in? Is it possible to create your own challenge in Marble Blast Platinum? Or is it only possible to do it in Marble Blast Powered Up?

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

  • whirligig
  • whirligig's Avatar
  • Offline
  • Professional Marbler
  • Professional Marbler
More
24 Jan 2016 19:38 - 24 Jan 2016 19:38 #4 by whirligig

thebourret wrote:
Which folder do I find the TorqueScript in?


Not sure what you mean. The scripts for individual challenges are in marble/data/challenges. If you mean the other scripts that those depend on, well, they're all over the place. Anything with a .cs extension is a TorqueScript file, and as you can see, there are many of these in the game.

thebourret wrote:
Is it possible to create your own challenge in Marble Blast Platinum? Or is it only possible to do it in Marble Blast Powered Up?


Currently only MBPU has support for challenges (of the MBPU kind, not the unrelated multiplayer mode). I don't think the Platinum team has any plans to introduce them to MBP.
Last edit: 24 Jan 2016 19:38 by whirligig.

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

  • thebourret
  • thebourret's Avatar Topic Author
  • Offline
  • Beginner Marbler
  • Beginner Marbler
More
24 Jan 2016 21:34 #5 by thebourret
Hello whirligig, there is no .cs file extensions in the Marble/Data/Challenges folder, or in the Marble/Data/Challenges/Beginner folder. There's only .chl file extensions, and .dso file extensions. But there are .cs file extensions in a lot of other folders. Whenever I try to open them to see the script I get an error that says "windows cannot open this file", meaning that the computer won't let me open that file, and I can't see the script. How can I create my own .cs file? How do you create your own Torque Script for your own challenge?

Also, I was curious if you can add a challenge button (challenge_h) in Marble Blast Platinum so that you can make your own challenge in platinum. Not in the multiplayer mode. Just in the offline single player mode, because most of my custom levels are platinum levels.

Many thanks!
Attachments:

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

  • Three
  • Three's Avatar
  • Offline
  • Lead Developer
  • Lead Developer
  • level designer
More
24 Jan 2016 21:49 - 24 Jan 2016 21:52 #6 by Three
We do not have plans to introduce single player challenges to Marble Blast Platinum, and unfortunately, modding the client beyond custom levels and assets for said custom levels is against the Terms of Service. Sorry about that. Modding MBPU however is fine, as long as Whirligig is okay with it.

If you were to make your own level and then give it custom code in its .mis file, that would be acceptable.

Follow me on twitter at @threefolder
Last edit: 24 Jan 2016 21:52 by Three.

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

  • whirligig
  • whirligig's Avatar
  • Offline
  • Professional Marbler
  • Professional Marbler
More
24 Jan 2016 21:57 #7 by whirligig

thebourret wrote:
Hello whirligig, there is no .cs file extensions in the Marble/Data/Challenges folder, or in the Marble/Data/Challenges/Beginner folder. There's only .chl file extensions, and .dso file extensions. But there are .cs file extensions in a lot of other folders. Whenever I try to open them to see the script I get an error that says "windows cannot open this file", meaning that the computer won't let me open that file, and I can't see the script. How can I create my own .cs file? How do you create your own Torque Script for your own challenge?


Right. The .chl files are TorqueScript files for the challenges themselves, and the .cs files are other script files that have the code necessary for the .chl files (and, for that matter, most of the game) to run. You can open either of these in Notepad or another text editor; try right-clicking and hitting "Open With" to choose which program to open them with. However, please know that you'll probably need some amount of programming experience in order to get very far with creating your own challenges. (That being said, if you're trying to learn programming, it could be a good way to get practice.)

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

Moderators: Kalle29AayrlRegislian