/// <summary> /// UpdateRelatedInLocation finds objects inside the location and adds them to the relatedSubjects locally /// </summary> public void UpdateRelatedInLocation() { LocationSubject locationSubject = subject as LocationSubject; if (locationSubject == null) { return; } //grab collides within the area of our location and create a list of objects int layerMask = ~((1 << 8) | (1 << 9)); // filter out terrain and locations Collider[] hitColliders = Physics.OverlapSphere(locationSubject.Coordinates, locationSubject.Radius, layerMask); List <int> foundSubjectIDs = new List <int>(); localObjects.Clear(); for (int i = 0; i < hitColliders.Length; i++) { // get the base script class for our objects SubjectObjectScript script = hitColliders[i].GetComponent <SubjectObjectScript>() as SubjectObjectScript; if (script == null) { Debug.Log("SubjectObjectScript was not assigned to " + hitColliders[i].name); continue; } //tell each Object that it is within our location script.Location = subject as LocationSubject; //record each subjectID found if not already recorded int foundID = script.Subject.SubjectID; if (!foundSubjectIDs.Contains(foundID)) { foundSubjectIDs.Add(foundID); } //record object quantites for NPC memory ObjectMemory existingMemory = localObjects.Find(o => o.SubjectID == script.Subject.SubjectID); if (existingMemory != null) { existingMemory.Quantity++; } else { localObjects.Add(new ObjectMemory() { Quantity = 1, SubjectID = script.Subject.SubjectID }); } } //Compare to old so that we may not need to publish to master int[] newRelated = new int[foundSubjectIDs.Count]; newRelated = foundSubjectIDs.ToArray(); if (newRelated.Length != subject.RelatedSubjects.Length) { isChanged = true; } else { for (int i = 0; i < newRelated.Length; i++) { if (newRelated[i] != subject.RelatedSubjects[i]) { isChanged = true; break; } } } //Store output in local subject copy subject.RelatedSubjects = foundSubjectIDs.ToArray(); }
public void Remember(object ox, int seconds) { TidyMemory(); if (ox == null) return; if (Recall(ox) != null) { // we already know about this guy - just refresh Refresh(ox); //(World.FindMobile(1) as Mobile).Say(String.Format("Refreshing {0}", (ox as Mobile).Name )); return; } m_MemoryCache[ox] = new ObjectMemory(ox, seconds); //(World.FindMobile(1) as Mobile).Say(String.Format("Remembering {0}", (ox as Mobile).Name)); }
/*public virtual bool OtherAttackers(Mobile cur) { //anything that hasnt attacked us in over a minute is low priority DateTime LowAttackIntrest = DateTime.Now - TimeSpan.FromMinutes(1.0); //somehow current target just went null so forget about it. if(cur == null) return true; ArrayList aggressors = m_Mobile.Aggressors; if ( aggressors.Count > 0 ) { for ( int i = 0; i < aggressors.Count; ++i ) { AggressorInfo info = (AggressorInfo)aggressors[i]; Mobile temp = info.Attacker; if(info.LastCombatTime > LowAttackIntrest && temp != null && temp != cur && m_Mobile.CanSee(temp) && m_Mobile.InLOS(temp) && temp.Alive && !temp.IsDeadBondedPet && m_Mobile.CanBeHarmful( temp, false ) && temp.Map == m_Mobile.Map) return true; //were being attacked by something else recently and we can still fight em } } return false; //nothing thats a big concern }*/ public virtual bool DoProcessReveal(Mobile c) { m_Mobile.DebugSay("I am going to try and reveal {0} from memory", c.Name); bool tryReveal = false; double ss = m_Mobile.Skills.DetectHidden.Value; double ts = c.Skills[SkillName.Hiding].Value; ObjectMemory om = Recall(c as object); // we don't reveal the mobile's current location, we reveal the last location we SAW the mobile at //plasma.. check here if the mobile is the constant focus, as we always remember that. if (om == null && m_Mobile.ConstantFocus == c) { om = new ObjectMemory(m_Mobile.ConstantFocus, 10); } if (om == null) return tryReveal; m_Mobile.DebugSay("Doing reveal logic"); if (m_Mobile.Skills.DetectHidden.Value >= 40 && ss >= ts) { //compute range double srcSkill = m_Mobile.Skills[SkillName.DetectHidden].Value; int range = (int)(srcSkill / 20.0); if (!m_Mobile.InRange(om.LastKnownLocation, range)) RunTo(om.LastKnownLocation, CanRun); else { if (m_Mobile.Target != null && m_Mobile.Target.GetType() != typeof(DetectHidden.InternalTarget)) m_Mobile.Target.Cancel(m_Mobile, TargetCancelType.Canceled); m_Mobile.UseSkill(SkillName.DetectHidden); tryReveal = true; } } else if (m_Mobile.Mana >= 30 && m_Mobile.Skills.Magery.Value >= 70 && (m_Mobile.Spell == null || (m_Mobile.Spell != null && m_Mobile.Spell.GetType() != typeof(RevealSpell))) && DateTime.Now >= m_Mobile.NextSpellTime) { int range = 1 + (int)(m_Mobile.Skills[SkillName.Magery].Value / 20.0); //cancel spell ISpell i = m_Mobile.Spell; if (i != null && i.IsCasting) { Spell s = (Spell)i; s.Disturb(DisturbType.EquipRequest, true, false); m_Mobile.FixedEffect(0x3735, 6, 30); } m_Mobile.Spell = null; if (!m_Mobile.InRange(om.LastKnownLocation, range)) RunTo(om.LastKnownLocation, CanRun); else { new RevealSpell(m_Mobile, null).Cast(); tryReveal = true; } } return tryReveal; }