Hello, ForgeHub Community! I need help with scripting a scoring system for a Basketball minigame that can be used in the Minigame game mode. I know that I could use the Grifball game mode to make this possible but I am going to implement the Basketball game into a Social Space that will have other features in it. As for the scoring system, I don't necessarily need the scripts to increase the game score when a player scores but I would like to have the scripts for it so that others could implement it either as its own game mode or as part of another social space. So, the bare minimum that I need the system to do is have 2 goals that can reward the appropriate team that scored in the enemy goal by announcing that "[Team A] has scored". The Goals will be 2 "Script Brains" with boundaries and the Ball will be the "Ball [Only]" object.
one recommendation I would have , having recently gone through the whole "which team is scoring?" issue, which is hard to resolve in H5, is that you do not worry about that at all. Have it be like real Basketball, where if the ball goes through Team 1's hoop, they score, no matter who put it in. You need the ball to have a User label. You need your hoop to detect when it is inside, and do a set of things when that occurs. There is a cool method one of those above guys taught me a while back, where you have an object first constantly update its own number to the count of objects with the ball label. The nanother script checking to see when that number is >0, and score in that situation. It is not hard to set up what you are asking at all... (it seems)
I have a map that uses something similar to what Terrestr was talking about though it doesnt use that object with user label thing that he was talking about
sure, so to be sure, you can do without a user label on the object if ther eis no chance any OTHER object could make it through the hoop. The above logic is for when you have to make sure a specific object has gone through. For instance, you don't want a nade or dropped weapon to possibly score. Scripting (Pro) tip: Never leave open possibilities that others will find if the yare not intended to happen. Just like leaving a space in your map where players could escape, you should always close down all unintended, undesirable circumstances from happening in your scripting.
BASKETBALL HOOP SCORING WITH BALL [ONLY] I'm just doing this in my head so see what ya can do with it. Here's what they were talking about: HOOP OBJECT (Set each hoop to a team) //keep getting the count of balls in the hoop (1) Timer 1.00 0.05 Number Change THIS [add] Set Object Count(Boundary THIS [add], Label [include] ball: object) //if the ball count is 1 then 1. give this hoop's team points, 2. signal for the last player who held the ball to get points, 4. reset the ball (2) Number Check Object Equals 1 Score Change Team SCORERS=THIS [add], Increment 2 Number Change Player {sierra} NUMBERS={{ Players [add] }} Increment Constant 1 (Save space for wait or something) Despawn Boundary THIS [add], Label [include] ball: object /OR/ Damage Ratio 100.00 (one might explode the ball.. not sure) BALL OBJECT (make sure it has the ball: object label) (1) Despawned (you can also try the Ball's Respawn On Destroyed Property) Wait 3.00 Spawn Force=ON //constantly mark the player holding the ball by setting their {sierra} number to 10 (2) Timer 1.00 0.10 Number Change Player {sierra} NUMBERS={{ Boundary THIS [add], Players [include] }} Set Constant 10 SCRIPT BRAIN OBJECT (just need one of these) //when a player's {sierra} number becomes 10 they have the ball so set everyone else back to 0 (1) Number Check Player {sierra} Equals 10 Number Change Player {sierra} NUMBERS={{ Players [add], EXTRA [remove] }} Set Constant 0 //when a basket is made all the {sierra} numbers go up 1 so only the last ball holder's {sierra} is 11, so 1. give them points ,2. reset all {sierra} numbers to 0 (2) Number Check Player {sierra} Equals 11 Score Change Player SCORERS=EXTRA [add], Increment Constant 2 Number Change Player {sierra} NUMBERS={{ Players [add] }} Set Constant 0
Alright i'll give a crack at this. Spawn a ball "weapon" and add a script Spoiler Script 1: On Boundary: Continuous 0.00 Player A1: Number Set Object Number- This Change- Set Object Count Players [Add] Team 1 (Include) Boundary [This] (Include) Offset=-2 A2: Number Set Object Number- This Change- Set Object Count Players [Add] Team 2 (Include) Boundary [This] (Include) Offset=0 Condition interrupt=off Add two more scripts: Spoiler Script 2: Number: Check Object Offset=0 if<0 A1: Label: Change This Remove user:bravo A2: Label: Change This Add user:romeo condition interrupt=off Spoiler Script 3: Number: Check Object Offset=0 if>0 A1: Label: Change This Remove user:romeo A2: Label: Change This Add user:bravo condition interrupt=off Now to have it score add a script on the red teams ball boundary: Spoiler Script 1: On Timer: 0.00 0.05 A1: Number: Change Object Number- This Change- Set Object Count Label [Add]- user:romeo Boundary [This] (Include) Offset=0 Spoiler Script 2: Number: Check Object Offset=0 if>0 Score: Change Team Team 1 [Add] Increment +1 Do the same for blue's goal, except use the blue label. (this is the net red team is defending.) Spoiler Script 1: On Timer: 0.00 0.05 A1: Number: Change Object Number- This Change- Set Object Count Label [Add]- user:bravo Boundary [This] (Include) Offset=0 Spoiler Script 2: Number: Check Object Offset=0 if>0 Score: Change Team Team 2 [Add] Increment +1