Exemplo n.º 1
0
void BuildItemPoolList()
{
	ITEM_POOL *temp;
	IPListNode *tail = NULL;
	INT32 i;
	KillItemPoolList();
	for( i = 0; i < WORLD_MAX; i++ )
	{
		if( GetItemPoolFromGround( i, &temp ) )
		{
			if( !pIPHead )
			{
				pIPHead = (IPListNode*)MemAlloc( sizeof( IPListNode ) );
				Assert( pIPHead );
				tail = pIPHead;
			}
			else
			{
				tail->next = (IPListNode*)MemAlloc( sizeof( IPListNode ) );
				Assert( tail->next );
				tail = tail->next;
			}
			ShowItemCursor( i );
			tail->sGridNo = i;
			tail->next = NULL;
		}
	}
	gpCurrItemPoolNode = pIPHead;
	SpecifyItemToEdit( NULL, -1 );
}
Exemplo n.º 2
0
void HandleRightClickOnItem( INT32 sGridNo )
{
	ITEM_POOL *pItemPool;
	IPListNode *pIPCurr;

	if( gsItemGridNo == sGridNo )
	{ //Clicked on the same gridno as the selected item.	Automatically select the next
		//item in the same pool.
		pItemPool = gpItemPool->pNext;
		if( !pItemPool )
		{ //currently selected item was last node, so select the head node even if it is the same.
			GetItemPoolFromGround( sGridNo, &pItemPool );
		}
	}
	else if( !GetItemPoolFromGround( sGridNo, &pItemPool ) )
	{
		//possibly relocate selected item to this gridno?
		return;
	}

	gpItemPool = pItemPool;

	//set up the item pool pointer to point to the same mapindex node
	pIPCurr = pIPHead;
	gpCurrItemPoolNode = NULL;
	while( pIPCurr )
	{
		if( pIPCurr->sGridNo == sGridNo )
		{
			gpCurrItemPoolNode = pIPCurr;
			break;
		}
		pIPCurr = pIPCurr->next;
	}
	Assert( gpCurrItemPoolNode );
	SpecifyItemToEdit( &gWorldItems[ gpItemPool->iItemIndex ].object, gpItemPool->sGridNo );
}
Exemplo n.º 3
0
void SelectNextItemInPool()
{
	if( gpItemPool )
	{
		if( gpItemPool->pNext )
		{
			gpItemPool = gpItemPool->pNext;
		}
		else
		{
			GetItemPoolFromGround( gpItemPool->sGridNo, &gpItemPool );
		}
		SpecifyItemToEdit( &gWorldItems[ gpItemPool->iItemIndex ].object, gpItemPool->sGridNo );
		MarkWorldDirty();
	}
}
Exemplo n.º 4
0
BOOLEAN TriggerAtGridNo( INT32 sGridNo )
{
	ITEM_POOL *pItemPool;
	if( !GetItemPoolFromGround( sGridNo, &pItemPool ) )
	{
		return FALSE;
	}
	while( pItemPool )
	{
		if( gWorldItems[ pItemPool->iItemIndex ].object.usItem == SWITCH )
		{
			return TRUE;
		}
		pItemPool = pItemPool->pNext;
	}
	return FALSE;
}
Exemplo n.º 5
0
UINT16 CountNumberOfPressureActionsInWorld()
{
	ITEM_POOL *pItemPool;
	IPListNode *pIPCurr;
	UINT16 num = 0;
	pIPCurr = pIPHead;
	while( pIPCurr )
	{
		GetItemPoolFromGround( pIPCurr->sGridNo, &pItemPool );
		while( pItemPool )
		{
			if( gWorldItems[ pItemPool->iItemIndex ].object.usItem == ACTION_ITEM &&
				gWorldItems[ pItemPool->iItemIndex ].object[0]->data.misc.bDetonatorType == BOMB_PRESSURE )
			{
				num++;
			}
			pItemPool = pItemPool->pNext;
		}
		pIPCurr = pIPCurr->next;
	}
	return num;
}
Exemplo n.º 6
0
UINT16 CountNumberOfItemsWithFrequency( UINT16 usItem, INT8 bFrequency )
{
	ITEM_POOL *pItemPool;
	IPListNode *pIPCurr;
	UINT16 num = 0;
	pIPCurr = pIPHead;
	while( pIPCurr )
	{
		GetItemPoolFromGround( pIPCurr->sGridNo, &pItemPool );
		while( pItemPool )
		{
			if( gWorldItems[ pItemPool->iItemIndex ].object.usItem == usItem &&
				gWorldItems[ pItemPool->iItemIndex ].object[0]->data.misc.bFrequency == bFrequency )
			{
				num++;
			}
			pItemPool = pItemPool->pNext;
		}
		pIPCurr = pIPCurr->next;
	}
	return num;
}
Exemplo n.º 7
0
UINT16 CountNumberOfItemPlacementsInWorld( UINT16 usItem, UINT16 *pusQuantity )
{
	ITEM_POOL *pItemPool;
	IPListNode *pIPCurr;
	INT16 num = 0;
	*pusQuantity = 0;
	pIPCurr = pIPHead;
	while( pIPCurr )
	{
		GetItemPoolFromGround( pIPCurr->sGridNo, &pItemPool );
		while( pItemPool )
		{
			if( gWorldItems[ pItemPool->iItemIndex ].object.usItem == usItem )
			{
				num++;
				*pusQuantity += gWorldItems[ pItemPool->iItemIndex ].object.ubNumberOfObjects;
			}
			pItemPool = pItemPool->pNext;
		}
		pIPCurr = pIPCurr->next;
	}
	return num;
}
Exemplo n.º 8
0
UINT16 CountNumberOfKeysOfTypeInWorld( UINT8 ubKeyID )
{
	ITEM_POOL *pItemPool;
	IPListNode *pIPCurr;
	INT16 num = 0;
	pIPCurr = pIPHead;
	while( pIPCurr )
	{
		GetItemPoolFromGround( pIPCurr->sGridNo, &pItemPool );
		while( pItemPool )
		{
			if( Item[ gWorldItems[ pItemPool->iItemIndex ].object.usItem ].usItemClass == IC_KEY )
			{
				if( gWorldItems[ pItemPool->iItemIndex ].object[0]->data.key.ubKeyID == ubKeyID )
				{
					num++;
				}
			}
			pItemPool = pItemPool->pNext;
		}
		pIPCurr = pIPCurr->next;
	}
	return num;
}
Exemplo n.º 9
0
void SelectNextItemPool()
{
	if( !gpCurrItemPoolNode )
		return;
//remove the current hilight.
	if( gpItemPool )
	{
		MarkMapIndexDirty( gpItemPool->sGridNo );
	}

	//go to the next node.	If at end of list, choose pIPHead
	if( gpCurrItemPoolNode->next )
		gpCurrItemPoolNode = gpCurrItemPoolNode->next;
	else
		gpCurrItemPoolNode = pIPHead;
	//get the item pool at this node's gridno.
	GetItemPoolFromGround( gpCurrItemPoolNode->sGridNo, &gpItemPool );
	MarkMapIndexDirty( gpItemPool->sGridNo );
	SpecifyItemToEdit( &gWorldItems[ gpItemPool->iItemIndex ].object, gpItemPool->sGridNo );
	if( gsItemGridNo != -1 )
	{
		CenterScreenAtMapIndex( gsItemGridNo );
	}
}
Exemplo n.º 10
0
void RenderSelectedItemBlownUp()
{
	UINT32 uiVideoObjectIndex;
	HVOBJECT hVObject;
	INT16 sScreenX, sScreenY, xp, yp;
	ITEM_POOL	*pItemPool;
	CHAR16 szItemName[ SIZE_ITEM_NAME ];
	INT32 i, iStackIndex;
	INT16 sWidth, sHeight, sOffsetX, sOffsetY;

	GetGridNoScreenPos( gsItemGridNo, 0, &sScreenX, &sScreenY );

	if( sScreenY > (2 * iScreenHeightOffset + 340) )
		return;

	//Display the enlarged item graphic
	uiVideoObjectIndex = GetInterfaceGraphicForItem( &Item[ gpItem->usItem ] );
	GetVideoObject( &hVObject, uiVideoObjectIndex );

	UINT16 usGraphicNum = g_bUsePngItemImages ? 0 : Item[ gpItem->usItem ].ubGraphicNum;
	sWidth = hVObject->pETRLEObject[ usGraphicNum ].usWidth;
	sOffsetX = hVObject->pETRLEObject[ usGraphicNum ].sOffsetX;
	xp = sScreenX + (40 - sWidth - sOffsetX*2) / 2;

	sHeight = hVObject->pETRLEObject[ usGraphicNum ].usHeight;
	sOffsetY = hVObject->pETRLEObject[ usGraphicNum ].sOffsetY;
	yp = sScreenY + (20 - sHeight - sOffsetY*2) / 2;

	BltVideoObjectOutlineFromIndex( FRAME_BUFFER, uiVideoObjectIndex, usGraphicNum, xp, yp, Get16BPPColor(FROMRGB(0, 140, 170)), TRUE );

	//Display the item name above it
	SetFont( FONT10ARIAL );
	SetFontForeground( FONT_YELLOW );
	SetFontShadow( FONT_NEARBLACK );
	if( gpItem->usItem == ACTION_ITEM || gpItem->usItem == SWITCH )
	{
		BuildTriggerName( gpItem, szItemName );
	}
	else if( Item[ gpItem->usItem ].usItemClass == IC_KEY )
	{
		swprintf( szItemName, L"%S", LockTable[ (*gpItem)[0]->data.key.ubKeyID ].ubEditorName );
	}
	else
	{
		LoadItemInfo( gpItem->usItem, szItemName, NULL );
	}
	xp = sScreenX - (StringPixLength( szItemName, FONT10ARIAL ) - 40) / 2;
	yp -= 10;
	mprintf( xp, yp, szItemName );

	if( gpItem->usItem == ACTION_ITEM )
	{
		STR16 pStr;
		pStr = GetActionItemName( gpItem );
		xp = sScreenX - (StringPixLength( pStr, FONT10ARIALBOLD ) - 40) / 2;
		yp += 10;
		SetFont( FONT10ARIALBOLD );
		SetFontForeground( FONT_LTKHAKI );
		mprintf( xp, yp, pStr );
		SetFontForeground( FONT_YELLOW );
	}
	else
	{
		// Display item index no
		xp = sScreenX + 2;
		yp += 10;
		SetFont( BLOCKFONTNARROW );
		SetFontForeground( FONT_LTGREEN );
		mprintf( xp, yp, L"%d", Item[ gpItem->usItem ].uiIndex );
	}

	//Display current item stack index and number of items in stack
	i = 0;
	GetItemPoolFromGround( gsItemGridNo, &pItemPool );
	Assert( pItemPool );
	//Count the number of items in the current pool
	while( pItemPool )
	{
		i++;
		if ( gpItemPool == pItemPool )
			iStackIndex = i;
		pItemPool = pItemPool->pNext;
	}
	xp = sScreenX;
	yp = sScreenY + 10;
	SetFont( FONT10ARIAL );
	SetFontForeground( FONT_YELLOW );
	//Omit current item stack index if only 1 item in stack
	if ( i == 1 )
		mprintf( xp, yp, L"%d", i );
	else
		mprintf( xp - 6, yp, L"%d/%d", iStackIndex , i );	

	//If the item is hidden, render a blinking H (just like DG)
	if( gWorldItems[ gpItemPool->iItemIndex ].bVisible == HIDDEN_ITEM ||
			gWorldItems[ gpItemPool->iItemIndex ].bVisible == BURIED )
	{
		SetFont( FONT10ARIALBOLD );
		if( GetJA2Clock() % 1000 > 500 )
		{
			SetFontForeground( 249 );
		}
		mprintf( sScreenX + 16, sScreenY + 7, L"H" );
		InvalidateRegion( sScreenX + 16, sScreenY + 7, sScreenX + 24, sScreenY + 27 );
	}
}
Exemplo n.º 11
0
void AddSelectedItemToWorld( INT32 sGridNo )
{
	OBJECTTYPE *pObject;
	INVTYPE		*pItem;
	ITEM_POOL *pItemPool;
	INT32 iItemIndex;
	INT8 bVisibility = INVISIBLE;
	BOOLEAN fFound = FALSE;
	IPListNode *pIPCurr, *pIPPrev;
	UINT16 usFlags;

	//Extract the currently selected item.
	SpecifyItemToEdit( NULL, -1 );

	if( eInfo.uiItemType == TBAR_MODE_ITEM_KEYS )
	{
		CreateKeyObject( &gTempObject, 1, (UINT8)eInfo.sSelItemIndex );
	}
	else
	{
		CreateItem( eInfo.pusItemIndex[eInfo.sSelItemIndex], 100, &gTempObject );
	}
	usFlags = 0;
	switch( gTempObject.usItem )
	{
		case MINE:
			if ( bVisibility == BURIED )
			{
				usFlags |= WORLD_ITEM_ARMED_BOMB;
			}
			break;
		case MONEY:
		case SILVER:
		case GOLD:
			gTempObject[0]->data.objectStatus = 100;
			gTempObject[0]->data.money.uiMoneyAmount = 100 + Random( 19901 );
			break;
		case OWNERSHIP:
			gTempObject[0]->data.owner.ubOwnerProfile = NO_PROFILE;
			bVisibility = BURIED;
			break;
		case SWITCH:
			if( TriggerAtGridNo( sGridNo ) )
			{ //Restricted to one action per gridno.
				return;
			}
			bVisibility = BURIED;
			gTempObject[0]->data.objectStatus = 100;
			gTempObject[0]->data.misc.ubBombOwner = 1;
			if( eInfo.sSelItemIndex < 2 )
				gTempObject[0]->data.misc.bFrequency = PANIC_FREQUENCY;
			else if( eInfo.sSelItemIndex < 4 )
				gTempObject[0]->data.misc.bFrequency = PANIC_FREQUENCY_2;
			else if( eInfo.sSelItemIndex < 6 )
				gTempObject[0]->data.misc.bFrequency = PANIC_FREQUENCY_3;
			else
				gTempObject[0]->data.misc.bFrequency = (INT8)(FIRST_MAP_PLACED_FREQUENCY + (eInfo.sSelItemIndex-4) / 2);
			usFlags |= WORLD_ITEM_ARMED_BOMB;
			break;
		case ACTION_ITEM:
			bVisibility = BURIED;
			gTempObject[0]->data.objectStatus = 100;
			gTempObject[0]->data.misc.ubBombOwner = 1;
			gTempObject[0]->data.bTrap = gbDefaultBombTrapLevel;
			if( eInfo.sSelItemIndex < PRESSURE_ACTION_ID )
			{
				gTempObject[0]->data.misc.bDetonatorType = BOMB_REMOTE;
				if( eInfo.sSelItemIndex < 2 )
					gTempObject[0]->data.misc.bFrequency = PANIC_FREQUENCY;
				else if( eInfo.sSelItemIndex < 4 )
					gTempObject[0]->data.misc.bFrequency = PANIC_FREQUENCY_2;
				else if( eInfo.sSelItemIndex < 6 )
					gTempObject[0]->data.misc.bFrequency = PANIC_FREQUENCY_3;
				else
					gTempObject[0]->data.misc.bFrequency = (INT8)(FIRST_MAP_PLACED_FREQUENCY + (eInfo.sSelItemIndex-4) / 2);
			}
			else
			{
				gTempObject[0]->data.misc.bDetonatorType = BOMB_PRESSURE;
				gTempObject[0]->data.misc.bDelay = 0;
			}
			ChangeActionItem( &gTempObject, gbActionItemIndex );
			gTempObject.fFlags |= OBJECT_ARMED_BOMB;
			if( gbActionItemIndex == ACTIONITEM_SMPIT )
				Add3X3Pit( sGridNo );
			else if( gbActionItemIndex == ACTIONITEM_LGPIT )
				Add5X5Pit( sGridNo );
			usFlags |= WORLD_ITEM_ARMED_BOMB;
			break;
	}

	pObject = InternalAddItemToPool( &sGridNo, &gTempObject, bVisibility, 0, usFlags, 0, -1, &iItemIndex );
	if( gTempObject.usItem != OWNERSHIP )
	{
		gWorldItems[ iItemIndex ].ubNonExistChance = (UINT8)(100 - giDefaultExistChance);
	}
	else
	{
		gWorldItems[ iItemIndex ].ubNonExistChance = 0;
	}

	pItem = &( Item[ pObject->usItem ] );
	if( pItem->usItemClass == IC_AMMO )
	{
		if (Random( 2 ))
		{
			(*pObject)[0]->data.ubShotsLeft = Magazine[ pItem->ubClassIndex ].ubMagSize;
		}
		else
		{
			(*pObject)[0]->data.ubShotsLeft = (UINT8) Random( Magazine[ pItem->ubClassIndex ].ubMagSize );
		}
	}
	else
	{
		if(gTempObject.usItem != OWNERSHIP)//dnl ch35 110909
			(*pObject)[0]->data.objectStatus = (INT8)(70 + Random( 26 ));
	}
	if( pItem->usItemClass & IC_GUN )
	{
		if ( pObject->usItem == ROCKET_LAUNCHER )
		{
			(*pObject)[0]->data.gun.ubGunShotsLeft = 1;
		}
		else
		{
			(*pObject)[0]->data.gun.ubGunShotsLeft = (UINT8)(Random( Weapon[ pObject->usItem ].ubMagSize ));
		}
	}

	if( !GetItemPoolFromGround( sGridNo, &pItemPool ) )
		Assert( 0 );
	while( pItemPool )
	{
		if( &(gWorldItems[ pItemPool->iItemIndex ].object) == pObject )
		{
			fFound = TRUE;
			//ShowSelectedItem();
			break;
		}
		pItemPool = pItemPool->pNext;
	}
	Assert( fFound );

	gpItemPool = pItemPool;

	SpecifyItemToEdit( pObject, sGridNo );

	//Get access to the itempool.
	//search for a current node in list containing same mapindex
	pIPCurr = pIPHead;
	pIPPrev = NULL;
	while( pIPCurr )
	{
		pIPPrev = pIPCurr;
		if( pIPCurr->sGridNo == sGridNo )
		{
			//found one, so we don't need to add it
			gpCurrItemPoolNode = pIPCurr;
			return;
		}
		pIPCurr = pIPCurr->next;
	}
	//there isn't one, so we will add it now.
	ShowItemCursor( sGridNo );
	if( pIPPrev )
	{
		pIPPrev->next = (IPListNode*)MemAlloc( sizeof( IPListNode ) );
		Assert( pIPPrev->next );
		pIPPrev = pIPPrev->next;
		pIPPrev->next = NULL;
		pIPPrev->sGridNo = sGridNo;
		gpCurrItemPoolNode = pIPPrev;
	}
	else
	{
		pIPHead = (IPListNode*)MemAlloc( sizeof( IPListNode ) );
		Assert( pIPHead );
		pIPHead->next = NULL;
		pIPHead->sGridNo = sGridNo;
		gpCurrItemPoolNode = pIPHead;
	}
}
Exemplo n.º 12
0
void SelectNextPressureAction()
{
	IPListNode *curr;
	OBJECTTYPE *pObject;
	if( gpItemPool )
	{
		curr = pIPHead;
		while( curr )
		{ //skip quickly to the same gridno as the item pool
			if( curr->sGridNo == gWorldItems[ gpItemPool->iItemIndex ].sGridNo )
			{
				gpItemPool = gpItemPool->pNext;
				while( gpItemPool )
				{
					pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
					if( pObject->usItem == ACTION_ITEM && (*pObject)[0]->data.misc.bDetonatorType == BOMB_PRESSURE )
					{
						SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
						CenterScreenAtMapIndex( gsItemGridNo );
						return; //success! (another item in same itempool)
					}
					gpItemPool = gpItemPool->pNext;
				}
				curr = curr->next;
				break;
			}
			curr = curr->next;
		}
		while( curr )
		{ //search to the end of the list
			GetItemPoolFromGround( curr->sGridNo, &gpItemPool );
			while( gpItemPool )
			{
				pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
				if( pObject->usItem == ACTION_ITEM && (*pObject)[0]->data.misc.bDetonatorType == BOMB_PRESSURE )
				{
					SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
					CenterScreenAtMapIndex( gsItemGridNo );
					return; //success! (found another item before reaching the end of the list)
				}
				gpItemPool = gpItemPool->pNext;
			}
			curr = curr->next;
		}
	}
	curr = pIPHead;
	while( curr )
	{ //search to the end of the list
		GetItemPoolFromGround( curr->sGridNo, &gpItemPool );
		while( gpItemPool )
		{
			pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
			if( pObject->usItem == ACTION_ITEM && (*pObject)[0]->data.misc.bDetonatorType == BOMB_PRESSURE )
			{
				SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
				CenterScreenAtMapIndex( gsItemGridNo );
				return; //success! (found first item in the list)
			}
			gpItemPool = gpItemPool->pNext;
		}
		curr = curr->next;
	}
}
Exemplo n.º 13
0
void SelectNextTriggerWithFrequency( UINT16 usItem, INT8 bFrequency )
{
	IPListNode *curr;
	OBJECTTYPE *pObject;
	if( gpItemPool )
	{
		curr = pIPHead;
		while( curr )
		{ //skip quickly to the same gridno as the item pool
			if( curr->sGridNo == gWorldItems[ gpItemPool->iItemIndex ].sGridNo )
			{
				gpItemPool = gpItemPool->pNext;
				while( gpItemPool )
				{
					pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
					if( pObject->usItem == usItem && (*pObject)[0]->data.misc.bFrequency == bFrequency )
					{
						SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
						CenterScreenAtMapIndex( gsItemGridNo );
						return; //success! (another item in same itempool)
					}
					gpItemPool = gpItemPool->pNext;
				}
				curr = curr->next;
				break;
			}
			curr = curr->next;
		}
		while( curr )
		{ //search to the end of the list
			GetItemPoolFromGround( curr->sGridNo, &gpItemPool );
			while( gpItemPool )
			{
				pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
				if( pObject->usItem == usItem && (*pObject)[0]->data.misc.bFrequency == bFrequency )
				{
					SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
					CenterScreenAtMapIndex( gsItemGridNo );
					return; //success! (found another item before reaching the end of the list)
				}
				gpItemPool = gpItemPool->pNext;
			}
			curr = curr->next;
		}
	}
	curr = pIPHead;
	while( curr )
	{ //search to the end of the list
		GetItemPoolFromGround( curr->sGridNo, &gpItemPool );
		while( gpItemPool )
		{
			pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
			if( pObject->usItem == usItem && (*pObject)[0]->data.misc.bFrequency == bFrequency )
			{
				SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
				CenterScreenAtMapIndex( gsItemGridNo );
				return; //success! (found first item in the list)
			}
			gpItemPool = gpItemPool->pNext;
		}
		curr = curr->next;
	}
}
Exemplo n.º 14
0
void SelectNextKeyOfType( UINT8 ubKeyID )
{
	IPListNode *curr;
	OBJECTTYPE *pObject;
	if( gpItemPool )
	{
		curr = pIPHead;
		while( curr )
		{ //skip quickly to the same gridno as the item pool
			if( curr->sGridNo == gWorldItems[ gpItemPool->iItemIndex ].sGridNo )
			{
				gpItemPool = gpItemPool->pNext;
				while( gpItemPool )
				{
					pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
					if( Item[ pObject->usItem ].usItemClass == IC_KEY && (*pObject)[0]->data.key.ubKeyID == ubKeyID )
					{
						SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
						CenterScreenAtMapIndex( gsItemGridNo );
						return; //success! (another item in same itempool)
					}
					gpItemPool = gpItemPool->pNext;
				}
				curr = curr->next;
				break;
			}
			curr = curr->next;
		}
		while( curr )
		{ //search to the end of the list
			GetItemPoolFromGround( curr->sGridNo, &gpItemPool );
			while( gpItemPool )
			{
				pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
				if( Item[ pObject->usItem ].usItemClass == IC_KEY && (*pObject)[0]->data.key.ubKeyID == ubKeyID )
				{
					SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
					CenterScreenAtMapIndex( gsItemGridNo );
					return; //success! (found another item before reaching the end of the list)
				}
				gpItemPool = gpItemPool->pNext;
			}
			curr = curr->next;
		}
	}
	curr = pIPHead;
	while( curr )
	{ //search to the end of the list
		GetItemPoolFromGround( curr->sGridNo, &gpItemPool );
		while( gpItemPool )
		{
			pObject = &gWorldItems[ gpItemPool->iItemIndex ].object;
			if( Item[ pObject->usItem ].usItemClass == IC_KEY && (*pObject)[0]->data.key.ubKeyID == ubKeyID )
			{
				SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
				CenterScreenAtMapIndex( gsItemGridNo );
				return; //success! (found first item in the list)
			}
			gpItemPool = gpItemPool->pNext;
		}
		curr = curr->next;
	}
}
Exemplo n.º 15
0
void DeleteSelectedItem()
{
	SpecifyItemToEdit( NULL, -1 );
	//First, check to see if there even is a currently selected item.
	if( iCurrentTaskbar == TASK_MERCS )
	{
		DeleteSelectedMercsItem();
		return;
	}
	if( gpItemPool )
	{ //Okay, we have a selected item...
		INT32 sGridNo;
		//save the mapindex
		if( gpItemPool->pNext )
		{
			SpecifyItemToEdit( &gWorldItems[ gpItemPool->pNext->iItemIndex ].object, gpItemPool->sGridNo );
		}
		sGridNo = gpItemPool->sGridNo;
		//remove the item
		if( gWorldItems[ gpItemPool->iItemIndex ].object.usItem == ACTION_ITEM )
		{
			if( gWorldItems[ gpItemPool->iItemIndex ].object[0]->data.misc.bActionValue == ACTION_ITEM_SMALL_PIT )
				Remove3X3Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
			else if( gWorldItems[ gpItemPool->iItemIndex ].object[0]->data.misc.bActionValue == ACTION_ITEM_LARGE_PIT )
				Remove5X5Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo );
		}
		if( gpEditingItemPool == gpItemPool )
			gpEditingItemPool = NULL;
		RemoveItemFromPool( sGridNo, gpItemPool->iItemIndex, 0 );
		gpItemPool = NULL;
		//determine if there are still any items at this location
		if( !GetItemPoolFromGround( sGridNo, &gpItemPool ) )
		{ //no items left, so remove the node from the list.
			IPListNode *pIPPrev, *pIPCurr;
			pIPCurr = pIPHead;
			pIPPrev = NULL;
			while( pIPCurr )
			{
				if( pIPCurr->sGridNo == sGridNo )
				{
					if( pIPPrev ) //middle of list
						pIPPrev->next = pIPCurr->next;
					else //head of list
						pIPHead = pIPHead->next;
					//move the curr item pool to the next one.
					if( pIPCurr->next )
						gpCurrItemPoolNode = pIPCurr->next;
					else
						gpCurrItemPoolNode = pIPHead;
					if( gpCurrItemPoolNode )
					{
						GetItemPoolFromGround( gpCurrItemPoolNode->sGridNo, &gpItemPool );
						Assert( gpItemPool );
					}
					//remove node
					HideItemCursor( sGridNo );
					MemFree( pIPCurr );
					pIPCurr = NULL;
					return;
				}
				pIPPrev = pIPCurr;
				pIPCurr = pIPCurr->next;
			}
		}
	}
}
Exemplo n.º 16
0
//DBrot: More Rooms
void RemoveRoomRoof( INT32 sGridNo, UINT16 usRoomNum, SOLDIERTYPE *pSoldier )
{
	INT32			cnt;
	ITEM_POOL					*pItemPool;
	INT16							sX, sY;
	BOOLEAN						fSaidItemSeenQuote = FALSE;

//	STRUCTURE					*pStructure;//, *pBase;

	// LOOP THORUGH WORLD AND CHECK ROOM INFO
	for ( cnt = 0; cnt < WORLD_MAX; cnt++ )
	{
		if ( gusWorldRoomInfo[ cnt ] == usRoomNum )
		{

			SetGridNoRevealedFlag( cnt );//dnl ch56 141009

			RemoveRoofIndexFlagsFromTypeRange( cnt, FIRSTROOF, SECONDSLANTROOF, LEVELNODE_REVEAL );

			// Reveal any items if here!
			if ( GetItemPoolFromGround( cnt, &pItemPool ) )
			{
				// Set visible! ( only if invisible... )
				if ( SetItemPoolVisibilityOn( pItemPool, INVISIBLE, TRUE ) )
				{
					if ( !fSaidItemSeenQuote )
					{
						fSaidItemSeenQuote = TRUE;

						if ( pSoldier != NULL )
						{
						//ddd
							//TacticalCharacterDialogue( pSoldier, (UINT16)( QUOTE_SPOTTED_SOMETHING_ONE + Random( 2 ) ) );
							if(Chance(gGameExternalOptions.iChanceSayAnnoyingPhrase) )
								TacticalCharacterDialogue( pSoldier, (UINT16)( QUOTE_SPOTTED_SOMETHING_ONE + Random( 2 ) ) );
								//ddd
						}
					}
				}
			}

			// OK, re-set writeframes ( in a radius )
			// Get XY
			ConvertGridNoToXY( cnt, &sX, &sY );
			SetRecalculateWireFrameFlagRadius( sX, sY, 2 );

		}
	}

	//for ( cnt = 0; cnt < WORLD_MAX; cnt++ )
	//{
	//	if ( gubWorldRoomInfo[ cnt ] == bRoomNum )
	//	{
	//		ExamineGridNoForSlantRoofExtraGraphic( (INT16)cnt );
	//	}
	//}

	// DIRTY THE WORLD!
	InvalidateWorldRedundency();
	SetRenderFlags(RENDER_FLAG_FULL );


	CalculateWorldWireFrameTiles( FALSE );

}