Welcome to
Mod The Sims
Online: 2481
News:
Have an account? Sign in:
pass:
If you don't have an account, why not sign up now? It's free!
Other sites: SimsWiki
Reply  Replies: 3 (Who?), Viewed: 2307 times.
Search this Thread
Old 8th Mar 2012, 06:46 AM DefaultNeed script help: Trying to restore Unicorn Magic Points #1
hmiller61615
Original Poster

Test Subject

Join Date: Nov 2008
Posts: 12
1 Achievements


I'll admit, this is my first mod, and I find myself at a loss. I'm trying to make an object that, once your pet unicorn loses all magic, you simply click and the magic will restore, and the buffs will go away.

I have it working so that the "power shortage" and "power failure" moodlets go away, but the magic is not restoring, so it's causing the same effect as if you ctrl+clicked the "power failure" moodlet (an obvious no-no, since this permanently deletes the unicorn's magic). I've tried adding in RestoreMagicPoints(), but it claims it doesn't have a definition, and I'm afraid this would require me to disassemble game dlls, and I'm trying to avoid that.

The short version: How do I ACTUALLY get the magic points back to 100?

Here's my code, but NOTE: there are a couple unused fields that I left in because I suspected they might be needed (kMaxMagicPoints, mUnicornMagicPoints, and mSimDescription). And yes, I realize I have nothing added in run() to make the points restore, because I've tried a billion things and just need someone to TELL me at this point what would do it.

Code:
using Sims3.Gameplay.Objects.Decorations.Mimics;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.CAS;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.Gameplay.ObjectComponents;
using System.Collections.Generic;
using System;
using Sims3.UI.Hud;

namespace Sims3.Gameplay.Objects.Decorations.Mimics
{
class UnicornMagicRecharger : SculptureTablePlushGiraffe
{
public sealed class RestoreMagicWithPlushie : ImmediateInteraction<Sim, UnicornMagicRecharger>
{
public static readonly InteractionDefinition Singleton = new Definition();
[TunableComment("Maximum magic points the unicorn can have"), Tunable]
private static int kMaxMagicPoints = 100;
private int mUnicornMagicPoints;
private SimDescription mSimDescription = null;
private AlarmHandle mMagicPointsUsedAlarm = new AlarmHandle(0L, 0);
protected override bool Run()
{
base.Actor.RemoveAlarm(mMagicPointsUsedAlarm);
base.Actor.BuffManager.RemoveElement(BuffNames.PowerShortage);
base.Actor.BuffManager.RemoveElement(BuffNames.PowerFailure);
return true;
}
}
[DoesntRequireTuning]
private sealed class Definition : ImmediateInteractionDefinition<Sim, UnicornMagicRecharger, UnicornMagicRecharger.RestoreMagicWithPlushie>
{
protected override string GetInteractionName(Sim Actor, UnicornMagicRecharger target, InteractionObjectPair interaction)
{
return "Recharge Magic";
}
protected override bool Test(Sim Actor, UnicornMagicRecharger target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
if(!Actor.SimDescription.IsUnicorn)
{
return false;
}
return !isAutonomous;
}
}
public override void OnStartup()
{
base.AddComponent<ItemComponent>(new object[] { false, new List<Type>(new Type[] { typeof(Sim) }) });
base.AddComponent<NameComponent>(new object[0]);
base.AddInteraction(RestoreMagicWithPlushie.Singleton);
}
}
}
Last edited by hmiller61615 : 8th Mar 2012 at 07:27 AM.
Old 12th Mar 2012, 02:26 AM #2
hmiller61615
Original Poster

Test Subject

Join Date: Nov 2008
Posts: 12
1 Achievements


...okay...

Lets try this: Here's what happens when I have the "RestoreMagicPoints" under "Run()"

Code:
using Sims3.Gameplay.Objects.Decorations.Mimics;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.CAS;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.Gameplay.ObjectComponents;
using System.Collections.Generic;
using System;
using Sims3.UI.Hud;

namespace Sims3.Gameplay.Objects.Decorations.Mimics
{
class UnicornMagicRecharger : SculptureTablePlushGiraffe
{
public sealed class RestoreMagicWithPlushie : ImmediateInteraction<Sim, UnicornMagicRecharger>
{
public static readonly InteractionDefinition Singleton = new Definition();
[TunableComment("Maximum magic points the unicorn can have"), Tunable]
public static int kMaxMagicPoints = 100;
public static int mUnicornMagicPoints;
private SimDescription mSimDescription = null;
public AlarmHandle mMagicPointsUsedAlarm = new AlarmHandle(0L, 0);
protected override bool Run()
{
base.Actor.RestoreMagicPoints(Sims3.Gameplay.ActorSystems.OccultUnicorn.kMaxMagicPoints);
return true;
}
[DoesntRequireTuning]
private sealed class Definition : ImmediateInteractionDefinition<Sim, UnicornMagicRecharger, UnicornMagicRecharger.RestoreMagicWithPlushie>
{
protected override string GetInteractionName(Sim Actor, UnicornMagicRecharger target, InteractionObjectPair interaction)
{
return "Recharge Magic";
}
protected override bool Test(Sim Actor, UnicornMagicRecharger target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
if (!Actor.SimDescription.IsUnicorn)
{
return false;
}
return !isAutonomous;
}
}
}
public override void OnStartup()
{
base.AddComponent<ItemComponent>(new object[] { false, new List<Type>(new Type[] { typeof(Sim) }) });
base.AddComponent<NameComponent>(new object[0]);
base.AddInteraction(RestoreMagicWithPlushie.Singleton);
}
}
}


But it gets me the error:

"Sims3.Gameplay.Actors.Sim' does not contain a definition for 'RestoreMagicPoints' and no extension method 'RestoreMagicPoints' accepting a first argument of type 'Sims3.Gameplay.Actors.Sim' could be found (are you missing a using directive or an assembly reference?)

Any help is welcome, even if it's, "You're an idiot." Just tell me why so I can learn from my mistake.
Old 12th Mar 2012, 04:23 AM #3
Odistant
Field Researcher

Join Date: Jul 2009
Posts: 259
Thanks: 998 in 5 Posts
7 Achievements


You will have to disassemble the DLLs to use it since its private. However, the way mono works, you can just change the definition to public after disassembling and then reassemble and use that. Your mod still wouldn't be a core mod. There's a tutorial that tells you how to do this. Just follow the steps on making the DLL a IL file and back for the core Modding tutorials. Obviously, you would only be changing the accesses identifiers.
Old 15th Mar 2012, 03:04 AM #4
hmiller61615
Original Poster

Test Subject

Join Date: Nov 2008
Posts: 12
1 Achievements


aaaaaahhh...that's what I was afraid of. Alrighty, good to know

Thank you much!
Reply


Section jump:


Powered by MariaDB Some icons by http://dryicons.com.