haxball / haxball-issues

115 stars 43 forks source link

someone could pass a script that notifies the goal with assistance #1241

Open holyss opened 3 years ago

holyss commented 3 years ago

What is the easiest score system I can make? All I need is basically just for bot to say who scored goal, who asisted, and if it was a own goal.

ghost commented 3 years ago

Take a look at this code that written by Wazarr94. or Take a look at ball touching example script by Haxball itself

dapucita commented 3 years ago

Use Stack for trace the ball. Stack is LIFO(Last In First Out). 300px-Data_stack svg

See these Javascript APIs: Array.prototype.pop() Array.prototype.push()

You have to use two events(onPlayerBallKick, onTeamGoal) and global Stack.

Suppose that: Player 1(Blue) kicked the ball : push(1) Player 2(Red) kicked the ball : push(2) Player 3(Red) kicked the ball : push(3) [onTeamGoal Event called by Red Team] pop() //returned Red Player 3 (scorer) pop() //returned Red Player 2 (assist)

And you can imagine other situation, Own Goal: Player 1(Blue) kicked the ball : push(1) Player 2(Red) kicked the ball : push(2) Player 3(Red) kicked the ball : push(3) [onTeamGoal Event called by Blue Team] pop() //returned Red Player 3 (scorer) //you can judge Own Goal when the scorer and scored team is different.