/// <summary> /// Constructor /// Contains design info for the Duel Gump /// </summary> /// <param name="from">Mobile the gump is displayed to</param> /// <param name="stone">Duel Stone the gump is linked to</param> public DuelGump(Mobile from, DuelStone stone) : base(20, 30) { m_Owner = from; m_Stone = stone; this.Closable = false; this.Disposable = true; this.Dragable = true; this.Resizable = false; AddPage(0); AddBackground(100, 100, 276, 331, 9350); AddHtml(117, 115, 241, 32, @"<center>Duel Terms</center>", (bool)true, (bool)false); AddLabel(122, 164, 0, @"Duel Fee(%):"); AddLabel(122, 201, 0, @"Gear:"); AddLabel(122, 239, 0, @"Time Limit:"); AddLabel(124, 278, 0, @"Rules:"); AddHtml(202, 159, 153, 30, m_Stone.Fee.ToString(), (bool)true, (bool)false); // Duel Fee AddHtml(202, 195, 153, 30, m_Stone.SuppliedDuel ? "Provided":"User", (bool)true, (bool)false); // Gear AddHtml(202, 233, 153, 30, m_Stone.MaxDuelTime.TotalMinutes.ToString() + "min", (bool)true, (bool)false); // Time Limit AddHtml(202, 272, 153, 30, @"Field", (bool)true, (bool)false); // Ruleset AddLabel(140, 319, 0, @"How much do you wish to wager?"); AddBackground(124, 342, 230, 33, 9350); AddButton(222, 393, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(291, 393, 241, 242, 0, GumpButtonType.Reply, 0); AddTextEntry(129, 346, 217, 23, 0, 0, m_Stone.MinimumWager.ToString()); m_InTime = new InternalTimer(m_Owner, m_Stone); m_InTime.Start(); }
/// <summary> /// Timer constructer /// </summary> /// <param name="m">Mobile that has either the gumps or the target option</param> /// <param name="stone">Duel Stone that is linked to these events</param> public InternalTimer(Mobile m, DuelStone stone) : base(TimeSpan.FromSeconds(0.0), TimeSpan.FromSeconds(1.0)) { m_StartTime = DateTime.Now; m_EndTime = m_StartTime + m_ChoiceTime; m_Owner = m; m_Stone = stone; }
/// <summary> /// Contains the design infor for the Duel Confirmation gump /// </summary> /// <param name="from">Mobile requesting the duel</param> /// <param name="to">Mobile requested to duel</param> /// <param name="stone">Duel Stone the gump is linked to</param> public DuelConfirmGump(Mobile from, Mobile to, DuelStone stone) : base(20, 30) { m_Requester = from; m_Acceptor = to; m_Stone = stone; this.Closable = false; this.Disposable = true; this.Dragable = true; this.Resizable = false; AddPage(0); AddBackground(100, 100, 276, 331, 9350); AddHtml(117, 115, 241, 32, @"<center>Duel Terms</center>", (bool)true, (bool)false); AddLabel(122, 164, 0, @"Duel Fee(%):"); AddLabel(122, 201, 0, @"Gear:"); AddLabel(122, 239, 0, @"Time Limit:"); AddLabel(124, 278, 0, @"Rules:"); AddLabel(124, 312, 0, @"Opponent"); AddLabel(124, 347, 0, @"Wager"); AddHtml(202, 159, 153, 30, m_Stone.Fee.ToString(), (bool)true, (bool)false); // Duel Fee AddHtml(202, 195, 153, 30, m_Stone.SuppliedDuel ? "Provided" : "User", (bool)true, (bool)false); // Gear AddHtml(202, 233, 153, 30, m_Stone.MaxDuelTime.TotalMinutes.ToString() + "min", (bool)true, (bool)false); // Time Limit AddHtml(202, 272, 153, 30, @"Field", (bool)true, (bool)false); // Ruleset AddHtml(202, 306, 153, 30, m_Requester.Name, (bool)true, (bool)false); AddHtml(202, 341, 153, 30, m_Stone.Wager.ToString(), (bool)true, (bool)false); AddButton(222, 393, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(291, 393, 241, 242, 0, GumpButtonType.Reply, 0); m_InTime = new InternalTimer(m_Acceptor, m_Stone); m_InTime.Start(); }
/// <summary> /// Used to allow the mobile to target its duel opponent /// and send the duel request /// </summary> /// <param name="owner">Mobile requesting the duel</param> /// <param name="stone">Duel Stone linked to the targetting</param> public InternalTarget(Mobile owner, DuelStone stone) : base(5, true, TargetFlags.None) { m_Owner = owner; m_Stone = stone; m_InTime = new InternalTimer(m_Owner, m_Stone); m_InTime.Start(); }
/// <summary> /// Constructor /// </summary> /// <param name="d1">Duelist One</param> /// <param name="d2">Duelist Two</param> /// <param name="item">Duel Stone that contains the Duel info</param> public DuelTimer(Mobile d1, Mobile d2, DuelStone item) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(1.0)) { m_Duelist1 = d1; m_Duelist2 = d2; m_Stone = item; double fee = (double)m_Stone.Wager * ((double)m_Stone.Fee / 100); m_CalcFee = (int)fee; m_Staging = DateTime.Now + m_Stone.StagingTime; GetDuelists(); }
protected override void OnTick() { int thishour = DateTime.Now.Hour; if (thishour == OpeningHour1 || thishour == OpeningHour2) { if (dsBrit == null) { dsBrit = new DuelStone(); dsBrit.MoveToWorld(new Point3D(1433, 1691, 20), Map.Felucca); } if (dsBuccDen == null) { dsBuccDen = new DuelStone(); dsBuccDen.MoveToWorld(new Point3D(2677, 2124, 0), Map.Felucca); } if ((thishour != m_LastAnnounce) && (AnnounceOpening)) { { foreach (NetState ns in NetState.Instances) { Mobile m = ns.Mobile; if (m != null && !(m.Region is Server.Regions.Jail)) { m.SendMessage(0x482, "Message from the Duelmaster:"); m.SendMessage(0x482, "The Duel Arena has just opened. If you wish to challenge someone to a duel now is the time to do it! The arena will close again after 1 hour."); } } m_LastAnnounce = thishour; } } } else { if (dsBrit != null) { dsBrit.Delete(); dsBrit = null; } if (dsBuccDen != null) { dsBuccDen.Delete(); dsBuccDen = null; } } }
public static void ResetTimers( DuelStone ds ) { if( ds == null ) return; if( ds.CountTimer != null ) { ds.CountTimer.Stop(); ds.CountTimer = null; } if( ds.MoveTimer != null ) { ds.MoveTimer.Stop(); ds.MoveTimer = null; } if( ds.EndDuelTimer != null ) { ds.EndDuelTimer.Stop(); ds.EndDuelTimer = null; } ds.EndTimer = false; }
public static void GiveGold( DuelStone ds, Mobile to ) { if( ds.DuelCost != 0 && !ds.StoneType.ToString().Contains( "Loot" ) ) { to.Backpack.AddItem( new Gold( (int)( ds.DuelCost * 0.9 ) ) ); to.SendAsciiMessage( (int)( ds.DuelCost * 0.9 ) + " gold has been added to your backpack." ); } }
public static void EndTeleOut( DuelStone ds, Mobile toTele ) { if( toTele != null ) if( ds != null ) { if( !ds.StoneType.ToString().Contains( "Loot" ) && !toTele.Alive ) { if( toTele.Corpse != null ) toTele.MoveToWorld( toTele.Corpse.Location, toTele.Corpse.Map ); toTele.Resurrect(); } else if( toTele.Alive ) { toTele.Hits = toTele.HitsMax; toTele.Mana = toTele.ManaMax; toTele.Stam = toTele.StamMax; } toTele.Location = ds.AfterDuelLocation; toTele.Frozen = false; if( !toTele.Alive ) toTele.Resurrect(); (toTele).HasFilter = false; // Clear aggressor list List<AggressorInfo> toRemove = new List<AggressorInfo>(); foreach (AggressorInfo aI in toTele.Aggressors) { if (aI.Attacker == toTele || aI.Defender == toTele) toRemove.Add(aI); } if (toRemove.Count > 0) foreach (AggressorInfo aI in toRemove) toTele.Aggressors.Remove(aI); toRemove.Clear(); foreach (AggressorInfo aI in toTele.Aggressed) { if (aI.Attacker == toTele || aI.Defender == toTele) toRemove.Add(aI); } if (toRemove.Count > 0) foreach (AggressorInfo aI in toRemove) toTele.Aggressed.Remove(aI); //AggressorInfo toRemove = null; //foreach (AggressorInfo aI in toTele.Aggressors) //{ // if (aI.Attacker == toTele) // Might also want to // toRemove = aI; //Add a break here //} } else toTele.SendAsciiMessage( "Error with the stone, page a GM" ); }
public static void JoinDuel( DuelStone ds, Mobile to ) { if( to != null && ds.DuelerLocation1 != new Point3D( 0, 0, 0 ) && ( ds.Combatant1 == null || ds.Combatant2 == null ) ) { if( ds.CountTimer != null ) { to.SendAsciiMessage( "The stone is busy!" ); return; } if( !AffordsDuel( ds, to, ds.DuelCost ) ) return; to.Location = ds.DuelerLocation1; if( ds.Combatant1 == null ) { ds.Combatant1 = to; ((PlayerMobile)ds.Combatant1).DuelStone = ds; } else if( ds.Combatant2 == null ) { ds.Combatant2 = to; ((PlayerMobile)ds.Combatant2).DuelStone = ds; } if( ds.Combatant1 != null && ds.Combatant2 != null ) { ResetTimers( ds ); ds.EndDuelTimer = Timer.DelayCall( TimeSpan.FromMinutes( maxDuelLenght ), TimeSpan.FromMinutes( maxDuelLenght ), 2, new TimerStateCallback( EndLongDuel ), ds ); ds.Combatant1.SendAsciiMessage( "The duel will end in " + maxDuelLenght + " minutes if both players are still alive." ); ds.Combatant2.SendAsciiMessage( "The duel will end in " + maxDuelLenght + " minutes if both players are still alive." ); (ds.Combatant1).HasFilter = true; (ds.Combatant2).HasFilter = true; } } }
public static void GiveOpponentMoney( DuelStone ds, Mobile from ) { if( !from.Alive ) { if( ds.Combatant1 == from && ds.Combatant2 != null ) GiveGold( ds, ds.Combatant2 ); else if( ds.Combatant2 == from && ds.Combatant1 != null ) GiveGold( ds, ds.Combatant1 ); } else if( ds.Combatant1 == from && ds.Combatant2 != null && !ds.Combatant2.Alive ) GiveGold( ds, from ); else if( ds.Combatant2 == from && ds.Combatant1 != null && !ds.Combatant1.Alive ) GiveGold( ds, from ); }
public static void LeaveDuel( DuelStone ds, Mobile from ) { if( ( ( ds.Combatant1 == from && ds.Combatant2 != null && ds.Combatant2.Alive && ds.Combatant1.Alive && ds.MoveTimer == null ) || ( ds.Combatant2 == from && ds.Combatant1 != null && ds.Combatant1.Alive && ds.Combatant2.Alive && ds.MoveTimer == null ) ) ) { from.SendAsciiMessage( "Someone has to die first!" ); from.PublicOverheadMessage( MessageType.Regular, from.SpeechHue, true, "I am trying to escape a certain death!" ); return; } if( !from.Alive ) { if( ds.Combatant1 == from && ds.Combatant2 != null ) { ((PlayerMobile)ds.Combatant1).DuelStone = null; ds.Combatant1 = null; } else if( ds.Combatant2 == from && ds.Combatant1 != null ) { ((PlayerMobile)ds.Combatant2).DuelStone = null; ds.Combatant2 = null; } } else if( ds.Combatant1 == from && ( ( ds.Combatant2 != null && !ds.Combatant2.Alive ) || ds.Combatant2 == null ) ) { GiveGold( ds, from ); ((PlayerMobile)ds.Combatant1).DuelStone = null; ds.Combatant1 = null; if( ds.Combatant2 != null ) { EndTeleOut( ds, ds.Combatant2 ); ((PlayerMobile)ds.Combatant2).DuelStone = null; ds.Combatant2 = null; } //End movetimer if( ds.MoveTimer != null ) { ds.MoveTimer.Stop(); ds.MoveTimer = null; } } else if( ds.Combatant2 == from && ( ( ds.Combatant1 != null && !ds.Combatant1.Alive ) || ds.Combatant1 == null ) ) { GiveGold( ds, from ); ((PlayerMobile)ds.Combatant2).DuelStone = null; ds.Combatant2 = null; if( ds.Combatant1 != null ) { EndTeleOut( ds, ds.Combatant1 ); ((PlayerMobile)ds.Combatant1).DuelStone = null; ds.Combatant1 = null; } //End movetimer if( ds.MoveTimer != null ) { ds.MoveTimer.Stop(); ds.MoveTimer = null; } } ds.EndTimer = true; //if(ds.Combatant1 != null && ds.Combatant1 != from) // if(from.Aggressors.Contains((AggressorInfo) ds.Combatant1)) EndTeleOut( ds, from ); }
public static bool CanUseStone( DuelStone ds, Mobile from ) { #region MutualChecks if( ds.DuelerLocation1 == new Point3D( 0, 0, 0 ) ) { from.SendAsciiMessage( "This stone has not yet been set, page a GM." ); return false; } if( ( ds.StoneType == DuelStoneEventType.Loot2vs2 || ds.StoneType == DuelStoneEventType.Money2vs2 ) && ds.DuelerLocation2 == new Point3D( null ) ) { from.SendAsciiMessage( "This stone has not yet been set, page a GM." ); return false; } /*if( ( ds.DuelCost == 0 ) && ( ds.StoneType == DuelStoneEventType.Money1vs1 || ds.StoneType == DuelStoneEventType.Money2vs2 ) ) { from.SendAsciiMessage( "This stone has not yet been set, page a GM." ); return false; }*/ if( from.Hits != from.HitsMax && !ds.IsUsingStone( from ) ) { from.SendAsciiMessage( "You do not have enough HP to join this duel." ); return false; } #endregion if( ( ( ds.StoneType == DuelStoneEventType.Money1vs1 || ds.StoneType == DuelStoneEventType.Loot1vs1 ) && ( ds.Combatant1 != null && ds.Combatant2 != null ) && ( ds.Combatant1 != from && ds.Combatant2 != from ) ) ) { from.SendAsciiMessage( "This stone is busy!" ); return false; } return true; }
public static bool AffordsDuel( DuelStone ds, Mobile from, int price ) { if( price == 0 ) return true; if( ds.IsUsingStone( from ) ) return true; if( from.Backpack.TotalGold >= price ) { from.Backpack.ConsumeTotal( typeof( Gold ), price ); from.SendAsciiMessage( price + " has been withdrawn from your account." ); return true; } else if( ( from.BankBox.TotalGold + from.Backpack.TotalGold ) >= price ) { from.BankBox.ConsumeTotal( typeof( Gold ), price - from.Backpack.TotalGold ); from.Backpack.ConsumeTotal( typeof( Gold ), from.Backpack.TotalGold ); from.SendAsciiMessage( price + " has been withdrawn from your account." ); return true; } else { from.SendAsciiMessage( "You do not have enough money for this duel!" ); return false; } }