void MakeSound(int pulse)
{
  struct char_data *ch;

/*  objects */
  
  ForAllObjects(NULL,pulse,ObjNoise);

/* mobiles */

  for (ch = character_list; ch; ch = ch->next) {
    if (IS_NPC(ch) && (ch->player.sounds) && (number(0,5)==0)) {
      if (ch->specials.default_pos > POSITION_SLEEPING) {
	if (GET_POS(ch) > POSITION_SLEEPING) {
	  /*  Make the sound; */
	  MakeNoise(ch->in_room, ch->player.sounds, ch->player.distant_snds);
	} else if (GET_POS(ch) == POSITION_SLEEPING) {
	  char buf[MAX_STRING_LENGTH];
	  /* snore */	 
	  sprintf(buf, "%s snores loudly.\n", ch->player.short_descr);
	  MakeNoise(ch->in_room, buf, "You hear a loud snore nearby.\n");
	}
      } else if (GET_POS(ch) == ch->specials.default_pos) {
	/* Make the sound */       
	MakeNoise(ch->in_room, ch->player.sounds, ch->player.distant_snds);
      }
    }
  }
}
Exemple #2
0
float ANimModCharacter::TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser)
{
	ANimModPlayerController* MyPC = Cast<ANimModPlayerController>(Controller);
	if (MyPC && MyPC->HasGodMode())
	{
		return 0.f;
	}

	if (Health <= 0)
	{
		return 0;
	}

	// Modify based on game rules.
	ANimModGameMode* const Game = GetWorld()->GetAuthGameMode<ANimModGameMode>();
	Damage = Game ? Game->ModifyDamage(Damage, this, DamageEvent, EventInstigator, DamageCauser) : 0.f;

	const float ActualDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);
	if (ActualDamage > 0.f)
	{
		Health -= (int)ActualDamage;
		if (Health <= 0)
		{
			Die(ActualDamage, DamageEvent, EventInstigator, DamageCauser);
		}
		else
		{
			PlayHit(ActualDamage, DamageEvent, EventInstigator ? EventInstigator->GetPawn() : NULL, DamageCauser);
		}

		MakeNoise(1.0f, EventInstigator ? EventInstigator->GetPawn() : this);
	}

	return ActualDamage;
}
void APlayerCharacter::MakePawnNoise(float Loudness)
{
	if (Role == ROLE_Authority)
	{
		/* Make noise to be picked up by PawnSensingComponent by the enemy pawns */
		MakeNoise(Loudness, this, GetActorLocation());
	}
}
void ASCharacter::MakePawnNoise(float Loudness)
{
	if (Role == ROLE_Authority)
	{
		/* Make noise to be picked up by PawnSensingComponent by the enemy pawns */
		MakeNoise(Loudness, this, GetActorLocation());
	}

	LastNoiseLoudness = Loudness;
	LastMakeNoiseTime = GetWorld()->GetTimeSeconds();
}
Exemple #5
0
int Moribondo( struct char_data *pChar, int nCmd, const char *szArg,
               struct char_data *pMob, int nType )
{
  if( pMob == NULL || pChar == NULL )
  {
    mudlog( LOG_SYSERR, 
            "pMob == NULL || pChar == NULL in Moribondo( carceri.h )" );
    return FALSE;
  }

  if( nType == EVENT_TICK )
  {
    switch( pMob->generic )
    {
    case 0:
      GET_HIT( pMob ) = -3;
      GET_POS( pMob ) = POSITION_INCAP;
      pMob->generic = 1;
      break;
    case 1:
      if( GET_HIT( pMob ) > 0 && !pMob->specials.fighting )
      {
        do_say( pMob, "Grazie! Grazie! Chiunque sia stato.", 0 );
        if( pMob->player.description )
          free( pMob->player.description );
        pMob->player.description = strdup( "Il piccolo nano e` contento e "
                                           "grato a chi lo ha aiutato.\n\r" );
        pMob->generic = 2;
      }
      else if( !pMob->specials.fighting )
      {
        MakeNoise( pMob->in_room, NULL, "Senti qualcuno lamentarsi.\n\r" );
      }
      break;
    case 2:
      if( !pMob->specials.fighting )
      {
        do_say( pMob, 
                "Guardate vicino al letto. C'e` un passaggio segreto!", 0 );
        pMob->generic = 3;
      }
      break;
    default:
      if( !number( 0, 5 ) && !pMob->specials.fighting )
      {
        do_say( pMob, 
                "Guardate vicino al letto. C'e` un passaggio segreto!", 0 );
      }
      break;
    }
  }
  return FALSE;
}
Exemple #6
0
string mammalia::ToString()
{
LOGFILE << POS_IN_PROGRAM << "start of function" << endl;	
ostringstream oss;
oss << boolalpha <<  animal::GetFormattedName() << endl;
oss <<  "Blood:"       << blood << endl;
oss <<  "Egg Layer:"   << egg_layer << endl;
oss <<  "Live Birth:"  << live_birth << endl;
oss << "Movement: " << Move() << endl;
oss << "Noise: " <<MakeNoise() << endl;
return oss.str();
}
Exemple #7
0
bool EffectNoise::Process()
{
   if (noiseDuration <= 0.0)
      noiseDuration = sDefaultGenerateLen;

   //Iterate over each track
   TrackListIterator iter(mWaveTracks);
   WaveTrack *track = (WaveTrack *)iter.First();
   while (track) {
      WaveTrack *tmp = mFactory->NewWaveTrack(track->GetSampleFormat(), track->GetRate());
      numSamples = (longSampleCount)(noiseDuration * track->GetRate() + 0.5);
      longSampleCount i = 0;
      float *data = new float[tmp->GetMaxBlockSize()];
      sampleCount block;

      while(i < numSamples) {
         block = tmp->GetBestBlockSize(i);
         if (block > (numSamples - i))
             block = numSamples - i;

         MakeNoise(data, block, track->GetRate(), noiseAmplitude);

         tmp->Append((samplePtr)data, floatSample, block);
         i += block;
      }
      delete[] data;

      tmp->Flush();
      track->Clear(mT0, mT1);
      track->Paste(mT0, tmp);
      delete tmp;

      //Iterate to the next track
      track = (WaveTrack *)iter.Next();
   }

   /*
      save last used values
      save duration unless value was got from selection, so we save only
      when user explicitely setup a value
   */
   if (mT1 == mT0)
      gPrefs->Write(wxT("/CsPresets/NoiseGen_Duration"), noiseDuration);

   gPrefs->Write(wxT("/CsPresets/NoiseGen_Type"), noiseType);
   gPrefs->Write(wxT("/CsPresets/NoiseGen_Amp"), noiseAmplitude);

   mT1 = mT0 + noiseDuration; // Update selection.

   return true;
}
static int ObjNoise(struct obj_data *obj,struct char_data *ch, int pulse)
{
  int room;

  if (!obj->action_description) return(0);
  if (!ITEM_TYPE(obj,ITEM_AUDIO)) return(0);
  if (((obj->obj_flags.value[0]) && (pulse % obj->obj_flags.value[0])==0) || (!number(0,5))) {
    if (obj->carried_by)
      room = obj->carried_by->in_room;
    else if (obj->equipped_by)
      room = obj->equipped_by->in_room;
    else if (obj->in_room != NOWHERE)
      room = obj->in_room;
    else
      room = RecGetObjRoom(obj);
    MakeNoise(room, obj->action_description, obj->action_description);
    return(1);
  }
  return(0);
}
Exemple #9
0
MakeSound(int pulse)
{
  int room;
  char buffer[128];
  struct obj_data *obj;
  struct char_data *ch;

/*
 *  objects
 */
  
  for (obj = object_list; obj; obj = obj->next) {
    if (ITEM_TYPE(obj) == ITEM_AUDIO) {
      if (((obj->obj_flags.value[0]) && 
	   (pulse % obj->obj_flags.value[0])==0) ||
	  (!number(0,5))) {
	if (obj->carried_by) {
	  room = obj->carried_by->in_room;
	} else if (obj->equipped_by) {
	  room = obj->equipped_by->in_room;
	} else if (obj->in_room != NOWHERE) {
	  room = obj->in_room;
	} else {
	  room = RecGetObjRoom(obj);
	}
	/*
	 *  broadcast to room
	 */
	
	if (obj->action_description) {	  
	  MakeNoise(room, obj->action_description, obj->action_description);
	}
      }
    }
  }

/*
 *   mobiles
 */

  for (ch = character_list; ch; ch = ch->next) {
    if (IS_NPC(ch) && (ch->player.sounds) && (number(0,5)==0)) {
      if (ch->specials.default_pos > POSITION_SLEEPING) {
	if (GET_POS(ch) > POSITION_SLEEPING) {
	  /*
	   *  Make the sound;
	   */
	  MakeNoise(ch->in_room, ch->player.sounds, ch->player.distant_snds);
	} else if (GET_POS(ch) == POSITION_SLEEPING) {
	  /*
	   * snore 
	   */	 
	  sprintf(buffer, "%s snores loudly.\n\r", ch->player.short_descr);
	  MakeNoise(ch->in_room, buffer, "You hear a loud snore nearby.\n\r");
	}
      } else if (GET_POS(ch) == ch->specials.default_pos) {
	/*
	 * Make the sound
	 */       
	MakeNoise(ch->in_room, ch->player.sounds, ch->player.distant_snds);
      }
    }
  }
}
Image2D TestSetGenerator::MakeTestSet(int number, Mask2D& rfi, unsigned width, unsigned height, int gaussianNoise)
{
	Image2D image;
	switch(number)
	{
		case 0: // Image of all zero's
		return Image2D::MakeZeroImage(width, height);
		case 1: // Image of all ones
		image = Image2D::MakeUnsetImage(width, height);
		image.SetAll(1.0);
		break;
		case 2: // Noise
		return MakeNoise(width, height, gaussianNoise);
		case 3: { // Several broadband lines
		image = MakeNoise(width, height, gaussianNoise);
		AddBroadbandToTestSet(image, rfi, 1.0);
		} break;
		case 4: { // Several broadband lines
		image = MakeNoise(width, height, gaussianNoise);
		AddBroadbandToTestSet(image, rfi, 0.5);
		} break;
		case 5: { // Several broadband lines of random length
		image = MakeNoise(width, height, gaussianNoise);
		AddVarBroadbandToTestSet(image, rfi);
		} break;
		case 6: { // Different broadband lines + low freq background
		image = MakeNoise(width, height, gaussianNoise);
		AddVarBroadbandToTestSet(image, rfi);
		for(unsigned y=0;y<image.Height();++y) {
			for(unsigned x=0;x<image.Width();++x) {
				image.AddValue(x, y, sinn(num_t(x)*M_PIn*5.0 / image.Width()) + 0.1);
			}
		}
		} break;
		case 7: { // Different broadband lines + high freq background 
		image = MakeNoise(width, height, gaussianNoise);
		for(unsigned y=0;y<image.Height();++y) {
			for(unsigned x=0;x<image.Width();++x) {
				image.AddValue(x, y, sinn((long double) (x+y*0.1)*M_PIn*5.0L / image.Width() + 0.1));
				image.AddValue(x, y, sinn((long double) (x+pown(y, 1.1))*M_PIn*50.0L / image.Width() + 0.1));
			}
		}
		AddVarBroadbandToTestSet(image, rfi);
		for(unsigned y=0;y<image.Height();++y) {
			for(unsigned x=0;x<image.Width();++x) {
				image.AddValue(x, y, 1.0); 
			}
		}
		} break;
		case 8: {  // Different droadband lines + smoothed&subtracted high freq background
		image = MakeNoise(width, height, gaussianNoise);
		for(unsigned y=0;y<image.Height();++y) {
			for(unsigned x=0;x<image.Width();++x) {
				image.AddValue(x, y, sinn((num_t) (x+y*0.1)*M_PIn*5.0 / image.Width() + 0.1));
				image.AddValue(x, y, sinn((num_t) (x+pown(y, 1.1))*M_PIn*50.0 / image.Width() + 0.1));
			}
		}
		SubtractBackground(image);
		AddVarBroadbandToTestSet(image, rfi);
		} break;
		case 9: { //FFT of 7
		image = MakeTestSet(7, rfi, width, height);
		Image2D copy(image);
		FFTTools::CreateHorizontalFFTImage(image, copy, false);
		for(unsigned y=0;y<rfi.Height();++y) {
			for(unsigned x=0;x<rfi.Width();++x) {
				image.SetValue(x, y, image.Value(x, y) / sqrtn(image.Width()));
			}
		}
		} break;
		case 10: { // Identity matrix
		image = Image2D::MakeZeroImage(width, height);
		unsigned min = width < height ? width : height;
		for(unsigned i=0;i<min;++i) {
			image.SetValue(i, i, 1.0);
			rfi.SetValue(i, i, true);
		}
		} break;
		case 11: { // FFT of identity matrix
		image = MakeTestSet(10, rfi, width, height);
		Image2D copy(image);
		FFTTools::CreateHorizontalFFTImage(image, copy, false);
		for(unsigned y=0;y<rfi.Height();++y) {
			for(unsigned x=0;x<rfi.Width();++x) {
				image.SetValue(x, y, image.Value(x, y) / sqrtn(width)); 
			}
		}
		} break;
		case 12: { // Broadband contaminating all channels
		image = MakeNoise(width, height, gaussianNoise);
		for(unsigned y=0;y<image.Height();++y) {
			for(unsigned x=0;x<image.Width();++x) {
				image.AddValue(x, y, sinn((num_t) (x+y*0.1)*M_PIn*5.0 / image.Width() + 0.1));
				image.AddValue(x, y, sinn((num_t) (x+powl(y, 1.1))*M_PIn*50.0 / image.Width() + 0.1));
			}
		}
		AddBroadbandToTestSet(image, rfi, 1.0);
		} break;
		case 13: { // Model of three point sources with broadband RFI
		SetModelData(image, rfi, 3);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		AddBroadbandToTestSet(image, rfi, 1.0);
		} break;
		case 14: { // Model of five point sources with broadband RFI
		SetModelData(image, rfi, 5);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		AddBroadbandToTestSet(image, rfi, 1.0);
		} break;
		case 15: { // Model of five point sources with partial broadband RFI
		SetModelData(image, rfi, 5);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		AddBroadbandToTestSet(image, rfi, 0.5);
		} break;
		case 16: { // Model of five point sources with random broadband RFI
		SetModelData(image, rfi, 5);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		AddVarBroadbandToTestSet(image, rfi);
		} break;
		case 17: { // Background-fitted model of five point sources with random broadband RFI
		SetModelData(image, rfi, 5);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		SubtractBackground(image);
		AddVarBroadbandToTestSet(image, rfi);
		} break;
		case 18: { // Model of three point sources with random RFI
		SetModelData(image, rfi, 3);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		AddVarBroadbandToTestSet(image, rfi);
		} break;
		case 19: { // Model of three point sources with noise
		SetModelData(image, rfi, 3);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		} break;
		case 20: { // Model of five point sources with noise
		SetModelData(image, rfi, 5);
		Image2D noise = MakeNoise(image.Width(), image.Height(), gaussianNoise);
		image += noise;
		} break;
		case 21: { // Model of three point sources
		SetModelData(image, rfi, 3);
		} break;
		case 22: { // Model of five point sources
		image = Image2D::MakeZeroImage(width, height);
		SetModelData(image, rfi, 5);
		} break;
		case 23:
			image = MakeNoise(width, height, gaussianNoise);
			AddBroadbandToTestSet(image, rfi, 0.5, 0.1, true);
		break;
		case 24:
			image = MakeNoise(width, height, gaussianNoise);
			AddBroadbandToTestSet(image, rfi, 0.5, 10.0, true);
		break;
		case 25:
			image = MakeNoise(width, height, gaussianNoise);
			AddBroadbandToTestSet(image, rfi, 0.5, 1.0, true);
		break;
		case 26: { // Several Gaussian broadband lines
			image = MakeNoise(width, height, gaussianNoise);
			AddBroadbandToTestSet(image, rfi, 1.0, 1.0, false, GaussianShape);
		} break;
		case 27: { // Several Sinusoidal broadband lines
			image = MakeNoise(width, height, gaussianNoise);
			AddBroadbandToTestSet(image, rfi, 1.0, 1.0, false, SinusoidalShape);
		} break;
		case 28: { // Several slewed Gaussian broadband lines
			image = MakeNoise(width, height, gaussianNoise);
			AddSlewedBroadbandToTestSet(image, rfi, 1.0);
		} break;
		case 29: { // Several bursty broadband lines
			image = MakeNoise(width, height, gaussianNoise);
			AddBurstBroadbandToTestSet(image, rfi);
		} break;
		case 30: { // noise + RFI ^-2 distribution
			image = sampleRFIDistribution(width, height, 1.0);
			rfi.SetAll<true>();
		} break;
		case 31: { // noise + RFI ^-2 distribution
			image = sampleRFIDistribution(width, height, 0.1);
			rfi.SetAll<true>();
		} break;
		case 32: { // noise + RFI ^-2 distribution
			image = sampleRFIDistribution(width, height, 0.01);
			rfi.SetAll<true>();
		} break;
	}
	return image;
}
Exemple #11
0
bool EffectNoise::Process()
{
   if (noiseDuration <= 0.0)
      noiseDuration = sDefaultGenerateLen;

   //Iterate over each track
   int ntrack = 0;
   this->CopyInputWaveTracks(); // Set up mOutputWaveTracks.
   bool bGoodResult = true;

   TrackListIterator iter(mOutputWaveTracks);
   WaveTrack *track = (WaveTrack *)iter.First();
   while (track) {
      WaveTrack *tmp = mFactory->NewWaveTrack(track->GetSampleFormat(), track->GetRate());
      numSamples = (longSampleCount)(noiseDuration * track->GetRate() + 0.5);
      longSampleCount i = 0;
      float *data = new float[tmp->GetMaxBlockSize()];
      sampleCount block;

      while ((i < numSamples) && bGoodResult) {
         block = tmp->GetBestBlockSize(i);
         if (block > (numSamples - i))
             block = numSamples - i;

         MakeNoise(data, block, track->GetRate(), noiseAmplitude);

         tmp->Append((samplePtr)data, floatSample, block);
         i += block;

         //Update the Progress meter
         if (TrackProgress(ntrack, (double)i / numSamples))
            bGoodResult = false;
      }
      delete[] data;

      tmp->Flush();
      track->Clear(mT0, mT1);
      track->Paste(mT0, tmp);
      delete tmp;

      if (!bGoodResult)
         break;

      //Iterate to the next track
      ntrack++;
      track = (WaveTrack *)iter.Next();
   }

   if (bGoodResult)
   {
      /*
         save last used values
         save duration unless value was got from selection, so we save only
         when user explicitely setup a value
      */
      if (mT1 == mT0)
         gPrefs->Write(wxT("/CsPresets/NoiseGen_Duration"), noiseDuration);

      gPrefs->Write(wxT("/CsPresets/NoiseGen_Type"), noiseType);
      gPrefs->Write(wxT("/CsPresets/NoiseGen_Amp"), noiseAmplitude);

      mT1 = mT0 + noiseDuration; // Update selection.
   }

   this->ReplaceProcessedWaveTracks(bGoodResult); 
   return bGoodResult;
}
Exemple #12
0
void EffectNoise::GenerateBlock(float *data,
                                const WaveTrack &track,
                                sampleCount block)
{
   MakeNoise(data, block, track.GetRate(), noiseAmplitude);
}