// iType:
//  1 = Dretch
//  2 = Balor
//  3 = Vrock
//  4 = Hezrou
//  5 = 1d2 Vrock or Glebrezu
//  6 = Glebrezu or Nalfeshnee
//  7 = Nalfeshnee or Marilith
//  8 = Marilith
//
// Note: Although, technically, they should be able to try again in another
//      hour or day, I am limiting it to an one-shot event.
//
// Timer for the 24 hours period depends largely on how many minutes per hour
//      the module is set for.  I use 4 minutes per hour, but the default is
//      2 hours per minute, so I am setting the "next chance" to that.
//      The formula is as follows:
//          iWait = (MinutesPerHourModule)*(HoursPerDay)*(HeartbeatsPerMinute)
//          iWait = iMinPerHour*24*10
//      Set iMinPerHour to Equal the Modules hours per minute setting.
float fMinPerHour = 2.0;
float fWait = -fMinPerHour*24.0*10.0;

void SummonTanarii(int iType)
{
        ClearAllActions();

        switch (iType) {
          // Dretch Summon, 35%
          case 1:
            SpeakString("Come to me, foul brother!");
            // 35% chance
            if (d100() < 36) {
                // success!
                effect eSummon = EffectSummonCreature("sr_dretchdemon",VFX_FNF_SUMMON_MONSTER_3);
                ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            } else {
                // failure - wait 14400 heartbeats (24 hours)
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            }
            break;

          // Balor Summon, 10%
          case 2:
            SpeakString("Aid me great master!!!");
            // 10% chance
            if (d100() < 11) {
                // success!
                effect eSummon = EffectSummonCreature("sr_balordemon",VFX_FNF_SUMMON_MONSTER_3);
                ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            } else {
                // failure - wait 14400 heartbeats (24 hours)
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            }
            break;

          // Vrock Summon, 35%
          case 3:
            SpeakString("Come to me, foul brother!");
            // 35% chance
            if (d100() < 36) {
                // success!
                effect eSummon = EffectSummonCreature("sr_vrock",VFX_FNF_SUMMON_MONSTER_3);
                ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            } else {
                // failure - wait 14400 heartbeats (24 hours)
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            }
            break;

          // Hezrou Summon, 35%
          case 4:
            SpeakString("Come to me, foul brother!");
            // 35% chance
            if (d100() < 36) {
                // success!
                effect eSummon = EffectSummonCreature("sr_hezroudemon",VFX_FNF_SUMMON_MONSTER_3);
                ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            } else {
                // failure - wait 14400 heartbeats (24 hours)
                SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            }
            break;

          // Glebrezu (20%) or 1d2 Vrock (50%) Summon
          case 5:
            SpeakString("Come to me, foul brothers!");
            if (d2() == 1) {
              // 50% chance on 1d2 Vrock
              if (d100() < 51) {
                  // success!
                  effect eSummon = EffectSummonCreature("sr_vrock",VFX_FNF_SUMMON_MONSTER_3);
                  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
                  if (d2() == 2)
                      ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                  CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              } else {
                  // failure - wait 14400 heartbeats (24 hours)
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              }
            } else {
              // 20% chance on Glebrezu
              if (d100() < 21) {
                  // success!
                  effect eSummon = EffectSummonCreature("sr_glebrezudemon",VFX_FNF_SUMMON_MONSTER_3);
                  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                  CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              } else {
                  // failure - wait 14400 heartbeats (24 hours)
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              }
            }
            break;

          // Nalfeshnee (20%) or Glebrezu (50%) Summon
          case 6:
            SpeakString("Come to me, foul brother!");
            if (d2() == 1) {
              // 50% chance on Glebrezu
              if (d100() < 51) {
                  // success!
                  effect eSummon = EffectSummonCreature("sr_glebrezudemon",VFX_FNF_SUMMON_MONSTER_3);
                  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                  CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              } else {
                  // failure - wait 14400 heartbeats (24 hours)
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              }
            } else {
              // 20% chance on Nalfeshnee
              if (d100() < 21) {
                  // success!
                  effect eSummon = EffectSummonCreature("sr_nalfeshdemom",VFX_FNF_SUMMON_MONSTER_3);
                  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                  CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              } else {
                  // failure - wait 14400 heartbeats (24 hours)
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              }
            }
            break;

          // Nalfeshnee (50%) or Marilith (20%) Summon
          case 7:
            SpeakString("Come to me, choas servants!");
            if (d2() == 1) {
              // 50% chance on Nalfeshnee
              if (d100() < 51) {
                  // success!
                  effect eSummon = EffectSummonCreature("sr_nalfeshdemom",VFX_FNF_SUMMON_MONSTER_3);
                  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                  CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              } else {
                  // failure - wait 14400 heartbeats (24 hours)
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              }
            } else {
              // 20% chance on Marilith
              if (d100() < 21) {
                  // success!
                  effect eSummon = EffectSummonCreature("sr_marilithdemon",VFX_FNF_SUMMON_MONSTER_3);
                  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//                  CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              } else {
                  // failure - wait 14400 heartbeats (24 hours)
                  SetLocalFloat(OBJECT_SELF, "Minute", fWait);
              }
            }
            break;

          // Marilith Summon, 100%
          case 8:
            SpeakString("Come to me, servant of chaos!");
            // success!
            effect eSummon = EffectSummonCreature("sr_marilithdemon",VFX_FNF_SUMMON_MONSTER_3);
            ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(1));
//            CreateObject(OBJECT_TYPE_CREATURE, GetTag(OBJECT_SELF), GetLocation(OBJECT_SELF), TRUE);
            SetLocalFloat(OBJECT_SELF, "Minute", fWait);
            break;

        } // switch
}
