From e7f60c01d36244ad129e4d377fabb30cab6fbdd6 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 22 Nov 2023 15:16:28 -0600 Subject: [PATCH] Fix suction/player pull-in effect for item drops. --- Crawler/ItemDrop.cpp | 23 ++++++++++++++++++----- Crawler/Version.h | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Crawler/ItemDrop.cpp b/Crawler/ItemDrop.cpp index 98e6cdd2..38458a2a 100644 --- a/Crawler/ItemDrop.cpp +++ b/Crawler/ItemDrop.cpp @@ -50,6 +50,7 @@ ItemDrop::ItemDrop(ItemInfo*item,vf2d pos) speed.x=util::random("ItemDrop.Item Drop Horizontal Speed"_f[1]-"ItemDrop.Item Drop Horizontal Speed"_f[0])+"ItemDrop.Item Drop Horizontal Speed"_f[0]; speed.y=util::random("ItemDrop.Item Drop Vertical Speed"_f[1]-"ItemDrop.Item Drop Vertical Speed"_f[0])+"ItemDrop.Item Drop Vertical Speed"_f[0]; zSpeed="ItemDrop.Item Drop Initial Rise Speed"_F; + randomSpinOffset=util::random(PI/2); } vf2d ItemDrop::GetPos(){ @@ -68,9 +69,14 @@ void ItemDrop::Draw(){ } #pragma endregion - game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F}); + float yOffset=0; + if(GetZ()==0){ + yOffset=sin((game->levelTime+randomSpinOffset)*3)*0.5; + } + game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()+yOffset},GFX["skill_overlay_icon_overlay.png"].Decal(),0,GFX["skill_overlay_icon_overlay.png"].Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},YELLOW); + game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()+yOffset},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},{255,255,255,128}); game->SetDecalMode(DecalMode::ADDITIVE); - game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},{uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),255}); + game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()+yOffset},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},{uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),128}); game->SetDecalMode(DecalMode::NORMAL); } @@ -78,7 +84,10 @@ void ItemDrop::UpdateDrops(float fElapsedTime){ for(ItemDrop&drop:drops){ #pragma region Handle Z Speed drop.z+=drop.zSpeed*fElapsedTime; - if(drop.z<0)drop.zSpeed=0; + if(drop.z<=0){ + drop.zSpeed=0; + drop.z=0; + } else{ drop.zSpeed+=gravity*fElapsedTime; drop.pos+=drop.speed*fElapsedTime; @@ -90,8 +99,12 @@ void ItemDrop::UpdateDrops(float fElapsedTime){ geom2d::linelineTo=geom2d::line(drop.pos,game->GetPlayer()->GetPos()); float dist=lineTo.length(); if(dist<="ItemDrop.Item Drop Suction Range"_F){ - vf2d pointVel=lineTo.vector(); - drop.pos+=pointVel*(1/dist*fElapsedTime); + vf2d pointVel=lineTo.vector().norm(); + if((1.f/dist)*200*fElapsedTime>dist){ + drop.pos=game->GetPlayer()->GetPos(); + }else{ + drop.pos+=pointVel*(1.f/dist)*200*fElapsedTime; + } } } #pragma endregion diff --git a/Crawler/Version.h b/Crawler/Version.h index 758e2e55..9c2cc810 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -35,7 +35,7 @@ SUCH DAMAGE. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 3052 +#define VERSION_BUILD 3073 #define stringify(a) stringify_(a) #define stringify_(a) #a