Home | Download | Discussion | Help | Site Map | New Posts | Sign in
Replies: 12 (Who?), Viewed: 2277 times.
Test Subject
Original Poster
#1 Old 3rd Jun 2011 at 11:27 AM Last edited by futureactorjon : 3rd Jun 2011 at 1:30 PM.
Animation and C# scripting - Go figure.
Alright, so I'm pretty sure that this is an e-mail task however, I'm beyond confused. I'm jump right into it.

Objective: Create an object to make a sim do an interaction.

Progress: I've cloned/created the object, I've created/picked the animations. Now I need to C# script it all together.

I followed the tutorials on the C# scripting and have managed to get the object to talk back to be through the a text box. This is obvious progress however, not what I'm trying to accomplish.

So my request is, either if someone can point me in the direction of a "Sims 3" C# scripting tutorial or if there is just a simple code that my brain is not gathering.

Best,
Jonathan
Advertisement
Field Researcher
#2 Old 3rd Jun 2011 at 1:24 PM
What exactly are you trying to accomplish?

You can do so much things with scripting like creating new Lifetime Wishes, skills, different types of beds that make motives static, new services, etc.

I recommend looking at some of the objects already and seeing how they are run with. Once you get more into the coding, you can start adding interactions to already existing objects in the world like Sims.

There really is no tutorial that will tell you everything. From my experience the best way is to learn it yourself and take a look at some general c# tutorials.

I'm guessing you already took a look at Buzzlers Object Modding tutorial. I would also recommend to view his other tutorials for general scripting (no objects needed for that).

Edit: For animations, you use the base.EnterStateMachine() method and base.SetActor() methods. I highly suggest that you take a look at _ani's killing mod which uses a custom jazz. It would give you a good start.
Test Subject
Original Poster
#3 Old 3rd Jun 2011 at 1:29 PM
I actually managed to pull an animation from the game through my object!

Quote:
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay.Objects.Miscellaneous;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.Gameplay.ActorSystems;

namespace Sims3.Gameplay.Objects.Miscellaneous.Futureactorjon
{
class MovieInteractions : StuffedAnimal
{
public sealed class TalktoMe : ImmediateInteraction<Sim, MovieInteractions>
{
public static readonly InteractionDefinition Singleton = new Definition();

protected override bool Run()
{
return base.Actor.PlayReaction(ReactionTypes.Cry, ReactionSpeed.Immediate);
}

[DoesntRequireTuning]
public class Definition : InteractionDefinition<Sim, MovieInteractions, MovieInteractions.TalktoMe>
{
protected override string GetInteractionName(Sim a, MovieInteractions target, InteractionObjectPair interaction)
{
return "Make Me Act";
}
protected override bool Test(Sim a, MovieInteractions target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
return !isAutonomous;
}
}
}

public override void OnStartup()
{
base.OnStartup();
base.AddInteraction(TalktoMe.Singleton);
}
}
}



Now I am just need to code it to pull the animation that I put into the package file.
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
staff: moderator
#4 Old 3rd Jun 2011 at 1:54 PM
Quote:
Now I am just need to code it to pull the animation that I put into the package file.


The JAZZ-less way would be:

Code:
base.Actor.PlaySoloAnimation(<animation_name>, true);

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| ( ◡)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Test Subject
Original Poster
#5 Old 3rd Jun 2011 at 2:06 PM
Quote:
Originally Posted by cmomoney
The JAZZ-less way would be:

Code:
base.Actor.PlaySoloAnimation(<animation_name>, true);



Thanks. I am getting an error though when I insert that:
The name 'a_futureactorjon_tutorialanimation' does not exist in the current context

Is this correct?

base.Actor.PlaySoloAnimation(a_futureactorjon_tutorialanimation, true);

Also, I tried looking for Jazz-less on here, but I couldn't find anything on it.
1978 gallons of pancake batter
staff: retired moderator
#6 Old 3rd Jun 2011 at 2:24 PM
Give

base.Actor.PlaySoloAnimation("a_futureactorjon_tutorialanimation", true);

a try.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Test Subject
Original Poster
#7 Old 3rd Jun 2011 at 2:35 PM
Quote:
Originally Posted by Buzzler
Give

base.Actor.PlaySoloAnimation("a_futureactorjon_tutorialanimation", true);

a try.


No, I must be so exhausted that I'm just missing something. I will give it a try later.

Any chance any of you would know how to overlay animations? Something like "laugh at" and an Idle position? I'm trying to make the interaction more subtle, less crazy.
1978 gallons of pancake batter
staff: retired moderator
#8 Old 3rd Jun 2011 at 2:52 PM
Quote:
Originally Posted by futureactorjon
No, I must be so exhausted that I'm just missing something.
Yes, probably the quotes. The parameters of PlaySoloAnimation() are string and bool. Notice now?

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Test Subject
Original Poster
#9 Old 3rd Jun 2011 at 2:56 PM
Quote:
Originally Posted by Buzzler
Yes, probably the quotes. The parameters of PlaySoloAnimation() are string and bool. Notice now?


No, I definitely see how that makes sense. I have my animation file in my clone object file though, so it doesn't really know where to call from.

Quote:
protected override bool Run()
{
base.Actor.PlaySoloAnimation("a_futureactorjon_tutorialanimation", true);
}
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
staff: moderator
#10 Old 3rd Jun 2011 at 3:01 PM
Quote:
Originally Posted by futureactorjon
I have my animation file in my clone object file though, so it doesn't really know where to call from.

Yes, it does. It will call it from anywhere in the installed packages.

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| ( ◡)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Test Subject
Original Poster
#11 Old 3rd Jun 2011 at 3:05 PM
I get this error though:

Sims3.Gameplay.Objects.Miscellaneous.Futureactorjon.MovieInteractions.TalktoMe.Run()': not all code paths return a value

This is the code I'm using to call that animation:

Quote:
public sealed class TalktoMe : ImmediateInteraction<Sim, MovieInteractions>
{
public static readonly InteractionDefinition Singleton = new Definition();

protected override bool Run()
{
base.Actor.PlaySoloAnimation("a_futureactorjon_tutorialpose", true);
}

[DoesntRequireTuning]
public class Definition : InteractionDefinition<Sim, MovieInteractions, MovieInteractions.TalktoMe>
{
protected override string GetInteractionName(Sim a, MovieInteractions target, InteractionObjectPair interaction)
{
return "Talk To Me";
}
protected override bool Test(Sim a, MovieInteractions target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
return !isAutonomous;
}
}
}


I'll keep playing around with it. Anyway chance you know about overlaying animations such as a talking animation with an idle?

Thanks for your guys help by the way. Much appreciated.
1978 gallons of pancake batter
staff: retired moderator
#12 Old 3rd Jun 2011 at 3:11 PM
Quote:
Originally Posted by futureactorjon
Sims3.Gameplay.Objects.Miscellaneous.Futureactorjon.MovieInteractions.TalktoMe.Run()': not all code paths return a value
Run() must return a boolean. Just add "return true;" to it.

Quote:
This is the code I'm using to call that animation:
Please use code tags instead of the quote tags for code.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Test Subject
Original Poster
#13 Old 3rd Jun 2011 at 3:19 PM
You do know that you are a GENIUS, correct?! It works.

Now, I either need to reanimate the animations individually or somehow figure out how to overlay two animations to create a more subtle looking animation.
Back to top

Section jump