Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.09 KB | None | 0 0
  1. package com.hjax.bodhisattva.analysis;
  2.  
  3. import com.github.ocraft.s2client.protocol.data.Abilities;
  4. import com.github.ocraft.s2client.protocol.data.Units;
  5. import com.github.ocraft.s2client.protocol.debug.Color;
  6. import com.github.ocraft.s2client.protocol.spatial.Point2d;
  7. import com.github.ocraft.s2client.protocol.unit.Alliance;
  8. import com.hjax.bodhisattva.Vector2d;
  9. import com.hjax.kagamine.game.Game;
  10. import com.hjax.kagamine.game.GameInfoCache;
  11. import com.hjax.kagamine.game.HjaxUnit;
  12.  
  13. public class WallFinder {
  14.    
  15.     //public static boolean done = false;
  16.  
  17.    
  18.     public static void onFrame() {
  19.        
  20.         int count = 0;
  21.        
  22.         for (float x =  Game.min_point().getX(); x < Game.max_point().getX(); x++ ) {
  23.             for (float y = Game.min_point().getY(); y < Game.max_point().getY(); y++) {
  24.                
  25.                 Vector2d current = new Vector2d(x, y);
  26.                
  27.                 Vector2d pylon1 = current.add(new Vector2d(-0, -2));
  28.                 Vector2d pylon2 = current.add(new Vector2d(2, -1));
  29.                 Vector2d pylon3 = current.add(new Vector2d(-2, -1));
  30.                
  31.                 if (canBuild(current)) {
  32.                     if (canBuild(pylon1) && canBuild(pylon2) && canBuild(pylon3)) {
  33.                         if (is_blocked(current.add(new Vector2d((float) 3, 0.5f))) && is_blocked(current.add(new Vector2d((float) -3, 0.5f)))) {
  34.                             count++;
  35.                             if (count > 0) {
  36.                                
  37.                                 Game.draw_box(current.toPoint2d(), Color.YELLOW);
  38.                                 Game.draw_box(pylon1.toPoint2d(), Color.GREEN);
  39.                                 Game.draw_box(pylon2.toPoint2d(), Color.WHITE);
  40.                                 Game.draw_box(pylon3.toPoint2d(), Color.PURPLE);
  41.  
  42.                             }
  43.                         }
  44.                     }
  45.                 }
  46.             }
  47.         }
  48.         System.out.println(count);
  49.        
  50.     }
  51.    
  52.     public static boolean canBuild(Vector2d point) {
  53.         return Game.is_placeable(point.add(new Vector2d(0.9f, 0.9f)).toPoint2d()) &&
  54.                 Game.is_placeable(point.add(new Vector2d(-0.9f, 0.9f)).toPoint2d()) &&
  55.                 Game.is_placeable(point.add(new Vector2d(0.9f, -0.9f)).toPoint2d()) &&
  56.                 Game.is_placeable(point.add(new Vector2d(-0.9f, -0.9f)).toPoint2d());
  57.     }
  58.    
  59.     public static boolean is_blocked(Vector2d point) {
  60.         return !Game.is_placeable(point.toPoint2d()) && !Game.pathable(point.toPoint2d());
  61.     }
  62.    
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement