New feature: We can now create non-profile-based merchants via lua.scripts.

Requires GameDir >= r2320.

For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=23061&goto=345526&#msg_345526

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8212 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-05-15 17:11:29 +00:00
parent d594ba0e67
commit 7bb401b1fb
27 changed files with 295 additions and 296 deletions
+23 -22
View File
@@ -17,6 +17,7 @@
#include "Quests.h"
#include "Scheduling.h"
#include "GameSettings.h"
#include "Overhead.h" // added by Flugente for MercPtrs[]
#endif
#ifdef JA2UB
@@ -1161,14 +1162,10 @@ BOOLEAN IsMercADealer( UINT8 ubMercID )
return( FALSE );
}
INT8 GetArmsDealerIDFromMercID( UINT8 ubMercID )
{
INT8 cnt;
//loop through the list of arms dealers
for( cnt=0; cnt<NUM_ARMS_DEALERS; cnt++ )
for ( INT8 cnt = 0; cnt<NUM_ARMS_DEALERS; ++cnt )
{
if( armsDealerInfo[ cnt ].ubShopKeeperID == ubMercID )
return( cnt );
@@ -1177,8 +1174,6 @@ INT8 GetArmsDealerIDFromMercID( UINT8 ubMercID )
return( -1 );
}
UINT8 GetTypeOfArmsDealer( UINT8 ubDealerID )
{
return( armsDealerInfo[ ubDealerID ].ubTypeOfArmsDealer );
@@ -1769,28 +1764,34 @@ void RemoveRandomItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemI
}
BOOLEAN AddDeadArmsDealerItemsToWorld( UINT8 ubMercID )
BOOLEAN AddDeadArmsDealerItemsToWorld( UINT8 usProfileID, UINT8 aMercID )
{
INT8 bArmsDealer;
#ifdef JA2UB
BOOLEAN fBoobyTrapItemsWhenDropping=FALSE;
#endif
//Get Dealer ID from from merc Id
bArmsDealer = GetArmsDealerIDFromMercID( ubMercID );
if( bArmsDealer == -1 )
INT8 bArmsDealer = GetArmsDealerIDFromMercID( usProfileID );
//Get a pointer to the dealer
SOLDIERTYPE* pSoldier = FindSoldierByProfileID( usProfileID, FALSE );
// not if this isn't a proper profile
if ( usProfileID == NO_PROFILE )
{
pSoldier = MercPtrs[aMercID];
if ( pSoldier && pSoldier->sNonNPCTraderID > 0 )
bArmsDealer = pSoldier->sNonNPCTraderID;
else
bArmsDealer = -1;
}
if( bArmsDealer <= -1 )
{
// not a dealer, that's ok, we get called for every dude that croaks.
return( FALSE );
}
SOLDIERTYPE *pSoldier;
// mark the dealer as being out of business!
gArmsDealerStatus[ bArmsDealer ].fOutOfBusiness = TRUE;
//Get a pointer to the dealer
pSoldier = FindSoldierByProfileID( ubMercID, FALSE );
if( pSoldier == NULL )
{
// This should never happen, a dealer getting knocked off without the sector being loaded, should it?
@@ -1815,8 +1816,7 @@ BOOLEAN AddDeadArmsDealerItemsToWorld( UINT8 ubMercID )
}
gArmsDealersInventory[bArmsDealer].clear();
//if the dealer has money
if( gArmsDealerStatus[ bArmsDealer ].uiArmsDealersCash > 0 )
{
@@ -1831,6 +1831,7 @@ BOOLEAN AddDeadArmsDealerItemsToWorld( UINT8 ubMercID )
gArmsDealerStatus[ bArmsDealer ].uiArmsDealersCash = 0;
}
return( TRUE );
}