Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Lab Assistant
Original Poster
#26 Old 2nd Feb 2021 at 1:44 PM
I managed to make it work! I now only need to debug some things -- It seems that the conditional triggers for seeing ghosts are not working. Don't know what exactly could cause this. Here are they:

Code:
public static bool RefreshVisibility(SimDescription targetDescription, bool immediate)
{
	if (targetDescription == null)
	{
		return false;
	}
	Sim createdSim = targetDescription.CreatedSim;
	if (createdSim == null)
	{
		return false;
	}
	bool flag = false;
	if (!targetDescription.IsGhost)
	{
		flag = true;
	}
	else
	{
		Sim selectedActor = PlumbBob.SelectedActor;
		SimDescription simDescription = (selectedActor == null) ? null : selectedActor.SimDescription;
		if (simDescription != null && (simDescription.Occupation is GhostHunter || (simDescription.SkillManager.HasElement(SkillNames.Spellcraft) && simDescription.SkillManager.GetElement(SkillNames.Spellcraft).SkillLevel >= 5) || simDescription.CreatedSim.BuffManager.HasElement(0x15DABBECF72A9084) || selectedActor == createdSim))
		{
			flag = true;
		}
	}
	float fadeTime = immediate ? 0f : GameObject.kGlobalObjectFadeTime;
	if (flag)
	{
		createdSim.FadeIn(false, fadeTime);
	}
	else
	{
		createdSim.FadeOut(false, false, fadeTime);
	}
	Audio.MuteAllSounds(createdSim.ObjectId, !flag);
	return flag;
}


and

Code:
public static class CanSocialize
{
	public static bool CanSocializeWith(Sim otherSim)
{
	SimDescription simDescription = otherSim.SimDescription;
	if (simDescription.IsGhost)
	{
		return true;
	}
	if (otherSim == null)
	{
		return true;
	}
	
	if (simDescription == mSimDescription)
	{
		return true;
	}
	if (simDescription != null && (simDescription.Occupation is GhostHunter || (simDescription.SkillManager.HasElement(SkillNames.Spellcraft) && simDescription.SkillManager.GetElement(SkillNames.Spellcraft).SkillLevel >= 5) || simDescription.CreatedSim.BuffManager.HasElement(0x15DABBECF72A9084)))
	{
		return true;
	}
	return false;
}
	public static bool CanSimSocializeWithSim(Sim actor, Sim target)
{
	if (!actor.SimDescription.IsGhost && !CanSocializeWith(target))
	{
		return false;
	}
	if (!target.SimDescription.IsGhost && !CanSocializeWith(actor))
	{
		return false;
	}
	return true;
}
	public static SimDescription mSimDescription;
}
Advertisement
Virtual gardener
staff: administrator
#27 Old 3rd Feb 2021 at 10:25 AM
Quote: Originally posted by CyrusBanefort
So... I think both copying the code from the Imaginary Friend occult and using ITUN files is out of question. What should I do? It's still very strange for sims to randomly start chatting with something that they cannot see.

EDIT: Is it possible to add a listener that checks if the sim is trying to interact with another?

EDIT2: I found something that might be able to help me. I found a eventlistener called OnSocialization. My aim is to change these two pieces of code:

Code:
public static bool CanSimSocializeWithSim(Sim actor, Sim target)
{
   OccultImaginaryFriend occult;
   if (TryGetOccultFromSim(actor, out occult) && !occult.CanSocializeWith(target))
   {
      return false;
   }
   OccultImaginaryFriend occult2;
   if (TryGetOccultFromSim(target, out occult2) && !occult2.CanSocializeWith(actor))
   {
      return false;
   }
   return true;
}


and

Code:
public static bool TryGetOccultFromSim(Sim sim, out OccultImaginaryFriend occult)
{
   if (sim != null && sim.SimDescription.IsImaginaryFriend)
   {
      occult = (sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend);
      return occult != null;
   }
   occult = null;
   return false;
}


In something that could be used by ghosts, using the first boolean to cancel social interactions in case the sim isn't who I want to be, but I need help. I think if I finish these two interactions, the most difficult part of the mod is done, and I only need to focus on interactions.
Keep in mind that the "CanSimSocializeWith" methods are actually being called in social events. (See: CanBeInSameGroupTalkAsMe(Sim sim)) in Ilspy) 

So the function is hard to apply 'globally' so to speak. I can't actually figure out a way on how to apply a check like this otherwise without having to do a loooot of work to get it to work :/ Except for the buff method where you trigger sims to have a conversation with the ghost. 
Lab Assistant
Original Poster
#28 Old 3rd Feb 2021 at 1:02 PM
Yeah, that's certainly a lot of work. I've been trying many ways to restrict the interactions, to no avail. If you have a suggestion, I'm open to it -- Tell me more about that buff thing.

If I, in the end, couldn't add these restrictions, would it be fine if the ghosts would only be invisible, without the autonomy being turned off?
Page 2 of 2
Back to top