context: #region
  
  using System;
  using wServer.logic.attack;
  using wServer.logic.loot;
  using wServer.logic.movement;
  using wServer.logic.taunt;
  
  #endregion
  
  namespace wServer.logic
  {
      partial class BehaviorDb
      {
          private static _ Crystal = Behav()
              .Init(0x0935, Behaves("Mysterious Crystal",
                  new RunBehaviors(
                      HpGreaterEqual.Instance(945000,
                          Cooldown.Instance(5000, Heal.Instance(1, 1000000, 0x0935))),
                      /*This is the standard healing behavior. */
                      Once.Instance(new SetKey(-1, 1)),
  
                      #region HpLesserPercent
  
                      /* These lines we're completely wrong, so I rewrote them.*/
                      /*If.Instance(
                And.Instance(HpLesser.Instance(999000, NullBehavior.Instance), HpGreaterEqual.Instance(1000000, NullBehavior.Instance)),
                  new SetKey(-1, 2)  //
              ),
              If.Instance(
                And.Instance(HpLesser.Instance(998000, NullBehavior.Instance), HpGreaterEqual.Instance(999000, NullBehavior.Instance)),
                  new SetKey(-1, 3)  //
              ),
              If.Instance(
                And.Instance(HpLesser.Instance(997000, NullBehavior.Instance), HpGreaterEqual.Instance(998000, NullBehavior.Instance)),
                  Once.Instance(new SetKey(-1, 7))   //break
              ),*/
                      /* Cooldown.Instance(5000, HpLesserPercent.Instance(0.9f, new SetKey(-1, 2))), 
              Cooldown.Instance(5000, HpLesserPercent.Instance(0.85f, new SetKey(-1, 3))),
              Cooldown.Instance(5000, HpLesserPercent.Instance(0.8f, new SetKey(-1, 7))), */
                      Cooldown.Instance(4000, HpLesser.Instance(995000, new SetKey(-1, 2))),
                      Cooldown.Instance(4000, HpLesser.Instance(985000, new SetKey(-1, 3))),
                      Cooldown.Instance(4000, HpLesser.Instance(945000, new SetKey(-1, 7))),
  
                      #endregion
                      IfEqual.Instance(-1, 1,
                          new QueuedBehavior(
                              Cooldown.Instance(100),
                              True.Instance(Rand.Instance(
                                  new RandomTaunt(0.5, "Break the crystal for great rewards..."),
                                  new RandomTaunt(0.5, "Help me...")
                                  )
                                  ),
                              CooldownExact.Instance(10000, new SetKey(-1, 1))
                              )
                          ),
                      IfEqual.Instance(-1, 2,
                          new QueuedBehavior(
                              Cooldown.Instance(0, Flashing.Instance(1000, 0xffffffff)),
                              Cooldown.Instance(1100, Flashing.Instance(1000, 0xffffffff)),
                              True.Instance(Rand.Instance(
                                  new RandomTaunt(0.5, "Fire upon this crystal with all your might for 5 seconds"),
                                  new RandomTaunt(0.5, "If your attacks are weak, the crystal magically heals"),
                                  new RandomTaunt(0.5, "Gather a large group to smash it open")
                                  )
                                  ),
                              Cooldown.Instance(5000, new SetKey(-1, 1))
                              )
                          ),
                      IfEqual.Instance(-1, 3,
                          new QueuedBehavior(
                              Cooldown.Instance(100),
                              True.Instance(Rand.Instance(
                                  new RandomTaunt(0.5, "Sweet treasure awaits for powerful adventurers!"),
                                  new RandomTaunt(0.5, "Yes!  Smash my prison for great rewards!")
                                  )
                                  ),
                              Cooldown.Instance(5000, new SetKey(-1, 4))
                              )
                          ),
                      IfEqual.Instance(-1, 4,
                          new QueuedBehavior(
                              Cooldown.Instance(100),
                              True.Instance(Rand.Instance(
                                  new RandomTaunt(0.5, "If you are not very strong, this could kill you"),
                                  new RandomTaunt(0.5, "If you are not yet powerful, stay away from the Crystal"),
                                  new RandomTaunt(0.5, "New adventurers should stay away"),
                                  new RandomTaunt(0.5, "That's the spirit. Lay your fire upon me."),
                                  new RandomTaunt(0.5, "So close...")
                                  )
                                  ),
                              Cooldown.Instance(5000, new SetKey(-1, 5))
                              )
                          ),
                      IfEqual.Instance(-1, 5,
                          new QueuedBehavior(
                              Cooldown.Instance(100),
                              True.Instance(Rand.Instance(
                                  new RandomTaunt(0.5, "I think you need more people..."),
                                  new RandomTaunt(0.5, "Call all your friends to help you break the crystal!")
                                  )
                                  ),
                              CooldownExact.Instance(10000, new SetKey(-1, 6))
                              )
                          ),
                      IfEqual.Instance(-1, 6,
                          /*Changed runbehaviors to queuedbehavior here so that the ringattack would not be repeated infinitely*/
                          new RunBehaviors(
                              new QueuedBehavior(
                                  new SimpleTaunt("Perhaps you need a bigger group. Ask others to join you!"),
                                  Cooldown.Instance(0, Flashing.Instance(1000, 0xffffffff)),
                                  RingAttack.Instance(16, 22, 16, projectileIndex: 0),
                                  Cooldown.Instance(1100, Flashing.Instance(1000, 0xffffffff)),
                                  CooldownExact.Instance(5000, new SetKey(-1, 1))
                                  ))
                          ),
                      IfEqual.Instance(-1, 7,
                          new QueuedBehavior(
                              SetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                              Once.Instance(new SimpleTaunt("You cracked the crystal! Soon we shall emerge!")),
                              Cooldown.Instance(1000, SetSize.Instance(95)),
                              Cooldown.Instance(1000, SetSize.Instance(90)),
                              Cooldown.Instance(1000, SetSize.Instance(85)),
                              Cooldown.Instance(1000, SetSize.Instance(80)),
                              Flashing.Instance(1000, 0xffffffff),
                              Flashing.Instance(1000, 0xffffffff),
                              CooldownExact.Instance(4000, new SetKey(-1, 8))
                              )
                          ),
                      IfEqual.Instance(-1, 8,
                          new QueuedBehavior(
                              Once.Instance(
                                  new SimpleTaunt("This your reward! Imagine what evil even Oryx needs to keep locked up!")),
                              Once.Instance(RingAttack.Instance(16, 22, 16, projectileIndex: 0)),
                              Once.Instance(SpawnMinionImmediate.Instance(0x0941, 0, 1, 1)),
                              Once.Instance(Despawn.Instance)
                              ))
                      )
                  ))
              .Init(0x0941, Behaves("Crystal Prisoner",
                  new RunBehaviors(
                      Once.Instance(new SimpleTaunt("I'm finally free! Yesss!!!")),
                      Once.Instance(SetConditionEffect.Instance(ConditionEffectIndex.Invulnerable)),
                      SmoothWandering.Instance(1f, 1f),
                      Once.Instance(SpawnMinionImmediate.Instance(0x0943, 3, 3, 5)
                          ),
                      If.Instance(
                          EntityLesserThan.Instance(100, 3, 0x0943), //IsEntityNotPresent.Instance(100, 0x0943),
                          Rand.Instance(
                              Reproduce.Instance(0x0943, 3, 100, 3)
                              )
                          )
                      ),
                  new QueuedBehavior( //here Is shooting start
  
                      #region Circle Attack 1
                      Cooldown.Instance(4000),
                      new RunBehaviors(
                          UnsetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          SimpleAttack.Instance(5, 3),
                          RingAttack.Instance(4, offset: 0*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 18*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 36*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          SetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          RingAttack.Instance(4, offset: 54*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 72*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          SimpleAttack.Instance(5, 3),
                          RingAttack.Instance(4, offset: 90*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          UnsetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          RingAttack.Instance(4, offset: 108*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 126*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 144*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 162*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          SetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          SimpleAttack.Instance(5, 3),
                          RingAttack.Instance(4, offset: 180*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 198*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 216*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 234*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          UnsetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          RingAttack.Instance(4, offset: 252*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          SimpleAttack.Instance(5, 3),
                          RingAttack.Instance(4, offset: 270*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 288*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          SetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          RingAttack.Instance(4, offset: 306*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 324*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 342*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(250),
                      new RunBehaviors(
                          UnsetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          RingAttack.Instance(4, offset: 360*(float) Math.PI/180)
                          ),
  
                      #endregion
  
                      #region Circle Attack 2
  
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          UnsetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          SimpleAttack.Instance(5, 3),
                          RingAttack.Instance(4, offset: 0*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 18*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 36*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          SetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          RingAttack.Instance(4, offset: 54*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 72*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          SimpleAttack.Instance(5, 3),
                          RingAttack.Instance(4, offset: 90*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          UnsetConditionEffect.Instance(ConditionEffectIndex.Invulnerable),
                          RingAttack.Instance(4, offset: 108*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 126*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
                          RingAttack.Instance(4, offset: 144*(float) Math.PI/180)
                          ),
                      Cooldown.Instance(200),
                      new RunBehaviors(
  
gt:                         RingAttack.Instance(4, offset: 162*(float) Math.PI/180)