H5 Scripting Help: Basketball scoring system for Minigame game mode.

Discussion in 'Halo and Forge Discussion' started by Blackangel3942, Feb 13, 2018.

  1. Blackangel3942

    Messages:
    4
    Likes Received:
    2
    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.
     
  2. Ascend Hyperion

    Ascend Hyperion The Homeslice
    Staff Member Forge Critic

    Messages:
    1,099
    Likes Received:
    3,060
  3. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    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)
     
    Egggnog and Yumudas Beegbut like this.
  4. mccluretim96

    mccluretim96 Heroic

    Messages:
    9
    Likes Received:
    2
    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
     
    ExTerrestr1al likes this.
  5. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    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.
     
    Yumudas Beegbut likes this.
  6. Blackangel3942

    Messages:
    4
    Likes Received:
    2
    Do remember how you set it up?
     
  7. Yumudas Beegbut

    Yumudas Beegbut Spartan II
    Wiki Contributor

    Messages:
    391
    Likes Received:
    349
    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
      1. 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
      1. Score Change Team SCORERS=THIS [add], Increment 2
      2. Number Change Player {sierra} NUMBERS={{ Players [add] }} Increment Constant 1
      3. (Save space for wait or something)
      4. 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)
      1. Wait 3.00
      2. Spawn Force=ON
    //constantly mark the player holding the ball by setting their {sierra} number to 10
    • (2) Timer 1.00 0.10
      1. 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
      1. 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
      1. Score Change Player SCORERS=EXTRA [add], Increment Constant 2
      2. Number Change Player {sierra} NUMBERS={{ Players [add] }} Set Constant 0
     
    #7 Yumudas Beegbut, Feb 13, 2018
    Last edited: Feb 13, 2018
    Egggnog likes this.
  8. mccluretim96

    mccluretim96 Heroic

    Messages:
    9
    Likes Received:
    2
    Yeah i still have the map. Are you in ForgeHub's discord?
     
  9. Blackangel3942

    Messages:
    4
    Likes Received:
    2
    No, I am not.
     
  10. mccluretim96

    mccluretim96 Heroic

    Messages:
    9
    Likes Received:
    2
    Here is an invite link.
    https://discord.gg/QNYQjCJ
     
  11. Blackangel3942

    Messages:
    4
    Likes Received:
    2
    I have joined the discord. Username is @Blackangel3942#1053
     
  12. Agent Zero85

    Agent Zero85 Spartan I
    Wiki Contributor

    Messages:
    399
    Likes Received:
    432
    Alright i'll give a crack at this. Spawn a ball "weapon" and add a script
    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:


    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


    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:

    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

    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.)


    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

    Script 2:
    Number: Check
    Object
    Offset=0
    if>0

    Score: Change
    Team
    Team 2 [Add]
    Increment
    +1
     

Share This Page