haxball / haxball-issues

115 stars 43 forks source link

Is it just a simple rearrange of joints or a hack? #1179

Closed thenorthstar closed 3 years ago

thenorthstar commented 3 years ago

eKDQE0m

Firstly sorry for spamming content above. I have pressed wrong key before sending the issue. Now, please look at this image. They told that they display the scores and try rights of players on the pitch by using rearrangement of joints but their map cannot be scored and I have no idea how they do it.

Link: https://hbanz.org/forum/portal.php

basro commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

thenorthstar commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following).

https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357

Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Phantomat0 commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following).

https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357

Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Any update on how this works? My only need is to be able to create a straight line using the joints, but I am struggling on how to position them dynamically, and how to implement them into the live map.

thenorthstar commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following). https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357 Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Any update on how this works? My only need is to be able to create a straight line using the joints, but I am struggling on how to position them dynamically, and how to implement them into the live map.

@Phantomat0 I have not any new update on this one but I have something new with joints... Called gamebar. Let's look at how does it work.

https://thehax.pl/forum/powtorki.php?nagranie=46e9b4aee3b8370e73a1bc914723c055

I think that this one is easier than to do the above one, either with if's and else's or like the hbanz community did.

Phantomat0 commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following). https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357 Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Any update on how this works? My only need is to be able to create a straight line using the joints, but I am struggling on how to position them dynamically, and how to implement them into the live map.

@Phantomat0 I have not any new update on this one but I have something new with joints... Called gamebar. Let's look at how does it work.

https://thehax.pl/forum/powtorki.php?nagranie=46e9b4aee3b8370e73a1bc914723c055

I think that this one is easier than to do the above one, either with if's and else's or like the hbanz community did.

Interesting, my exact question would be how exactly are you able to manipulate the vectors, more specifically, changing their position? I understand that the vectors are already in the map code, so in what way are you able to access their properties when there is no method of doing so, unlike the getDisc method for discs.

thenorthstar commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following). https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357 Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Any update on how this works? My only need is to be able to create a straight line using the joints, but I am struggling on how to position them dynamically, and how to implement them into the live map.

@Phantomat0 I have not any new update on this one but I have something new with joints... Called gamebar. Let's look at how does it work. https://thehax.pl/forum/powtorki.php?nagranie=46e9b4aee3b8370e73a1bc914723c055 I think that this one is easier than to do the above one, either with if's and else's or like the hbanz community did.

Interesting, my exact question would be how exactly are you able to manipulate the vectors, more specifically, changing their position? I understand that the vectors are already in the map code, so in what way are you able to access their properties when there is no method of doing so, unlike the getDisc method for discs.

@Phantomat0 Let me say so, firstly I have to say that I'm talking about this new game bar. So yes, the vectors are already prepared in map codes. Think so: a lot of horizontal segments are located next to the each other. And then I'm getting the number of the jointed discs. (e.g. 72, 74, 76 etc.) And changing their position related to players' position (by using room.setDiscProperties). For example, my game bar uses the most forward player's position.

Now, let me explain in what way I'm accessing the properties of the balls: here, what the hard is to access the number of the balls, then rest is easily done. To access the number of the balls, I'm counting the balls carefully and adding their numbers into arrays (Here, red and blue has to be added separately). That's how I did that game bar works fluently but you can create a function which finds the balls which were jointed to somewhere and send them automatically into the arrays.

Phantomat0 commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following). https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357 Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Any update on how this works? My only need is to be able to create a straight line using the joints, but I am struggling on how to position them dynamically, and how to implement them into the live map.

@Phantomat0 I have not any new update on this one but I have something new with joints... Called gamebar. Let's look at how does it work. https://thehax.pl/forum/powtorki.php?nagranie=46e9b4aee3b8370e73a1bc914723c055 I think that this one is easier than to do the above one, either with if's and else's or like the hbanz community did.

Interesting, my exact question would be how exactly are you able to manipulate the vectors, more specifically, changing their position? I understand that the vectors are already in the map code, so in what way are you able to access their properties when there is no method of doing so, unlike the getDisc method for discs.

@Phantomat0 Let me say so, firstly I have to say that I'm talking about this new game bar. So yes, the vectors are already prepared in map codes. Think so: a lot of horizontal segments are located next to the each other. And then I'm getting the number of the jointed discs. (e.g. 72, 74, 76 etc.) And changing their position related to players' position (by using room.setDiscProperties). For example, my game bar uses the most forward player's position.

Now, let me explain in what way I'm accessing the properties of the balls: here, what the hard is to access the number of the balls, then rest is easily done. To access the number of the balls, I'm counting the balls carefully and adding their numbers into arrays (Here, red and blue has to be added separately). That's how I did that game bar works fluently but you can create a function which finds the balls which were jointed to somewhere and send them automatically into the arrays.

Very interesting! Maybe the issue im having is that I do not understand the logic in the maps and how haxball maps work, so excuse me if these questions appear elementary. From my understanding, you are editing the disc position to move the segments, but how are the segments connected to the discs, what relationship do they have with each other? Essentially, the discs are acting as vertices, how are you able to achieve this behavior? I am playing around with the map editor, and I cannot seem to replicate it. Basically what I am asking is, how you are able to achieve this:

Think so: a lot of horizontal segments are located next to the each other. And then I'm getting the number of the jointed discs. (e.g. 72, 74, 76 etc.)

I am able to move positions of discs in headless, but the segments do not follow, so my question is how you connect the segments to discs? Sorry if this sounds like a dumb question.

thenorthstar commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following). https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357 Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Any update on how this works? My only need is to be able to create a straight line using the joints, but I am struggling on how to position them dynamically, and how to implement them into the live map.

@Phantomat0 I have not any new update on this one but I have something new with joints... Called gamebar. Let's look at how does it work. https://thehax.pl/forum/powtorki.php?nagranie=46e9b4aee3b8370e73a1bc914723c055 I think that this one is easier than to do the above one, either with if's and else's or like the hbanz community did.

Interesting, my exact question would be how exactly are you able to manipulate the vectors, more specifically, changing their position? I understand that the vectors are already in the map code, so in what way are you able to access their properties when there is no method of doing so, unlike the getDisc method for discs.

@Phantomat0 Let me say so, firstly I have to say that I'm talking about this new game bar. So yes, the vectors are already prepared in map codes. Think so: a lot of horizontal segments are located next to the each other. And then I'm getting the number of the jointed discs. (e.g. 72, 74, 76 etc.) And changing their position related to players' position (by using room.setDiscProperties). For example, my game bar uses the most forward player's position. Now, let me explain in what way I'm accessing the properties of the balls: here, what the hard is to access the number of the balls, then rest is easily done. To access the number of the balls, I'm counting the balls carefully and adding their numbers into arrays (Here, red and blue has to be added separately). That's how I did that game bar works fluently but you can create a function which finds the balls which were jointed to somewhere and send them automatically into the arrays.

Very interesting! Maybe the issue im having is that I do not understand the logic in the maps and how haxball maps work, so excuse me if these questions appear elementary. From my understanding, you are editing the disc position to move the segments, but how are the segments connected to the discs, what relationship do they have with each other? Essentially, the discs are acting as vertices, how are you able to achieve this behavior? I am playing around with the map editor, and I cannot seem to replicate it. Basically what I am asking is, how you are able to achieve this:

Think so: a lot of horizontal segments are located next to the each other. And then I'm getting the number of the jointed discs. (e.g. 72, 74, 76 etc.)

I am able to move positions of discs in headless, but the segments do not follow, so my question is how you connect the segments to discs? Sorry if this sounds like a dumb question.

@Phantomat0 Let me explain a bit more detailedly:

Firstly this game bar doesn't consist of walls. Walls are only located around the red and blue bars, as in gray color. Now, what you were failed is to distinguish joints and segments here. In fact, it's not completely your fault because of it's seeming exactly like a line segment. But this is not true.

What happened here is there are two balls of radius zero which are located at both of the ends of each of the joints. And these joints give an aspect of a bar by being located side by side. Also, these joints can lengthen and shorten (this can be set on map codes). That is, the joints has not a constant length as you can understand. And so, this makes us be able to change the length of the joints in mid-game.

Now, the rest (changing the position of joints) is made on the bot scripts. But our problem is to decide which balls we should move. Balls we should move are the second element of each of the joints. For example, in one of my maps (there are 3 different maps which uses this game bar), the second element of game bar joints are even numbered which is starting from 72 (this is why I said 72, 74, 76 etc.). For example, the red bar has 19 different joints and blue bar has 19 different joints like the red one. So one should create an array which holds the even numbers starting from 72 and has 19 entries. And then should create an array like as the red ones which starts from 110. I'm repeating, this is just an example and changes related to the map and number of balls you have used.

And now, we have small problem, too. According to what we will change the joints position? Of course, according to the most forward player's position, logically. The farther player to the ball is the farther the joint to the middle in a ration. For example, this ration is 1/10 for my maps. You can change it, either 1/5 or 1/20 or whatever else.

Now we are at the final step! Because we should find the most forward player in each of the teams. This means sorting players by their positions. Here, such a code can help us.

function sortByPosition(players) {
    return players.sort(function(p1, p2) {
        return p1.position.x - p2.position.x;
    });
}

function mostForwardPlayer(teamID){
    var players = room.getPlayerList();
    var playersTeam = players.filter(p => p.team === teamID);
    var redTeam = GetTeam(1);
    var blueTeam = GetTeam(2);
    var redTeamLength = GetTeam(1).length;
    var blueTeamLength = GetTeam(2).length;
    teamSorted = sortByPosition(playersTeam);
    if(redTeamLength > 0 || blueTeamLength > 0){
    if(teamID === 1){
        return teamSorted[redTeamLength-1]; //I have edited here to access the exact player object and then jump to the ID to change the joint positions related to the player position.
    }
    else if(teamID === 2){
        return teamSorted[0];
    }
    }
}

And the rest is to use the numbers in arrays in a for loop and apply the bot commands like this: room.setDiscProperties(Map1_GameBar_RedJointBalls[i],{x:0.1 * room.getPlayerDiscProperties(mfp_red.id).x}); //This is a row of my bot code

Finally, I think that I was comprehensible enough now. If you have still some problems, then you can share discord address and let me add you and send a simplified version of the code.

By the way as much as I have noticed, we are currently out of the main subject. Anybody who knows (firstly hbanz community) can still help us or I'm going to close this issue.

Phantomat0 commented 3 years ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

I have done a similar thing for scoring, with a horrible row of if's and else's (you can watch via the following). https://thehax.pl/forum/powtorki.php?nagranie=f18c2e9c7b6bae3b19da25f166546357 Of course, doing this by if's and else's isn't true but I don't know how to push letters (or numbers) like on the first image. Yes, I know that I should convert the words (or numbers) to arrays but don't know what should I do then.

Any update on how this works? My only need is to be able to create a straight line using the joints, but I am struggling on how to position them dynamically, and how to implement them into the live map.

@Phantomat0 I have not any new update on this one but I have something new with joints... Called gamebar. Let's look at how does it work. https://thehax.pl/forum/powtorki.php?nagranie=46e9b4aee3b8370e73a1bc914723c055 I think that this one is easier than to do the above one, either with if's and else's or like the hbanz community did.

Interesting, my exact question would be how exactly are you able to manipulate the vectors, more specifically, changing their position? I understand that the vectors are already in the map code, so in what way are you able to access their properties when there is no method of doing so, unlike the getDisc method for discs.

@Phantomat0 Let me say so, firstly I have to say that I'm talking about this new game bar. So yes, the vectors are already prepared in map codes. Think so: a lot of horizontal segments are located next to the each other. And then I'm getting the number of the jointed discs. (e.g. 72, 74, 76 etc.) And changing their position related to players' position (by using room.setDiscProperties). For example, my game bar uses the most forward player's position. Now, let me explain in what way I'm accessing the properties of the balls: here, what the hard is to access the number of the balls, then rest is easily done. To access the number of the balls, I'm counting the balls carefully and adding their numbers into arrays (Here, red and blue has to be added separately). That's how I did that game bar works fluently but you can create a function which finds the balls which were jointed to somewhere and send them automatically into the arrays.

Very interesting! Maybe the issue im having is that I do not understand the logic in the maps and how haxball maps work, so excuse me if these questions appear elementary. From my understanding, you are editing the disc position to move the segments, but how are the segments connected to the discs, what relationship do they have with each other? Essentially, the discs are acting as vertices, how are you able to achieve this behavior? I am playing around with the map editor, and I cannot seem to replicate it. Basically what I am asking is, how you are able to achieve this:

Think so: a lot of horizontal segments are located next to the each other. And then I'm getting the number of the jointed discs. (e.g. 72, 74, 76 etc.)

I am able to move positions of discs in headless, but the segments do not follow, so my question is how you connect the segments to discs? Sorry if this sounds like a dumb question.

@Phantomat0 Let me explain a bit more detailedly:

Firstly this game bar doesn't consist of walls. Walls are only located around the red and blue bars, as in gray color. Now, what you were failed is to distinguish joints and segments here. In fact, it's not completely your fault because of it's seeming exactly like a line segment. But this is not true.

What happened here is there are two balls of radius zero which are located at both of the ends of each of the joints. And these joints give an aspect of a bar by being located side by side. Also, these joints can lengthen and shorten (this can be set on map codes). That is, the joints has not a constant length as you can understand. And so, this makes us be able to change the length of the joints in mid-game.

Now, the rest (changing the position of joints) is made on the bot scripts. But our problem is to decide which balls we should move. Balls we should move are the second element of each of the joints. For example, in one of my maps (there are 3 different maps which uses this game bar), the second element of game bar joints are even numbered which is starting from 72 (this is why I said 72, 74, 76 etc.). For example, the red bar has 19 different joints and blue bar has 19 different joints like the red one. So one should create an array which holds the even numbers starting from 72 and has 19 entries. And then should create an array like as the red ones which starts from 110. I'm repeating, this is just an example and changes related to the map and number of balls you have used.

And now, we have small problem, too. According to what we will change the joints position? Of course, according to the most forward player's position, logically. The farther player to the ball is the farther the joint to the middle in a ration. For example, this ration is 1/10 for my maps. You can change it, either 1/5 or 1/20 or whatever else.

Now we are at the final step! Because we should find the most forward player in each of the teams. This means sorting players by their positions. Here, such a code can help us.

function sortByPosition(players) {
    return players.sort(function(p1, p2) {
        return p1.position.x - p2.position.x;
    });
}

function mostForwardPlayer(teamID){
    var players = room.getPlayerList();
    var playersTeam = players.filter(p => p.team === teamID);
    var redTeam = GetTeam(1);
    var blueTeam = GetTeam(2);
    var redTeamLength = GetTeam(1).length;
    var blueTeamLength = GetTeam(2).length;
    teamSorted = sortByPosition(playersTeam);
    if(redTeamLength > 0 || blueTeamLength > 0){
  if(teamID === 1){
      return teamSorted[redTeamLength-1]; //I have edited here to access the exact player object and then jump to the ID to change the joint positions related to the player position.
  }
  else if(teamID === 2){
      return teamSorted[0];
  }
    }
}

And the rest is to use the numbers in arrays in a for loop and apply the bot commands like this: room.setDiscProperties(Map1_GameBar_RedJointBalls[i],{x:0.1 * room.getPlayerDiscProperties(mfp_red.id).x}); //This is a row of my bot code

Finally, I think that I was comprehensible enough now. If you have still some problems, then you can share discord address and let me add you and send a simplified version of the code.

By the way as much as I have noticed, we are currently out of the main subject. Anybody who knows (firstly hbanz community) can still help us or I'm going to close this issue.

Thank you for the explanation. I appreciate the clarification regarding joints and vertices, and walls and segments. I thought you were referring to joints as vertices, using the same word. It wasn't until I did some further research into the code of some maps that I realized there is a property named "joint" that can be appended to discs, I was not aware of this before - im such a noob.

CenasPTS commented 1 year ago

Joints are the only visible lines that you could possibly modify without restarting the map, so yes it's most likely using joints connected to invisible discs. Very creative!

hey, is there a way to change invisible segments cMask or cGroup properties without restarting the map? I wanted to change it to redKO and blueKO on some segments and haven't seen any information about it

basro commented 1 year ago

hey, is there a way to change invisible segments cMask or cGroup properties without restarting the map? I wanted to change it to redKO and blueKO on some segments and haven't seen any information about it

It's not possible to do that, the map is immutable. The only thing you can modify is discs.

CenasPTS commented 1 year ago

hey, is there a way to change invisible segments cMask or cGroup properties without restarting the map? I wanted to change it to redKO and blueKO on some segments and haven't seen any information about it

It's not possible to do that, the map is immutable. The only thing you can modify is discs.

thank you for answering, so I'm building a 6 man script and when a player scores and he's in the middle of the field I wanted the other players stuck in their goals but when positions resetted and everyone was on their goal I wanted them to all be free and go all for the ball, is there a way to do this?

basro commented 1 year ago

Unfortunately there's currently no way to toggle segments for this purpose. Edit: There's a way...

An alternative solution I can think of is to monitor the position of the players in the onGameTick event and set their position to their goal's origin point when they move too far away.

Phantomat0 commented 1 year ago

hey, is there a way to change invisible segments cMask or cGroup properties without restarting the map? I wanted to change it to redKO and blueKO on some segments and haven't seen any information about it

It's not possible to do that, the map is immutable. The only thing you can modify is discs.

thank you for answering, so I'm building a 6 man script and when a player scores and he's in the middle of the field I wanted the other players stuck in their goals but when positions resetted and everyone was on their goal I wanted them to all be free and go all for the ball, is there a way to do this?

This sounds possible to me. I don’t know how to do it exactly off the top of my head, but my approach would be:

  1. Add a collision flag to the goal line segments
  2. On goal, move the person who is supposed to kickoff next to the ball, everyone else behind their goal.
  3. Give all the players the same collision flag that you have to the segment, that way it will act as a wall. So they will not be able to move through the goal line.
  4. Track the ball position, and once it has moved, remove the collision flags from the players.

My knowledge of collision flags is that you can make anything a wall as long as it’s immutable in the map code, and it’s position can’t be changed. For example segments connected by two vectors don’t work

basro commented 1 year ago

Sorry, I was mistaken. I did consider the cmask trick (which is what I use in the game to toggle the kickoff boundaries). But cmask is controlled by haxball haxball gameplay code and will be overwritten every frame. Trying to set a player's cMask will do nothing.

However I forgot there's also cGroup which will not be overwritten every frame. You can make a script that will change each player's cGroup property to toggle what they will collide with.

CenasPTS commented 1 year ago

Sorry, I was mistaken. I did consider the cmask trick (which is what I use in the game to toggle the kickoff boundaries). But cmask is controlled by haxball haxball gameplay code and will be overwritten every frame. Trying to set a player's cMask will do nothing.

However I forgot there's also cGroup which will not be overwritten every frame. You can make a script that will change each player's cGroup property to toggle what they will collide with.

Thank you so much ! I was able to toggle the players colliding with those segments changing the player's cGroup property just like you said