Esempio n. 1
0
void CMyRng::TestChance() // TEST CHANCE /////////////////////////////////////////////
{
	printf("  Testing CHANCE ----------------------------------\n");
	int x[10];
	double chance[10];
	int i;
	for (i=0;i<10;i++) 
	{
		x[i]=0;
		chance[i]=FromTo(0.1,0.999);
	}
	long t1=time(0);
	for (int j=0;j<10;j++)
	{
		for (i=0;i<1e6;i++)
		{
			if (Chance(chance[j])) x[j]++;
		}
	}
	long t2=time(0);
	for (i=0;i<10;i++)
	{
		printf("    Chance %2.1lf: Success %2.1lf%% [%2.1lf%%]\n",
			100.0*chance[i],((double)x[i]/1e6)*100.0,100.0*chance[i]);
	}
	printf("    Time: %lds\n",t2-t1);
	printf("\n");
}
Esempio n. 2
0
void HourlyCheckIfSlayAloneSoHeCanLeave()
{
	SOLDIERTYPE *pSoldier;
	pSoldier = FindSoldierByProfileID( SLAY, TRUE );
	if( !pSoldier )
	{
		return;
	}
	if( pSoldier->fBetweenSectors )
	{
		return;
	}
	if( !pSoldier->bActive || !pSoldier->bLife )
	{
		return;
	}
	if( PlayerMercsInSector( (UINT8)pSoldier->sSectorX, (UINT8)pSoldier->sSectorY, pSoldier->bSectorZ ) == 1 )
	{
		if( Chance( 15 ) )
		{
			pSoldier->ubLeaveHistoryCode = HISTORY_SLAY_MYSTERIOUSLY_LEFT;
			TacticalCharacterDialogueWithSpecialEvent( pSoldier, 0, DIALOGUE_SPECIAL_EVENT_CONTRACT_ENDING_NO_ASK_EQUIP, 0, 0 );
		}
	}
}
void CPlayer::Attack(CMap* pMap, CEntity* pTarget)
{
	CWeaponType* pWeaponType;
	if(WieldedItem && WieldedItem->GetType() == IT_WEAPON) {
		pWeaponType = (CWeaponType*) CItemTypeList::GetType(WieldedItem->TypeId);
	} else {
		pWeaponType = (CWeaponType*)CItemTypeList::GetType(ITL_FIST_WEAPON);
	}

	if(Chance(pWeaponType->HitPercentage)) {
		pTarget->GetHurt(pWeaponType->Damage, pMap, this);
	} else gMessages.AddFMessage("Du verfehlst den %s", pTarget->GetName());

	CMobEntity::Attack(pMap, pTarget);
}
Esempio n. 4
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 );

}