Here's an example in cChicken.cpp
20% chance to drop an egg and 100% chance to drop a feather. Both can happen at the same time. After you run Pickup->Initialize( GetWorld() ); you can create the object again.
Code:
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
Pickup->Initialize( GetWorld() );
}
20% chance to drop an egg and 100% chance to drop a feather. Both can happen at the same time. After you run Pickup->Initialize( GetWorld() ); you can create the object again.