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!
Virtual gardener
staff: administrator
Original Poster
#1 Old 17th Jul 2018 at 4:02 PM
Default StateMachineClient... wondering if i'm doing this right
Hi guys!

So for quite a while I have been working on a sewing table script mod. Now it's still pretty much in it's state of 'held together with duct tape' kind of code, which is good enough for a first test However, I am a little confused about the script that will eventually do the jazz script. I know how to do the jazz script itself but calling it from C# is still a bit of a vague thing for me. To be really honest, I totally lost track of what should do what and such due to it...

So, I've got a few questions, and this is more of a validation of whether I got this idea of how it works right.

1. Call all the skills and stuff that's needed, this depends on the script obviously, but some of EA's skill-related objects seem to start with this, or halfway through, which, looking at it I guess should belong under the function CommodityUpdates?
2. Assign an actor go to the routingSlot... in this case I need to get it working with a chair, which I will convert it to in a bit.
3. base.StandardEntry();
4. base.BeginCommodityUpdates(); (And Commodity is a little confusing, but I suspect that's where the skills and Commodity-type things are suppose to be called?)
5. Set the actors for the animation, which in my case would be: X as the sim, "Sewingtable" as the base.Target, "SewingPiece" as the prop. (Or well, stated as a gameobject but I think that's how props are done).
6. Enter state, which is where I am starting to get confused... if I were to assign a routing for the sim to hop on the chair, I suspect this should be right before assigning the actor right? Enter state, the meaning to me is something I do understand.
7. Request state, Is where the script get's the animation running right?
8. Stop specific Commodity type stuff.
9. RequestState, Which would be ExitSim.
10. Destroy the prop used.
11. Added a bunch of 'Sim created object, get that object' type of code.
12. End commodityUpdates.
13. Standard exit
14 return flag.

Now most of the coding I got from specific skill objects, because I'm so clueless on what exactly what is And purpose of things and when to use it, etc... I guess it sort of makes sense to me but I am really clueless on if this is even going to work. For the ones who want to see the code itself:



(I still need to make the Jazz script itself, Although I did add the routing slot and the chair slot in my package, just need to figure a way out on how to add the chair slot in this type of code, since in my own code I did add references to it... This is probably confusing :P

Thanks in advanced!
Advertisement
Virtual gardener
staff: administrator
Original Poster
#2 Old 17th Jul 2018 at 4:36 PM
I just realised something, and I might be wrong with that, but is RequestState specifically animating the object at hand (So basically the 'base.target')? Since I noticed base.AnimateSim is also a thing
Space Pony
#3 Old 19th Jul 2018 at 2:49 AM
Quote: Originally posted by Lyralei
Hi guys!

So for quite a while I have been working on a sewing table script mod. Now it's still pretty much in it's state of 'held together with duct tape' kind of code, which is good enough for a first test However, I am a little confused about the script that will eventually do the jazz script. I know how to do the jazz script itself but calling it from C# is still a bit of a vague thing for me. To be really honest, I totally lost track of what should do what and such due to it...

So, I've got a few questions, and this is more of a validation of whether I got this idea of how it works right.

1. Call all the skills and stuff that's needed, this depends on the script obviously, but some of EA's skill-related objects seem to start with this, or halfway through, which, looking at it I guess should belong under the function CommodityUpdates?
2. Assign an actor go to the routingSlot... in this case I need to get it working with a chair, which I will convert it to in a bit.
3. base.StandardEntry();
4. base.BeginCommodityUpdates(); (And Commodity is a little confusing, but I suspect that's where the skills and Commodity-type things are suppose to be called?)
5. Set the actors for the animation, which in my case would be: X as the sim, "Sewingtable" as the base.Target, "SewingPiece" as the prop. (Or well, stated as a gameobject but I think that's how props are done).
6. Enter state, which is where I am starting to get confused... if I were to assign a routing for the sim to hop on the chair, I suspect this should be right before assigning the actor right? Enter state, the meaning to me is something I do understand.
7. Request state, Is where the script get's the animation running right?
8. Stop specific Commodity type stuff.
9. RequestState, Which would be ExitSim.
10. Destroy the prop used.
11. Added a bunch of 'Sim created object, get that object' type of code.
12. End commodityUpdates.
13. Standard exit
14 return flag.

Now most of the coding I got from specific skill objects, because I'm so clueless on what exactly what is And purpose of things and when to use it, etc... I guess it sort of makes sense to me but I am really clueless on if this is even going to work. For the ones who want to see the code itself:



(I still need to make the Jazz script itself, Although I did add the routing slot and the chair slot in my package, just need to figure a way out on how to add the chair slot in this type of code, since in my own code I did add references to it... This is probably confusing :P

Thanks in advanced!


You must have used the glassblowing station code as a reference, because your code here looks almost exactly like that object's script

I'm no expert on jazz scripts and state machines, but it looks to me like your code should work as long as the chair is a part of the object itself and not a separate item (like with the chess table and drafting table). If not, then, like you said, you will have to sit the sim on the chair (take a look at the chess table's "ScootInActor" for an example of this) before doing any state machine craziness, and you may also have to specify the chair as an actor as well -- don't ask, I don't get it either...

You could also shorten up your code a bit while still achieving the same results by using some alternative methods, one of which you touched on already. Instead of saying:

Code:
base.mCurrentStateMachine = StateMachineClient.Acquire(base.Actor, "SewingTable_Lyra");
//Cut for clarity
base.mCurrentStateMachine.SetActor("x", base.Actor);
base.mCurrentStateMachine.SetActor("Sewingtable", base.Target);
base.mCurrentStateMachine.SetActor("sewingPiece", mSewingpiece);
base.mCurrentStateMachine.EnterState("x", "SimEnter");
base.mCurrentStateMachine.RequestState("x", "Crafting");
//Cut for clarity
base.mCurrentStateMachine.RequestState("x", "ExitSim");
base.mCurrentStateMachine.RemoveActor("sewingPiece");


You could just say:

Code:
base.AcquireStateMachine("SewingTable_Lyra");
//Cut for clarity
base.SetActorAndEnter("x", this.Actor, "SimEnter");
base.SetActor("Sewingtable", this.Target);
base.SetActor("sewingPiece", mSewingpiece);
base.AnimateSim("Crafting");
//Cut for clarity
base.AnimateSim("ExitSim");
base.RemoveActor("sewingPiece");


And achieve the same effects with a lot less mess.

The "commodities" in the context of BeginCommodityUpdates() and EndCommodityUpdates() are the motive outputs specified in the ITUN file for the interaction. It's what allows us to put stuff like:

Code:
<Output>
    <Change type="Fun" advertised="-30" locked="True" actual="-25" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
</Output>


In the ITUN and have the game parse and update the motives accordingly.

Additionally, since the sewing table is tied to a skill -- which is impressive if the skill shows up in the journal and isn't hidden -- I would put in a small chance of what EA would call "EpicFailure" in which no object is produced that decreases as sims level up until a certain point where the chance is eliminated altogether. There could be a special animation associated with it like the glassblowing station or inventing workbench. If you REALLY want to go down the rabbit hole, you could even try putting in custom sounds. Just suggestions, though.

Do let me know how it all turns out. This sounds like an incredibly interesting project!

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Virtual gardener
staff: administrator
Original Poster
#4 Old 19th Jul 2018 at 3:33 PM
HI there! Thanks for the helpful reply!

I did take a look at the glassblow workbench for the Jazz script, and taking a way of how they do it. (And how exactly to go with creating stuff through the jazz script from an external perspective, because that's how EA made their Store objects anyways... take buffs for example here, and since the Glassblowing skill has a journal as well, just felt like seeing how they did it and reading Arsil's explanation as well as what's been discussed before). Right now I'm taking a look at the drawing table, which I seem to now understand what they were doing, which is mainly having a slot for the chair, having a sim routing there (So I don't think I even need to have a sim to route to RoutingSlot_0)

But I didn't know that SimAndEnter was a thing. Thanks for pointing that out! Same for the CommodityUpdates, which seemed like I was going into the right direction of what I thought it meant.

Also, the suggestions were some things I didn't think of, certainly will take them into account and see what I can do, I also feel like I should do the whole 'selecting a object' a bit better, since right now it's only a pie selection. But I will see if I can inject/add a bit of Battery's Library in there and see how that goes

Thanks for the help and feedback! I really appreciate it
Space Pony
#5 Old 19th Jul 2018 at 4:38 PM
Quote: Originally posted by Lyralei
Right now I'm taking a look at the drawing table, which I seem to now understand what they were doing, which is mainly having a slot for the chair, having a sim routing there (So I don't think I even need to have a sim to route to RoutingSlot_0)


Yeah, I didn't notice this earlier, but the routing slots only seem to be used for interactions in which the sim is standing up (e.g. the easel and glassblowing station), so I don't think it would be needed here. If you're looking at the drafting table for reference, do note that it uses a barstool, which does not move and thus is easy to animate through the EnterState. That's fine for barstools or a chair that is actually a part of the object, but if you're planning on using a dining chair that is snapped on to the object separately then it gets a bit more complicated because the sim has to pull out the chair to sit in it and then scoot in before anything else can start.

Quote: Originally posted by Lyralei
I also feel like I should do the whole 'selecting a object' a bit better, since right now it's only a pie selection. But I will see if I can inject/add a bit of Battery's Library in there and see how that goes


I mean, it depends on how many different objects there are to select from, and whether or not they can be categorized at all. The glassblowing station got away with just using a pie menu, but anything more than that would probably warrant a selection menu with thumbnails.

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Virtual gardener
staff: administrator
Original Poster
#6 Old 19th Jul 2018 at 6:14 PM
Yeah I was thinking of going for the Drafting board approach but looking at the scoot in function, it seems to already have the animation with it so to speak. And since 'ChairDining' seems to have all the things I pretty much need rather than having to make my own animation, I guess that will indeed be the best approach

I really should do some more research regarding animating stuff lol

Regarding the categorizing, It's indeed a pretty challenging and big project. I have about half of the meshes ready that I wanted to get packed with the mod itself, so I figured it's probably better to have a invention bench-wise list. That being, a list with thumbnails and a price. I know TS2 version of the sewing table didn't had that but I think it's quite an important factor... especially when it's a mix of TS2 objects and my own stuff.
Space Pony
#7 Old 19th Jul 2018 at 10:50 PM
Quote: Originally posted by Lyralei
Yeah I was thinking of going for the Drafting board approach but looking at the scoot in function, it seems to already have the animation with it so to speak. And since 'ChairDining' seems to have all the things I pretty much need rather than having to make my own animation, I guess that will indeed be the best approach


If you're going the dining chair route, make sure that the sewing table implements the IChairOwningSurface interface and that there is a condition in the Test() override of your interaction to check that there is a chair parented to the table and return false and a greyedOutTooltipCallback if there isn't. Additionally, when you're making the ITUN for your interaction, make sure to put these lines somewhere in it:

Code:
<PosturePrecondition name="Sitting" value="1">
    <Check name="InFrontOfSurfaceForTarget" />
</PosturePrecondition>
<RouteLeadIn allowed="True" />


Then, in your sewing table class, put in the following override:

Code:
public override bool IsObjectInFrontOfMe(IGameObject gameObject)
{
    if (!(gameObject is ChairDining))
    {
        return false;
    }
    SewingTable sewingTable = gameObject.Parent as SewingTable;
    return sewingTable == this;
}


This, I suspect, is what actually tells sims to route to the parented chair. The ScootInActor() method only serves to make sure that the chair is actually scooted in after the sim is sitting in it. It looks like the drafting table uses a similar precondition -- not the EntryState as I initially thought -- to actually sit the sim on the barstool.

In fact, you may even be able to add:

Code:
<Check name="ChairScootedIntoSurface" />


To your posture preconditions and not have to implement a ScootInActor method, but I'm not sure if that would work.

You'll also need to make sure the chair can actually snap to a slot on the sewing table object in the first place. I assume you know how to do that, because I sure don't

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Back to top