Skip to content

Commit

Permalink
Merge pull request #339 from sigureling/dev
Browse files Browse the repository at this point in the history
fix viewRange
  • Loading branch information
DreamEnderKing authored May 9, 2024
2 parents 61160f8 + 80cca68 commit a56b1bf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
2 changes: 2 additions & 0 deletions CAPI/cpp/API/include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace AssistFunction
THUAI7::PlaceType newPlace = map[GridToCell(newX)][GridToCell(newY)];
if (newPlace == THUAI7::PlaceType::Shadow && myPlace != THUAI7::PlaceType::Shadow)
return false;
if (distance > viewRange * viewRange)
return false;
int32_t divide = std::max(std::abs(deltaX), std::abs(deltaY)) / 100;
if (divide == 0)
return true;
Expand Down
73 changes: 36 additions & 37 deletions CAPI/python/PyAPI/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,44 @@ def HaveView(
newPlace = map[AssistFunction.GridToCell(newX)][AssistFunction.GridToCell(newY)]
if myPlace != THUAI7.PlaceType.Shadow and newPlace == THUAI7.PlaceType.Shadow:
return False
if distance <= viewRange * viewRange:
divide = max(abs(deltaX), abs(deltaY)) // 100
if divide == 0:
return True
dx = deltaX / divide
dy = deltaY / divide
selfX = float(x)
selfY = float(y)
if (
newPlace == THUAI7.PlaceType.Shadow
and myPlace == THUAI7.PlaceType.Shadow
):
for _ in range(divide):
selfX += dx
selfY += dy
if (
map[AssistFunction.GridToCell(int(selfX))][
AssistFunction.GridToCell(int(selfY))
]
!= THUAI7.PlaceType.Shadow
):
return False
else:
return True
if distance > viewRange * viewRange:
return False
divide = max(abs(deltaX), abs(deltaY)) // 100
if divide == 0:
return True
dx = deltaX / divide
dy = deltaY / divide
selfX = float(x)
selfY = float(y)
if (
newPlace == THUAI7.PlaceType.Shadow
and myPlace == THUAI7.PlaceType.Shadow
):
for _ in range(divide):
selfX += dx
selfY += dy
if (
map[AssistFunction.GridToCell(int(selfX))][
AssistFunction.GridToCell(int(selfY))
]
!= THUAI7.PlaceType.Shadow
):
return False
else:
for _ in range(divide):
selfX += dx
selfY += dy
if (
map[AssistFunction.GridToCell(int(selfX))][
AssistFunction.GridToCell(int(selfY))
]
== THUAI7.PlaceType.Ruin
):
return False
else:
return True
return True
else:
return False
for _ in range(divide):
selfX += dx
selfY += dy
if (
map[AssistFunction.GridToCell(int(selfX))][
AssistFunction.GridToCell(int(selfY))
]
== THUAI7.PlaceType.Ruin
):
return False
else:
return True


class Proto2THUAI7:
Expand Down

0 comments on commit a56b1bf

Please sign in to comment.