Welcome to
Mod The Sims
Online: 2019
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: 12 (Who?), Viewed: 1779 times.
Search this Thread
Old 3rd Jun 2011, 11:27 AM Animation and C# scripting - Go figure. #1
futureactorjon
Original Poster

Test Subject

Join Date: Jun 2006
Posts: 23


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
Last edited by futureactorjon : 3rd Jun 2011 at 01:30 PM.
Old 3rd Jun 2011, 01:24 PM #2
Odistant
Field Researcher

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


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.
Old 3rd Jun 2011, 01:29 PM #3
futureactorjon
Original Poster

Test Subject

Join Date: Jun 2006
Posts: 23


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.
Old 3rd Jun 2011, 01:54 PM #4
cmomoney
Who wants to play video games?



Join Date: Dec 2008
Posts: 1,693
Thanks: 71842 in 82 Posts
25 Achievements


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
Have you seen my Simple E Modern Bed @Leefish
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Old 3rd Jun 2011, 02:06 PM #5
futureactorjon
Original Poster

Test Subject

Join Date: Jun 2006
Posts: 23


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.
Old 3rd Jun 2011, 02:24 PM #6
Buzzler
1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28074 in 74 Posts
22 Achievements

View My Journal


Give

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

a try.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 3rd Jun 2011, 02:35 PM #7
futureactorjon
Original Poster

Test Subject

Join Date: Jun 2006
Posts: 23


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.
Old 3rd Jun 2011, 02:52 PM #8
Buzzler
1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28074 in 74 Posts
22 Achievements

View My Journal


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.
Old 3rd Jun 2011, 02:56 PM #9
futureactorjon
Original Poster

Test Subject

Join Date: Jun 2006
Posts: 23


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);
}
Old 3rd Jun 2011, 03:01 PM #10
cmomoney
Who wants to play video games?



Join Date: Dec 2008
Posts: 1,693
Thanks: 71842 in 82 Posts
25 Achievements


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
Have you seen my Simple E Modern Bed @Leefish
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Old 3rd Jun 2011, 03:05 PM #11
futureactorjon
Original Poster

Test Subject

Join Date: Jun 2006
Posts: 23


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.
Old 3rd Jun 2011, 03:11 PM #12
Buzzler
1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28074 in 74 Posts
22 Achievements

View My Journal


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.
Old 3rd Jun 2011, 03:19 PM #13
futureactorjon
Original Poster

Test Subject

Join Date: Jun 2006
Posts: 23


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.
Reply


Section jump:


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