@ -143,7 +143,7 @@ void Player::ForceSetPos(vf2d pos){
Moved ( ) ;
}
bool Player : : _SetX ( float x , const bool playerInvoked ) {
bool Player : : _SetX ( float x , MoveFlag : : MoveFlag flags , const bool playerInvoked ) {
vf2d newPos = { x , pos . y } ;
vi2d tilePos = vi2d ( newPos / float ( game - > GetCurrentMapData ( ) . tilewidth ) ) * game - > GetCurrentMapData ( ) . tilewidth ;
geom2d : : rect < float > collisionRect = game - > GetTileCollision ( game - > GetCurrentLevel ( ) , newPos , upperLevel ) ;
@ -152,7 +152,7 @@ bool Player::_SetX(float x,const bool playerInvoked){
# pragma endregion
if ( NoTileCollisionExistsHere ( ) ) {
pos . x = std : : clamp ( x , game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) , float ( game - > GetCurrentMapData ( ) . width * game - > GetCurrentMapData ( ) . tilewidth - game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) ) ) ;
Moved ( ) ;
Moved ( flags ) ;
return true ;
} else {
geom2d : : rect < float > collision = { collisionRect . pos , collisionRect . size } ;
@ -162,21 +162,21 @@ bool Player::_SetX(float x,const bool playerInvoked){
collision . pos + = tilePos ;
if ( NoPlayerCollisionWithTile ( ) ) {
pos . x = std : : clamp ( x , game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) , float ( game - > GetCurrentMapData ( ) . width * game - > GetCurrentMapData ( ) . tilewidth - game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) ) ) ;
Moved ( ) ;
Moved ( flags ) ;
return true ;
} else
if ( playerInvoked ) { //If player invoked, we'll try the smart move system.
vf2d pushDir = geom2d : : line < float > ( collision . middle ( ) , pos ) . vector ( ) . norm ( ) ;
newPos = { newPos . x , pos . y + pushDir . y * 12 } ;
if ( NoPlayerCollisionWithTile ( ) ) {
return _SetY ( pos . y + pushDir . y * game - > GetElapsedTime ( ) * 12 , false ) ;
return _SetY ( pos . y + pushDir . y * game - > GetElapsedTime ( ) * 12 , flags , false ) ;
}
}
}
return false ;
} ;
bool Player : : _SetY ( float y , const bool playerInvoked ) {
bool Player : : _SetY ( float y , MoveFlag : : MoveFlag flags , const bool playerInvoked ) {
vf2d newPos = { pos . x , y } ;
vi2d tilePos = vi2d ( newPos / float ( game - > GetCurrentMapData ( ) . tilewidth ) ) * game - > GetCurrentMapData ( ) . tilewidth ;
geom2d : : rect < float > collisionRect = game - > GetTileCollision ( game - > GetCurrentLevel ( ) , newPos , upperLevel ) ;
@ -185,7 +185,7 @@ bool Player::_SetY(float y,const bool playerInvoked){
# pragma endregion
if ( NoTileCollisionExistsHere ( ) ) {
pos . y = std : : clamp ( y , game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) , float ( game - > GetCurrentMapData ( ) . height * game - > GetCurrentMapData ( ) . tilewidth - game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) ) ) ;
Moved ( ) ;
Moved ( flags ) ;
return true ;
} else {
geom2d : : rect < float > collision = { collisionRect . pos , collisionRect . size } ;
@ -195,37 +195,37 @@ bool Player::_SetY(float y,const bool playerInvoked){
collision . pos + = tilePos ;
if ( NoPlayerCollisionWithTile ( ) ) {
pos . y = std : : clamp ( y , game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) , float ( game - > GetCurrentMapData ( ) . height * game - > GetCurrentMapData ( ) . tilewidth - game - > GetCurrentMapData ( ) . tilewidth / 2.f * GetSizeMult ( ) ) ) ;
Moved ( ) ;
Moved ( flags ) ;
return true ;
} else
if ( playerInvoked ) { //If player invoked, we'll try the smart move system.{
vf2d pushDir = geom2d : : line < float > ( collision . middle ( ) , pos ) . vector ( ) . norm ( ) ;
newPos = { pos . x + pushDir . x * 12 , newPos . y } ;
if ( NoPlayerCollisionWithTile ( ) ) {
return _SetX ( pos . x + pushDir . x * game - > GetElapsedTime ( ) * 12 , false ) ;
return _SetX ( pos . x + pushDir . x * game - > GetElapsedTime ( ) * 12 , flags , false ) ;
}
}
}
return false ;
}
bool Player : : SetX ( float x ) {
return _SetX ( x ) ;
bool Player : : SetX ( float x , MoveFlag : : MoveFlag flags ) {
return _SetX ( x , flags ) ;
}
bool Player : : SetY ( float y ) {
return _SetY ( y ) ;
bool Player : : SetY ( float y , MoveFlag : : MoveFlag flags ) {
return _SetY ( y , flags ) ;
}
void Player : : SetZ ( float z ) {
this - > z = z ;
}
bool Player : : SetPos ( vf2d pos ) {
bool resultX = SetX ( pos . x ) ;
bool resultY = SetY ( pos . y ) ;
bool Player : : SetPos ( vf2d pos , MoveFlag : : MoveFlag flags ) {
bool resultX = SetX ( pos . x , flags ) ;
bool resultY = SetY ( pos . y , flags ) ;
if ( resultY & & ! resultX ) {
resultX = SetX ( pos . x ) ;
resultX = SetX ( pos . x , flags ) ;
}
return resultX | | resultY ;
}
@ -548,6 +548,12 @@ void Player::Update(float fElapsedTime){
ERR ( std : : format ( " WARNING! The velocity vector for the player is NOT normal! Current vel:{} . Attempting manual resetting of velocity. " , vel . str ( ) ) ) ;
vel = { } ;
}
vf2d finalWindSpd = game - > GetWindSpeed ( ) ;
if ( GetState ( ) = = State : : BLOCK ) finalWindSpd * = 1 - ( " Warrior.Right Click Ability.Knockback Reduction " _F / 100.f ) ;
game - > GetPlayer ( ) - > SetPos ( game - > GetPlayer ( ) - > GetPos ( ) + finalWindSpd * game - > GetElapsedTime ( ) , MoveFlag : : PREVENT_CAST_CANCELLING ) ;
if ( vel ! = vf2d { 0 , 0 } ) {
float newX = pos . x + vel . x * fElapsedTime ;
float newY = pos . y + vel . y * fElapsedTime ;
@ -875,8 +881,8 @@ void Player::CancelCast(){
}
}
void Player : : Moved ( ) {
if ( state = = State : : CASTING ) {
void Player : : Moved ( MoveFlag : : MoveFlag flags ) {
if ( ! ( flags & MoveFlag : : PREVENT_CAST_CANCELLING ) & & state = = State : : CASTING ) {
state = State : : NORMAL ;
castPrepAbility - > waitForRelease = true ;
CancelCast ( ) ;
@ -1078,7 +1084,7 @@ void Player::_SetIframes(float duration){
}
bool Player : : Heal ( int damage , bool suppressDamageNumber ) {
hp = std : : clamp ( hp + damage , 0 , int ( GetStat ( " Health " ) ) ) ;
hp = std : : clamp ( hp + damage , 0 , int ( GetMaxHealth ( ) ) ) ;
if ( ! suppressDamageNumber & & damage > 0 ) {
DAMAGENUMBER_LIST . push_back ( std : : make_shared < DamageNumber > ( GetPos ( ) , damage , true , HEALTH_GAIN ) ) ;
}
@ -1577,5 +1583,5 @@ void Player::ProximityKnockback(const vf2d centerPoint,const float knockbackFact
}
void Player : : AddVelocity ( vf2d vel ) {
this - > vel + = vel ;
this - > vel + = vel * game - > GetElapsedTime ( ) ;
}