Added display configuration parameter for debugging pathfinding. Reduced distance threshold for Wizard teleport to prevent jarring returns to previous position.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/28/head
parent 293938dc3f
commit 596d4122b4
  1. 11
      Crawler/Crawler.cpp
  2. 1
      Crawler/Crawler.h
  3. 1
      Crawler/Pathfinding.cpp
  4. 2
      Crawler/Wizard.cpp
  5. 3
      Crawler/assets/config/configuration.txt

@ -63,6 +63,8 @@ Crawler::Crawler()
std::string MONSTERSTRATEGIES_CONFIG = CONFIG_PATH + "monsterstrategies_config"_S;
utils::datafile::Read(DATA,MONSTERSTRATEGIES_CONFIG);
DEBUG_PATHFINDING="debug_pathfinding"_I;
for(std::string&cl:DATA.GetProperty("class_list").GetValues()){
std::cout<<cl<<std::endl;
utils::datafile::Read(DATA,CONFIG_PATH + "class_directory"_S + cl + ".txt");
@ -743,6 +745,13 @@ void Crawler::RenderWorld(float fElapsedTime){
std::string text=std::to_string(dn->damage);
view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,DARK_RED);
}
if(DEBUG_PATHFINDING){
std::vector<vf2d>pathing=game->pathfinder.Solve_AStar(player.get()->GetPos(),GetWorldMousePos(),8,player.get()->OnUpperLevel());
for(vf2d&square:pathing){
view.FillRectDecal(square*24,{24,24},DARK_GREEN);
}
}
}
Player*Crawler::GetPlayer(){
@ -1077,7 +1086,7 @@ geom2d::rect<int>Crawler::GetTileCollision(MapName map,vf2d pos,bool upperLevel)
if(!upperLevel){ //We are looking for lower bridge collisions.
for(geom2d::rect<int>&zone:MAP_DATA[map].ZoneData["LowerBridgeCollision"]){
if(geom2d::contains(zone,pos)){
return {{0,0},{32,32}};
return {{0,0},{24,24}};
}
}
}

@ -53,6 +53,7 @@ private:
int bridgeLayerIndex=-1;
float bridgeFadeFactor=0.f;
void InitializeClasses();
int DEBUG_PATHFINDING=0;
public:
Crawler();
bool OnUserCreate() override;

@ -88,6 +88,7 @@ std::vector<vf2d> Pathfinding::Solve_AStar(vf2d startPos,vf2d endPos,float maxRa
nodeStart->fGlobalGoal = heuristic(nodeStart, nodeEnd);
std::list<sNode*> listNotTestedNodes;
//if((!upperLevel && nodeStart->bObstacle)||(upperLevel && nodeStart->bObstacleUpper))return {};
listNotTestedNodes.push_back(nodeStart);
while (!listNotTestedNodes.empty() && nodeCurrent != nodeEnd)

@ -81,7 +81,7 @@ void Wizard::InitializeClassAbilities(){
if(dist<"Wizard.Right Click Ability.TilesMin"_I*12)return false;
vf2d teleportPoint=p->GetPos()+pointTowardsMouse*dist;
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)&&p->CanPathfindTo(p->GetPos(),teleportPoint,"Wizard.Right Click Ability.TilesMax"_I)){
dist-=24;
dist-=4;
teleportPoint=p->GetPos()+pointTowardsMouse*dist;
}
if(dist>0&&p->CanPathfindTo(p->GetPos(),teleportPoint,"Wizard.Right Click Ability.TilesMax"_I)){

@ -35,3 +35,6 @@ debug_player_info = 0
# Shows collision boxes of tiles.
debug_collision_boxes = 0
# Shows pathfinding debugging
debug_pathfinding = 0
Loading…
Cancel
Save