public override bool DoActionWander() { // try breeding? if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.BreedingEnabled)) { if (!m_Mobile.Female && // males do the finding (double)m_Mobile.Hits / m_Mobile.HitsMax > MateHealthThreshold && // must be minimum health m_BecameIdle + MateIdleDelay < DateTime.Now && // wait after starting to wander m_LastMate + MaleMateDelay < DateTime.Now && // wait after last mating - we gotta recoup! m_NextMateAttempt < DateTime.Now) // gotta give it a while between looking { FindMate(); m_NextMateAttempt += TimeSpan.FromSeconds(Utility.RandomMinMax(MinMateAttemptDelay, MaxMateAttemptDelay)); if (m_MateTarget != null && Utility.RandomDouble() < MateAttemptChance) { m_Mobile.DebugSay("Found a mate I like! Trying to mate..."); BreedingState = BreedState.Approaching; Action = ActionType.Interact; m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); } return(true); } } return(base.DoActionWander()); }
public void EndMate(bool success) { if (success) { m_LastMate = DateTime.Now; } m_MateTarget = null; m_NextMateAttempt = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(MinMateAttemptDelay, MaxMateAttemptDelay)); m_BeganTheNasty = DateTime.MaxValue; BreedingState = BreedState.None; }
private void SetState(BreedState state) { switch (state) { case BreedState.ApproachingTarget: break; case BreedState.GoingForBreed: break; case BreedState.WaitingForResponse: waitingTimer = 0.0f; break; case BreedState.Breeding: breedingTimer = 0.0f; break; } this.state = state; }
public override bool DoActionInteract() { m_Mobile.DebugSay("Interacting.."); if (!m_Mobile.Controlled) { m_Mobile.DebugSay("I'm wild now... for some reason, I don't wanna bone anymore. Hm."); if (m_MateTarget != null) { m_MateTarget.EndMate(false); } EndMate(false); Action = ActionType.Wander; return(true); } if (m_Mobile.Deleted || !m_Mobile.Alive) { m_Mobile.DebugSay("Oh shit, I've got bigger things to worry about now."); if (m_MateTarget != null) { m_MateTarget.EndMate(false); } EndMate(false); Action = ActionType.Wander; return(true); } if (m_MateTarget == null) { m_Mobile.DebugSay("My mate target is gone! Going back to wander..."); EndMate(false); Action = ActionType.Wander; return(true); } if (m_Mobile.Female) { // stand still and get mated with - occasionally make sounds if (Utility.RandomDouble() < .3) { m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); } return(true); } switch (BreedingState) { case BreedState.Approaching: { // if we are not at most one tile away from mate target, get one tile away if (WalkMobileRange(m_MateTarget, 1, false, 0, 1)) { m_FightDistance = -1 + (int)Math.Round((m_Mobile.Temper + Utility.RandomMinMax(-10, 10)) / 35.0); m_Ignore = new List <Chicken>(); BreedingState = BreedState.FightingCompetition; } break; } case BreedState.FightingCompetition: { // depending on temper, fight all other male chickens near target if (m_FightDistance > -1) { IPooledEnumerable eable = m_Mobile.Map.GetMobilesInRange(m_MateTarget.Location, m_FightDistance); foreach (Mobile m in eable) { Chicken c = m as Chicken; // wisdom, temper and target's damagemin/max affect chance to attack if (c != null && !c.Female && c != m_Mobile && !m_Ignore.Contains(c) && (m_Mobile.Temper + Utility.RandomMinMax(-10, 10)) > (m_Mobile.Wisdom + c.DamageMax + c.DamageMin)) { m_Mobile.Combatant = c; m_Mobile.DebugSay("Get away from my woman!"); Action = ActionType.Combat; return(true); } else { m_Ignore.Add(c); } } eable.Free(); } // if we got here, then we're done fighting away competition m_Ignore = null; BreedingState = BreedState.MovingIn; break; } case BreedState.MovingIn: { // if we are not same loc as target, get same loc m_Mobile.DebugSay("Gettin in close..."); if (WalkMobileRange(m_MateTarget, 1, false, 0, 0)) { if (m_MateTarget.CheckBreedWith(m_Mobile)) // does she like us? { BeginMate(m_MateTarget); m_MateTarget.BeginMate(m_Mobile as Chicken); BreedingState = BreedState.Mating; } else // shit! rejected! { m_Mobile.DebugSay("Shit! Rejected!"); // do NOT endmate on woman! she might be mating with someone else. EndMate(false); } } break; } case BreedState.Mating: { if (!m_MateTarget.CheckBreedWith(m_Mobile)) // does she STILL like us? { // crap, she doesn't m_MateTarget.EndMate(false); // important that this goes first, as EndMateWith nullifies m_MateTarget EndMate(false); m_Mobile.DebugSay("Shit, she don't like me anymore."); break; } if (m_BeganTheNasty + MateDuration < DateTime.Now) { // patience affects chance to successfully procreate if (Utility.RandomDouble() < (MateSuccessChance + (m_Mobile.Patience - 10) / 500.0)) { m_Mobile.DebugSay("Smokin a cig..."); m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); Chicken child = m_MateTarget.BreedWith(m_Mobile) as Chicken; ChickenEgg egg; if (Utility.RandomDouble() < StillBornChance) { egg = new ChickenEgg(null); } else { egg = new ChickenEgg(child); } egg.MoveToWorld(m_Mobile.Location, m_Mobile.Map); m_MateTarget.EndMate(true); EndMate(true); } else { m_Mobile.DebugSay("Crap, 'sploded early."); if (m_MateTarget != null) { m_MateTarget.EndMate(false); } EndMate(false); m_Mobile.PlaySound(112); } return(true); } else { m_Mobile.DebugSay("Get down tonight..."); if (Utility.RandomDouble() < .3) { m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); } return(true); } } case BreedState.None: { m_Mobile.DebugSay("I'm not supposed to be breeding. Going back to wander.."); Action = ActionType.Wander; break; } default: { Console.WriteLine("{0} had an invalid BreedingState (= {1}). Reverting to none.", this, BreedingState); BreedingState = BreedState.None; break; } } return(true); }
public override bool DoActionInteract() { m_Mobile.DebugSay("Interacting.."); if (!m_Mobile.Controlled) { m_Mobile.DebugSay("I'm wild now... for some reason, I don't wanna bone anymore. Hm."); if (m_MateTarget != null) m_MateTarget.EndMate(false); EndMate(false); Action = ActionType.Wander; return true; } if (m_Mobile.Deleted || !m_Mobile.Alive) { m_Mobile.DebugSay("Oh shit, I've got bigger things to worry about now."); if (m_MateTarget != null) m_MateTarget.EndMate(false); EndMate(false); Action = ActionType.Wander; return true; } if (m_MateTarget == null) { m_Mobile.DebugSay("My mate target is gone! Going back to wander..."); EndMate(false); Action = ActionType.Wander; return true; } if (m_Mobile.Female) { // stand still and get mated with - occasionally make sounds if (Utility.RandomDouble() < .3) m_Mobile.PlaySound(Utility.RandomList(362, 364, 365, 705, 711, 712, 714, 715, 718)); return true; } // must be AFTER female case - females don't ever get m_BeganMateAttempt set! // funky check - basically we can exceed timeout by Random * Patience seconds // or, if we're already actually doing the nasty, we're not gonna give up /* DEBUG VERSION -- so we can see what's going on double seconds = ((m_BeganMateAttempt + MateAttemptTimout) - DateTime.Now).TotalSeconds; double patience = Utility.RandomDouble() * m_Mobile.Patience; if (this.m_Mobile.ControlMaster != null && this.m_Mobile.ControlMaster.AccessLevel > AccessLevel.Player && this.m_Mobile.ControlMaster.NetState != null) this.m_Mobile.SayTo(this.m_Mobile.ControlMaster, String.Format("seconds {0} > patience {1}", seconds, patience)); if (BreedingState != BreedState.Mating && seconds > patience) */ // original version - always times out on Patience //if (BreedingState != BreedState.Mating && //((m_BeganMateAttempt + MateAttemptTimout) - DateTime.Now).TotalSeconds > Utility.RandomDouble() * m_Mobile.Patience) // adam: new temp version until taran cn have a look .. here I'm simply removing Patience // but keeping the basic timeout logic if (BreedingState != BreedState.Mating && DateTime.Now > (m_BeganMateAttempt + MateAttemptTimout)) { m_Mobile.DebugSay("F it. This broad's too much work."); if (m_MateTarget != null) { Console.WriteLine("DEBUG: EndMating on the female during timeout. Tell Taran Kain."); m_MateTarget.EndMate(false); } EndMate(false); Action = ActionType.Wander; return true; } switch (BreedingState) { case BreedState.Approaching: { // if we are not at most one tile away from mate target, get one tile away if (WalkMobileRange(m_MateTarget, 1, false, 0, 1)) { m_FightDistance = -1 + (int)Math.Round((m_Mobile.Temper + Utility.RandomMinMax(-10, 10)) / 35.0); m_Ignore = new List<Dragon>(); BreedingState = BreedState.FightingCompetition; } break; } case BreedState.FightingCompetition: { // depending on temper, fight all other male dragons near target if (m_FightDistance > -1) { IPooledEnumerable eable = m_Mobile.Map.GetMobilesInRange(m_MateTarget.Location, m_FightDistance); foreach (Mobile m in eable) { Dragon c = m as Dragon; // wisdom, temper and target's damagemin/max affect chance to attack if (c != null && !c.Female && c != m_Mobile && !m_Ignore.Contains(c) && (m_Mobile.Temper + Utility.RandomMinMax(-10, 10)) > (m_Mobile.Wisdom + c.DamageMax + c.DamageMin)) { m_Mobile.Combatant = c; m_Mobile.DebugSay("Get away from my woman!"); Action = ActionType.Combat; return true; } else m_Ignore.Add(c); } eable.Free(); } // if we got here, then we're done fighting away competition m_Ignore = null; BreedingState = BreedState.MovingIn; break; } case BreedState.MovingIn: { // if we are not same loc as target, get same loc m_Mobile.DebugSay("Gettin in close..."); if (WalkMobileRange(m_MateTarget, 1, false, 0, 0)) { if (m_MateTarget.CheckBreedWith(m_Mobile)) // does she like us? { BeginMate(m_MateTarget); m_MateTarget.BeginMate(m_Mobile as Dragon); BreedingState = BreedState.Mating; } else // shit! rejected! { m_Mobile.DebugSay("Shit! Rejected!"); // do NOT endmate on woman! she might be mating with someone else. EndMate(false); } } break; } case BreedState.Mating: { if (!m_MateTarget.CheckBreedWith(m_Mobile) || // does she STILL like us? m_MateTarget.Location != m_Mobile.Location || // did she leave? !InFireDungeon(m_Mobile)) // sanity check { // crap, she doesn't m_MateTarget.EndMate(false); // important that this goes first, as EndMateWith nullifies m_MateTarget EndMate(false); m_Mobile.DebugSay("Shit, she don't like me anymore."); break; } if (m_BeganTheNasty + MateDuration < DateTime.Now) { // patience affects chance to successfully procreate if (Utility.RandomDouble() < (MateSuccessChance + (m_Mobile.Patience - 10) / 500.0)) { m_Mobile.DebugSay("Smokin a cig..."); m_Mobile.PlaySound(Utility.RandomList(362, 364, 365, 705, 711, 712, 714, 715, 718)); Dragon child = m_MateTarget.BreedWith(m_Mobile) as Dragon; DragonEgg egg; if (Utility.RandomDouble() < StillBornChance) egg = new DragonEgg(null); else egg = new DragonEgg(child); egg.MoveToWorld(m_Mobile.Location, m_Mobile.Map); m_MateTarget.EndMate(true); EndMate(true); } else { m_Mobile.DebugSay("Crap, 'sploded early."); if (m_MateTarget != null) m_MateTarget.EndMate(false); EndMate(false); m_Mobile.PlaySound(366); } return true; } else { m_Mobile.DebugSay("Get down tonight..."); if (Utility.RandomDouble() < .3) m_Mobile.PlaySound(Utility.RandomList(362, 364, 365, 705, 711, 712, 714, 715, 718)); return true; } } case BreedState.None: { m_Mobile.DebugSay("I'm not supposed to be breeding. Going back to wander.."); Action = ActionType.Wander; break; } default: { Console.WriteLine("{0} had an invalid BreedingState (= {1}). Reverting to none.", this, BreedingState); BreedingState = BreedState.None; break; } } return true; }
public override bool DoActionWander() { // try breeding? Dragon mob = m_Mobile as Dragon; if (mob == null) return false; // big problems! if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.BreedingEnabled) && mob.BreedingParticipant) { if (!m_Mobile.Female && // males do the finding m_Mobile.Alive && // ... mob.Maturity == Dragon.DragonMaturity.Adult && // must be an adult (double)m_Mobile.Hits / m_Mobile.HitsMax >= MateHealthThreshold && // must be minimum health m_BecameIdle + MateIdleDelay < DateTime.Now && // wait after starting to wander m_LastMate + MaleMateDelay < DateTime.Now && // wait after last mating - we gotta recoup! m_NextMateAttempt < DateTime.Now && // gotta give it a while between looking InFireDungeon(m_Mobile)) // gotta be in fire dungeon { FindMate(); m_NextMateAttempt += TimeSpan.FromSeconds(Utility.RandomMinMax(MinMateAttemptDelay, MaxMateAttemptDelay)); if (m_MateTarget != null && Utility.RandomDouble() < MateAttemptChance) { m_Mobile.DebugSay("Found a mate I like! Trying to mate..."); BreedingState = BreedState.Approaching; Action = ActionType.Interact; m_BeganMateAttempt = DateTime.Now; m_Mobile.PlaySound(Utility.RandomList(364, 365, 362)); } return true; } } return base.DoActionWander(); }
public override bool DoActionInteract() { m_Mobile.DebugSay("Interacting.."); if (!m_Mobile.Controlled) { m_Mobile.DebugSay("I'm wild now... for some reason, I don't wanna bone anymore. Hm."); if (m_MateTarget != null) m_MateTarget.EndMate(false); EndMate(false); Action = ActionType.Wander; return true; } if (m_Mobile.Deleted || !m_Mobile.Alive) { m_Mobile.DebugSay("Oh shit, I've got bigger things to worry about now."); if (m_MateTarget != null) m_MateTarget.EndMate(false); EndMate(false); Action = ActionType.Wander; return true; } if (m_MateTarget == null) { m_Mobile.DebugSay("My mate target is gone! Going back to wander..."); EndMate(false); Action = ActionType.Wander; return true; } if (m_Mobile.Female) { // stand still and get mated with - occasionally make sounds if (Utility.RandomDouble() < .3) m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); return true; } switch (BreedingState) { case BreedState.Approaching: { // if we are not at most one tile away from mate target, get one tile away if (WalkMobileRange(m_MateTarget, 1, false, 0, 1)) { m_FightDistance = -1 + (int)Math.Round((m_Mobile.Temper + Utility.RandomMinMax(-10, 10)) / 35.0); m_Ignore = new List<Chicken>(); BreedingState = BreedState.FightingCompetition; } break; } case BreedState.FightingCompetition: { // depending on temper, fight all other male chickens near target if (m_FightDistance > -1) { IPooledEnumerable eable = m_Mobile.Map.GetMobilesInRange(m_MateTarget.Location, m_FightDistance); foreach (Mobile m in eable) { Chicken c = m as Chicken; // wisdom, temper and target's damagemin/max affect chance to attack if (c != null && !c.Female && c != m_Mobile && !m_Ignore.Contains(c) && (m_Mobile.Temper + Utility.RandomMinMax(-10, 10)) > (m_Mobile.Wisdom + c.DamageMax + c.DamageMin)) { m_Mobile.Combatant = c; m_Mobile.DebugSay("Get away from my woman!"); Action = ActionType.Combat; return true; } else m_Ignore.Add(c); } eable.Free(); } // if we got here, then we're done fighting away competition m_Ignore = null; BreedingState = BreedState.MovingIn; break; } case BreedState.MovingIn: { // if we are not same loc as target, get same loc m_Mobile.DebugSay("Gettin in close..."); if (WalkMobileRange(m_MateTarget, 1, false, 0, 0)) { if (m_MateTarget.CheckBreedWith(m_Mobile)) // does she like us? { BeginMate(m_MateTarget); m_MateTarget.BeginMate(m_Mobile as Chicken); BreedingState = BreedState.Mating; } else // shit! rejected! { m_Mobile.DebugSay("Shit! Rejected!"); // do NOT endmate on woman! she might be mating with someone else. EndMate(false); } } break; } case BreedState.Mating: { if (!m_MateTarget.CheckBreedWith(m_Mobile)) // does she STILL like us? { // crap, she doesn't m_MateTarget.EndMate(false); // important that this goes first, as EndMateWith nullifies m_MateTarget EndMate(false); m_Mobile.DebugSay("Shit, she don't like me anymore."); break; } if (m_BeganTheNasty + MateDuration < DateTime.Now) { // patience affects chance to successfully procreate if (Utility.RandomDouble() < (MateSuccessChance + (m_Mobile.Patience - 10) / 500.0)) { m_Mobile.DebugSay("Smokin a cig..."); m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); Chicken child = m_MateTarget.BreedWith(m_Mobile) as Chicken; ChickenEgg egg; if (Utility.RandomDouble() < StillBornChance) egg = new ChickenEgg(null); else egg = new ChickenEgg(child); egg.MoveToWorld(m_Mobile.Location, m_Mobile.Map); m_MateTarget.EndMate(true); EndMate(true); } else { m_Mobile.DebugSay("Crap, 'sploded early."); if (m_MateTarget != null) m_MateTarget.EndMate(false); EndMate(false); m_Mobile.PlaySound(112); } return true; } else { m_Mobile.DebugSay("Get down tonight..."); if (Utility.RandomDouble() < .3) m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); return true; } } case BreedState.None: { m_Mobile.DebugSay("I'm not supposed to be breeding. Going back to wander.."); Action = ActionType.Wander; break; } default: { Console.WriteLine("{0} had an invalid BreedingState (= {1}). Reverting to none.", this, BreedingState); BreedingState = BreedState.None; break; } } return true; }
public override bool DoActionWander() { // try breeding? if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.BreedingEnabled)) if (!m_Mobile.Female && // males do the finding (double)m_Mobile.Hits / m_Mobile.HitsMax > MateHealthThreshold && // must be minimum health m_BecameIdle + MateIdleDelay < DateTime.Now && // wait after starting to wander m_LastMate + MaleMateDelay < DateTime.Now && // wait after last mating - we gotta recoup! m_NextMateAttempt < DateTime.Now) // gotta give it a while between looking { FindMate(); m_NextMateAttempt += TimeSpan.FromSeconds(Utility.RandomMinMax(MinMateAttemptDelay, MaxMateAttemptDelay)); if (m_MateTarget != null && Utility.RandomDouble() < MateAttemptChance) { m_Mobile.DebugSay("Found a mate I like! Trying to mate..."); BreedingState = BreedState.Approaching; Action = ActionType.Interact; m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115)); } return true; } return base.DoActionWander(); }