Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Feature Currency Tags #273

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
26/04/2024 - Dragon Slayer
Added Copper and Silver Coin DFN tags for npcs similar to GOLD tag.

22/03/2024 - Dragon Slayer/Xuri
Leading/trailing whitespace is now trimmed from account names during login.

Expand Down
64 changes: 64 additions & 0 deletions source/npcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,38 @@ auto CCharStuff::ApplyNpcSection( CChar *applyTo, CScriptSection *NpcCreation, s
applyTo->SetControlSlots( static_cast<UI16>( ndata ));
}
break;
case DFNTAG_COPPER:
if( !isGate )
{
if( !ValidateObject( mypack ))
{
mypack = applyTo->GetPackItem();
}
if( ValidateObject( mypack ))
{
if( ndata >= 0 )
{
bool shouldSave = applyTo->ShouldSave();
if( odata && odata > ndata )
{
retitem = Items->CreateScriptItem( nullptr, applyTo, "0x0EEA", static_cast<UI16>( RandomNum( ndata, odata )), OT_ITEM, true, 0xFFFF, shouldSave );
}
else
{
retitem = Items->CreateScriptItem( nullptr, applyTo, "0x0EEA", ndata, OT_ITEM, true, 0xFFFF, shouldSave );
}
}
else
{
Console.Warning( oldstrutil::format( "Invalid data found in COPPER tag inside NPC script [%s]", sectionId.c_str() ));
}
}
else
{
Console.Warning( oldstrutil::format( "Bad NPC Script ([%s]) with problem no backpack for copper", sectionId.c_str() ));
}
}
break;
case DFNTAG_DEX:
if( ndata > 0 )
{
Expand Down Expand Up @@ -1699,6 +1731,38 @@ auto CCharStuff::ApplyNpcSection( CChar *applyTo, CScriptSection *NpcCreation, s
break;
case DFNTAG_SECTIONID: applyTo->SetSectionId( cdata ); break;
case DFNTAG_SKIN: applyTo->SetSkin( static_cast<UI16>( ndata )); break;
case DFNTAG_SILVER:
if( !isGate )
{
if( !ValidateObject( mypack ))
{
mypack = applyTo->GetPackItem();
}
if( ValidateObject( mypack ))
{
if( ndata >= 0 )
{
bool shouldSave = applyTo->ShouldSave();
if( odata && odata > ndata )
{
retitem = Items->CreateScriptItem( nullptr, applyTo, "0x0EF0", static_cast<UI16>( RandomNum( ndata, odata )), OT_ITEM, true, 0xFFFF, shouldSave );
}
else
{
retitem = Items->CreateScriptItem( nullptr, applyTo, "0x0EF0", ndata, OT_ITEM, true, 0xFFFF, shouldSave );
}
}
else
{
Console.Warning( oldstrutil::format( "Invalid data found in SILVER tag inside NPC script [%s]", sectionId.c_str() ));
}
}
else
{
Console.Warning( oldstrutil::format( "Bad NPC Script ([%s]) with problem no backpack for silver", sectionId.c_str() ));
}
}
break;
case DFNTAG_SHOPKEEPER:
if( !isGate )
{
Expand Down
4 changes: 4 additions & 0 deletions source/ssection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const UI08 dfnDataTypes[DFNTAG_COUNTOFTAGS] =
DFN_STRING, // DFNTAG_COLOURLIST,
DFN_NODATA, // DFNTAG_COLOURMATCHHAIR,
DFN_NUMERIC, // DFNTAG_CONTROLSLOTS,
DFN_DOUBLENUMERIC, // DFNTAG_COPPER,
DFN_DOUBLENUMERIC, // DFNTAG_COOKING,
DFN_NUMERIC, // DFNTAG_CORPSE,
DFN_NUMERIC, // DFNTAG_CREATOR,
Expand Down Expand Up @@ -208,6 +209,7 @@ const UI08 dfnDataTypes[DFNTAG_COUNTOFTAGS] =
DFN_UNKNOWN, // DFNTAG_SKILLVAR,
DFN_NUMERIC, // DFNTAG_SKIN,
DFN_STRING, // DFNTAG_SKINLIST,
DFN_DOUBLENUMERIC, // DFNTAG_SILVER,
DFN_DOUBLENUMERIC, // DFNTAG_SNOOPING,
DFN_NUMERIC, // DFNTAG_SNOW,
DFN_NUMERIC, // DFNTAG_SPADELAY,
Expand Down Expand Up @@ -296,6 +298,7 @@ const std::map<std::string, DFNTAGS> strToDFNTag
{"COLORMATCHHAIR"s, DFNTAG_COLOURMATCHHAIR},
{"COLOURMATCHHAIR"s, DFNTAG_COLOURMATCHHAIR},
{"CONTROLSLOTS"s, DFNTAG_CONTROLSLOTS},
{"COPPER"s, DFNTAG_COPPER},
{"COOKING"s, DFNTAG_COOKING},
{"CORPSE"s, DFNTAG_CORPSE},
{"CREATOR"s, DFNTAG_CREATOR},
Expand Down Expand Up @@ -467,6 +470,7 @@ const std::map<std::string, DFNTAGS> strToDFNTag
{"SKILL"s, DFNTAG_SKILL},
{"SKIN"s, DFNTAG_SKIN},
{"SKINLIST"s, DFNTAG_SKINLIST},
{"SILVER"s, DFNTAG_SILVER},
{"SNOOPING"s, DFNTAG_SNOOPING},
{"SNOW"s, DFNTAG_SNOW},
{"SPADELAY"s, DFNTAG_SPADELAY},
Expand Down
2 changes: 2 additions & 0 deletions source/ssection.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum DFNTAGS
DFNTAG_COLOURLIST,
DFNTAG_COLOURMATCHHAIR,
DFNTAG_CONTROLSLOTS,
DFNTAG_COPPER,
DFNTAG_COOKING,
DFNTAG_CORPSE,
DFNTAG_CREATOR,
Expand Down Expand Up @@ -215,6 +216,7 @@ enum DFNTAGS
DFNTAG_SKILLVAR,
DFNTAG_SKIN,
DFNTAG_SKINLIST,
DFNTAG_SILVER,
DFNTAG_SNOOPING,
DFNTAG_SNOW,
DFNTAG_SPADELAY,
Expand Down