- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Game won't recognize custom Sim interaction script
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Game won't recognize custom Sim interaction script
Replies: 2 (Who?), Viewed: 3036 times.
#1
11th Jun 2017 at 1:36 PM
Posts: 3,860
Thanks: 8548 in 67 Posts
Game won't recognize custom Sim interaction script
And yet again I'm back with more scripting questions!
I've been trying to get this script to work, getting it at least assign on a sim or appear. But it doesn't matter what I try it just won't. Appear. I've read Cmar's Sim Pie Interaction tutorial and used it as a template to see if it would work, but it just doesn't appear in-game. I've a XML file for the kInstantiator as well, so that's not the issue. I also included the STBL files with the package. If anyone wants to see the package itself, feel free to ask!
Here's the script:
Code:
using System; using System.Xml; using System.Collections.Generic; using System.Text; using Sims3.Gameplay; using Sims3.Gameplay.Actors; using Sims3.Gameplay.ActorSystems; using Sims3.Gameplay.Autonomy; using Sims3.Gameplay.CAS; using Sims3.Gameplay.Core; using Sims3.Gameplay.EventSystem; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Objects; using Sims3.Gameplay.Utilities; using Sims3.Gameplay.Socializing; using Sims3.SimIFace; using Sims3.UI; using Sims3.Gameplay.UI; using Sims3.SimIFace.CAS; namespace Sims3.Greenie { public class ImaginaryEffect { [PersistableStatic] private static EventListener sSimInstantiatedListener; private static EventListener sSimAgedUpListener; private static string text; [Tunable] protected static bool kInstantiator = false; static ImaginaryEffect() { ImaginaryEffect.kInstantiator = false; ImaginaryEffect.sSimInstantiatedListener = null; ImaginaryEffect.sSimAgedUpListener = null; World.OnWorldLoadFinishedEventHandler += new EventHandler(ImaginaryEffect.OnWorldLoadFinishedHandler); Localization.LocalizeString("ImaginaryEffect...", new object[0]); } public static void OnWorldLoadFinishedHandler(object sender, EventArgs e) { try { Sim[] objects = Sims3.Gameplay.Queries.GetObjects<Sim>(); for (int i = 0; i < objects.Length; i++) { Sim sim = objects[i]; bool flag = sim != null; if (flag) { ImaginaryEffect.AddSimInteractions(sim); } } } catch (Exception exception) { ImaginaryEffect.Exception(exception); } } protected static ListenerAction OnSimInstantiatedOrAgedUp(Event e) { try { Sim sim = e.TargetObject as Sim; bool flag = sim != null; if (flag) { ImaginaryEffect.AddSimInteractions(sim); } } catch (Exception exception) { ImaginaryEffect.Exception(exception); } return ListenerAction.Keep; } public static void AddSimInteractions(Sim sim) { bool flag = sim.SimDescription.IsHuman && sim.SimDescription.ChildOrAbove; if (flag) { sim.AddInteraction(TurnOn.Singleton, true); sim.AddInteraction(Turnoff.Singleton, true); } } public static bool Exception(Exception exception) { try { return ((IScriptErrorWindow)AppDomain.CurrentDomain.GetData("ScriptErrorWindow")).DisplayScriptError(null, exception); } catch { WriteLog(exception); return true; } } public static bool WriteLog(Exception exception) { try { new ScriptError(null, exception, 0).WriteMiniScriptError(); return true; } catch { return false; } } internal sealed class TurnOn : ImmediateInteraction<Sim, Sim> { public static readonly InteractionDefinition Singleton = new TurnOn.Definition(); private VisualEffect mAntennaVfx; private CASAgeGenderFlags mAntennaVfxAge; private SimDescription mSimDescription; protected override bool Run() { CASAgeGenderFlags age = this.mSimDescription.Age; if (this.mAntennaVfxAge != age) { this.mAntennaVfxAge = age; this.mAntennaVfx.Stop(VisualEffect.TransitionType.HardTransition); } if (this.mAntennaVfx == null) { this.mAntennaVfx = VisualEffect.Create(this.mSimDescription.Child ? "ep4ImaginaryFriendGlowHeadChild" : "ep4ImaginaryFriendGlowHead"); this.mAntennaVfx.ParentTo(base.Actor, Sim.FXJoints.HatGrip); this.mAntennaVfx.Start(VisualEffect.TransitionType.HardTransition); } return true; } [DoesntRequireTuning] private sealed class Definition : ImmediateInteractionDefinition<Sim, Sim, TurnOn> { protected override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair interaction) { return Localization.LocalizeString("ImaginaryEffect/TurnEffectOn/InteractionName", new object[0]); } public override string[] GetPath(bool bPath) { string text = Localization.LocalizeString("Greenie/ImaginaryEffect/Path", new object[0]); return new string[] { Localization.LocalizeString("ImaginaryEffect...", new object[0]), text }; } protected override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return true; } } } internal sealed class Turnoff : ImmediateInteraction<Sim, Sim> { public static readonly InteractionDefinition Singleton = new Turnoff.Definition(); private VisualEffect mAntennaVfx; protected override bool Run() { if (this.mAntennaVfx != null) { this.mAntennaVfx.Stop(VisualEffect.TransitionType.HardTransition); this.mAntennaVfx.Dispose(); this.mAntennaVfx = null; } return true; } [DoesntRequireTuning] private sealed class Definition : ImmediateInteractionDefinition<Sim, Sim, Turnoff> { protected override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair interaction) { return Localization.LocalizeString("ImaginaryEffect/TurnEffectOff/InteractionName", new object[0]); } public override string[] GetPath(bool bPath) { string text = Localization.LocalizeString("Greenie/ImaginaryEffect/Path", new object[0]); return new string[] { Localization.LocalizeString("ImaginaryEffect...", new object[0]), text }; } protected override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return true; } } private void Cleanup() { if (this.mAntennaVfx != null) { this.mAntennaVfx.Stop(VisualEffect.TransitionType.HardTransition); this.mAntennaVfx.Dispose(); this.mAntennaVfx = null; } } } } }
Advertisement
#2
11th Jun 2017 at 4:43 PM
I think the mod won't work as expected,
you need to instantiate and store the effect reference somewhere else, because you will lose the reference every time the interaction finishes so you won't be able to control the effect anymore.
In this situation, usually the game uses traits or moodlets to hold the effect reference for every sim. When the game is loaded, the effect starts, when the game quit, the effect is disposed.
you need to instantiate and store the effect reference somewhere else, because you will lose the reference every time the interaction finishes so you won't be able to control the effect anymore.
In this situation, usually the game uses traits or moodlets to hold the effect reference for every sim. When the game is loaded, the effect starts, when the game quit, the effect is disposed.
#3
17th Jun 2017 at 10:09 AM
Posts: 3,860
Thanks: 8548 in 67 Posts
I can see why that would work out. I'll take a look at the buffs and see if I can get it to work with a buff instead
Thanks for your reply!
Thanks for your reply!
Who Posted
|