Register    Login    Forum    FAQ    PinSimDB.org

Board index » Future Pinball » BAM corner




Post new topic Reply to topic  [ 130 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9, 10, 11 ... 13  Next
Author Message
 Post subject: Re: Custom balls
 Post Posted: Mon Mar 07, 2016 5:37 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 2477
Location: Arkansas, USA
Attention: Moderators,

Please make this a "Sticky" topic so it can be used for future reference. This is the only location where you can get custom balls.

George


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Mon Mar 07, 2016 7:51 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2811
Location: Ontario, Canada
Quote:
Ravarcaade Said: Please send me table with script. Only ths way i can debug.


It's ok for now I think I am getting the hang of it !!

Quote:
This is the only location where you can get custom balls.


Most of them are being included with BAM, but you are right thanks to Miownkhan, this is the source


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Wed Mar 09, 2016 4:44 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2811
Location: Ontario, Canada
re:Indiana Jones Mod:
I haven't updated Skinooe's Zed mod yet....Soon I hope
but I have sent out a Custom Ball version both the 2.6/ and GeorgeH Custom for testers to try.
Hopefully it works :)
It can be hard to keep track of all the files...

1. I put a default ball texture in table.zip folder (we might change this default?)
2.Added a switch in menu: default is custom balls on.
only the main table ball can be switched with "N"/"P" keys. Different table events
will release different balls.
Boulder Multiball will release 3 boulder balls
Other Multiball Modes will release "fireball"
Adventure Modes will release knight ball

3.When "Custom Balls Off" it will behave like all other tables
and all balls can be simultaneously switched with "N"/"P" keys

Thanks Rav for this amazing MOD !
It creates a lot of new possibilities...


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Sat Mar 12, 2016 5:31 pm 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 1001
@Gimli

Today i have something cool for you.
I managed to get more control over FP VBScript engine and i finally can:
- get ride of that nast "LoadExternalScript" tricks
- add functions, properties/variables, own structures
In short, we have 2 way comunication between BAM and script.
I can add anything and it will be accessible same way as any FP function or variable.

Files:
http://www.ravarcade.pl/debug/BAM.dll
http://www.ravarcade.pl/debug/ballDemo4.fpt

I did not add any new things, but please look at new script in ballDemo4.

All new FP functions/variables i will give names with "xBAM_" at begin.

To create ball you have:
xBAM_CreateBall(...)
It will not call any functions in VBScript... it goes stright to BAM.
This funtion will return structure with 4 variables:
- Red, Green, Blue - this colors should be passed to Kicker1.CreateBall
- BallNumer - id of ball used in BAM

Another new thing. You have variable: xBAM_BallID. You may read it befor you call xBAM_CreateBall. It will be same BallID as returned in structure.

Now small new thing:
xBAM_EnableSpeedDebug

If you add this line to any script:
xBAM_EnableSpeedDebug = 1
BAM will measure time used in all VBscript event and log it BAM menu. (Press Q).
All times are in ms. This way you may check if some events in VBScript take too much time.

For example i checked time used to change ball looks. New syntax is little bit faster:
~0.080 ms vs ~0.140 ms. That is not much.


Check how that new syntax looks for you.
I case if you worry. I did not remove any old stuff.

Adding now functions to script is now much easier for me. Popote few days ago ask for ability to read ball position and velocity. Now it can be done.

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-267, released: Nov 9, 2019


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Sat Mar 12, 2016 8:16 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2811
Location: Ontario, Canada
Thanks Rav,

I will definitely have a look....


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Sat Mar 12, 2016 8:55 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2811
Location: Ontario, Canada
Ok, I am not a real coder , just a tweaker Rav, so be patient with me....

The demo4 table doesn't seem to be using any of the new codes you are describing... it seems the the same as before?

Kickers 1, 2, 3 are using "transformations" from previous demo table
and Plungerkey is using "call CreateCustomBall(PlungerKicker, BALL_A)"

Can you apply your new code to the script of the demo table, so I can see how you use it?
And give a "help section" again with examples


Quote:
xBAM_CreateBall(...)
This funtion will return structure with 4 variables:
- Red, Green, Blue - this colors should be passed to Kicker1.CreateBall
- BallNumber - id of ball used in BAM


So let me get this straight:

Code:
'Example One:

Plungerkicker.createball()   'is the old FP way

call xBAM_CreateBall (PlungerKicker, BALL_A)  'is the new way ?


And Other coding options wil be:

Code:
call xBAM_CreateCaptiveBall (PlungerKicker, BALL_A)
call xBAM_UpdateBall (PlungerKicker, BALL_B)


Quote:
It will not call any functions in VBScript... it goes stright to BAM.


Does this mean, I won't have to use "surfaces" on table editor and import textures usig
texture manager?

Quote:
Another new thing. You have variable: xBAM_BallID. You may read it before you call xBAM_CreateBall. It will be same BallID as returned in structure.


How is this used and why? So that BAM can switch balls by BallID using "N" and "P" keys?


Thanks Ravarcade


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Sun Mar 13, 2016 2:32 am 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 1001
I did not chane how table works. It is not about it.

I previous version real call to BAM look like this:
Code:
ExecuteGlobal LoadExternalScript("!BAM CREATEBALL 1 0 192 192 192 basket_452 basket_334 basket_334" )

This line orders BAM to create custom ball with params:
- Red color value for custom ball (used to detect it) = 1
- Index of ball used to store data about ball inside BAM = 0
- color red = 192
- color green = 192
- color blue = 192
- texture name for dirt = "basket_452"
- texture name for reflection = "basket_334"
- texture name for reflection in playfield = "basket_344"

All params and command is passed as text.
"!BAM" is only marker used in BAM to detect command.
Rest in script was only needed to build that text and make function look more friendly.
In BAM i have to intercept I/O operation, parse string and execute command.
I can't return any value.
I is slow.
I have to manage in VBScript BAM internal index of custom balls. (See: BAM_BallCounter). After every ball creation i execute:
Code:
BAM_BallCounter = BAM_BallCounter + 1
If BAM_BallCounter >= BAM_MAX_BALLS Then
  BAM_BallCounter = 0
End If

I have to in VBScript calc color values passed to FP CreateBall, like this:
Code:
Red = BAM_BALL_RED_COLOR
Green = BAM_BallCounter Mod 256
Blue = BAM_BallCounter / 256

And finally i call FP Create ball function with caluclated values:
Code:
source.CreateBall Red Green Blue BallID


Now real call to BAM to do same thing:
Code:
Dim BallCreationRaport
Set BallCreationRaport = xBAM_CreateBall(192,192,192,"basket_452","basket_334","basket_334")

I don't send to BAM red color value used to mark it.
I don't send index of custom BAM. Now it is alway inside BAM.
In return i get structure with informations. So i don't have to calc params, i just call FP funtion:
Code:
  Kicker.CreateBall BallCreationRaport.Red, BallCreationRaport.Blue, BallCreationRaport.Green BallID


Now i combine all above in to one single function to show where is differenct:
Old version:
Code:
Dim BallCounter
BallCounter = 0
Const BAM_BALL_RED_COLOR = 1
Sub BAM_CreateBall(Source, Red, Green, Blue, BallID, Dirt, Reflection, ReflectionInPlayfield)
  Dim cr
  cr = BAM_BALL_RED_COLOR
  ExecuteGlobal LoadExternalScript("!BAM CREATEBALL 1 "&cr&" "&BAM_BallCounter&" "&Red&" "&Green&" "&Blue&" "&Dirt&" "&Reflection&" "&ReflectionInPlayfield)

  Red = BAM_BALL_RED_COLOR
  Green = BAM_BallCounter Mod 256
  Blue = BAM_BallCounter / 256

  BAM_BallCounter = BAM_BallCounter + 1
  If BAM_BallCounter >= BAM_MAX_BALLS Then
    BAM_BallCounter = 0
  End If      

  Source.CreateBall Red, Green, Blue, BallID
Sub End

If you need in script index of custom ball (need as argument for BAM_UpdateBall) you have to red BAM_BallCounter befor you call BAM_CreateBall

In new version
Code:
Sub BAM_CreateBall(Source, Red, Green, Blue, BallID, Dirt, Reflection, ReflectionInPlayfield)
  Dim bi
  Set bi = xBAM_CreateBall(Red, Green, Blue, BallID, Dirt, Reflection, ReflectionInPlayfield)

  Source.CreateBall bi.Red, bi.Green, bi.Blue BallID
Sub End

again if you need in script index of custom ball, this time you read xBAM_BallID.
Params for source.CreateBall are calculated inside BAM.

Here is what i can do now:
I can move whole custom ball managment from script to BAM. So all what will i left in script will look like this:
Code:
Dim BALL_A, BALL_B, BALL_C, BALL_D, BALL_E
BALL_A = BallManager.DefineCustomBall(192,192,192,"basket_452","basket_334","basket_334")
BALL_B = BallManager.DefineCustomBall(192,   1,192,"basket_452","basket_334","basket_334")
BALL_C = BallManager.DefineCustomBall(192,192,192,"anytexname","basket_334","basket_334")
BALL_D = BallManager.DefineCustomBall(192,192,192,"basket_452","basket_334","basket_334")
BALL_E = BallManager.DefineCustomBall(192,192,192,"basket_452","basket_334","basket_334")

Dim TransformationForKickier2
Set TransformationForKickier2 = BallManager.CreateTransformation
TransformationForKickier2.AddRule(BALL_A, BALL_B)
TransformationForKickier2.AddRule(BALL_B, BALL_C)
TransformationForKickier2.AddRule(BALL_C, BALL_D)
TransformationForKickier2.AddRule(BALL_D, BALL_E)
TransformationForKickier2.AddRule(BALL_E, BALL_A)

Sub NewCreateBall(source, ballName)
  Dim bi
  Set bi = BallManager.CreateBall(ballName)
  source.CreateBall bi.Red, bi.Blue, bi.Green, bi.BallNumber 
Sub End

Sub Kicker1_Hit()
  BallManager.UpdateBall(ballID, BALL_B)
Sub End

Sub Kicker2_Hit()
  BallManager.UseTranformation(ballID, TransformationForKickier2)
Sub End

See?
BallManager will be like built in FP object.
Only restriction will be same as in previous version. Red color of normal/standard ball can't be =1

If you give me time, i will put it in next BAM today.

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-267, released: Nov 9, 2019


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Sun Mar 13, 2016 7:26 am 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 1001
Whole "custom ball" in script will be now super simple.
New beta bam.dll
http://www.ravarcade.pl/debug/BAM.dll

Demo/example tables:
http://www.ravarcade.pl/debug/ballDemo5.fpt
http://www.ravarcade.pl/debug/ballDemo6.fpt

Both tables do exacly same (almost)
ballDemo5.fpt will work only with new beta bam.dll. On previous BAM or without BAM it will cause script erros.

ballDemo6.fpt have additional part at begin of script to prevent script erros. If BAM is old or there is no BAM it will run with all balls same.
Part to prevent errors is cleary market with "cut here" tag and instruction.

Now about custom balls and how to use new "xBAM_BallManager".
First you need variables to store something what i call "BallName". It is integer, it idetyfy how ball look.
Code:
Dim BALL_A, BALL_B, BALL_C

You may use as many BallNames as you need and please give it more meaningful names.

Now define how they look:
Code:
BALL_A = xBAM_BallManager.DefineCustomBall(192, 192, 192, "basket_452", "basket_334", "basket_334")
BALL_B = xBAM_BallManager.DefineCustomBall(300, 192, 192, "", "", "")
BALL_C = xBAM_BallManager.DefineCustomBall(192, 192, 192, "knight_452", "knight_334", "knight_334")

First 3 params are color, next 3 params are textures name. If you left it empty, default ball texture is used.
Please remember, that FP will not load textures not used on table. So if you add texture only for ball, then:
- create surface. It may be moved outside table
- uncheck "Render Object (Initial Value)" - this will make that surface not visible
- assign that ball texture to it.

We need function to create custom ball:
Code:
Function CreateCustomBall ( Source, BallName )
   Dim bi
   Set bi = xBAM_BallManager.CreatCustomBall(BallName)
   Source.CreateBall bi.Red, bi.Green, bi.Blue, bi.BallNumber
   CreateCustomBall = bi.BallNumber
End Function

Use it like this:
call CreateCustomBall( PlungerKicker, BALL_A )
This will create ball and that ball will look like defined above.

Create some transformation rules (optional):
Code:
Dim TransformRule
Set TransformRule = xBAM_BallManager.CreateTransformation
call TransformRule.AddRule(BALL_A, BALL_B)  ' convert ball A in to ball B
call TransformRule.AddRule(BALL_B, BALL_C)  ' B => C
call TransformRule.AddRule(BALL_C, BALL_A)  ' C => A


Change ball on any event:
Code:
' this will change ball to look as BALL_C
Sub Kicker3_Hit()
   call xBAM_BallManager.UpdateBall (fpBallID, BALL_C)
End Sub

' this time we will change ball with previously defined rule: A=>B, B=>C, C=>A
Sub Kicker2_Hit()
   TransformRule.UpdateBall(fpBallID)
   Kicker2.SolenoidPulse(500)
End Sub

' Now we will check what type of ball hit me
Sub Kicker1_Hit()
  If xBAM_BallManager.GetBallName(fpBallID) = BALL_A Then
    ' do somthing cool.. play different sound
  End If
  If xBAM_BallManager.GetBallName(fpBallID) = BALL_B Then
    ' do somthing different
  End If

  Kicker1.SolenoidPulse(500)
End Sub


Finally please look at ballDemo6.fpt and copy part from begin to prevent script erros if user have old BAM or don't have BAM.

@Gimli:
Is this new version simpler?

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-267, released: Nov 9, 2019


Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Sun Mar 13, 2016 7:38 am 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2811
Location: Ontario, Canada
That is very cool Rav, thanks.

Sounds like this new development will
give BAM a lot of new posibilities in the future?

I will look at demo table when I get back home later today.
thanks


Last edited by Gimli on Sun Mar 13, 2016 7:14 pm, edited 1 time in total.

Top 
 Profile  
 
 Post subject: Re: Custom balls
 Post Posted: Sun Mar 13, 2016 6:49 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2811
Location: Ontario, Canada
Quote:
@Gimli:
Is this new version simpler?


The new version works great !

From my perspective it works the same. ( It was already doing everything I wanted...)

But I understand what you are saying that now with BAM you can have a two way conversation and pass parameters and instructions to Future Pinball. Instead of of a one way conversation where you were "intercepting" info.

A few observations for those who are interested and from some of the discussions I have had with those trying the IJ demo with custom balls.

Here is what "Custom Balls for BAM" gives us:

1. We can now run any previously released table under BAM and toggle between different custom balls as we play (using the "N' and "P" keys) NO SCRIPTING REQUIRED

2. Also , we can add Custom Ball events to the script. Using Rav's "cut and Paste" code
and then using the simple custom commands.

3. The events can include:

a.) different balls released at different times ( ie "Boulder Multiball" releases boulders, and "Well of Souls Multiball" releases "Eyeballs")

b.) the current ball can be "updated" when it strikes an object. ie a Silver ball becomes
a "fireball" when it hits the Hell Hole

c.) Sequential transformations each time it hits a certain target it changes to the next ball
on the list (from a basket ball , to a baseball, to a golf ball , whatever)

The events coded in the above way, require importing the ball textures and assigning them
to "surfaces". These balls DO NOT change when you press "N" or "P" keys (they are fixed images on surfaces)

4. You can create a table with a hybrid approach (which I prefer).

The main game ball (if you use standard FP commands such as Kicker1.createball())
will be selectable by using "N"/"P" keys.

BUT balls released during events such as "Boulder Multiball" releasing boulder balls ,are
predetermined and fixed by the coding process mentioned above

5.Rav's code mentioned above is designed such that if people make tables using coding for custom balls, but the users in the community are still either using standard Future Pinball or older versions of BAM, it will not crash , but just use a default Silver Ball. (ie BAM is backward "compatible" or at least backward "friendly" :D )

Anyways there are lots of variations on the theme, but I hope you can see how versatile
this update by Rav is.

And thanks also goes to Miownkhan for the increasing library of amazing custom ball.zip files to copy into the C:/Future Pinball/Bam/Balls directory to give lots of selectable custom balls


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 130 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9, 10, 11 ... 13  Next

Board index » Future Pinball » BAM corner


Who is online

Users browsing this forum: No registered users and 7 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to: