BAM BAM: Milestone Releases with Ravarcade's Instructions

@GeorgeH

I hate to keep beating this drum..... but if you are updating a table to the point that it "requires BAM"... why even bother supporting FP Original? There's no graphical benefit, and if a player doesn't have the hardware to run the table smoothly with New Renderer, they are a lost cause anyway.

It's a lot of work for you to add just for players that will most likely post another message "all my other tables work fine...so I shouldn't need BAM to run this table!"...blah, blah. Those guys are a lost cause and not worth your extra work to accommodate them.
 
As an example... the new flasher spotlights "require" New Renderer to work. There's no going back now if you want your table to "be.... all that it can be.... in the Army...." (old U.S. TV commercial flashback)

It took SLAM a long while to grasp the idea of only supporting BAM and New Renderer..... but once he did, his tables were much better for it, and it was less workaround for him to deal with.
 
@GeorgeH
First, SetTexParams subroutine.
You don't need 4 versions of same sub to set different SpecularLevels. You may add param to subroutine, like this:
Code:
Sub SetTexParams(texNames, specLevel)
    Dim texArray, oneTexName, tex
    texArray = Split(texNames,",")
    For each oneTexName in texArray
        Set tex = xBAM.GetTexture(oneTexName)
        If tex.isValid Then
            tex.SpecularLevel = specLevel
            ' Here you can add more params to set.
        End If       
    Next
End Sub
You will call it like this:
Code:
SetTexParams("einstein,zweitein,treistein", 0)
SetTexParams("boom,doom,kaboom", 0)
....
SetTexParams("einstein,zweitein,treistein", 0.3)
SetTexParams("boom,doom,kaboom", 0.3)
...

Any given specular level that looks good on New Renderer is excessively bright on FP Original. I created some code to set the specular level for FP Original so it is always set to 0.
If you set SpecularLevel to 0 for FP Original rendere you make game look very old, like in year 2000. You may try to play with shininess params. This param will control angle of visible specular light reflection. If you set bigger value, that angle become narrow. You should try if for curved objects (not flat).

If I start with New Renderer and switch to the FP Original light mode during a game, the excessively bright specular level still occurs.
I need simple example to debug this. Right now, i can only advise you to add more own debug code (more AddDebugText) and check if you realy set things you expect.
 
There's no graphical benefit, and if a player doesn't have the hardware to run the table smoothly with New Renderer, they are a lost cause anyway.

It's a lot of work for you to add just for players that will most likely post another message "all my other tables work fine...so I shouldn't need BAM to run this table!"...blah, blah. Those guys are a lost cause and not worth your extra work to accommodate them.

I am aware FP Orig does not look good. As far as hardware goes, I guess I look at it differently. I grew up not having much money so I understand why some can't upgrade their PCs as frequently as I do. It doesn't take much work to add this one option and I explain that it is for low end PCs in the write ups and on the menu.
 
@GeorgeH
First, SetTexParams subroutine.
You don't need 4 versions of same sub to set different SpecularLevels. You may add param to subroutine, like this:
Code:
Sub SetTexParams(texNames, specLevel)
    Dim texArray, oneTexName, tex
    texArray = Split(texNames,",")
    For each oneTexName in texArray
        Set tex = xBAM.GetTexture(oneTexName)
        If tex.isValid Then
            tex.SpecularLevel = specLevel
            ' Here you can add more params to set.
        End If      
    Next
End Sub
You will call it like this:
Code:
SetTexParams("einstein,zweitein,treistein", 0)
SetTexParams("boom,doom,kaboom", 0)
....
SetTexParams("einstein,zweitein,treistein", 0.3)
SetTexParams("boom,doom,kaboom", 0.3)
...


If you set SpecularLevel to 0 for FP Original rendere you make game look very old, like in year 2000. You may try to play with shininess params. This param will control angle of visible specular light reflection. If you set bigger value, that angle become narrow. You should try if for curved objects (not flat).


I need simple example to debug this. Right now, i can only advise you to add more own debug code (more AddDebugText) and check if you realy set things you expect.

Thanks Rafal. I will work on it some more and see if I can figure it out.
 
Rafal.

I figured it out. I determined that my lighting subroutine needed to run one of the subroutines LightsOn or LightsOff every time the lighting sub runs. It determines which one to run using the SetLightingFlag included below.

For everyone else, I inserted the code I used below. If you are not aware, "Attack from Mars" has lighting modes depending on the game mode. The game starts dark but the lights turn on when you press the start game key. They turn off when the ball drains and back on when the ball is kicked out to the plunger. I added additional lighting code to the existing on and off lighting modes. The "nvR4 = 5" part of the code below identifies the "FP Original" lighting and the else part represents the 4 "New Renderer" lighting modes. The code includes parameters for SpecularLevel and Shininess that Rafal explained to me how to set up. I think in most cases you will need both. Increasing Shininess not only makes the object more shiny but it also makes the lighting for it more directional. I added lighting for the decals on the ramps but set the Shininess to 0.001 so you can see the light from different angles. You can make an object look metalic by setting Shininess quite high but you will need to increase the SpecularLevel because the object will look dark if you don't.

Code:
Dim SetLightingFlag

Code:
Sub SetTexParams(texNames, specLevel, shineLevel)
    Dim texArray, oneTexName, tex
    texArray = Split(texNames,",")
    For each oneTexName in texArray
        Set tex = xBAM.GetTexture(oneTexName)
        If tex.isValid Then
            tex.SpecularLevel = specLevel
            tex.Shininess = shineLevel
        End If   
    Next
End Sub

Code:
Sub LightsOff()
    SetLightingFlag = 2
        If nvR4 = 5 then
        SetTexParams "Target,target-t2-red,target-t1-red,target-t1-red,target-t2-green,AlienTextura2,UFO Texture GOLD 3b,saucer2,card1,card2,bumper,rampa_cow_dec2,lobster", 0.001, 5.0
    else
        SetTexParams "Target,target-t2-red,target-t1-red,target-t1-red,target-t2-green,AlienTextura2,UFO Texture GOLD 3b,saucer2,card1,card2,bumper,rampa_cow_dec2,lobster", 0.1, 5.0
    End If
End Sub

Code:
Sub LightsOn()
    SetLightingFlag = 1
        If nvR4 = 5 then
        SetTexParams "Target,target-t2-red,target-t1-red,target-t1-red,target-t2-green,AlienTextura2,card1,card2,bumper,rampa_cow_dec2,lobster", 0.2, 5.0
        SetTexParams "UFO Texture GOLD 3b,saucer2", 0.6, 100.0
    else
        SetTexParams "Target", 2.0, 1.0
        SetTexParams "target-t2-red,target-t2-green", 2.7, 1.0
        SetTexParams "target-t1-red", 2.6, 1.0
        SetTexParams "bumper", 5.0, 0.5
        SetTexParams "card1,card2,rampa_cow_dec2,lobster", 0.8, 0.001
        SetTexParams "AlienTextura2", 1.2, 4.0
        SetTexParams "UFO Texture GOLD 3b,saucer2", 4.5, 70.0
    End If
End Sub

This is the if/then statement I added to my lighting subroutine:
Code:
    If SetLightingFlag = 1 then
        LightsOn()
    else
        LightsOff()
    End If

George
 
@ravarcade

I have been using this code and was wandering if it could be adapted to long lists of lights.

Sub SetTexParams(texNames, specLevel, shineLevel)
Dim texArray, oneTexName, tex
texArray = Split(texNames,",")
For each oneTexName in texArray
Set tex = xBAM.GetTexture(oneTexName)
If tex.isValid Then
tex.SpecularLevel = specLevel
tex.Shininess = shineLevel
End If
Next
End Sub

I got started with it but got stuck on the items bolded in red below. Is there a way to do it without using execute or eval functions?

Sub SetLightParams(lightNames, Bright, GlowBright)
Dim lightArray, oneLightName, Light
lightArray = Split(lightNames,",")
For each oneLightName in lightArray
Set light = ?(oneLightName)
If light.isValid Then
lightExt.Brightness = Bright
lightExt.GlowBrightness = GlowBright
End If
Next
End Sub

...Or maybe it is not possible. I ask because I generate long lists of light names.
 
George, well to repeat same code pattern for lights and lightsExt object you will need to use Eval or Execute commands in script.
I believe, that this 2 command are evil. I think you should use different approach.
Because this is common problems with FP scripts and it is october, halloween is near, it is time to give you silver bullets.

This may look as wast of time, but if you go thu this, your script will be simplier, easy to extend and easy to read.

Part 1. Underscore: _
At begin you have to call on function with a lot of arguments. You end with very long line:
Code:
Text = ConcatenateTexts( "Lorem ipsum",  "GeorgeH", "Someone write long text here and this is inconvinent", "Next we call function", GiveMeMoreText(100))
This is hard to read and it is realy hard to find argument passed to GiveMeMoreText.
With unercoscore at end of line, you can split that one line into few more and all will look better:
Code:
Text = ConcatenateTexts(_
    "Lorem ipsum",_
    "GeorgeH",_
    "Someone write long text here and this is inconvinent",_
    "Next we call function",_
    GiveMeMoreText(100))
Now, you have one argument per line and it is easy to find that 100 passed to GiveMeMoreText

This is how it looks in FP script editor:
1603026957673.png
It may look wird at begin.

Sometimes you will need to pass one big long text, like list of texture names. You can use it to split that text into few lines in script.
This will make your life easie, if you want to add something more to it or check if something exist.
Example: how long it will take you to check if you added bulb13 to string:
1603027273620.png
vs
1603027299293.png

I added this as first, because i'm using this in next part.
 
Well, I didn't see above answers in phone. So I edited this.
I blame my phone :)
 
Part 2. Put FP objects or textures in array.

If you have many, many objects on table and you want to change at once state of 40, you will use Eval or Execute to itarate thru all. This is just wrong.
It is easier to select that subset of object and put all in one array.

So, i added bunch of helper functions to select subset of FP objects (or BAM textures) and put it into array for later use.
See attached table.

Here is list:
- GetObjectsRangePreserveIndex (baseName, min, max)
- GetObjectsRangePreserveIndexWithPostfix (baseName, min, max, postfix)
- GetObjectsRange (baseName, min, max)
- GetObjectsRangeWithPostfix (baseName, min, max, postfix)
- GetObjectsFromList (listOfNames)
- GetObjectsFromListWithPostfix (listOfNames, postifx)
- GetObjectsFromListWithExtPostfix(listOfNames)
- GetTexturesFromList (listOfTextureNames)

You should think not about 8 functions. There are only 3: GetObjectsRange, GetObjectsFromList, GetTexturesFromList.
Case 1: GetObjectsRange
Lets say you have 100 bulbs on table. Some have names like this: bulb101, bulb102, bulb103, ...., bulb122.
You have 22 bulbs and you will want to do something with all that bulbs with one command.
First lets put all 22 bulbs in one array simple way:
Code:
Dim red22bulbs  : red22bulbs = GetObjectsRange("Bulb", 101, 122)
That's all. You have array of 22 bulbs ready to use for later.

... and you are not limited to bulbs.... it may be anything in FP with name, flashers, imagelights ....

Case 2: GetObjectsFromList
Lets say you have: bulbLeftSligshot, bulbRighSligshot, bulbAnotherBuble, flasher1, flasherWin.
So, you have 5 objects... they may be even different type, but all are lights and you may want to change State property in one line.
No, you can put all that objects in one array with one command:
Code:
Dim fewLights : fewLights = GetObjectsFromList(_
    "bulbLeftSligshot, bulbRighSligshot, bulbAnotherBuble,"&_
    "flasher1, flasherWin")
Look, i used that underscore character to put bulbs and flashers into 2 different lines, it is easier to read!
Also, you can use spaces between names, so you can format that command to make it easy to read and easy to add more if you need,
Here is screenshot from editor how it looks:
1603028766183.png
Case 3: GetTexturesFromList
It is like GetObjectsFromList. But there is two things to remember:
- In FP texture manager you can add space (one or more) at end of texture name. This will make that texture inaccessible, because before search for texture, all spaces befor and after name are removed.
- If you have typo in texture name, it will be not added to array. If you run table with F9 you will see message *** Error: texture not found or something like that.

What about other versions?
You have 3 functions with "WithPostfix" and end of name. They have one more arg at end: postfix. This is text added to end of object name before you search for it.
Example:
You have same 22 bulbs with names bulb101, bulb102, bulb103, ...., bulb122. But you want to use that BAM lightExt params. So, you have xBAM.CreateAllExt command in script and you search for bulb101Ext, bulb102Ext, bulb103Ext, ...., bulb122Ext
So, there is postfix at end of object name.... this is why you have that 3 extra functions.
Code:
Dim red22bulbsExt  : red22bulbsExt = GetObjectsRangeWithPostfix("Bulb", 101, 122, "Ext")

.... and versions with PreserveIndex?
Well, with GetObjectsRange you have 22 bulbs in one array, but to access bulb106 you need to use red22bulbs(5).
This may be inconvenient. It is not easy to translate numbers.
So, you have.... PreserveIndex
Code:
Dim red22bulb  : red22bulb = GetObjectsRangePreserveIndex("Bulb", 101, 122)
... and you can use it this way: red22bulb(106).State = BulbOff
But remember, in that array at indexs from 0 to 100 there is nothing!
 

Attachments

  • helpers.fpt
    232.5 KB · Views: 95
Part 3. MergeArrays and MergeArraysPreserveIndex.
That are helper methods to combine 2 or more arrays into one.
Lets say you have 100 bulbs in matrix 10 x 10. So, 10 rows, 10 columns. You want to create border with columns 1 & 10 and rows 1 & 10.
You want to control whole border with one command (.... about this in Part 4).
Here is code to create that array with all that bulbs:


Code:
Dim boxOfBulbs : boxOfBulbs = MergeArrays(Array(_
        GetObjectsRange("Bulb", 1, 10),_
        GetObjectsRange("Bulb", 91, 100),_
        GetObjectsRangeWithPostfix("Bulb", 1, 8, "1"),_
        GetObjectsRangeWithPostfix("Bulb", 2, 9, "0"),_
    ))
So, we have 4 arrays of bulbs:
- GetObjectsRange("Bulb", 1, 10) is bulb1, bulb2, .... bulb10
- GetObjectsRange("Bulb", 91, 100) is bulb91, bulb92, .... bulb100
- GetObjectsRangeWithPostfix("Bulb", 1, 8, "1") is bulb11, bulb21, .... , bulb81
- GetObjectsRangeWithPostfix("Bulb", 2, 9, "0") is bulb20, bulb30, .... , bulb90
... all are now in one array..... cool

You have also MergeArraysPreserveIndex. Version of MergeArrays but it will preserve indexes.
No big difference.

Please note, that you don't have use all that functions... they are only helpes.
You may also do same thing with GetObjectsFromList and enter names of all bulbs you want.


Last important thing. Functions from Part 2 are using Eval. This function is evil... is slow. So, use that functions in script initialization not during gameplay.
 
Part 4. How to use that arrays .... easy way.
Here are few functions from helpers.fpt table:
Code:
Sub SetLightsBright(list, bright, glowBright)
    Dim i, light
    For i = 0 To UBound(list)
        If Not isEmpty(list(i)) Then
            Set light = list(i)
            light.Brightness = bright
            light.GlowBrightness = glowBright
        End If
    Next
End Sub

Sub SetLightsState(list, state)
    Dim i, item
    For i = 0 To UBound(list)
        If Not isEmpty(list(i)) Then
            Set item = list(i)
            item.State = state
        End If
    Next
End Sub

Sub SetLightsLitColor(list, red, green, blue)
    Dim i, item
    For i = 0 To UBound(list)
        If Not isEmpty(list(i)) Then
            Set item = list(i)
            item.SetLitColor red, green, blue
        End If
    Next
End Sub

Sub SetTexturesSpecularLevelAndShininess(list, specLevel, shineLevel)
    Dim i, item
    For i = 0 To UBound(list)
        If Not isEmpty(list(i)) Then
            Set item = list(i)
            item.SpecularLevel = specLevel
            item.Shininess  = shineLevel
        End If
    Next
End Sub

Sub SetTexturesBrightness(list, bright)
    Dim i, item
    For i = 0 To UBound(list)
        If Not isEmpty(list(i)) Then
            Set item = list(i)
            item.Brightness  = bright
        End If
    Next
End Sub

Look, they have same pattern.... Lets compare how they look in script editor:
1603031440342.png
I marked regions, where they are different: That is
- name
- params (only first param is same: list)
- command used to change state of light, params of texture....
There is very little work needed to create another function to change diffrent params.

There left only one thing.... arrays of objects/textures from PreserveIndex will have empty slots.
That functions used to moddify params can handle that empty slots easly.... but they will interate that empty slots. You will not have crash here, but...
If you put in array bulbs with numbers like 1000 - 1010. You will end with array of 1010 elements and only 10 will be active. So, if you want for example to turn of that 10 bulbs function will check 1000 empty slots.
In that case use functions to create arrays without PreserveIndex.

... and another case of possible problems:
You may use same indexes for bulbs and flashers. If you try to combine in one array and preserve indexes.... well it will be problem.

That's all folks. Have fun.
 

Attachments

  • 1603031282988.png
    1603031282988.png
    5.7 KB · Views: 89
  • 1603031303694.png
    1603031303694.png
    20.9 KB · Views: 94
Thanks Rafal! I am pretty much finished with the lighting on "Attack Form Mars" which has long light lists but I will give this a try on my next table.
 
@ravarcade

We had been getting 2 false positives on Windows Defender for the DOFLinx.vbs file when it runs. One of the guys on VP Forums suggested doing this:

In admin powershell windows do the following
Add-MpPreference -ExclusionProcess "c:\emulation\FP\Future Pinball.exe"
Add-MpPreference -ExclusionPath "c:\emulation\FP\Scripts\*.vbs"

I posted a case on Microsoft's web site and they resolved the 2 false positives so I don't have a problem running the DOFLinx.vbs file anymore. I never tried changing powershell. Do you recommend doing this? I am not sure about it. Do you think this would fix the problem we are experiencing with execute and eval commands?

George
 
Last edited:
@ravarcade

We had been getting 2 false positives on Windows Defender for the DOFLinx.vbs file when it runs. One of the guys on VP Forums suggested doing this:

In admin powershell windows do the following
Add-MpPreference -ExclusionProcess "c:\emulation\FP\Future Pinball.exe"
Add-MpPreference -ExclusionPath "c:\emulation\FP\Scripts\*.vbs"

I posted a case on Microsoft's web site and they resolved the 2 false positives so I don't have a problem running the DOFLinx.vbs file anymore. I never tried changing powershell. Do you recommend doing this? I am not sure about it. Do you think this would fix the problem we are experiencing with execute and eval commands?

George
This is safe. Remember to change path to correct locations on your hard disk.
 
This is safe. Remember to change path to correct locations on your hard disk.

Yes... we've had problems with FP-BAM, DOFLinx, PinEvent and VPX because of recent Win 10 updates to Defender. Adding exceptions are not good enough to prevent Defender from blocking access to vbs files or commands on some people's systems.

In my FP and BAM Mega Guide, I now recommend that everyone disables Defender completely (not temporarily as it re-enables itself), and use another anti virus solution to prevent problems with vbs related apps like FP and VPX.
 
I completely agree that adding exceptions to Defender for false positives is not good. The exception would leave you vulnerable to the real virus.

I am not sure if I am right but it appears the code for powershell (above) disables the real time protection on Defender exclusively for Future Pinball. I would say that would be safer than adding exceptions. Does anyone know if the powershell code above would prevent Defender's real time protection from affecting execute and eval commands in the script? This would be nice because I have spent quite a bit of time converting these commands on older tables to use something else.

I have proven that Microsoft does support fixing false positives. Every antivirus program produces false positives on occasion so I am not sure if using a different program will help.
 
I completely agree that adding exceptions to Defender for false positives is not good. The exception would leave you vulnerable to the real virus.

I am not sure if I am right but it appears the code for powershell (above) disables the real time protection on Defender exclusively for Future Pinball. I would say that would be safer than adding exceptions. Does anyone know if the powershell code above would prevent Defender's real time protection from affecting execute and eval commands in the script? This would be nice because I have spent quite a bit of time converting these commands on older tables to use something else.

I have proven that Microsoft does support fixing false positives. Every antivirus program produces false positives on occasion so I am not sure if using a different program will help.




From DJRox in relation to the problems VPX has i regards to Defender:



I used to work for Symantec and McAfee. I know a lot about how things work from an AV vendor perspective.

This community is constantly creating new content. But we're not making commercial products, so none of it is digitally signed with a reputable certificate. Strike one.

It's a niche community, and a lot of us have AV turned off. Reputation information for this stuff is pretty much non-existent. Strike two.

Well, it's not signed, and it has no reputation, I guess we'll have to look at the behavior. It controls and kills applications, and runs lots of VBScript? Doesn't sound safe. CONVICT! Strike three, you're out.

VPX now has a new problem with AV - something called AMSI that looks at dynamic VBscript code starting with Win10 1803. It's designed for the Excel spreadsheets with some embedded vbscript to crunch some numbers, not high performance game scripting. Exclusions do not work for this currently. You have to turn off real time protection or tables take a massive performance hit. It's something I consider a Microsoft bug, but good luck getting them to fix it.

None of these problems are easy for this community, nor AV vendors to solve. There's just no way human AV analysts are going to look at our content to whitelist it at the rate we make it. The most common suggestion is to treat your pinball computer as a "red zone" and carefully limit internet activities on that machine. Only download pnball software from well known sites like this one. Not too big of a deal if you have a pincab (keep backups!), but if you're playing desktop pinballl on a machine you otherwise use, it's a tough problem for sure.
 
2. OnPreHitFlipperExt
Here is scenario: you have "LeftFlipper" & "RightFlipper" and you need to write same flipper "PreHit" subroutine for both flippers. In old BAM you need to write 2 separate "PreHit" subroutines. In both most likely you will call third "PreHit" subroutine with FlippeExt as argument.

Once again a lot of code to write.

Lets make your life easy.
You don't need to write "LeftFlipper_PreHit", "RightFlipper_PreHit". You can rename "OnPreHitFlipperSetting" subroutine to "OnPreHitFlipperExt" and it will be called for every flipper on table without own "PreHit" subroutine.
Image


... and if you still need different params for "LeftFlipper" you can create "PreHit" subroutine only for it.
Image
@ravarcade ,

By searching in update history, i find this that should be very usefull to make script more simplier for FlipperEXT with "OnPreHitFlipperExt" sub

OnPreHitFlipperExt work well, but as soon as i add "LeftFlipper_PreHit", "RightFlipper_PreHit" etc etc for specific value, the "OnPreHitFlipperExt" sub don't work anymore....

Is there an update that canceled that?
 
@ravarcade ,

By searching in update history, i find this that should be very usefull to make script more simplier for FlipperEXT with "OnPreHitFlipperExt" sub

OnPreHitFlipperExt work well, but as soon as i add "LeftFlipper_PreHit", "RightFlipper_PreHit" etc etc for specific value, the "OnPreHitFlipperExt" sub don't work anymore....

Is there an update that canceled that?
@Gimli , maybe you know something about this too?
 
It's one of the problem of not instaling fresh windows with good old format.

I only reboot my pc for updates. It doesn't happen everyday but yesterday I did and nothing usb worked.. somehow I had a lot of usb devices disabled. Took me a while to figure this one out until I recal something I did between updates... But it might have not happened and I thought my mobo was dying!

This stuff doesn't happen with the good old way of reinstalling windows from scratch every year :)

Anyway, glad you solved it
are you sure you answer the good topic @AnonTet ? 🤣🤣
 
I have found that Rav responds to questions better if you send him a private message.
I have tag him.
I don't want to bother him anymore in Private for something that could be better, but not 100% necessary
 
I can move your post to other topic, but I just need to make sure which post you were replying to.
Was it to the person who just fixed there problem with VP9 not working for them?

Something about VP9 issues. I think from clx and dx9. I haven't slept so... i'll be back later. not important anyway. May as well delete it.
 
Forum activity
Help Users
You can interact with the ChatGPT Bot in any Chat Room and there is a dedicated room. The command is /ai followed by a space and then your ? or inquiry.
ie: /ai What is a EM Pinball Machine?
  • No one is chatting at the moment.
      Chat Bot Mibs Chat Bot Mibs: AnushDCosta is our newest member. Welcome!
      Back
      Top