void TimgFilterNoiseMplayer::Tprocess::init(int strength,const TnoiseSettings *Icfg)
{
    cfg=*Icfg;
    noise=(int8_t*)aligned_malloc(MAX_NOISE*sizeof(int8_t));
    int i,j;
    for (i=0,j=0; i<MAX_NOISE; i++,j++) {
        if(cfg.uniform)
            if (cfg.averaged)
                if (cfg.pattern) {
                    noise[i]=int8_t((RAND_N(strength)-strength/2)/6+TimgFilterNoise::patt[j%4]*strength*0.25/3);
                } else {
                    noise[i]=int8_t((RAND_N(strength)-strength/2)/3);
                }
            else if (cfg.pattern) {
                noise[i]=int8_t((RAND_N(strength)-strength/2)/2+TimgFilterNoise::patt[j%4]*strength*0.25);
            } else {
                noise[i]=int8_t(RAND_N(strength)-strength/2);
            }
        else {
            double x1, x2, w, y1;
            do {
                x1=2.0*rand()/(float)RAND_MAX-1.0;
                x2=2.0*rand()/(float)RAND_MAX-1.0;
                w=x1*x1+x2*x2;
            } while (w>=1.0);

            w=sqrt((-2.0*log(w))/w);
            y1=x1*w;
            y1*=strength/sqrt(3.0);
            if (cfg.pattern) {
                y1/=2;
                y1+=TimgFilterNoise::patt[j%4]*strength*0.35;
            }
            if      (y1<-128) {
                y1=-128;
            } else if (y1> 127) {
                y1= 127;
            }
            if (cfg.averaged) {
                y1/=3.0;
            }
            noise[i]=(int8_t)y1;
        }
        if (RAND_N(6)==0) {
            j--;
        }
    }

    for (i=0; i<MAX_RES; i++)
        for (j=0; j<3; j++) {
            prev_shift[i][j]=noise+(rand()&(MAX_SHIFT-1));
        }

    if (nonTempRandShift[0]==-1)
        for (i=0; i<MAX_RES; i++) {
            nonTempRandShift[i]=rand()&(MAX_SHIFT-1);
        }

    shiftptr=0;
}
Esempio n. 2
0
void infuscor::PrayBadEffect()
{
  truth Success = false;
  if(GetRelation() < -200)
  {
    uint c;

    for(c = 1; c < uint(PLAYER->GetBodyParts()); ++c) // annoying :(
    {
      bodypart* BodyPart = PLAYER->GetBodyPart(c);

      if(BodyPart && BodyPart->IsDestroyable(PLAYER))
        if(BodyPart->GetMainMaterial())
          if(BodyPart->CanBeBurned()
             && (BodyPart->GetMainMaterial()->GetInteractionFlags() & CAN_BURN)
             && !BodyPart->IsBurning())
          {
            if(BodyPart->TestActivationEnergy(50))
            {
                Success = true;
            }
          }
    }
    if(Success)
      ADD_MESSAGE("\"I'm going to enjoy watching you burn, insolent mortal!\"");
  }

  ADD_MESSAGE("Vile and evil knowledge pumps into your brain. It's too much for you to handle; you faint.");
  PLAYER->LoseConsciousness(1000 + RAND_N(1000));
}
Esempio n. 3
0
truth web::TryToTearDown(character* Actor,int Modifier)
{
  if(Modifier==-1)
    Modifier = GetRemoveTrapModifier(Actor);
  
  if(!RAND_N(Max(Modifier << 1, 2)))
  {
    //if(GetLSquareUnder()->GetPos()==Actor->GetPos())C->RemoveTrap(GetTrapID());else
    if(GetLSquareUnder()->GetCharacter())
      GetLSquareUnder()->GetCharacter()->RemoveTrap(GetTrapID());
    TrapData.VictimID = 0;
    GetLSquareUnder()->RemoveTrap(this);
    SendToHell();

    if(Actor->IsPlayer())
      ADD_MESSAGE("You tear the web down.");
    else if(Actor->CanBeSeenByPlayer())
      ADD_MESSAGE("%s tears the web down.", Actor->CHAR_NAME(DEFINITE));

    Actor->EditAP(-500);
    return true;
  }
  
  return false;
}
Esempio n. 4
0
void atavus::PrayGoodEffect()
{
  if(!Timer && Relation > 500 + RAND_N(500))
  {
    item* Reward = bodyarmor::Spawn(PLATE_MAIL, NO_MATERIALS);
    Reward->InitMaterials(MAKE_MATERIAL(ARCANITE));
    ADD_MESSAGE("%s materializes before you.", Reward->CHAR_NAME(INDEFINITE));
    PLAYER->GetGiftStack()->AddItem(Reward);
    AdjustTimer(45000);
    AdjustRelation(-300);
  }
  else
    ADD_MESSAGE("Nothing happens.");
}
Esempio n. 5
0
void scabies::PrayGoodEffect()
{
  if(!RAND_N(10))
  {
    for(int c = 0; c < game::GetTeams(); ++c)
      if(PLAYER->GetTeam()->GetRelation(game::GetTeam(c)) == HOSTILE)
	for(std::list<character*>::const_iterator i = game::GetTeam(c)->GetMember().begin(); i != game::GetTeam(c)->GetMember().end(); ++i)
	{
	  character* Char = *i;

	  if((*i)->IsEnabled() && !Char->IsImmuneToLeprosy())
	    Char->GainIntrinsic(LEPROSY);
	}

    ADD_MESSAGE("You feel a a horrible disease spreading.");
    return;
  }

  if(!(RAND() % 50))
  {
    ADD_MESSAGE("Five cans full of school food drop from somewhere above!");

    for(int c = 0; c < 5; ++c)
    {
      can* Reward = can::Spawn(0, NO_MATERIALS);
      Reward->InitMaterials(MAKE_MATERIAL(IRON), MAKE_MATERIAL(SCHOOL_FOOD));
      PLAYER->GetGiftStack()->AddItem(Reward);
    }

    return;
  }

  bool Success = false;

  for(int d = 0; d < PLAYER->GetNeighbourSquares(); ++d)
  {
    lsquare* Square = PLAYER->GetNeighbourLSquare(d);

    if(Square && Square->GetCharacter() && Square->GetCharacter()->GetRelation(PLAYER) == HOSTILE)
    {
      ADD_MESSAGE("%s throws poison on %s!", GetName(), Square->GetCharacter()->CHAR_DESCRIPTION(DEFINITE));
      Square->SpillFluid(PLAYER, liquid::Spawn(POISON_LIQUID, 500));
      Success = true;
    }
  }

  if(!Success)
    PLAYER->PolymorphRandomly(2500, 10000, 1000 + RAND() % 1000);
}
Esempio n. 6
0
void atavus::PrayGoodEffect()
{
  item* Enchantable;
  item* PairEnchantable;
  int LowEnchant = 99;
  truth Pair = false;

  for(int c = 0; c < PLAYER->GetEquipments(); ++c)
  {
    item* Equipment = PLAYER->GetEquipment(c);

    if(Equipment && Equipment->CanBeEnchanted() && !Equipment->IsWeapon(PLAYER)
        && (Equipment->GetEnchantment() < LowEnchant))
    {
      Enchantable = Equipment;
      LowEnchant = Enchantable->GetEnchantment();
      Pair = false;
      continue;
    }

    if(Enchantable && Equipment && Equipment->HandleInPairs()
        && Equipment->CanBePiledWith(Enchantable, PLAYER))
    {
      Pair = true;
      PairEnchantable = Equipment;
    }
  }
  if(LowEnchant < 99)
  {
    int EnchDiff = ((Enchantable->GetEnchantment()+2)*250 - GetRelation()) / 50;
    if(EnchDiff <= 1 || !RAND_N(EnchDiff)) {
      if(Pair)
      {
        ADD_MESSAGE("Your %s glow briefly blue. They feel very warm now.", Enchantable->CHAR_NAME(PLURAL));
        Enchantable->EditEnchantment(1);
        PairEnchantable->EditEnchantment(1);
      }
      else
      {
        ADD_MESSAGE("Your %s glows briefly blue. It feels very warm now.", Enchantable->CHAR_NAME(UNARTICLED));
        Enchantable->EditEnchantment(1);
      }
      return;
    }
  }
  ADD_MESSAGE("You feel that %s is watching your actions closely.", GetName());
}
Esempio n. 7
0
void infuscor::PrayBadEffect()
{
  ADD_MESSAGE("Vile and evil knowledge pulps into your brain. It's too much for it to handle; you faint.");
  PLAYER->LoseConsciousness(1000 + RAND_N(1000));
}
Esempio n. 8
0
void loricatus::PrayGoodEffect()
{
  item* MainWielded = PLAYER->GetMainWielded();

  if(MainWielded)
  {
    if(MainWielded->IsMaterialChangeable() && MainWielded->GetMainMaterial()->GetAttachedGod() == GetType())
    {
      int Config = MainWielded->GetMainMaterial()->GetHardenedMaterial(MainWielded);

      if(Config)
      {
	int IR = material::GetDataBase(Config)->IntelligenceRequirement - GetRelation() / 50;

	if(IR <= 1 || !RAND_N(IR))
	{
	  festring Desc;
	  item* SecondaryWielded;

	  if(MainWielded->HandleInPairs() && (SecondaryWielded = PLAYER->GetSecondaryWielded()) && SecondaryWielded->CanBePiledWith(MainWielded, PLAYER))
	  {
	    MainWielded->AddName(Desc, PLURAL);
	    Desc << " glow and sparkle like they were";

	    if(SecondaryWielded->GetSecondaryMaterial() && SecondaryWielded->GetSecondaryMaterial()->IsSameAs(MainWielded->GetMainMaterial()))
	      SecondaryWielded->ChangeSecondaryMaterial(MAKE_MATERIAL(Config));

	    SecondaryWielded->ChangeMainMaterial(MAKE_MATERIAL(Config));
	  }
	  else
	  {
	    MainWielded->AddName(Desc, UNARTICLED);
	    Desc << " glows and sparkles like it was";
	  }

	  if(MainWielded->GetSecondaryMaterial() && MainWielded->GetSecondaryMaterial()->IsSameAs(MainWielded->GetMainMaterial()))
	    MainWielded->ChangeSecondaryMaterial(MAKE_MATERIAL(Config));

	  MainWielded->ChangeMainMaterial(MAKE_MATERIAL(Config));
	  ADD_MESSAGE("Your %s reforged by invisible hands.", Desc.CStr());
	  return;
	}
      }

      if(!(RAND() % 10))
      {
	item* Scroll = scrollofrepair::Spawn();
	ADD_MESSAGE("%s gives you %s.", GetName(), Scroll->CHAR_NAME(INDEFINITE));
	PLAYER->GetGiftStack()->AddItem(Scroll);
	return;
      }
      else
	ADD_MESSAGE("\"Mortal, thou art always my valiant knight!\"");
    }
  }

  for(int c = 0; c < PLAYER->GetEquipments(); ++c)
  {
    item* Equipment = PLAYER->GetEquipment(c);

    if(Equipment && Equipment->IsBroken())
    {
      ADD_MESSAGE("%s fixes your %s.", GetName(), Equipment->CHAR_NAME(UNARTICLED));
      Equipment->Fix();
      return;
    }
  }

  if(PLAYER->GetUsableArms())
    ADD_MESSAGE("You feel a slight tingling in your hands.");
  else
    ADD_MESSAGE("You feel a slight tingle.");
}
Esempio n. 9
0
void nefas::PrayGoodEffect()
{
  rect Rect;
  femath::CalculateEnvironmentRectangle(Rect, game::GetCurrentLevel()->GetBorder(), PLAYER->GetPos(), 10);
  truth AudiencePresent = false;

  for(int x = Rect.X1; x <= Rect.X2; ++x)
  {
    for(int y = Rect.Y1; y <= Rect.Y2; ++y)
    {
      character* Audience = game::GetCurrentLevel()->GetSquare(x, y)->GetCharacter();

      if(Audience && Audience->CanBeSeenByPlayer() && !Audience->TemporaryStateIsActivated(CONFUSED)
         && Audience->CanBeConfused() && PLAYER->GetRelation(Audience) == HOSTILE)
      {
        AudiencePresent = true;
        break;
      }
    }

    if(AudiencePresent)
      break;
  }

  if(AudiencePresent)
  {
    for(int x = Rect.X1; x <= Rect.X2; ++x)
      for(int y = Rect.Y1; y <= Rect.Y2; ++y)
      {
        character* Audience = game::GetCurrentLevel()->GetSquare(x, y)->GetCharacter();

        if(Audience && !Audience->TemporaryStateIsActivated(CONFUSED)
           && Audience->CanBeConfused() && PLAYER->GetRelation(Audience) == HOSTILE)
        {
          if(Audience->CanBeSeenByPlayer())
            ADD_MESSAGE("%s confuses %s with her sweet lies.", GetName(), Audience->CHAR_NAME(DEFINITE));

          Audience->BeginTemporaryState(CONFUSED, 500 + RAND() % 500);
        }
      }
  }

  if((GetRelation() > 200) && RAND_N(5)) {
    int Chief = 3000/GetRelation();

    mistress* Mistress = mistress::Spawn(RAND_N(Chief) ? 0 : TORTURING_CHIEF);
    v2 Where = game::GetCurrentLevel()->GetNearestFreeSquare(Mistress, PLAYER->GetPos());

    if(Where == ERROR_V2)
    {
      if(PLAYER->CanHear())
        ADD_MESSAGE("You hear a strange scream from somewhere beneath.");
      else
        ADD_MESSAGE("You feel the air vibrating.");

      delete Mistress;
    }
    else
    {
      Mistress->SetTeam(PLAYER->GetTeam());
      Mistress->PutTo(Where);
      ADD_MESSAGE("You hear a sweet voice inside your head: \"Have fun, mortal!\"");
    }
  }
  else {
    ADD_MESSAGE("You hear a sweet voice inside your head: \"Enjoy, mortal!\".");
    potion* Bottle = potion::Spawn(0, NO_MATERIALS);
    Bottle->InitMaterials(MAKE_MATERIAL(GLASS), MAKE_MATERIAL(VODKA));
    PLAYER->GetGiftStack()->AddItem(Bottle);
    ADD_MESSAGE("%s drops from nowhere.", Bottle->CHAR_DESCRIPTION(INDEFINITE));
  }
}
Esempio n. 10
0
void cruentus::PrayGoodEffect()
{
  rect Rect;
  femath::CalculateEnvironmentRectangle(Rect, game::GetCurrentLevel()->GetBorder(), PLAYER->GetPos(), 10);
  truth AudiencePresent = false;

  for(int x = Rect.X1; x <= Rect.X2; ++x)
  {
    for(int y = Rect.Y1; y <= Rect.Y2; ++y)
    {
      character* Audience = game::GetCurrentLevel()->GetSquare(x, y)->GetCharacter();

      if(Audience && Audience->CanBeSeenByPlayer() && !Audience->TemporaryStateIsActivated(PANIC)
         && PLAYER->GetRelation(Audience) == HOSTILE)
      {
        AudiencePresent = true;
        break;
      }
    }

    if(AudiencePresent)
      break;
  }

  if(AudiencePresent)
  {
    ADD_MESSAGE("The thundering voice of a godly battle drum shakes everything around you.");

    for(int x = Rect.X1; x <= Rect.X2; ++x)
      for(int y = Rect.Y1; y <= Rect.Y2; ++y)
      {
        character* Audience = game::GetCurrentLevel()->GetSquare(x, y)->GetCharacter();

        if(Audience
           && !Audience->TemporaryStateIsActivated(PANIC)
           && PLAYER->GetRelation(Audience) == HOSTILE
           && Audience->GetPanicLevel() > RAND() % 33)
          Audience->BeginTemporaryState(PANIC, 500 + RAND() % 500);
      }

    return;
  }

  item* Weapon = PLAYER->GetMainWielded();

  for(int i = 0; i < 2; i++)
  {
    if(Weapon && Weapon->IsWeapon(PLAYER) && Weapon->CanBeEnchanted())
    {
      int EnchDiff = (Weapon->GetEnchantment()*250 - GetRelation()) / 50;
      if (EnchDiff <= 1 || !RAND_N(EnchDiff))
      {
        ADD_MESSAGE("Your %s glows briefly red. It feels very warm now.", Weapon->CHAR_NAME(UNARTICLED));
        Weapon->EditEnchantment(1);
        return;
      }
    }
    Weapon = PLAYER->GetSecondaryWielded();
  }

  if(RAND() & 3)
  {
    potion* Bottle = potion::Spawn(0, NO_MATERIALS);
    Bottle->InitMaterials(MAKE_MATERIAL(GLASS), MAKE_MATERIAL(TROLL_BLOOD));
    PLAYER->GetGiftStack()->AddItem(Bottle);
    ADD_MESSAGE("%s drops from nowhere.", Bottle->CHAR_DESCRIPTION(INDEFINITE));
  }
  else
  {
    ADD_MESSAGE("Cruentus recommends you to his master, Mortifer.");
    game::GetGod(MORTIFER)->AdjustRelation(100);
  }
}
Esempio n. 11
0
truth web::TryToUnStick(character* Victim, v2)
{
  ulong TrapID = GetTrapID();
  int Modifier = GetRemoveTrapModifier(Victim);

  if(!RAND_N(Max(Modifier, 2)))
  {
    Victim->RemoveTrap(TrapID);
    TrapData.VictimID = 0;

    if(Victim->IsPlayer())
      ADD_MESSAGE("You manage to free yourself from the web.");
    else if(Victim->CanBeSeenByPlayer())
      ADD_MESSAGE("%s manages to free %sself from the web.",
                  Victim->CHAR_NAME(DEFINITE), Victim->CHAR_OBJECT_PRONOUN);

    Victim->EditAP(-500);
    return true;
  }

  if(TryToTearDown(Victim,Modifier))
    return true;

  Modifier = GetTrapBaseModifier()
             * (Victim->GetAttribute(DEXTERITY)
                + Victim->GetAttribute(ARM_STRENGTH)) / 75;

  if(Victim->CanChokeOnWeb(this) && !RAND_N(Max(Modifier << 3, 2)))
  {
    if(Victim->IsPlayer())
      ADD_MESSAGE("You manage to choke yourself on the web.");
    else if(Victim->CanBeSeenByPlayer())
      ADD_MESSAGE("%s chokes %sself on the web.",
                  Victim->CHAR_NAME(DEFINITE), Victim->CHAR_OBJECT_PRONOUN);

    Victim->LoseConsciousness(250 + RAND_N(250));
    Victim->EditAP(-1000);
    return true;
  }

  if(!RAND_N(Max(Modifier, 2)))
  {
    int VictimBodyPart = Victim->GetRandomBodyPart(ALL_BODYPART_FLAGS
                                                   &~TrapData.BodyParts);

    if(VictimBodyPart != NONE_INDEX)
    {
      TrapData.BodyParts |= 1 << VictimBodyPart;
      Victim->AddTrap(GetTrapID(), 1 << VictimBodyPart);

      if(Victim->IsPlayer())
        ADD_MESSAGE("You fail to free yourself from the web "
                    "and your %s is stuck in it in the attempt.",
                    Victim->GetBodyPartName(VictimBodyPart).CStr());
      else if(Victim->CanBeSeenByPlayer())
        ADD_MESSAGE("%s tries to free %sself from the web "
                    "but is stuck more tightly in it in the attempt.",
                    Victim->CHAR_NAME(DEFINITE),
                    Victim->CHAR_OBJECT_PRONOUN);

      Victim->EditAP(-1000);
      return true;
    }
  }

  if(Victim->IsPlayer())
    ADD_MESSAGE("You are unable to escape from the web.");

  Victim->EditAP(-1000);
  return false;
}