|
Post by Jeff on Nov 16, 2011 3:01:28 GMT
Well, this will work for both big marble and small marble, but its not in powerup form. This weekend, I will release a video of me coding it in Powerup format.
Anyways, add this code to marble.cs:
datablock MarbleData(BigMarbleSize : DefaultMarble) { shapeFile = "~/data/shapes/balls/Big Marble.dts"; };
datablock MarbleData(SmallMarbleSize : DefaultMarble) { shapeFile = "~/data/shapes/balls/Small Marble.dts"; };
function changeMarbleSize(%marble) { if(!isObject(LocalClientConnection.player)) return; localClientConnection.player.setDatablock(%marble); }
When u want to change the Datablock in game, just call this method:
changeMarbleSize("datablock name you choose");
(name must be in quotes, no acceptions)
This is unreliable since you have to have a big marble dts or a small marble dts, but for now, its all we got, unless if somehow i can get the scale to work.
Enjoy guys!
Jeff
PS. To revert the marble, make the datablock parameter defaultmarble
|
|
|
Post by Hi Guy on Nov 17, 2011 1:06:19 GMT
Very nice. Could be useful for more MBO mega-marble style things.
|
|
|
Post by Jeff on Nov 17, 2011 1:10:02 GMT
i will be doing a video this weekend on intigrating it into a powerup . Just for you Higuy, lol.
|
|
NaCl586
Professional Marbler
Searching Stolen Seven Gems[ss:Phil'sEmpire Skin]
MBElite Level and Skybox Designer
Posts: 490
|
Post by NaCl586 on Nov 17, 2011 8:26:21 GMT
Thank you jeff, i may able to code it on powerup form. but im not sure, im bad programmer. BTW what I've said on MSN is correct? MBAdventure always use MBDK code so only less possibility for me to called as a code robber.
EDIT: That code is cursed and dont work properly.
See this code
datablock AudioProfile(PuMegaMarbleSfx) { filename = "~/data/sound/spawn.wav"; description = AudioDefault3d; preload = true; };
datablock ItemData(MegaMarble) { // Mission editor category category = "Powerups"; className = "PowerUp"; powerUpId = 6;
activeAudio = PuMegaMarbleSfx; //change to the audio root! pickupAudio = PuMegaMarbleSfx; //change to the pickup audio root!
// Basic Item properties shapeFile = "~/data/shapes/balls/BigMarble.dts"; //path of the shapefile mass = 1; friction = 1; elasticity = 0.3; emap = false;
// Dynamic properties defined by the scripts pickupName = "a Mega Marble Powerup!"; useName = ""; maxInventory = 1; };
function MegaMarble::onUse(%this,%marble) {
changeMarbleSize("BigMarbleSize");
schedule(10000, 0, "undoMegaMarble"); }
function undoMegaMarble() {
changeMarbleSize("DefaultMarbleSize");
}
And datablock MarbleData(BigMarbleSize) { shapeFile = "~/data/shapes/balls/BigMarble.dts"; };
datablock MarbleData(SmallMarbleSize) { shapeFile = "~/data/shapes/balls/SmallMarble.dts"; };
datablock MarbleData(DefaultMarbleSize) { shapeFile = "~/data/shapes/balls/ball-superball.dts"; };
function changeMarbleSize(%marble) { if(!isObject(LocalClientConnection.player)) return; localClientConnection.player.setDatablock(%marble); }
I know whats the mistake. Ah i must copy all codes from teh defaultmarble datablock. Aw man, That 100 line of code that mato said is just a COPY PASTE! I give up.
|
|
|
Post by Hi Guy on Nov 17, 2011 21:12:13 GMT
Actually, what you forgot was the ": DefaultMarble" section in the BigMarbleSize datablock definition. Watered-down version:
|
|
|
Post by Jeff on Nov 17, 2011 21:12:44 GMT
i will be doing a video this weekend on intigrating it into a powerup . Just for you Higuy, lol. How many more free post counds will i get? argh, ninga'd by Higuy -.-
|
|
NaCl586
Professional Marbler
Searching Stolen Seven Gems[ss:Phil'sEmpire Skin]
MBElite Level and Skybox Designer
Posts: 490
|
Post by NaCl586 on Nov 18, 2011 9:51:56 GMT
Jeff, im trying to beat you before you do that code. Hi Guy and jeff: so the code will be "changeMarbleSize("BigMarbleSize : DefaultMarble"); ?
|
|
|
Post by Jeff on Nov 18, 2011 20:03:40 GMT
no, thats only used as a child datablock, think of defaultmarble as a parent, and its children are bigmarble and small marble, u would just call big, small, or default marble, u dont use that syntax Also, because you did that, I had to go fix mbelite cause it kept crashing, so thanks
|
|
|
Post by Jeff on Nov 18, 2011 21:34:07 GMT
Excuse the double post: here is the guts of the powerup edition to the codes, if you want the full thing, you have to watch the 3 part video series on my youtube, which will be here within a few hours (its 3GB worth of footage ). heres the guts: //----------------------------------------------------------------------------- // Marble Changing Items by Jeff Hutchinson //-----------------------------------------------------------------------------
datablock MarbleData(BigMarble : DefaultMarble) { shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed };
datablock MarbleData(SmallMarble : DefaultMarble) { shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed };
function switchMarble(%powerup) { if(!isObject(LocalClientConnection.player)) return warn("Warning, there is no local client!"); //which powerup will we be choosing, hmmmm %returnval = "defaultMarble"; switch$ (%powerup) { case "BigMarble": localClientConnection.player.SetDatablock("BigMarble"); schedule(5000, 0, "SwitchMarble", %returnval); case "SmallMarble" : localClientConnection.player.SetDatablock("SmallMarble"); schedule(5000, 0, "SwitchMarble", %returnval); //5000 is time in miliseconds... till reloop :) case "DefaultMarble" : localClientConnection.player.SetDatablock("DefaultMarble"); default : return warn("Warning, the shape does not exist!"); //echo to the console displaying the error message... } }
//----------------------------------------------------------------------------- // Powerup stuff now :D //-----------------------------------------------------------------------------
datablock ItemData(BigMarbleItem) { category = "Powerups"; className = "PowerUp"; shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed emap = false; //we dont want reflection here..., unless u want it :P pickupName = "a Big Marble Powerup!"; powerupId = 6; };
datablock ItemData(SmallMarbleItem) { category = "Powerups"; className = "PowerUp"; shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed emap = false; //we dont want reflection here..., unless u want it :P pickupName = "a Small Marble Powerup!"; powerupId = 7; };
function BigMarbleItem::ondeploy(%this, %obj) { switchMarble("BigMarble"); //see that method above, now it comes in handy :) }
function SmallMarbleItem::ondeploy(%this, %obj) { switchMarble("SmallMarble"); //see that method above, not it really comes in handy :) }
|
|
Gary
Beginner Marbler
[ss:Prolassic]
i am Forfun before i get the English name
Posts: 72
|
Post by Gary on Jun 9, 2012 10:56:22 GMT
Excuse the double post: here is the guts of the powerup edition to the codes, if you want the full thing, you have to watch the 3 part video series on my youtube, which will be here within a few hours (its 3GB worth of footage ). heres the guts: //----------------------------------------------------------------------------- // Marble Changing Items by Jeff Hutchinson //-----------------------------------------------------------------------------
datablock MarbleData(BigMarble : DefaultMarble) { shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed };
datablock MarbleData(SmallMarble : DefaultMarble) { shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed };
function switchMarble(%powerup) { if(!isObject(LocalClientConnection.player)) return warn("Warning, there is no local client!"); //which powerup will we be choosing, hmmmm %returnval = "defaultMarble"; switch$ (%powerup) { case "BigMarble": localClientConnection.player.SetDatablock("BigMarble"); schedule(5000, 0, "SwitchMarble", %returnval); case "SmallMarble" : localClientConnection.player.SetDatablock("SmallMarble"); schedule(5000, 0, "SwitchMarble", %returnval); //5000 is time in miliseconds... till reloop :) case "DefaultMarble" : localClientConnection.player.SetDatablock("DefaultMarble"); default : return warn("Warning, the shape does not exist!"); //echo to the console displaying the error message... } }
//----------------------------------------------------------------------------- // Powerup stuff now :D //-----------------------------------------------------------------------------
datablock ItemData(BigMarbleItem) { category = "Powerups"; className = "PowerUp"; shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed emap = false; //we dont want reflection here..., unless u want it :P pickupName = "a Big Marble Powerup!"; powerupId = 6; };
datablock ItemData(SmallMarbleItem) { category = "Powerups"; className = "PowerUp"; shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed emap = false; //we dont want reflection here..., unless u want it :P pickupName = "a Small Marble Powerup!"; powerupId = 7; };
function BigMarbleItem::ondeploy(%this, %obj) { switchMarble("BigMarble"); //see that method above, now it comes in handy :) }
function SmallMarbleItem::ondeploy(%this, %obj) { switchMarble("SmallMarble"); //see that method above, not it really comes in handy :) } Sorry.I don't know which file should i edit...the“marble.cs”or “powerup.cs”? i tried to copy this code to both marble.cs and powerup.cs,i can see the powerups,but it doesn't work. (my marble.cs and powerup.cs are in the Attachment) Attachments:
|
|
|
Post by Jeff on Jun 9, 2012 16:00:03 GMT
You need to install HiGuy's custom powerup tutorial thing, so that these new powerups will take effect. The problem is without this hack, the engine thinks that you are trying to use an origional powerup, and not a normal one, so it just does nothing. Install this first, then come back for help if it still does not work: marbleblast.com/index.cgi?board=mbdkcode&action=display&thread=11902
|
|
whirligig
Experienced Marbler
[ss:Phil'sEmpire Skin]
Posts: 168
|
Post by whirligig on Jun 10, 2012 0:46:23 GMT
Note: you may want to apply an impulse to the marble when increasing its size (otherwise it can get stuck in the floor). This is a more complicated process than it might seem (as the normal applyImpulse is glitched; you have to mess around with server objects). I'm not sure if an applyImpulse fix has been posted on this forum.
|
|
|
Post by Hi Guy on Jun 11, 2012 2:45:29 GMT
*Takes the bait* I will post one shortly
|
|
Gary
Beginner Marbler
[ss:Prolassic]
i am Forfun before i get the English name
Posts: 72
|
Post by Gary on Jun 15, 2012 10:49:31 GMT
You need to install HiGuy's custom powerup tutorial thing, so that these new powerups will take effect. The problem is without this hack, the engine thinks that you are trying to use an origional powerup, and not a normal one, so it just does nothing. Install this first, then come back for help if it still does not work: marbleblast.com/index.cgi?board=mbdkcode&action=display&thread=11902ok..i will try..thanks~
|
|