Skip to content

Commit

Permalink
Updated Smelting and unraveling
Browse files Browse the repository at this point in the history
Checking for health above 1
Checking if usesleft abive 1
added tongs/tinkering tools/scissors to metals.
Updated skills.cpp with hp,maxhp,maxuses to set the to 1
  • Loading branch information
DragonSlayer62 committed Nov 9, 2023
1 parent 4bad740 commit e3eb237
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
3 changes: 2 additions & 1 deletion data/js/server/data/material_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const itemTileIDList = [
0x4075, 0x4076, 0x48ae, 0x48af, 0x48b0, 0x48b1, 0x48b2, 0x48b3, 0x48b4, 0x48b5, 0x48b6,
0x48b7, 0x48ba, 0x48bb, 0x48bc, 0x48bd, 0x48be, 0x48bf, 0x48c0, 0x48c1, 0x48c2, 0x48c3,
0x48c4, 0x48c5, 0x48c6, 0x48c7, 0x48c8, 0x48c9, 0x48ca, 0x48cb, 0x48cc, 0x48cd, 0x48ce,
0x48cf, 0x48d0, 0x48d1, 0x48d2, 0x48d3, 0xa341, 0xa342, 0xa345, 0xa346,
0x48cf, 0x48d0, 0x48d1, 0x48d2, 0x48d3, 0xa341, 0xa342, 0xa345, 0xa346, 0x0fbb, 0x0fbc,
0x1EBC, 0x0f9e, 0x0f9f,

// Armor
0x13bb, 0x13be, 0x13bf, 0x13c0, 0x13c3, 0x13c4, 0x13eb, 0x13ec, 0x13ed, 0x13ee, 0x13ef,
Expand Down
20 changes: 17 additions & 3 deletions data/js/skill/craft/blacksmithing.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,24 @@ function onCallback1( pSock, ourObj )
{
// Calculate amount of resources returned based on player's mining skill, item's wear and tear,
// and amount of resources that went into making the item in the first place
var itemHitpointsPercentage = Math.floor(( ourObj.health * 100 ) / ourObj.maxhp );
if ( ourObj.health >= 1 || ourObj.usesLeft >= 1 )
{
var healthPercentage = 0;
if( ourObj.health >= 1 )
{
healthPercentage = Math.floor( ( ourObj.health * 100) / ourObj.maxhp );
}

var usesPercentage = 0;
if( ourObj.usesLeft >= 1 )
{
usesPercentage = Math.floor( ( ourObj.usesLeft * 100 ) / ourObj.maxUses );
}

// Reduce amount of resources returned based on state of object's wear and tear
resourceAmount = Math.floor(( maxResourceAmount * itemHitpointsPercentage ) / 100 );
var itemPercentage = usesPercentage > 0 ? Math.min( healthPercentage, usesPercentage ) : healthPercentage;

resourceAmount = Math.floor( ( maxResourceAmount * itemPercentage ) / 100 );
}

// Halve the amount of resources returned
resourceAmount = Math.max( Math.floor( resourceAmount / 2 ), 1 );
Expand Down
21 changes: 18 additions & 3 deletions data/js/skill/craft/tailoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,25 @@ function onCallback2( pSock, ourObj )
{
// Calculate amount of resources returned based on player's mining skill, item's wear and tear,
// and amount of resources that went into making the item in the first place
var itemHitpointsPercentage = Math.floor(( ourObj.health * 100 ) / ourObj.maxhp );
if( ourObj.health >= 1 || ourObj.usesLeft >= 1 )
{
var healthPercentage = 0;
if( ourObj.health >= 1 )
{
healthPercentage = Math.floor( ( ourObj.health * 100 ) / ourObj.maxhp );
}

var usesPercentage = 0;
if( ourObj.usesLeft >= 1 )
{
usesPercentage = Math.floor( ( ourObj.usesLeft * 100 ) / ourObj.maxUses );
}

// Reduce amount of resources returned based on state of object's wear and tear
resourceAmount = Math.floor(( maxResourceAmount * itemHitpointsPercentage ) / 100 );
var itemPercentage = usesPercentage > 0 ? Math.min( healthPercentage, usesPercentage ) : healthPercentage;

// Reduce amount of resources returned based on state of object's wear and tear
resourceAmount = Math.floor( ( maxResourceAmount * itemPercentage ) / 100 );
}

// Halve the amount of resources returned
resourceAmount = Math.max( Math.floor( resourceAmount / 2 ), 1 );
Expand Down
6 changes: 6 additions & 0 deletions source/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
09/11/2023 - Dragon Slayer, Xuri
Fixed Smelting items with 0 hp (js blacksmithing)
Fixed Unraveling items with 0 hp (js tailoring)
Added Tongs, Scissors, Tinkering Tools to material types (js material_types)
Updated ApplyRank to set hp,maxhp and maxuses to 1. (cpp skills)

28/10/2023 - Dragon Slayer (0.99.6a)
Added DFN entries for hallow pumpkins, jack o lanterns and halloween decorations. (dfn item/misc/halloween)
Added DFN entrie for killerpumpkin in daemons.dfn. (dfn daemons)
Expand Down
16 changes: 8 additions & 8 deletions source/skills.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,20 @@ void CSkills::ApplyRank( CSocket *s, CItem *c, UI08 rank, UI08 maxrank )
c->SetResist( static_cast<UI16>(( rank * c->GetResist( PHYSICAL )) / 10 ), PHYSICAL );
}
if( c->GetHP() > 0 )
{
c->SetHP( static_cast<SI16>(( rank * c->GetHP() ) / 10 ));
}
if( c->GetMaxHP() > 0 )
{
c->SetMaxHP( static_cast<SI16>(( rank * c->GetMaxHP() ) / 10 ));
}
{
c->SetHP( std::max( static_cast<SI16>( 1 ), static_cast<SI16>(( rank * c->GetHP() ) / 10 )));
}
if( c->GetMaxHP() > 0 )
{
c->SetMaxHP( std::max( static_cast<SI16>( 1 ), static_cast<SI16>(( rank * c->GetMaxHP() ) / 10 )));
}
if( c->GetBuyValue() > 0 )
{
c->SetBuyValue( static_cast<UI32>(( rank * c->GetBuyValue() ) / 10 ));
}
if( c->GetMaxUses() > 0 )
{
c->SetUsesLeft( static_cast<UI16>(( rank * c->GetMaxUses() ) / 10 ));
c->SetUsesLeft( std::max( static_cast<SI16>( 1 ), static_cast<SI16>(( rank * c->GetMaxUses() ) / 10 )));
}
if( c->GetId() == 0x22c5 && c->GetMaxHP() > 0 ) // Runebook
{
Expand Down

0 comments on commit e3eb237

Please sign in to comment.