@ -1189,23 +1189,36 @@ void Crawler::RenderCooldowns(){
player - > GetAbility4 ( ) ,
} ;
const auto DrawCooldown = [ & ] ( vf2d pos , Ability & a ) {
const auto DrawCooldown = [ & ] ( vf2d pos , Ability & a , int loadoutSlot = - 1 /*Set to 0-2 to get an item slot rendered instead*/ ) {
bool circle = loadoutSlot = = - 1 ;
if ( a . name ! = " ??? " ) {
if ( a . cooldown > 0.1 ) {
DrawDecal ( pos , GFX [ a . icon ] . Decal ( ) , { 1 , 1 } , { 255 , 255 , 255 , 64 } ) ;
vf2d iconScale = { 1 , 1 } ;
if ( loadoutSlot ! = - 1 ) iconScale = { 0.7 , 0.7 } ;
DrawRotatedDecal ( pos + vf2d { 12 , 12 } , GFX [ a . icon ] . Decal ( ) , 0 , { 12 , 12 } , iconScale , { 255 , 255 , 255 , 64 } ) ;
if ( circle ) {
DrawPie ( pos + vf2d { 12 , 12 } , 12 , 360 - ( a . cooldown / a . COOLDOWN_TIME ) * 360 , PixelLerp ( a . barColor1 , a . barColor2 , ( a . cooldown / a . COOLDOWN_TIME ) ) ) ;
} else {
DrawSquarePie ( pos + vf2d { 12 , 12 } , 10 , 360 - ( a . cooldown / a . COOLDOWN_TIME ) * 360 , PixelLerp ( a . barColor1 , a . barColor2 , ( a . cooldown / a . COOLDOWN_TIME ) ) ) ;
}
std : : stringstream cooldownTimeDisplay ;
cooldownTimeDisplay < < std : : fixed < < std : : setprecision ( 1 ) < < a . cooldown ;
DrawShadowStringPropDecal ( pos + vf2d { 12 , 12 } - vf2d { float ( GetTextSizeProp ( cooldownTimeDisplay . str ( ) ) . x * 0.5 ) , float ( GetTextSizeProp ( cooldownTimeDisplay . str ( ) ) . y * 1 ) } / 2 , cooldownTimeDisplay . str ( ) , WHITE , BLACK , { 0.5 , 1 } ) ;
} else {
DrawDecal ( pos , GFX [ a . icon ] . Decal ( ) , { 1 , 1 } , WHITE ) ;
vf2d iconScale = { 1 , 1 } ;
if ( loadoutSlot ! = - 1 ) iconScale = { 0.7 , 0.7 } ;
DrawRotatedDecal ( pos + vf2d { 12 , 12 } , GFX [ a . icon ] . Decal ( ) , 0 , { 12 , 12 } , iconScale , WHITE ) ;
}
DrawDecal ( pos , GFX [ " skill_overlay_icon.png " ] . Decal ( ) ) ;
Decal * overlayIcon = GFX [ " skill_overlay_icon.png " ] . Decal ( ) ;
if ( ! circle ) overlayIcon = GFX [ " square_skill_overlay_icon.png " ] . Decal ( ) ;
DrawDecal ( pos , overlayIcon ) ;
Pixel shortNameCol = BLUE , manaCostShadowCol = DARK_BLUE , keyDisplayCol = YELLOW ;
if ( player - > GetMana ( ) < a . manaCost ) {
DrawDecal ( pos , GFX [ " skill_overlay_icon_overlay.png " ] . Decal ( ) , { 1 , 1 } , DARK_RED ) ;
Decal * overlayOverlayIcon = GFX [ " skill_overlay_icon_overlay.png " ] . Decal ( ) ;
if ( ! circle ) overlayOverlayIcon = GFX [ " square_skill_overlay_icon_empty.png " ] . Decal ( ) ;
DrawDecal ( pos , overlayOverlayIcon , { 1 , 1 } , DARK_RED ) ;
shortNameCol = RED ;
manaCostShadowCol = DARK_RED ;
keyDisplayCol = RED ;
@ -1216,6 +1229,20 @@ void Crawler::RenderCooldowns(){
keyDisplayCol = GREY ;
}
if ( loadoutSlot ! = - 1 ) {
uint32_t itemAmt = GetLoadoutItem ( loadoutSlot ) . Amt ( ) ;
if ( itemAmt > 0 ) {
std : : string amtString = " x " + std : : to_string ( itemAmt ) ;
vf2d qtySize = vf2d { GetTextSize ( amtString ) } * vf2d { 0.5 , 0.75 } ;
DrawShadowStringDecal ( pos + vf2d { 20 , 20 } - qtySize / 2 , amtString , WHITE , BLACK , { 0.5 , 0.75 } ) ;
} else {
DrawDecal ( pos , GFX [ " square_skill_overlay_icon_empty.png " ] . Decal ( ) , { 1 , 1 } , DARK_RED ) ;
shortNameCol = RED ;
manaCostShadowCol = DARK_RED ;
keyDisplayCol = RED ;
}
}
if ( a . manaCost > 0 ) {
vf2d manaCostSize = vf2d { GetTextSize ( std : : to_string ( a . manaCost ) ) } * vf2d { 0.5 , 0.75 } ;
DrawShadowStringDecal ( pos + vf2d { 20 , 4 } - manaCostSize / 2 , std : : to_string ( a . manaCost ) , { 192 , 192 , 255 } , manaCostShadowCol , { 0.5 , 0.75 } ) ;
@ -1238,6 +1265,15 @@ void Crawler::RenderCooldowns(){
}
DrawCooldown ( { float ( ScreenWidth ( ) - 32 ) , float ( ScreenHeight ( ) - 32 ) } , player - > GetRightClickAbility ( ) ) ;
for ( int i = - 1 ; i < 2 ; i + + ) {
int loadoutSlot = i + 1 ; //0-2
Ability * a = & GetPlayer ( ) - > useItem1 ;
if ( loadoutSlot = = 1 ) { a = & GetPlayer ( ) - > useItem2 ; } else
if ( loadoutSlot = = 2 ) { a = & GetPlayer ( ) - > useItem3 ; }
DrawCooldown ( { float ( ScreenWidth ( ) / 2 + i * 26 - 12 ) , float ( ScreenHeight ( ) - 26 ) } , * a , loadoutSlot ) ;
}
}
void Crawler : : AddEffect ( std : : unique_ptr < Effect > foreground , std : : unique_ptr < Effect > background ) {
@ -1590,6 +1626,9 @@ std::map<std::string,std::vector<ZoneData>>&Crawler::GetZoneData(MapName map){
}
void Crawler : : ChangePlayerClass ( Class cl ) {
Ability itemAbility1 = player - > useItem1 ;
Ability itemAbility2 = player - > useItem2 ;
Ability itemAbility3 = player - > useItem3 ;
switch ( cl ) {
case WARRIOR : {
player . reset ( NEW Warrior ( player . get ( ) ) ) ;
@ -1616,6 +1655,9 @@ void Crawler::ChangePlayerClass(Class cl){
player - > atkGrowthRate = DATA . GetProperty ( player - > GetClassName ( ) + " .AtkGrowthRate " ) . GetReal ( ) ;
sig : : Animation : : SetupPlayerAnimations ( ) ;
GetPlayer ( ) - > UpdateIdleAnimation ( DOWN ) ;
GetPlayer ( ) - > SetItem1UseFunc ( itemAbility1 ) ;
GetPlayer ( ) - > SetItem2UseFunc ( itemAbility2 ) ;
GetPlayer ( ) - > SetItem3UseFunc ( itemAbility3 ) ;
camera . SetTarget ( player - > GetPos ( ) ) ;
}
@ -2054,27 +2096,24 @@ void Crawler::SetLoadoutItem(int slot,std::string itemName){
inputGroup = & Player : : KEY_ITEM3 ;
} break ;
}
Ability itemAbility { itemName , " " , " " , " Item.Item Cooldown Time " _F , 0 , inputGroup , " items/ " + itemName , VERY_DARK_RED , DARK_RED , PrecastData { GetLoadoutItem ( slot ) . CastTime ( ) , 0 , 0 } , true } ;
Ability itemAbility { itemName , " " , " " , " Item.Item Cooldown Time " _F , 0 , inputGroup , " items/ " + itemName + " .png " , VERY_DARK_RED , DARK_RED , PrecastData { GetLoadoutItem ( slot ) . CastTime ( ) , 0 , 0 } , true } ;
switch ( slot ) {
case 0 : {
itemAbility . action = [ & ] ( Player * p , vf2d pos = { } ) {
game - > UseLoadoutItem ( 0 ) ;
return true ;
return game - > UseLoadoutItem ( 0 ) ;
} ;
game - > GetPlayer ( ) - > SetItem1UseFunc ( itemAbility ) ;
} break ;
case 1 : {
itemAbility . action = [ & ] ( Player * p , vf2d pos = { } ) {
game - > UseLoadoutItem ( 1 ) ;
return true ;
return game - > UseLoadoutItem ( 1 ) ;
} ;
game - > GetPlayer ( ) - > SetItem2UseFunc ( itemAbility ) ;
} break ;
case 2 : {
itemAbility . action = [ & ] ( Player * p , vf2d pos = { } ) {
game - > UseLoadoutItem ( 2 ) ;
return true ;
return game - > UseLoadoutItem ( 2 ) ;
} ;
game - > GetPlayer ( ) - > SetItem3UseFunc ( itemAbility ) ;
} break ;
@ -2085,14 +2124,15 @@ void Crawler::SetLoadoutItem(int slot,std::string itemName){
}
}
void Crawler : : UseLoadoutItem ( int slot ) {
bool Crawler : : UseLoadoutItem ( int slot ) {
if ( slot < 0 | | slot > loadout . size ( ) - 1 ) ERR ( " Invalid inventory slot " + std : : to_string ( slot ) + " , please choose a slot in range (0- " + std : : to_string ( loadout . size ( ) - 1 ) + " ). " ) ;
if ( GetLoadoutItem ( slot ) . Amt ( ) > 0 ) {
Inventory : : UseItem ( loadout [ slot ] . Name ( ) ) ;
GetLoadoutItem ( slot ) . OnUseAction ( ) ;
GetLoadoutItem ( slot ) . amt - - ;
return true ;
}
olc_UpdateKeyState ( K1 , false ) ;
return false ;
}
void Crawler : : ClearLoadoutItem ( int slot ) {