PROJECT: Scripting to detect player score changes/kills

YuYumudas BeegbutDec 12 201741.5K5
    Halo and Forge Discussion

My health has crapped out too much to allow me to get to making helpful game mode prefabs for objectives, game mechanics, player scoring, player IDs, etc etc.

So I'll try dumping one (really useful) game mode prefab idea here on Forgehub as a project any of us can work/help/comment on. Along with some script ideas and info that can help solve this thing. Sorry about the wall of text, but I'm not really sorry at all.

If this works out, we can do much, much more and rev up H5 Customs.

PROJECT: TRACK PLAYER SCORE CHANGES (AND MORE)
We can track player scores using Player Numbers and the Game Values section in the Number Change action. If we use a heartbeat timer to constantly check for player score changes, we'll constantly know when players have scored points. This project will open up all the things we can do if we can track player score changes:

  • In game modes based on Minigame you can add player scores to the team scores, which doesn't happen by default

  • In Slayer and Minigame, you can detect player kills

  • You can also track other useful info from the Game Values section:

    • Team (score)

    • Health (current), Health (max), Health (ratio) - also for objects

    • Shields (current), Shields (max), Sheilds (ratio) - also for objects

    • Players (current), Players: Team (current), Teams (current) - these can be used to know if players leave or new players join!!!

    • Spawn: Order - also for objects

IDEA + POTENTIAL SCRIPTS FOR DOING THIS

Overview

This is the idea, but it has to be tried out and debugged. If we're lucky it'll be all we need. These scripts use each player's {november} and {oscar} numbers to track individual score changes. What you do with the player score is determined by Script #S3 below.

  • {november}: Player number used to calculate score changes (NEW_SCORE - OLD_SCORE)

  • {oscar}: Player number that holds the player's old score from the last check

  • This example adds the points when a player's score goes up because it checks for changes Greater Than Constant 0... Use Greater Than Constant -9990 to include negative scores

Control Brain
The Control Brain continuously sets ALL player {november} numbers to -9999 to start a chain reaction that happens in the next game tick (1/60th of a second later).

Timer 1.00 0.10 //// use whatever timing/controls needed
A1) Number Change: Scope=Player, Channel={november}
NUMBERS=Players
Force Dirty=ON, Constant=-9999

Score Brains
There needs to be one of these brains per player, so use 16 to be sure or use less if you're sure there won't be more players than brains. The scripts can't be combined to use less and they need to be in this order... Probably.

Each brain picks one player (via Select Last: 1) to handle by changing her/his {november} to -9998.

Number Check: Scope=Player, Channel={november}, Equals Constant=-9999
A1) Number Change: Scope=Player, Channel={november}
NUMBERS=EXTRA, Select Last: 1
Increment, Constant=1

Copy that player's score to {november} then subtract the old score {oscar}. Now {november} has the amount the player's score has changed since last check.

Number Check: Scope=Player, Channel={november}, Equals, Constant=-9998
A1) Number Change: Scope=Player, Channel={november}
NUMBERS=EXTRA
Set, Source=Game Value, Player Score, Object=ACTIVATOR
A2) Number Change: Scope=Player, Channel={november}
NUMBERS=EXTRA
Decrement, Source=Number, Scope=Object, Object=ACTIVATOR
Scope=Player, Channel={Oscar}

If the player's score has increased (so {november} > 0), this example script will add that amount to their team's score. This can be changed to whatever you need to do when a player's score increases. Or you can add additional actions to do more, like for Slayer/Minigame {novermber} has the points the player gained for kills.

Number Check: Scope=Player, Channel={november}, Greater Than, Constant=0
A1) Score Change: Team, SCORERS=EXTRA
Increment, Source=Number, Scope=Object, Object=ACTIVATOR
Scope=Player, Channel={November}

Finally set this brain's selected player's {november} number to -9997 so this player won't get selected by other brains for the rest of this check/game tick since they will also check for -9999, -9998 and > -9990. Then copy the player's score to {oscar} so it'll be the old score for the next score check.

Number Check: Scope=Player, Channel={november}, Greater Than, Constant=-9990
A1) Number Change: Scope=Player, Channel={November}
NUMBERS=EXTRA
Set, Constant=-9997
A2) Number Change: Scope=Player, Channel={oscar}
NUMBERS=EXTRA
Set, Source=Game Value, Player Score, Object=ACTIVATOR

I used big negative numbers like -9999 to make sure player scores will always be higher than these number codes for {november}, but you can use smaller ones as long the codes you replace -9999, -9998 and -9997 with are bigger negative numbers than the -9990 replacement. Ex: -999, -998, -997 and -990.