I´m working on a checkered grid dungeon crawler, and while working with a Ranged unit, that should only attack while aligned with the player (think of it as a Ranged Rook) when I check LineOfSigth in the 90° it doesn´t detect it, it does work with every other angle thought, I tried trouble-shooting it by removing everything else but it still gives trouble with that angle, any ideas what I might be doing wrong?
I´ll leave some caps:
as you can see, all enemies attack expect the one straight down
(angle of sigth is only used for LOS, and angle of movement marks the moving direction
* On function 'EnemyRanged_PathFinding'
* Parameter 'UID' (Number)
+ Enemy: Pick instance with UID UID
// Check if the Enemy is closer to the Player in Y Axis
----+ System: abs(Enemy.X - Samurai.X) ≥ abs(Enemy.Y- Samurai.Y)
--------+ System: Enemy.X < Samurai.X
--------// Right
---------> Enemy: Set AngleOfSight to 0
--------+ System: Enemy.X > Samurai.X
--------// Left
---------> Enemy: Set AngleOfSight to 180
--------+ System: Enemy.Y < Samurai.Y
--------// Up
---------> Enemy: Set AngleOfMovement to 90
--------+ System: Enemy.Y > Samurai.Y
--------// Down
---------> Enemy: Set AngleOfMovement to 270
// Check if the Enemy is closer to the Player in X Axis
----+ System: abs(Enemy.X - Samurai.X) < abs(Enemy.Y- Samurai.Y)
--------+ System: Enemy.Y < Samurai.Y
--------// Up
---------> Enemy: Set AngleOfSight to 90
--------+ System: Enemy.Y > Samurai.Y
--------// Down
---------> Enemy: Set AngleOfSight to 270
--------+ System: Enemy.X < Samurai.X
--------// Right
---------> Enemy: Set AngleOfMovement to 0
--------+ System: Enemy.X > Samurai.X
--------// Left
---------> Enemy: Set AngleOfMovement to 180
----+ (no conditions)
-----> Functions: Call EnemyRanged_MoveOrAttack (UID: UID)
--------
* On function 'EnemyRanged_MoveOrAttack'
* Parameter 'UID' (Number)
+ Enemy: Pick instance with UID UID
// if the player is in range, attack
----+ Enemy: Has LineOfSight from (Self.X, Self.Y) angle Self.AngleOfSight to (Samurai.X, Samurai.Y)
-----> Functions: Call Move_Attack (UID: UID, AngleOfMotion: Enemy.AngleOfSight)
-----> Functions: Call PlayerGetsAttacked
--------+ [DISABLED] Enemy: Is overlapping Samurai at offset (round(cos(Enemy.AngleOfMovement) × TileSize), round(sin(Enemy.AngleOfMovement) × TileSize))
---------> (no actions)
// for some reason, it gives priority to MOVE>Attack, this "if" is to force it´s hand
----+ Enemy: [X] Has LineOfSight from (Self.X, Self.Y) angle Self.AngleOfSight to (Samurai.X, Samurai.Y)
// if you can move to, do so
--------+ Enemy: TileMovement can move to (Enemy.TileMovement.GridX + round(cos(Enemy.AngleOfMovement)),Enemy.TileMovement.GridY + round(sin(Enemy.AngleOfMovement)))
---------> Functions: Call Move_Forward (UID: Enemy.UID, AngleOfMotion: Enemy.AngleOfMovement)
// if there´s an obstacle, try to go around
--------+ Enemy: [X] TileMovement can move to (Enemy.TileMovement.GridX + round(cos(Enemy.AngleOfMovement)),Enemy.TileMovement.GridY + round(sin(Enemy.AngleOfMovement)))
--------+ Enemy: [X] Is TriedToMoveThisTurn
---------> Enemy: Set TriedToMoveThisTurn to True
// if its Left or Right
------------+ Enemy: AngleOfMovement = 0
------------+ OR Enemy: AngleOfMovement = 180
----------------+ System: Enemy.Y < Samurai.Y
----------------// Up
-----------------> Enemy: Set AngleOfMovement to 90
-----------------> Functions: Call EnemyMelee_MoveOrAttack (UID: UID)
----------------+ System: Enemy.Y ≥ Samurai.Y
----------------// Down
-----------------> Enemy: Set AngleOfMovement to 270
-----------------> Functions: Call EnemyMelee_MoveOrAttack (UID: UID)
// if its Up or Down
------------+ Enemy: AngleOfMovement = 90
------------+ OR Enemy: AngleOfMovement = 270
----------------+ System: Enemy.X < Samurai.X
----------------// Right
-----------------> Enemy: Set AngleOfMovement to 0
-----------------> Functions: Call EnemyMelee_MoveOrAttack (UID: UID)
----------------+ System: Enemy.X ≥ Samurai.X
----------------// Left
-----------------> Enemy: Set AngleOfMovement to 180
-----------------> Functions: Call EnemyMelee_MoveOrAttack (UID: UID)
// //if everything fails, just stand still
----+ System: Else
-----> (no actions)