@ -802,8 +802,8 @@ void AiL::RenderWorld(float fElapsedTime){
count + + ;
}
if ( player - > teleportAnimationTimer > 0 ) {
playerScale . x = 120 * float ( abs ( pow ( player - > teleportAnimationTimer - 0.175f , 3 ) ) ) ;
pos = player - > teleportStartPosition . lerp ( player - > teleportTarget , ( 0.35f - player - > teleportAnimationTimer ) / 0.35f ) ;
playerScale . x = 120 * float ( abs ( pow ( player - > teleportAnimationTimer - " Wizard.Right Click Ability.AnimationTime " _F / 2 , 3 ) ) ) ;
pos = player - > teleportStartPosition . lerp ( player - > teleportTarget , ( " Wizard.Right Click Ability.AnimationTime " _F - player - > teleportAnimationTimer ) / " Wizard.Right Click Ability.AnimationTime " _F ) ;
}
const std : : vector < Buff > attackBuffs = player - > GetStatBuffs ( { " Attack " , " Attack % " } ) ;
view . DrawPartialRotatedDecal ( pos + vf2d { 0 , - player - > GetZ ( ) * ( std : : signbit ( scale . y ) ? - 1 : 1 ) } , player - > GetFrame ( ) . GetSourceImage ( ) - > Decal ( ) , player - > GetSpinAngle ( ) , { 12 , 12 } , player - > GetFrame ( ) . GetSourceRect ( ) . pos , player - > GetFrame ( ) . GetSourceRect ( ) . size , playerScale * scale , attackBuffs . size ( ) > 0 ? Pixel { 255 , uint8_t ( 255 * abs ( sin ( 1.4 * attackBuffs [ 0 ] . duration ) ) ) , uint8_t ( 255 * abs ( sin ( 1.4 * attackBuffs [ 0 ] . duration ) ) ) } : WHITE ) ;
@ -898,9 +898,9 @@ void AiL::RenderWorld(float fElapsedTime){
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * GetCurrentMapData ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMapData ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
geom2d : : rect < floa t> collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vf2d { float ( x ) , float ( y ) } * float ( GetCurrentMapData ( ) . tilewidth ) + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vf2d { float ( x ) , float ( y ) } * float ( GetCurrentMapData ( ) . tilewidth ) + collision . pos , collision . size , GREY ) ;
}
}
# endif
@ -926,9 +926,9 @@ void AiL::RenderWorld(float fElapsedTime){
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * GetCurrentMapData ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMapData ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
geom2d : : rect < floa t> collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vf2d { float ( x ) , float ( y ) } * float ( GetCurrentMapData ( ) . tilewidth ) + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vf2d { float ( x ) , float ( y ) } * float ( GetCurrentMapData ( ) . tilewidth ) + collision . pos , collision . size , GREY ) ;
}
}
# endif
@ -948,6 +948,17 @@ void AiL::RenderWorld(float fElapsedTime){
}
} break ;
}
for ( int y2 = 0 ; y2 < 2 ; y2 + + ) {
for ( int x2 = 0 ; x2 < 2 ; x2 + + ) {
vf2d tilePos = vf2d { float ( x ) , float ( y ) } * 24 ;
vf2d gridPos = tilePos + pathfinder . gridSpacing * vf2d { float ( x2 ) , float ( y2 ) } ;
Pixel col = RED ;
if ( ! pathfinder . nodes [ gridPos ] . bObstacle & & ! pathfinder . nodes [ gridPos ] . bObstacleUpper ) {
col = GREEN ;
}
view . FillRectDecal ( gridPos , pathfinder . gridSpacing , { col . r , col . g , col . b , 128 } ) ;
}
}
} else {
if ( GetCurrentMap ( ) . backdrop . length ( ) > 0 ) {
vf2d tileWorldPos = vi2d { x , y } * GetCurrentMapData ( ) . tilewidth ;
@ -1067,11 +1078,19 @@ void AiL::RenderWorld(float fElapsedTime){
RenderTile ( * tile , { 255 , 255 , 255 , uint8_t ( 255 - tile - > tileOpacity / TileGroup : : FADE_TIME * TileGroup : : FADE_AMT ) } ) ;
float distToPlayer = geom2d : : line < float > ( player - > GetPos ( ) , tile - > pos + vf2d { 12 , 12 } ) . length ( ) ;
if ( distToPlayer < 24 * 3 & & tile - > tileOpacity > 0 & & tile - > tileSheet . tileset - > collision . find ( tile - > tileID ) ! = tile - > tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
geom2d : : rect < floa t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
distToPlayer / = 4 ;
if ( distToPlayer < 1 ) { distToPlayer = 1 ; }
view . FillRectDecal ( tile - > pos + collision . pos , collision . size , { 255 , 0 , 0 , uint8_t ( 128 * tile - > tileOpacity / sqrt ( distToPlayer ) ) } ) ;
view . DrawRectDecal ( tile - > pos + collision . pos , collision . size , { 128 , 0 , 0 , uint8_t ( 255 / sqrt ( distToPlayer ) ) } ) ;
# ifdef _DEBUG
if ( " debug_collision_boxes_snapping " _I ) {
if ( fmod ( tile - > pos . x + collision . pos . x , 1.f ) ! = 0.f | | fmod ( tile - > pos . y + collision . pos . y , 1.f ) ! = 0.f ) {
view . DrawShadowStringPropDecal ( tile - > pos + collision . pos - vf2d { 0 , 24 } , ( tile - > pos + collision . pos ) . str ( ) , RED , BLACK , { 0.5f , 1.f } , 24.f ) ;
view . DrawShadowStringPropDecal ( tile - > pos + collision . pos + vf2d { 0 , 24 } , ( ( tile - > pos + collision . pos ) + ( collision . size ) ) . str ( ) , GREEN , BLACK , { 0.5f , 1.f } , 24.f ) ;
}
}
# endif
}
}
# pragma endregion
@ -1092,11 +1111,19 @@ void AiL::RenderWorld(float fElapsedTime){
RenderTile ( * tile , { 255 , 255 , 255 , uint8_t ( 255 - tile - > tileOpacity / TileGroup : : FADE_TIME * TileGroup : : FADE_AMT ) } ) ;
float distToPlayer = geom2d : : line < float > ( player - > GetPos ( ) , tile - > pos + vf2d { 12 , 12 } ) . length ( ) ;
if ( distToPlayer < 24 * 3 & & tile - > tileOpacity > 0 & & tile - > tileSheet . tileset - > collision . find ( tile - > tileID ) ! = tile - > tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
geom2d : : rect < floa t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
distToPlayer / = 4 ;
if ( distToPlayer < 1 ) { distToPlayer = 1 ; }
view . FillRectDecal ( tile - > pos + collision . pos , collision . size , { 255 , 0 , 0 , uint8_t ( 128 * tile - > tileOpacity / sqrt ( distToPlayer ) ) } ) ;
view . DrawRectDecal ( tile - > pos + collision . pos , collision . size , { 128 , 0 , 0 , uint8_t ( 255 / sqrt ( distToPlayer ) ) } ) ;
# ifdef _DEBUG
if ( " debug_collision_boxes_snapping " _I ) {
if ( fmod ( tile - > pos . x + collision . pos . x , 1.f ) ! = 0.f | | fmod ( tile - > pos . y + collision . pos . y , 1.f ) ! = 0.f ) {
view . DrawShadowStringPropDecal ( tile - > pos + collision . pos - vf2d { 0 , 24 } , ( tile - > pos + collision . pos ) . str ( ) , RED , BLACK , { 0.5f , 1.f } , 24.f ) ;
view . DrawShadowStringPropDecal ( tile - > pos + collision . pos + vf2d { 0 , 24 } , ( ( tile - > pos + collision . pos ) + ( collision . size ) ) . str ( ) , GREEN , BLACK , { 0.5f , 1.f } , 24.f ) ;
}
}
# endif
}
}
# pragma endregion
@ -1124,9 +1151,9 @@ void AiL::RenderWorld(float fElapsedTime){
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * game - > GetCurrentMapData ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * game - > GetCurrentMapData ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
geom2d : : rect < floa t> collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vf2d { float ( x ) , float ( y ) } * float ( game - > GetCurrentMapData ( ) . tilewidth ) + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vf2d { float ( x ) , float ( y ) } * float ( game - > GetCurrentMapData ( ) . tilewidth ) + collision . pos , collision . size , GREY ) ;
}
}
# endif
@ -1210,7 +1237,7 @@ void AiL::RenderWorld(float fElapsedTime){
RenderTile ( * tile , { 255 , 255 , 255 , uint8_t ( 255 - tile - > tileOpacity / TileGroup : : FADE_TIME * TileGroup : : FADE_AMT ) } ) ;
float distToPlayer = geom2d : : line < float > ( player - > GetPos ( ) , tile - > pos + vf2d { 12 , 12 } ) . length ( ) ;
if ( distToPlayer < 24 * 3 & & tile - > tileOpacity > 0 & & tile - > tileSheet . tileset - > collision . find ( tile - > tileID ) ! = tile - > tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
geom2d : : rect < floa t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
distToPlayer / = 4 ;
if ( distToPlayer < 1 ) { distToPlayer = 1 ; }
view . FillRectDecal ( tile - > pos + collision . pos , collision . size , { 255 , 0 , 0 , uint8_t ( 128 * tile - > tileOpacity / sqrt ( distToPlayer ) ) } ) ;
@ -1235,7 +1262,7 @@ void AiL::RenderWorld(float fElapsedTime){
RenderTile ( * tile , { 255 , 255 , 255 , uint8_t ( 255 - tile - > tileOpacity / TileGroup : : FADE_TIME * TileGroup : : FADE_AMT ) } ) ;
float distToPlayer = geom2d : : line < float > ( player - > GetPos ( ) , tile - > pos + vf2d { 12 , 12 } ) . length ( ) ;
if ( distToPlayer < 24 * 3 & & tile - > tileOpacity > 0 & & tile - > tileSheet . tileset - > collision . find ( tile - > tileID ) ! = tile - > tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
geom2d : : rect < floa t> collision = tile - > tileSheet . tileset - > collision [ tile - > tileID ] . collision ;
distToPlayer / = 4 ;
if ( distToPlayer < 1 ) { distToPlayer = 1 ; }
view . FillRectDecal ( tile - > pos + collision . pos , collision . size , { 255 , 0 , 0 , uint8_t ( 128 * tile - > tileOpacity / sqrt ( distToPlayer ) ) } ) ;
@ -1895,7 +1922,7 @@ TilesheetData AiL::GetTileSheet(MapName map,int tileID){
}
bool AiL : : HasTileCollision ( MapName map , vf2d pos , bool upperLevel ) {
geom2d : : rect < in t> collisionRect = GetTileCollision ( map , pos , upperLevel ) ;
geom2d : : rect < floa t> collisionRect = GetTileCollision ( map , pos , upperLevel ) ;
vi2d collisionRectSnapPos = vi2d { pos / float ( game - > GetCurrentMapData ( ) . tilewidth ) } * game - > GetCurrentMapData ( ) . tilewidth ;
collisionRect . pos + = collisionRectSnapPos ;
return geom2d : : overlaps ( collisionRect , pos ) ;
@ -1905,7 +1932,7 @@ bool AiL::IsBridgeLayer(LayerTag&layer){
return layer . tag . data . find ( " class " ) ! = layer . tag . data . end ( ) & & layer . tag . data [ " class " ] = = " Bridge " ;
}
geom2d : : rect < in t> AiL : : GetTileCollision ( MapName map , vf2d pos , bool upperLevel ) {
geom2d : : rect < floa t> AiL : : GetTileCollision ( MapName map , vf2d pos , bool upperLevel ) {
if ( pos . x < 0 | | pos . y < 0 | | pos . x > = GetCurrentMapData ( ) . width * game - > GetCurrentMapData ( ) . tilewidth | | pos . y > = GetCurrentMapData ( ) . height * game - > GetCurrentMapData ( ) . tilewidth ) return NO_COLLISION ;
if ( GetCurrentMap ( ) . optimizedTile ) return NO_COLLISION ; //Overworld map has no collision.
@ -1919,13 +1946,13 @@ geom2d::rect<int>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel){
break ;
}
}
if ( ! hasTerrain ) return geom2d : : rect < int > ( { 0 , 0 } , { GetCurrentMapData ( ) . tilewidth , GetCurrentMapData ( ) . tilewidth } ) ; //We assume no terrain means we can't walk on this.
if ( ! hasTerrain ) return geom2d : : rect < float > ( { 0.f , 0.f } , { float ( GetCurrentMapData ( ) . tilewidth ) , float ( GetCurrentMapData ( ) . tilewidth ) } ) ; //We assume no terrain means we can't walk on this.
# pragma region Lower Bridge Collision Check
if ( ! upperLevel ) { //We are looking for lower bridge collisions.
for ( ZoneData & zone : MAP_DATA [ map ] . ZoneData [ " LowerBridgeCollision " ] ) {
if ( geom2d : : contains ( zone . zone , pos ) ) {
return { { 0 , 0 } , { game - > GetCurrentMapData ( ) . tilewidth , game - > GetCurrentMapData ( ) . tilewidth } } ;
return { { 0 , 0 } , { float ( game - > GetCurrentMapData ( ) . tilewidth ) , float ( game - > GetCurrentMapData ( ) . tilewidth ) } } ;
}
}
}
@ -1940,13 +1967,13 @@ geom2d::rect<int>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel){
return NO_COLLISION ;
}
}
geom2d : : rect < in t> foundRect = NO_COLLISION ;
geom2d : : rect < floa t> foundRect = NO_COLLISION ;
for ( int counter = 0 ; LayerTag & layer : MAP_DATA [ map ] . LayerData ) {
//auto HasNoClass=[&](){return layer.tag.data.find("class")==layer.tag.data.end();};
if ( counter ! = bridgeLayerIndex ) {
int tileID = layer . tiles [ int ( pos . y ) / GetCurrentMapData ( ) . tilewidth ] [ int ( pos . x ) / GetCurrentMapData ( ) . tilewidth ] - 1 ;
if ( tileID ! = - 1 & & GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . find ( tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ) ! = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . end ( ) ) {
geom2d : : rect < in t> collisionRect = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision [ tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ] . collision ;
geom2d : : rect < floa t> collisionRect = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision [ tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ] . collision ;
if ( foundRect . pos = = NO_COLLISION . pos & & foundRect . size = = NO_COLLISION . size ) {
foundRect = collisionRect ;
} else {